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
  • Thanks for all the help! I've now moved the bootloader to a higher address in the flash and moved back my application to the original address. I've also updated the UICR register with the bootloader address, so the bootloader is executed at startup.

    But I still have problems jumping to the application. When the bootloader executes nrf_dfu_mbr_init_sd inside nrf_bootloader_app_start.c I get a hard fault. This code results in the hard fault:

    uint32_t nrf_dfu_mbr_init_sd(void)
    {
        uint32_t ret_val;
    
        sd_mbr_command_t command =
        {
            .command = SD_MBR_COMMAND_INIT_SD
        };
    
        ret_val = sd_mbr_command(&command);
    
        return ret_val;
    }
    
Reply
  • Thanks for all the help! I've now moved the bootloader to a higher address in the flash and moved back my application to the original address. I've also updated the UICR register with the bootloader address, so the bootloader is executed at startup.

    But I still have problems jumping to the application. When the bootloader executes nrf_dfu_mbr_init_sd inside nrf_bootloader_app_start.c I get a hard fault. This code results in the hard fault:

    uint32_t nrf_dfu_mbr_init_sd(void)
    {
        uint32_t ret_val;
    
        sd_mbr_command_t command =
        {
            .command = SD_MBR_COMMAND_INIT_SD
        };
    
        ret_val = sd_mbr_command(&command);
    
        return ret_val;
    }
    
Children
No Data
Related