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

nRF52 softdevice hangs at sd_softdevice_enable when using custom bootloader

I have a problem initializing the ble stack when I'm starting my application via a custom bootloader. I'm using the nrf52832 device on a custom board.

My application has been working fine for a while on its own. But now I want to add a bootloader to the mix...

The memory layout in flash is like this:

0x00000000   - softdevice (s132_nrf52_4.0.2)
0x0001F000   - Primary bootloader
0x00022000   - Main application

There is no overlap in RAM

The point where the execution stops is at sd_softdevice_enable in softdevice_handler.c. I have seen several other questions about this where the solution often seemed to be related to the clock source. However I don't think this is my problem since the application works fine on its own. But I've tried both external and internal clock sources, with the same results:

// external clock source
nrf_clock_lf_cfg_t clock_lf_cfg =
{
    .source        = NRF_CLOCK_LF_SRC_XTAL,
    .rc_ctiv       = 0,
    .rc_temp_ctiv  = 0,
    .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_30_PPM
};

// internal clock source
nrf_clock_lf_cfg_t clock_lf_cfg =
{
    .source = NRF_CLOCK_LF_SRC_RC,
    .rc_ctiv = 16, // Interval in 0.25 s, 16 * 0.25 = 4 sec
    .rc_temp_ctiv = 2, // Check temperature every .rc_ctiv, but calibrate every .rc_temp_ctiv
    .xtal_accuracy = 0,
};

I'm currently out of ideas as to what could be wrong. Can anyone here point me in the right direction?

Parents
  • Ok, I did a little more reading on the subject and the above is correct for SDK11 and prior. The bootloader_util.h is a library that you include and the assembly code twiddles with some vectors in the NVIC.

    When they switched to SDK12 and later and buttonless DFU the method changed slightly. The still is some twiddling of the NVIC manually but now you approach this as including #include "nrf_bootloader_app_start.h"

    and using nrf_bootloader_app_start(MAIN_APPLICATION_START_ADDR);

    That function takes care of the SD app start and does all the manual stuff too.

    There could be other dependencies. Just look at the #includes for the secure_dfu_ble_s132

    So, all you really need to do is give that function your actual app start address and I think that is it.

Reply
  • Ok, I did a little more reading on the subject and the above is correct for SDK11 and prior. The bootloader_util.h is a library that you include and the assembly code twiddles with some vectors in the NVIC.

    When they switched to SDK12 and later and buttonless DFU the method changed slightly. The still is some twiddling of the NVIC manually but now you approach this as including #include "nrf_bootloader_app_start.h"

    and using nrf_bootloader_app_start(MAIN_APPLICATION_START_ADDR);

    That function takes care of the SD app start and does all the manual stuff too.

    There could be other dependencies. Just look at the #includes for the secure_dfu_ble_s132

    So, all you really need to do is give that function your actual app start address and I think that is it.

Children
No Data
Related