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

How to connect debugger to Thread Secure DFU example with Segger Embedded Studio

Hi,

Following the example https://infocenter.nordicsemi.com/topic/sdk_tz_v4.1.0/thread_example_dfu.html how can you connect a jlink debugger and step through the application?

Should a post-build script generate a settings.hex file to merge with the application?

Setup

Ubuntu 20.04 OS

Segger Embedded Studio 4.52c

nRF5 SDK for Thread and Zigbee v4.1.0

nRF52840

Parents
  • Hi,

    Could you elaborate more what exactly you want to achieve ? 

    If you want to debug the bootloader, you can just use SES and step through the code. 

    If you want to debug the application, after you receive the application image via DFU, you can run the debugger of the application in SES as normally. 

    Note that the settings.hex contains the bootloader setting and it's not located inside the application's flash area. So when you debug the application using your application compiled binary files the bootloader setting won't have any effect. 

  • Hi,

    I just want to be able to step through the application code, leaving the MBR/bootloader/settings as is. 

    So what I do: (as the documentation describes)

    Generate keys (once) with nrfutils

    Then the following commands

    # generate settings hex file
    nrfutil settings generate 
    --app-boot-validation NO_VALIDATION --family NRF52840 --application app.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 settings.hex

    # merge app + settings
    mergehex -m app.hex settings.hex -o merged.hex

    # erase the chip
    nrfjprog -f nrf52 --eraseall

    # flash mbr
    nrfjprog -f nrf52 -r --program components/softdevice/mbr/hex/mbr_nrf52_2.4.1_mbr.hex --chiperase

    # flash bootloader
    nrfjprog -f nrf52 -r --program bootloader.hex

    # flash settings + app
    nrfjprog -f nrf52 -r --program merged.hex --sectorerase

    After that from SES I do Debug > Go but the output screen show:

    Preparing target for user application
    Executing Reset script TargetInterface.resetAndStop()
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    Stopped by vector catch
  • Hi, 
     I just tested here and it worked fine for me. I can stop at the beginning of main(). 

    Please make sure you use the client application image that you built from SES, not the one in armgcc as suggested in the documentation. Different compile gives different image even though they are same application. 

    So the app.hex should be from \examples\thread\dfu\client\pca10056\blank\ses\Output\Release\Exe

    Please make sure you can debug it by just flashing MBR then app, before you test with merging settings and flashing bootloader. 

Reply
  • Hi, 
     I just tested here and it worked fine for me. I can stop at the beginning of main(). 

    Please make sure you use the client application image that you built from SES, not the one in armgcc as suggested in the documentation. Different compile gives different image even though they are same application. 

    So the app.hex should be from \examples\thread\dfu\client\pca10056\blank\ses\Output\Release\Exe

    Please make sure you can debug it by just flashing MBR then app, before you test with merging settings and flashing bootloader. 

Children
No Data
Related