Skip to content

Commit b163c7e

Browse files
committed
Don't boot the firmware if the exception table isn't initialized
If no firmware is flashed, then flash contains all 1's. The firmware's reset handler (stored in the exception table) would then be 0xffffffff. Jumping that address is very bad because that is the same as setting the cpu in LOCKUP state. * The common way to get to the LOCKUP state is with a double fault (fault in a fault handler), so this natuarally makes you go debug the wrong things. * The debugger cannot access the CPU when it is in LOCKUP state.
1 parent 1511148 commit b163c7e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/bootloader/bootloader.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,12 @@ static bool _devdevice_enter(secbool_u32 firmware_verified)
900900
UG_PutString(0, 0, " <Enter bootloader>", false);
901901
UG_PutString(0, SCREEN_HEIGHT / 2 - 11, "DEV DEVICE", false);
902902
UG_PutString(0, SCREEN_HEIGHT / 2 + 2, "NOT FOR VALUE", false);
903-
UG_PutString(0, SCREEN_HEIGHT - 9, " <Continue>", false);
903+
// Check that the firmware's reset handler isn't invalid.
904+
if (((uint32_t*)FLASH_APP_START)[1] != 0xffffffff) {
905+
UG_PutString(0, SCREEN_HEIGHT - 9, " <Continue>", false);
906+
} else {
907+
UG_PutString(0, SCREEN_HEIGHT - 9, " No firmware found", false);
908+
}
904909
uint16_t ypos = SCREEN_HEIGHT / 2 - 4;
905910
uint16_t xpos = SCREEN_WIDTH - 10;
906911
if (firmware_verified != sectrue_u32) {
@@ -921,7 +926,8 @@ static bool _devdevice_enter(secbool_u32 firmware_verified)
921926
if (qtouch_is_scroller_active(top_slider)) {
922927
return true;
923928
}
924-
if (qtouch_is_scroller_active(bottom_slider)) {
929+
if (qtouch_is_scroller_active(bottom_slider) &&
930+
((uint32_t*)FLASH_APP_START)[1] != 0xffffffff) {
925931
return false;
926932
}
927933
}

0 commit comments

Comments
 (0)