Hej allesammen!
I'm having trouble with the bootloader example "bootloader_secure_ble", which seems to stuck when calling nrf_dfu_mbr_init_sd. But one thing after another:
preconds: using nRF5_SDK_13.0.0, Segger embedded studio 3.26
bootloader_secure_ble has been ported by me to SES, using Bjørn's memory map and flash allocation examples from here
now, if I flash SD+MBR first like that:
nrfjprog.exe --program s132_nrf52_4.0.2_softdevice.hex -f nrf52 --chiperase
And then program the bootloader:
nrfjprog.exe --reset --program myBootloader.hex --sectoranduicrerase -f nrf52
nrfjprog does its job, resets and runs the bootloader at the end. Bootloader works as expected, I can update an application using nrf Connect and it will even be executed after a reset. I can even do a soft-reset using nrfjprog -r and the bootloader is still working.
BUT If I do a hard-reset using reset button (or cutting power), the bootloader will run but it seems getting stuck somewhere around that nrf_dfu_mbr_init_sd With enabled logging, output looks like this when working well (just after flashing as explained above):
0> :INFO:Inside main
0> :DEBUG:In nrf_bootloader_init
0> :DEBUG:In real nrf_dfu_init
0> :DEBUG:running nrf_dfu_settings_init
0> :DEBUG:Enter nrf_dfu_continue
0> :ERROR:Single: Invalid bank
0> :DEBUG:Application sent bootloader request
0> :DEBUG:In nrf_dfu_transports_init
0> :DEBUG:num transports: 1
0> :DEBUG:vector table: 0x0006e000
0> :DEBUG:vector table: 0x0006e000
0> :DEBUG:Error code - sd_softdevice_vector_table_base_set: 0x00000000
0> :DEBUG:Before SOFTDEVICE_HANDLER_APPSH_INIT
0> :DEBUG:After SOFTDEVICE_HANDLER_APPSH_INIT
0> :INFO:Error code - sd_ble_cfg_set: 0x00000000
0> :DEBUG:Enabling softdevice.
0> SDH:DEBUG:RAM start at 0x20002100.
0> SDH:WARNING:RAM start should be adjusted to 0x20002060.
0> SDH:WARNING:RAM size should be adjusted to 0xdfa0.
0> :DEBUG:Softdevice enabled
0> :DEBUG:After nrf_dfu_transports_init
0> :DEBUG:nrf_dfu: init dfu req handler:DEBUG:------- nrf_dfu_flash_init-------
0> :DEBUG:Waiting for events
and after a reset of any kind, looks like that:
0> :INFO:Inside main
0> :DEBUG:In nrf_bootloader_init
0> :DEBUG:In real nrf_dfu_init
0> :DEBUG:running nrf_dfu_settings_init
0> :DEBUG:Enter nrf_dfu_continue
0> :ERROR:Single: Invalid bank
0> :DEBUG:Application sent bootloader request
0> :DEBUG:In nrf_dfu_transports_init
0> :DEBUG:num transports: 1
and obviously, no normal bootloader operation anymore. It seems as if it got stuck somewhere somehow. Trying to locate where it got stuck pointed me to that nrf_dfu_mbr_init_sd called at line 827 in ble_stack_init in file nrf_ble_dfu.c :
uint32_t err_code;
nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;
if (init_softdevice)
{
err_code = nrf_dfu_mbr_init_sd();
VERIFY_SUCCESS(err_code);
}
NRF_LOG_DEBUG("vector table: 0x%08x\r\n", BOOTLOADER_START_ADDR);
The documentation about nrf_dfu_mbr_init_sd leaves me still clueless and the reason for above boolean switch "init_softdevice" as well. Ah.. and I have not fiddled with mergehex or any other trickery so there is no application in the flash nor bootloader settings (but the default zeroes).
Has anyone suggestions what I might have done wrong? Any hint is very much appreciated..