From ea0abaf3513beeb3c21c1105d91182a7a430f3fa Mon Sep 17 00:00:00 2001 From: Dave Allie Date: Wed, 24 Dec 2025 22:33:21 +1100 Subject: [PATCH] Prevent SD card error causing boot loop (#122) ## Summary * Prevent SD card error causing boot loop * We need the screen and fonts to be initialized to show the full screen error message * Prior to this change, trying to render the font would crash the firmware and boot loop it --- src/main.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 03f51508..83a33cc7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -158,6 +158,15 @@ void onGoHome() { enterNewActivity(new HomeActivity(renderer, inputManager, onGoToReaderHome, onGoToSettings, onGoToFileTransfer)); } +void setupDisplayAndFonts() { + einkDisplay.begin(); + Serial.printf("[%lu] [ ] Display initialized\n", millis()); + renderer.insertFont(READER_FONT_ID, bookerlyFontFamily); + renderer.insertFont(UI_FONT_ID, ubuntuFontFamily); + renderer.insertFont(SMALL_FONT_ID, smallFontFamily); + Serial.printf("[%lu] [ ] Fonts setup\n", millis()); +} + void setup() { t1 = millis(); @@ -179,6 +188,7 @@ void setup() { // SD Card Initialization if (!SD.begin(SD_SPI_CS, SPI, SPI_FQ)) { Serial.printf("[%lu] [ ] SD card initialization failed\n", millis()); + setupDisplayAndFonts(); exitActivity(); enterNewActivity(new FullScreenMessageActivity(renderer, inputManager, "SD card error", BOLD)); return; @@ -189,14 +199,7 @@ void setup() { // verify power button press duration after we've read settings. verifyWakeupLongPress(); - // Initialize display - einkDisplay.begin(); - Serial.printf("[%lu] [ ] Display initialized\n", millis()); - - renderer.insertFont(READER_FONT_ID, bookerlyFontFamily); - renderer.insertFont(UI_FONT_ID, ubuntuFontFamily); - renderer.insertFont(SMALL_FONT_ID, smallFontFamily); - Serial.printf("[%lu] [ ] Fonts setup\n", millis()); + setupDisplayAndFonts(); exitActivity(); enterNewActivity(new BootActivity(renderer, inputManager));