Buttonless DFU connect timeout issue on custom board

Hi,

I followed the DFU to SDK example post on https://www.u-blox.com/en/docs/UBX-19050198 to add Buttonless DFU to an application (I modified \ble_peripheral\ble_app_hrs). The details of firmware updates and HEX file generation are in section 5. Then All the testing in section 6 is successful when I used nRF52832DK to test uploading new version hrs application though buttonless DFU (using nRFconnect and another DK). The SDK I used is 17.0.2.

Then I repeated everything on my custom nRF52832 board, with the same changes applied to my custom application.

I also updated the secure bootloader under “\examples\dfu\secure_bootloader” for my custom board to generate “secure_bootloader_ble_s132_custom.hex”. The main changes are (1) Replace board.c, board.h (remove all the buttons and unused LEDs related code, since my board has no button and only two LEDs), add custom_board.h. (2) Changed softdevice clock setting macros in sdk_config.h, since I do not use external 32MHz crystal.  The bootloader was tested successfully with my customer board. I can see “DfuTarg” as the advertising name. OTA firmware upload is successful with my custom application .zip file (generated with command “nrfutil pkg generate --application custom.hex --application-version-string "2.0.0" --hw-version 52 --sd-req 0x101 --key-file private.key app_v2.zip”)

However, after I generated the combined .hex following steps in section 5, (merge bl_setting.hex, such successfully tested bootloader, softdevice image, and my updated application), downloaded such combined .hex file to my custom board. Recycle power and connect my custom board and application through nRF connect, click DFU button and start OTA uploading, the DFU always gives a message says “dfu failed with error: connect time out” after about 10 seconds waiting.

The downloaded .hex file (bl_set_s132_app.hex) is generated as below

  • nrfutil settings generate --family NRF52 --application custom.hex --application-version-string "1.2.3" --bootloader-version 0 --bl-settings-version 2 bl_setting.hex
  • mergehex --merge bl_setting.hex secure_bootloader_ble_s132_custom.hex s132_nrf52_7.2.0_softdevice.hex --output bl_set_s132.hex
  • mergehex --merge bl_set_s132.hex custom.hex --output bl_set_s132_app.hex

Then I download to custom board though

  • nrfjprog -f nrf52 –recover
  • nrfjprog --program bl_set_s132_app.hex

The .zip file for uploading though buttonless DFU is generated as below.

nrfutil pkg generate --application custom.hex --application-version-string "2.0.0" --hw-version 52 --sd-req 0x101 --key-file private.key app_v2.zip

Since I did exactly the same changes and everything is working on nRF52832DK, may I know what is the possible cause of such “connect time out” issue on my customer board? For example, does bootloader use a timer and accidently occupied by my customer application? It could explain why modified secure_bootloader can do OTA upload successfully, but DFU button on my application has time out error. If so, how to check that?

I already tried method (add “do while” to  sd_ble_gatts_hvx) following the link https://devzone.nordicsemi.com/f/nordic-q-a/38655/buttonless-dfu-sdk-14-2-dfu-failed-with-error

But it still does not working for me.

Appreciate all the helps and suggestions.

Parents
  • Hi,

    Changed softdevice clock setting macros in sdk_config.h, since I do not use external 32MHz crystal.  

    I guess you mean 32.768 kHz crystal.

    What did you change the clock settings to? something like this?

    // <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

    Did you do the same change in both the bootloader and in the application's sdk_config.h file?

    Do you have the nrf_log output from the nRF52 device? Logging is enabled in the _debug variant of the bootloader project (e.g. pca10040_s132_ble_debug)

  • No, Both debug or non-debug version of bootloader alone work fine with OTA on my customer board. With bootloader alone, the advertiser name is "DfuTarg". I have time out problem for OTA only if I merge Bootloader, softdevice and application to one .hex and download to my customer board (then the advertiser name is my device name), following test steps in section 5 and 6 of https://www.u-blox.com/en/docs/UBX-19050198. However, everything is OK if I try hrs example with nRF52832DK.

Reply Children
  • gte938x said:
    I have time out problem for OTA only if I merge Bootloader, softdevice and application to one .hex and download to my customer board (then the advertiser name is my device name)

    Since you have the app, bootloader settings page, SoftDevice and Bootloader flashed, the Bootloader will start application when the device is powered on. 

    How did you enter DFU mode? Did you add buttonless DFU service to your application? or did you reset the board while holding down button 4(NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN 16).

    gte938x said:
    Both debug or non-debug version of bootloader alone work fine

    Could you try the debug version of the bootloader + your app + bootloader settings page + SoftDevice ?

    after about 10 seconds waiting.

    Is it always 10 seconds?

Related