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

Trouble debugging custom PCB with DFU service on

Hi!

My software setup consists of SDK 15.0.0 and SD 6.0.0.

I am using nRF52DK for flashing and debugging my custom PCB board on nRF52832.

I am developing an application with buttonless DFU service so there also must be bootloader on the bottom. I added some preprocessor defines to allow or dissalow presence of DFU.

So when my defines are "0" the application behaves normally (without DFU), I can easily flash or debug in Segger Embedded Studio.

When my defines are "1" the application must be flashed other way:

SET family= NRF52
SET application= C:\repo\pikflometr\multiperipheral\pca10040\s132\ses\Output\Debug\Exe\ble_app_multiperipheral_pca10040_s132.hex
SET application-version= 1
SET soft_device= C:\repo\pikflometr\lib\s132_nrf52_6.0.0_softdevice.hex
SET bootloader= C:\repo\pikflometr\secure_bootloader\pca10040_ble\ses\Output\Release\Exe\secure_bootloader_ble_s132_pca10040.hex
SET bootloader-version= 1
SET bl-settings-version= 1
SET settings= settings_1.hex
SET dfu_client= dfu_client_1.hex
SET nrfutil_location= C:\repo\pikflometr\lib
cd %nrfutil_location%
nrfjprog.exe --family %family% --program %soft_device% --chiperase --verify
nrfutil settings generate --family %family% --application %application% --application-version %application-version% --bootloader-version %bootloader-version% --bl-settings-version %bl-settings-version% %settings%
mergehex -m %application% %settings% -o %dfu_client%
nrfjprog.exe --family %family% --program %dfu_client% --verify
nrfjprog.exe --reset --family %family% --program %bootloader% --verify

then F5 to run debug but nothing happens! I can see no logs in debug terminal in SES nor a debug cursor waiting for any function call.

Meanwhile using nRF52DK with the same procedure debugging with DFU enabled is possible, the cursor waits just before main() for action. My first guess is I don't use JTAG properly. Devboard has got on-board JTAG, but my custom PCB is connected like this:

It works until I want to add DFU service.

Is this a proper way of using devkit to program external boards?

Or should I Debug Out connector? If yes, then how?
I tried :
SWDIO-> SWDIO,
SWDCLK-> SWDCLK,
VTG-> Vcc,
GND+GNDdetect-> GND
while 3,8V battery powered but no success.

Are there any additional "DEBUGxxxx" defines/settings in secure_bootloader project that could matter when debugging external board?

  • Hi,

    Do you have the optional 32KHz crystal mounted on your custom board, and if not, have you remembered to change the LF clock source in your bootloader project? It would also be interesting to know if the bootloader works without the application. 

    sdk_config.h settings to select RCOSC as clock source:

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

  • Hi,

    Thank you for your answer.

    I can confirm that I use the external 32kHz in my design
    (this one to be absolutely sure  ?)

    So the settings are identical in app project and bootloader project:

    #define NRF_SDH_CLOCK_LF_SRC 1
    #define NRF_SDH_CLOCK_LF_RC_CTIV 0
    #define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 0
    #define NRF_SDH_CLOCK_LF_ACCURACY 7

    Then I tried to run only bootloader project on my boards. The approach was to erase chip with SD flashing and then press F5 (debug run in SES) in secure_bootloader project. Both nRF52DK and my custom board behave the same, debugger reaches line 142 in main() and loops. I believe it works as expected, at least it runs:

     

    In bootloader project I commented out all the bsp_board_xx(...) function calls from main.c. I am not using button_enter_method but buttonless so I did not bother configuring pinout for my board in bootloader project. Do you think there can hardcoded GPIO call or something like that disallowing me to debug app with DFU functionality?

  • Pawel Niedbala said:
    I am not using button_enter_method but buttonless so I did not bother configuring pinout for my board in bootloader project.

     Did you make sure to disable the NRF_BL_DFU_ENTER_METHOD_BUTTON option in sdk_config? It's enabled by default so it could explain why your board gets stuck in DFU mode.

    You may also place the breakpoint in nrf_bootloader.c::dfu_enter_check() to verify if there is a failing check that makes it to stay in DFU mode.

  • Thank you, it worked.

    Strange thing that custom board debugging with DFU worked only when NRF_BL_DFU_ENTER_METHOD_BUTTON=0 but devboard worked even with NRF_BL_DFU_ENTER_METHOD_BUTTON=1

Related