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

How can I debug in Segger Embedded Studio when bootloader exists?

I am using NRF52840DK with SDK15.2 to test the DFU. 

I use Segger Embedded Studio to compile both the secure_bootloader  project and ble_app_buttonless_dfu project.

Then I use nrfjprog to program the hex files including the setting , SD, and application  .into nrf52840dk

and DFU works perfectly.

My Question is : 

How can I debug in Segger Embedded Studio when bootloader exists?

I mean using the Debug > Go in the SES for the debugging.

I can debug line by line in the bootloader project  after  programming the merged image, 

but I cannot debug line by line with the ble_app_buttonless_dfu project. It fail to  start at "main". 

I cannot debug the application when bootloader exist. 

How to debug  in Segger Embedded Studio when bootloader is used. ? 

Thank you.

  • Hello,

    I just tested what you described, and I get the same behavior as you do. Sometimes I actually manage to debug, but when I reset, it goes back into bootloader mode. The reason for this is that the .hex file which you program with SES is a bit different than the .elf file that is used, so the CRC doesn't mach.

    The solution is to use the secure_bootloader\pca10056_ble_debug bootloader when you want to debug, which skips the CRC check. Use this for development, and switch to the non-debug bootloader for your final checks. The bootloader behaves the same, except that the CRC check is enabled.

    You still need to add keys (just use the same ones as you did in the debug bootloader), and create either the bootloader settings page or perform the DFU first, in order to update the bootloader settings to go into the application. The debug bootloader still checks the other requirements for the application.

    I hope that works. Let me know if it doesn't.

    Best regards,

    Edvin

  • Hi Edvin, I follow your instruction with the following steps

    1. compile the secure_bootloader\pca10056_ble_debug for the bootloader  with SES
    2. merge the bootloader's hex file with the application and  setting and then download to the nrf52840-dk.
    3. In SES , with the project ble_app_buttonless_dfu, run the debug 
    4. The debug cursor  then start at main . It seems debugging is worked now, but it will stop responding till it reach "err_code = ble_dfu_buttonless_async_svci_init();"

    Is there anything I need to add or change ?

    Thank you

  • Hello,

    If you use BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE, then the maximum allowed advertising duration is 180 seconds. This is mentioned in ble_hap.h ( #define BLE_GAP_ADV_TIMEOUT_LIMITED_MAX (18000) )

    If you use BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE, you can use a longer timeout. However, when I tested this, it seems like the softdevice only accepts 16 bits timeout value. 

    65535 works fine, while 65536 goes immediately to sleep.

    What you can do, if you need 14 minutes of advertising, you can use BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE, and set the APP_ADV_DURATION to 0 (it will not stop advertising), and use a different timer to count to 14 minutes, and then stop the advertisement manually from there.

    BR,

    Edvin

  • What do you mean by stop? Does it return, or not? If not, can you try to compile your application (not bootloader) without optimization? That may be what you are seeing. It may be that it somehow jumps to another place, which returns an err_code != 0, and is caught by an APP_ERROR_CHECK.

    Try to remove the optimization, and see if you are able to get past this point.

    BR,

    Edvin

  • Optimization Level is None and it still cannot past this point.


    Yes,  It cannot be return. It is more correctly to say that it doesn't return at  nrf_dfu_set_peer_data_init();

    Then I remove the the call to ble_dfu_buttonless_async_svci_init() in the main(), the program can be run and debug step by step. However,  DFU was always failed. 

    Does it mean that it is necessary to comment this line " ble_dfu_buttonless_async_svci_init() " when I need to debug ?

    Thank you

Related