Application debbuging with secure DFU bootloader

Hello,

I want to use the secure DFU bootloader (for OTA update) found in SDK 17.1.0 with a nRF52840-DK board.

I try the bootloader and the application named "ble_app_button_less_dfu_pca10056_s140". When the bootloader is loaded, it run correctly, and when the application is loaded through bootloader service, it works correctly.
But when I try to debug the same application, that does not work, because the application stops when the ble_dfu_buttonless_async_svci_init function is called, it is because the UICR register is set to 0xFFFFFFFF.

I do not understand why this register is erased.

Could you help me to solve this problem ? To be able to develop our application and debug it with this bootloader.

Best regards.

Parents
  • Which UICR register reads 0xFFFFFFFF? 
    Only the bootloader hex file has UICR register addresses in it and the application hex should not touch UICR by default during a DFU. It is reconfigurable in the bootloader as to which UICR_NFW register you want to use.

    It is not clear to me why UICR register gets cleared when you are debugging the application. Can you provide steps to reproduce this?

Reply
  • Which UICR register reads 0xFFFFFFFF? 
    Only the bootloader hex file has UICR register addresses in it and the application hex should not touch UICR by default during a DFU. It is reconfigurable in the bootloader as to which UICR_NFW register you want to use.

    It is not clear to me why UICR register gets cleared when you are debugging the application. Can you provide steps to reproduce this?

Children
  • Hello,

    The problem is in "ble_app_buttonless_dfu_pca10056_s140" project, in main function, when the ble_dfu_buttonless_async_svci_init() function is call, it returns an error in "err_code" variable and the application stops.

    And that's only in debug. When I download the application with bootloader and NrfConnect, it is run correctly.

    In debbug mode, with Segger IDE, I can see that the ble_dfu_buttonless_async_svci_init() function set an error because the UICR[0] is set to 0xFFFFFFFF. Normaly this register is set to 0x000F8000, the bootloader address.

    To reproduce this, you download the "secure_bootloader_ble_s140_pca10056" project in the nRF52840-DK board and after you download the "ble_app_buttonless_dfu_pca10056_s140" application to debug it. And when you read the UICR[0] register, it is set to 0xFFFFFFFF.

    I hope it will be more clear for you.

    I use the Segger IDE version 7.32, a nRF52840-DK (PCA10056 / 3.0.1 / 2023.16 / 1050298998) and the nRF5_SDK_17.1.0_ddde560, if that can help you to understand my problem.

    Thanks for your help.

    Best regards.

    Christophe

  • Sorry for late response. I have asked one of our DFU/Bootloader expert to see if he has any opinion here. Will be right back when he suggests/comments on this.

  • Hello,

    I solved the problem. I download the secure bootloader, the SoftDevice and Bootloader settings before downloaded the application (See attached picture).
    That seems work, but I do not know if it is the right way.

    Best Regards

  • Hi,

    ble_dfu_buttonless_async_svci_init() will return an error if the Bootloader is not present (which much be the case if UICR[0] is set to 0xFFFFFFFF). So it seems the flash was erased during or while programming the application when starting the debug session.

    One way around it, could be to load the bootloader as well as the SoftDevice when you start debugging, as you do.

    there are also other problems that can show up when debugging with a bootloader. Perhaps most importantly is that it will check the integrity of the application, and if it has changes (compared to the CRC in the bootloader setting page), the application will not be started. So making a modification and programming, the bootloader would stay in DFU mode and not start the application.

    There are a few ways around that. One is to simply debug without the bootloader, and skip the call to ble_dfu_buttonless_async_svci_init for debug builds, for example by encapsulating with #ifdef DEBUG ... #endif, and then simply don't program the bootloader when you debug your application. Another is to modify the bootloader to ignore the CRC check, by for instance making app_is_valid() in nrf_bootloader.c in the bootloader always return true if y ou are using a special debug bootloader. A third is to always generate and program a bootloader settings page after flashing a modified application before you start to debug it.

  • Hi,

    Thanks for your precise answer. Currently I download (in the order) softDevice, Bootloader, Bootloader settings, and application. And that works. I will try your others solutions.

    Best Regards

Related