Skip to content

Commit 348f268

Browse files
committed
app is invalid if both of its 2 first words are empty mask
1 parent 72902e6 commit 348f268

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/sdk11/components/libraries/bootloader_dfu/bootloader.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,20 @@ static void wait_for_events(void)
138138

139139
bool bootloader_app_is_valid(void)
140140
{
141+
bool success = false;
141142
uint32_t const app_addr = DFU_BANK_0_REGION_START;
143+
142144
bootloader_settings_t const *p_bootloader_settings;
145+
bootloader_util_settings_get(&p_bootloader_settings);
143146

144-
bool success = false;
147+
enum { EMPTY_FLASH = 0xFFFFFFFFUL };
145148

146-
bootloader_util_settings_get(&p_bootloader_settings);
149+
// Application is invalid if first 2 words are all 0xFFFFFFF
150+
if ( *((uint32_t *)app_addr ) == EMPTY_FLASH &&
151+
*((uint32_t *)(app_addr+4)) == EMPTY_FLASH )
152+
{
153+
return false;
154+
}
147155

148156
// The application in CODE region 1 is flagged as valid during update.
149157
if ( p_bootloader_settings->bank_0 == BANK_VALID_APP )

0 commit comments

Comments
 (0)