Skip to content

Commit 447207b

Browse files
committed
add failed safe mbr forward address
1 parent 570bd5b commit 447207b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-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
@@ -345,13 +345,14 @@ void bootloader_app_start(void)
345345
NVIC->ICPR[1]=0xFFFFFFFF;
346346
#endif
347347

348+
uint32_t fwd_ret;
348349
uint32_t app_addr;
349350

350351
if ( is_sd_existed() )
351352
{
352353
// App starts after SoftDevice
353354
app_addr = SD_SIZE_GET(MBR_SIZE);
354-
sd_softdevice_vector_table_base_set(app_addr);
355+
fwd_ret = sd_softdevice_vector_table_base_set(app_addr);
355356
}else
356357
{
357358
// App starts right after MBR
@@ -362,7 +363,14 @@ void bootloader_app_start(void)
362363
.params.irq_forward_address_set.address = app_addr,
363364
};
364365

365-
sd_mbr_command(&command);
366+
fwd_ret = sd_mbr_command(&command);
367+
}
368+
369+
// unlikely failed to forward vector table, manually set forward address
370+
if ( fwd_ret != NRF_SUCCESS )
371+
{
372+
// MBR use first 4-bytes of SRAM to store foward address
373+
*(uint32_t *)(0x20000000) = app_addr;
366374
}
367375

368376
// jump to app

src/flash_nrf5x.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ void flash_nrf5x_flush (bool need_erase)
3737
{
3838
if ( _fl_addr == FLASH_CACHE_INVALID_ADDR ) return;
3939

40+
// skip the write if contents matches
4041
if ( memcmp(_fl_buf, (void *) _fl_addr, FLASH_PAGE_SIZE) != 0 )
4142
{
4243
// - nRF52832 dfu via uart can miss incoming byte when erasing because cpu is blocked for > 2ms.

0 commit comments

Comments
 (0)