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

Problems with enabling softdevice while in DFU

Hi,

We are developping an app using nrf52840. We started with the SDK14.2 and needed to migrate to SDK15.0 in order to use the long range. We are also using a Bootloader and DFU in order to update the app Over The Air.

The app was migrated successfully and everything works as expected. The problem is with the bootloader project. Since the project was pretty empty we copied directly the secure bootloader ble exemple from the SDK15.0. After adjusting the flash and ram placements the bootloader project worked - as in: it started the main app. When our app activates DFU and performs a NVIC_SystemReset(); the bootloader starts, and recognize that we want to go in DFU. Everything looks ok until the bootloader reaches the function nrf_dfu_transports_init. In this function it recognizes that there is one transport and ble_stack_init() is called. The vector table is set correctly and nrf_sdh_enable_request(); is called. In this function we reach sd_softdevice_enable and then the device hangs. This functions doesn't return at all. We are then reset by the watchdog after about 90 seconds and the device does not enter DFU since it was reset and the flag has been cleared.

After reading other questions and answer on the subject I saw that the SoftDevice clock configuration in sdk_config.h was wrong, since it used the xtal crystal but there aren't any on my custom board. So I changed the setting to use these parameters:

//==========================================================

// <h> Clock - SoftDevice clock configuration

//==========================================================
// <o> NRF_SDH_CLOCK_LF_SRC  - SoftDevice clock source.
 
// <0=> NRF_CLOCK_LF_SRC_RC 
// <1=> NRF_CLOCK_LF_SRC_XTAL 
// <2=> NRF_CLOCK_LF_SRC_SYNTH 

#ifndef NRF_SDH_CLOCK_LF_SRC
#define NRF_SDH_CLOCK_LF_SRC 0
#endif

// <o> NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval. 
#ifndef NRF_SDH_CLOCK_LF_RC_CTIV
#define NRF_SDH_CLOCK_LF_RC_CTIV 16
#endif

// <o> NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature. 
// <i> How often (in number of calibration intervals) the RC oscillator shall be calibrated
// <i>  if the temperature has not changed.

#ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV
#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 2
#endif

// <o> NRF_SDH_CLOCK_LF_ACCURACY  - External clock accuracy used in the LL to compute timing.
 
// <0=> NRF_CLOCK_LF_ACCURACY_250_PPM 
// <1=> NRF_CLOCK_LF_ACCURACY_500_PPM 
// <2=> NRF_CLOCK_LF_ACCURACY_150_PPM 
// <3=> NRF_CLOCK_LF_ACCURACY_100_PPM 
// <4=> NRF_CLOCK_LF_ACCURACY_75_PPM 
// <5=> NRF_CLOCK_LF_ACCURACY_50_PPM 
// <6=> NRF_CLOCK_LF_ACCURACY_30_PPM 
// <7=> NRF_CLOCK_LF_ACCURACY_20_PPM 
// <8=> NRF_CLOCK_LF_ACCURACY_10_PPM 
// <9=> NRF_CLOCK_LF_ACCURACY_5_PPM 
// <10=> NRF_CLOCK_LF_ACCURACY_2_PPM 
// <11=> NRF_CLOCK_LF_ACCURACY_1_PPM 

#ifndef NRF_SDH_CLOCK_LF_ACCURACY
#define NRF_SDH_CLOCK_LF_ACCURACY 1
#endif

Now when I try to enter DFU the device resets right away. I use SEGGER_RTT_PRINT to debug and since there is a little delay with the printing it is kind of hard for me to know exactly where the system resets but I'm pretty sure that it reaches sd_softdevice_enable and that it is at this point that we reset.

I also saw that the problem may be linked to the memory layout. Here is the layout of my complete merged .hex file:

And here are the settings of my bootloader project:

FLASH_PH_START=0x0
FLASH_PH_SIZE=0x100000
RAM_PH_START=0x20000000
RAM_PH_SIZE=0x40000
FLASH_START=0xf7000
FLASH_SIZE=0x7000
RAM_START=0x200022b0
RAM_SIZE=0x3dd50

And of my main application project:

FLASH_PH_START=0x0
FLASH_PH_SIZE=0x100000
RAM_PH_START=0x20000000
RAM_PH_SIZE=0x40000
FLASH_START=0x26000
FLASH_SIZE=0xda000
RAM_START=0x200022b0
RAM_SIZE=0x3dd50

Best Regards

Related