This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SD_MBR_COMMAND_INIT_SD order of events?

I find in the following example code that if I start my application from a powered-off to a powered-on condition and main() executes the code as shown, everything works fine...ONCE. If I were to reset the device, and start executing in main() again (without a power cycle) that the sd_mbr_command() function will essentially lock up. I have no idea what it's doing, I just never get execution back after making the call.

I also find that if I comment out the sm_mbr_command() call, I can now reset and run as many times as I like, and everything works just fine.

I also find that if I leave the sm_mbr_command() call commented out, and power-cycle the device (remove power, reattach power) that the sd_softdevice_is_enabled() call will fail and execution will end up at address 0xFFFFFFFE or some such nonsense.

What am I missing here? Is there a way to tell if the SD_MBR_COMMAND_INIT_SD needs to be called via the sd_mbr_command() function? I can't just call it every time, nor can I assume that it has been called prior to my main(). Is there a flag that gets set? A register I can read? Some other function call?

 unsigned char e;

 sd_mbr_command_t com = {SD_MBR_COMMAND_INIT_SD, };
 Result = sd_mbr_command(&com);
 
 Result = sd_softdevice_is_enabled(&e);
Parents
  • Hi Mostly Harmless,

    Is your application a normal application or it's a bootloader ? If it's normal application, you don't have to call sd_mbr_command() with SD_MBR_COMMAND_INIT_SD.

    We only call this command if we are in a bootloader. When the MBR detect that there is a bootloader (there is an address in the bootloader address location in UICR) it will not initialize the softdevice but forward all interrupt to the bootloader. And it's upto the bootloader to init the softdevice or not (in case the softdevice is being updated).

  • @Wobs: Because we implemented the buttonless DFU, that share the bond information with the bootloader via RAM, and because of that we don't do reset => don't reinitialize the softdevice. That's why there is a branch to check if the softdevice should be initialized. Please have a look at question #C in this blog.

Reply Children
No Data
Related