So I have the following bootloader code:
int main() {
uint32_t code;
sd_mbr_command_t mbr_command = { SD_MBR_COMMAND_INIT_SD, };
code = sd_mbr_command(&mbr_command);
APP_ERROR_CHECK(code);
code = sd_softdevice_vector_table_base_set(BOOTLOADER_REGION_START);
APP_ERROR_CHECK(code);
SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, NULL);
serial_out("SD INITIALIZED - BOOTING APP\r\n");
sd_softdevice_disable();
code = sd_softdevice_vector_table_base_set(CODE_REGION_1_START);
APP_ERROR_CHECK(code);
bootloader_util_app_start(CODE_REGION_1_START);
return 0;
}
Pretty straightforward. Initializing SD, disabling it and then booting the application. However it appears something REALLY odd happens with the sd_mbr_command call. It makes the whole system crash.
So, I set up a breakpoint at that exact line and launched the debugger. I slowly trace the execution, line by line, trying to locate the culprit. It works, sd_mbr_command returns just fine and then the bootloader proceeds as normal.
Head scratching intensifies...
Okay, one more time, re-starting the chip and debugging again, with the same breakpoint. Only this time immediately resuming execution after hitting the breakpoint.
What happens? Absolutely nothing, sd_mbr_command never returns. It's always getting stuck on this exact point: http://i.imgur.com/DzNshAD.png
So. It appears sd_mbr_command works only when executed slowly by stepping into each line manually in the debugger. What.
Any assistance, please? Thank you