Skip to content

Commit 886e2fd

Browse files
authored
Merge pull request #1332 from NickeZ/nickez/dont-boot-to-ff
Nickez/dont boot to ff
2 parents 3b69f37 + b163c7e commit 886e2fd

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/bootloader/bootloader.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,8 @@ static size_t _api_write_chunk(const uint8_t* buf, uint8_t chunknum, uint8_t* ou
408408

409409
// Erase is handled inside of flash_write
410410
if (flash_write(
411-
&FLASH_0,
412-
FLASH_APP_START + (chunknum * FIRMWARE_CHUNK_LEN),
413-
(const uint8_t*)buf,
414-
FIRMWARE_CHUNK_LEN) != ERR_NONE) {
411+
&FLASH_0, FLASH_APP_START + (chunknum * FIRMWARE_CHUNK_LEN), buf, FIRMWARE_CHUNK_LEN) !=
412+
ERR_NONE) {
415413
return _report_status(OP_STATUS_ERR_WRITE, output);
416414
}
417415

@@ -902,7 +900,12 @@ static bool _devdevice_enter(secbool_u32 firmware_verified)
902900
UG_PutString(0, 0, " <Enter bootloader>", false);
903901
UG_PutString(0, SCREEN_HEIGHT / 2 - 11, "DEV DEVICE", false);
904902
UG_PutString(0, SCREEN_HEIGHT / 2 + 2, "NOT FOR VALUE", false);
905-
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+
}
906909
uint16_t ypos = SCREEN_HEIGHT / 2 - 4;
907910
uint16_t xpos = SCREEN_WIDTH - 10;
908911
if (firmware_verified != sectrue_u32) {
@@ -923,7 +926,8 @@ static bool _devdevice_enter(secbool_u32 firmware_verified)
923926
if (qtouch_is_scroller_active(top_slider)) {
924927
return true;
925928
}
926-
if (qtouch_is_scroller_active(bottom_slider)) {
929+
if (qtouch_is_scroller_active(bottom_slider) &&
930+
((uint32_t*)FLASH_APP_START)[1] != 0xffffffff) {
927931
return false;
928932
}
929933
}

0 commit comments

Comments
 (0)