Skip to content

Commit 570bd5b

Browse files
committed
more clean up, everything look good
usb example work without SD, which means ISR forwarding is working.
1 parent 99d31d2 commit 570bd5b

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,6 @@ uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms)
337337

338338
void bootloader_app_start(void)
339339
{
340-
// If the applications CRC has been checked and passed, the magic number will be written and we
341-
// can start the application safely.
342-
if ( is_sd_existed() ) sd_softdevice_disable();
343-
344340
// Disable all interrupts
345341
NVIC->ICER[0]=0xFFFFFFFF;
346342
NVIC->ICPR[0]=0xFFFFFFFF;
@@ -349,27 +345,27 @@ void bootloader_app_start(void)
349345
NVIC->ICPR[1]=0xFFFFFFFF;
350346
#endif
351347

352-
// default to boot right after MBR
353-
uint32_t app_addr = MBR_SIZE;
348+
uint32_t app_addr;
354349

355350
if ( is_sd_existed() )
356351
{
352+
// App starts after SoftDevice
357353
app_addr = SD_SIZE_GET(MBR_SIZE);
358354
sd_softdevice_vector_table_base_set(app_addr);
359355
}else
360356
{
357+
// App starts right after MBR
358+
app_addr = MBR_SIZE;
361359
sd_mbr_command_t command =
362360
{
363361
.command = SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET,
364362
.params.irq_forward_address_set.address = app_addr,
365363
};
366364

367365
sd_mbr_command(&command);
368-
369-
// VTOR as last resource ?
370-
// SCB->VTOR = app_addr;
371366
}
372367

368+
// jump to app
373369
bootloader_util_app_start(app_addr);
374370
}
375371

src/main.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,14 @@ int main(void)
284284

285285
if (bootloader_app_is_valid() && !bootloader_dfu_sd_in_progress())
286286
{
287-
// MBR must be init before start application
288-
if ( is_sd_existed() && !sd_inited ) softdev_mbr_init();
287+
if ( is_sd_existed() )
288+
{
289+
// MBR forward IRQ to SD (if not already)
290+
if ( !sd_inited ) softdev_mbr_init();
291+
292+
// Make sure SD is disabled
293+
sd_softdevice_disable();
294+
}
289295

290296
// clear in case we kept DFU_DBL_RESET_APP there
291297
(*dbl_reset_mem) = 0;
@@ -309,7 +315,7 @@ static uint32_t softdev_init(bool init_softdevice)
309315
{
310316
if (init_softdevice) softdev_mbr_init();
311317

312-
// map vector table to bootloader address
318+
// Forward vector table to bootloader address so that we can handle BLE events
313319
APP_ERROR_CHECK( sd_softdevice_vector_table_base_set(BOOTLOADER_REGION_START) );
314320

315321
// Enable Softdevice, Use Internal OSC to compatible with all boards

0 commit comments

Comments
 (0)