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
  • Also the problem came about due to the order of your memory layout. Normally Nordic puts the DFU/bootloader at the end of flash space leaving everything in between open for application code. The stock dfu code just looks at the size of the SD and assumes that the app code is next. I assume you based your bootloader on the stock stuff so when it does this calculation it just points back at itself.

    See this:

    #if defined(SOFTDEVICE_PRESENT)
    
    /** @brief  Main application start address (if the project uses a SoftDevice).
     *
     * @note   The start address is equal to the end address of the SoftDevice.
     */
    #define MAIN_APPLICATION_START_ADDR             (SD_SIZE_GET(MBR_SIZE))
    
    #else
    #define MAIN_APPLICATION_START_ADDR             MBR_SIZE
    #endif // #ifdef SOFTDEVICE_PRESENT
    #endif // #ifndef MAIN_APPLICATION_START_ADDR
    
Reply
  • Also the problem came about due to the order of your memory layout. Normally Nordic puts the DFU/bootloader at the end of flash space leaving everything in between open for application code. The stock dfu code just looks at the size of the SD and assumes that the app code is next. I assume you based your bootloader on the stock stuff so when it does this calculation it just points back at itself.

    See this:

    #if defined(SOFTDEVICE_PRESENT)
    
    /** @brief  Main application start address (if the project uses a SoftDevice).
     *
     * @note   The start address is equal to the end address of the SoftDevice.
     */
    #define MAIN_APPLICATION_START_ADDR             (SD_SIZE_GET(MBR_SIZE))
    
    #else
    #define MAIN_APPLICATION_START_ADDR             MBR_SIZE
    #endif // #ifdef SOFTDEVICE_PRESENT
    #endif // #ifndef MAIN_APPLICATION_START_ADDR
    
Children
No Data
Related