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

How to debug Application Code after add other service to Bottonless DFU?

All,

I already run BottonlessDFU example successfully after refer to below link. What's more, I added BAS and DIS service to Bottonless DFU example, and after use nrfutil.exe to generate app package, I can use nRF Connect to upload the application firmware succesfully, and I tried it many times, it works well. Now I want to add my own service and other function based on this and debug it with IDE IAR, so need your help and guidance to solve below qestions:

Q1:  How to debug Application Code to make sure it works well after add other service to Bottonless DFU? is there any guidance or suggested link to refer to?

Q2: Why did I met below errors when I try to debug my modified applciation code? How to solve it?

Q3: For DFU is need to add public key to bootloader and add private key with application, is it possible to disable uECC function? How?

Looking forward to your reply. Thanks. 

More detailed question description and test I did is as below,

1. Try to use Bottoneless DFU IAR project to see how to debug it with IAR. the step I operate is as below,

    1-a. Erase all --> download softdevice with nRFgo studio-->download secure_dfu_ble_s132(bootloader) with IAR, it can run to bootloader main --> download buttonless_dfu, it can't run to application main. so guess maybe it no private key with application when download and debug it with IDE directly, so can't run to application main.

   1-b. Then with nRF Connect app on Phone, to upload buttonless_DFU_application_package(nrfutil generate which add private key) based on DFUTarg, 100% complete, and Phone app can see Nordic_Bottonless. And then with IAR to download and debug ble_app_buttonless_dfu project, it can run to main.

2. Try to debug my own application (Add BAS and DIS service to Bottonless DFU example)

With same  operation steps, 1-a also can't run to application main, when try 1-b, IAR will give below error

"Simulator Driver

User error: Memory access error:

Trying to read outside mapped memory at address 0xf0000fe0 when PC is 0x2ce70. Check your memory configuration

"

https://devzone.nordicsemi.com/b/blog/posts/getting-started-with-nordics-secure-dfu-bootloader  

softdevice and SDK Rev I used is as below,

1. s132_nrf52_5.1.0_softdevice.hex

2. nRF5_SDK_14.2.0_17b948a

BR,

XiaoYa

Parents
  • Hi,

    A1: For debug sessions, always set the DEBUG preprocessor define and set optimization level to 0. For debugging the DFU bootloader, use the debug version of the bootloader. You can use nRF Connect for manually testing the services on your device. The nRF Sniffer lets you monitor on-air BLE traffic.

     

    A2: The DFU bootloader uses a page in flash, the bootloader settings page, for registering information about the current application. It writes to this page whenever it installs a new application over DFU, and it checks with this page to see if there is currently an application installed and that the application is the correct one.

    The bootloader settings page is separate from the bootloader (i.e. not included in the bootloader .hex). Therefore, when you use a programmer to download bootloader + SD + application, the bootloader settings page is still empty and the bootloader will not know that there is an application to start. For more on the bootloader settings page, see the last section of Device Firmware Update process on Infocenter.

    You can use nrfutil to generate a bootloader settings file for a given application. You then program the board with settings file, bootloader, SD and app, and then the app will start. See "Appendix 1. Advanced features" of Getting started with Nordic's Secure DFU bootloader that you referred to.

     

    A3: You need to add the public key in the bootloader, and use the private key to generate the DFU package. May I ask for what purpose you want to remove this signing? The code checking the signature is found in dfu_handle_prevalidate() in dfu_req_handling.c, under the "// Check the signature" comment on line 358.

    Regards,
    Terje

Reply
  • Hi,

    A1: For debug sessions, always set the DEBUG preprocessor define and set optimization level to 0. For debugging the DFU bootloader, use the debug version of the bootloader. You can use nRF Connect for manually testing the services on your device. The nRF Sniffer lets you monitor on-air BLE traffic.

     

    A2: The DFU bootloader uses a page in flash, the bootloader settings page, for registering information about the current application. It writes to this page whenever it installs a new application over DFU, and it checks with this page to see if there is currently an application installed and that the application is the correct one.

    The bootloader settings page is separate from the bootloader (i.e. not included in the bootloader .hex). Therefore, when you use a programmer to download bootloader + SD + application, the bootloader settings page is still empty and the bootloader will not know that there is an application to start. For more on the bootloader settings page, see the last section of Device Firmware Update process on Infocenter.

    You can use nrfutil to generate a bootloader settings file for a given application. You then program the board with settings file, bootloader, SD and app, and then the app will start. See "Appendix 1. Advanced features" of Getting started with Nordic's Secure DFU bootloader that you referred to.

     

    A3: You need to add the public key in the bootloader, and use the private key to generate the DFU package. May I ask for what purpose you want to remove this signing? The code checking the signature is found in dfu_handle_prevalidate() in dfu_req_handling.c, under the "// Check the signature" comment on line 358.

    Regards,
    Terje

Children
  • Terje,

    Thanks a lot for your kindly reply and help. According to your suggestion, I can set up A1 and A2. However, still not solve my question. What I want to know is "how to debug the application project (such as ble_app_buttonless_dfu project), if already have DFU bootloader+SD in nRF52832?", not to debug the DFU bootloader.

    What's more, the purpose I want to remove the uECC, is also because I want to debug the application project in IAR, for I want to add further functions based on Buttonless_DFU application project, and want to make sure the functions I add can run well. Before I thought maybe uECC lead to Buttonless_DFU can't run to main, when I use IAR to debug and download my modified application. After get your reply, maybe also need to add bootloader settings page checking.

    so what's your suggestion for how to debug the application project if already have DFU bootloader + SD in nRF52832?

    or maybe we can't debug it when have bootloader+SD? then what's your suggestion for steps to develop own application code based on Buttonless_DFU example?  maybe as below, 1. make sure own application code works well when no bootloader; 2. integrate own application code  into Buttonless DFU project; 3. use your A2 steps to program to flash, to see whether integrated application code can run well.

    Looking forward to your reply.

    BR,

    XiaoYa

  • Hi,

    It is not the signing that prevents the application from running. It is a CRC check done by the bootloader, in order to only start the application if it is there and if it is the correct one.

    You can do a small modification to the DFU bootloader in order to skip the CRC check of the application. Then it will jump straight into the application even if the application has been changed, which means you can do debugging, development, etc. without having to rewrite the bootloader settings page all the time.

    In nrf_dfu_utils.c, add the following lines to nrf_dfu_app_is_valid(), before the "// If CRC == 0, the CRC check is skipped." line:

    #ifdef DFU_BOOTLOADER_DISABLE_APP_CRC_CHECK
        NRF_LOG_DEBUG("Skipping application CRC check, as it is disabled.");
        return true;
    #endif

    Then add the preprocessor define DFU_BOOTLOADER_DISABLE_APP_CRC_CHECK to the bootloader project.

    Alternatively, if you do not want to modify the DFU library at all, you can set the bank_0.image_crc field of the DFU settings page to 0, as that will also skip checking the CRC of the application.

    Regards,
    Terje

  • Terje,

    Thanks a lot for your kindly help. Solve my issue.

    BR,

    Lina

  • Terje,

    SDK15.0.0 was released. Now I want to move to new SDK. so have same question that how to skip CRC checking in secure_bootloader_ble_s132_pca10040? It seems that CRC related function changes a lot, have below define in sdk_config.h. so if I want to disable CRC checking, add below code before nrf_bootloader_init(), is that ok? or have other simpler way to skip CRC? Thanks a lot. 

    NRF_POWER->GPREGRET2 |= 0x01; 

    #define NRF_BL_APP_CRC_CHECK_SKIPPED_ON_GPREGRET2
    Looking forward to your reply.
    BR,
    XiaoYa
Related