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

Getting error "DFU characteristic not found"

Dear

I am try to perform an  OTA  operation on a dongle of nrf52840 by ble_app_blinky for PCA10059 project   and  light-switch server for PCA10059 project, which works well on the PCA10059.

For the OTA operation, I have a Android smart phone with nRF toolbox , a PCA10056 DK which can be connect to a dongle by swd interface. I use nRF5 SDK_16.0.0 and SDK for MASH 4.0.0.

In these case, the Softdevice will be " s140_nrf52_7.0.1_softdevice"

Step1 : I make a pair keys for this operation by nrfutil command and build  "secure_bootloader_ble_s140_pca10056_debug.emProject" project with the new public_key.

Step2 :  I download the dfu_bootloader which be built last step to  dongle which be clean by "nrfjprog -e"

Step3 :  Make a dfu.zip for ble_app_blinky project by nrfutil command which is

nrfutil pkg generate --hw-version 52 --debug-mode --sd-req 0x00 --sd-id 0xCA --application ble_app_blinky_pca10059_s140.hex --key-file private.key --softdevice s140_nrf52_7.0.1_softdevice.hex ble_app_blinky_pca10059_s140_sd_DBdfu_package.zip

Make a dfu.zip for light-switch server for PCA10059 project by nrfutil command which is

nrfutil pkg generate --hw-version 52 --debug-mode --sd-req 0x00 --sd-id 0xCA --application light_switch_server_nrf52840_xxAA_s140_7.0.1.hex --key-file private.key --softdevice s140_nrf52_7.0.1_softdevice.hex light_switch_server_nrf52840_xxAA_s140_V701_sd_DBdfu_package.zip

Step4 :  Upload those packages to different Dongle separately by DFU of nRF Toolbox on Android smart phone. All of them be successful.

Step5 :  Modify the  ble_app_blinky for PCA10059 project   and  light-switch server for PCA10059 project by exchange LED pins with each other. Repeat step3 to step4. All of them be failure with a error "DFU characteristic not found"

Q1: Is there anything wrong with the process described above?Why does the first update succeed, but then fail (only once?)?

Q2: When  I doing DFU on DFU tools of nrf toolbox on my phone, if I select  "Application" as file type, I have to select an other file as init package. which mean is if I want download an app.hex to chips, an init package will be supported. Because the SES can build a project to generate a hex file and can download the hex file to chip.  For this reason, can I assume that SES also generated the corresponding init package during the build? If the answer is yes, where is the init package?

Q3: About the bootloader setting page, If a donwload a app.hex go through bootloader, a  bootloader setting page will be generated by bootloader. is it correct? 

When I read the post here, I donot uderstand  those words below.

"But in production for example, you may not want to install the application by doing OTA DFU for thousands of device which takes lots of time. The same when you are doing development. You don't want to do DFU for any change you made to your application.

To solve this, we can generate a bootloader setting manually and merge it with the bootloader to trick the bootloader to accept the pre-flashed application. We use nrfutil to generate the bootloader setting and can use mergehex.exe tool to merge the hex files. If you don't want to merge you can flash the setting first then flash the bootloader."

Would you explain the function to me. Some examples will be better for me.

Q5: I want doing  a OTA by a dongle and a PCA10056. which tools can be used on my disktop like the DFU of nrf toolbox on smart phone?  How I can connect the PCA10056 with the desktop(J2 or J3 or others connector)?  Do i need download the dfu project to the PCA10056? Do you have a manual with detail? 

Thanks,

Di-Sheng

Parents
  • Hi Edvin

    Thanks for your reply, That is very powerful.

    I have completed the BLE OTA DFU in button mode, which include from PDK to DK and Dongle by Bluetooth Low Energy and nRFUtil  of desktop and nRFconnect and Toolbox of smart phone. All of them works well, which include a pca10059_s140_ble_debug for PCA10059.

    Now I am doing the buttonless DFU . Would you like to help me for some questions below.

    Q1. I notice the "ble_app_buttonless_dfu" is an application code, because it occupy application area in the chips after flash it into chips. I read the some information here(Buttonless Secure DFU Service) and here(Buttonless DFU Template Application) in  Infocenter. I think it should be added to my own application project, not dfu bootloader, right? If the answer is yes,  a chip which just have BLE_DFU bootloader and SD can not implement a buttonless ble dfu procession. is it right?--which mean whether we can make a device which can implement Buttonless ble dfu function without a application project like the button ble dfu function?

    Q2. Would you like to use the sample project Light-Switch Server or ble_app_blinky as an example to show me how to add Buttonless BLE DFU to it? because I do not know how to generate the "bootloader_secure_ble_debug_without_bonds_s140.hex" which is in "nRF5_SDK_16.0.0_98a08e2\examples\dfu\secure_dfu_test_images\ble\nrf52840" and it seem do not inlude a application code.

    Q3. Can the "mergehex" tools  merge two or more HEX files together without conflict although  their  "SES-->Code-->Linker-->Section PLacement Macros" are same ?

    Thanks,

    Di-Sheng

Reply
  • Hi Edvin

    Thanks for your reply, That is very powerful.

    I have completed the BLE OTA DFU in button mode, which include from PDK to DK and Dongle by Bluetooth Low Energy and nRFUtil  of desktop and nRFconnect and Toolbox of smart phone. All of them works well, which include a pca10059_s140_ble_debug for PCA10059.

    Now I am doing the buttonless DFU . Would you like to help me for some questions below.

    Q1. I notice the "ble_app_buttonless_dfu" is an application code, because it occupy application area in the chips after flash it into chips. I read the some information here(Buttonless Secure DFU Service) and here(Buttonless DFU Template Application) in  Infocenter. I think it should be added to my own application project, not dfu bootloader, right? If the answer is yes,  a chip which just have BLE_DFU bootloader and SD can not implement a buttonless ble dfu procession. is it right?--which mean whether we can make a device which can implement Buttonless ble dfu function without a application project like the button ble dfu function?

    Q2. Would you like to use the sample project Light-Switch Server or ble_app_blinky as an example to show me how to add Buttonless BLE DFU to it? because I do not know how to generate the "bootloader_secure_ble_debug_without_bonds_s140.hex" which is in "nRF5_SDK_16.0.0_98a08e2\examples\dfu\secure_dfu_test_images\ble\nrf52840" and it seem do not inlude a application code.

    Q3. Can the "mergehex" tools  merge two or more HEX files together without conflict although  their  "SES-->Code-->Linker-->Section PLacement Macros" are same ?

    Thanks,

    Di-Sheng

Children
  • cor10 said:
    So this confirms your suspicions about the cached GATT table - thank you. How can I avoid this issue moving forward? I tried deleting and re-installing the nRF Connect Mobile app on my iphone to reset this cache, but it actually still has the same problem as before (cant see the Buttonless DFU Characteristic).

     This table is stored on the phone, and turning bluetooth completely off and on (or maybe even turning the phone off and on) typically solves this. It depends a bit on the phone model. 

    The usual workaround for this is to include something called the Service Changed service (defined by Bluetooth). The buttonless DFU example contains this service. Search for SERVICE_CHANGED in the buttonless dfu example's sdk_config.h file. What this service does is tell the central when it has added new services, and the phone will then do a new service discovery. The problem is if this service was not included from the beginning.

    Another temporary workaround is to change the address of the device when you experiment with different services. You can use sd_ble_gap_addr_get/set():

        ble_gap_addr_t my_addr;
        err_code = sd_ble_gap_addr_get(&my_addr);
        APP_ERROR_CHECK(err_code);
        my_addr.addr[0] += 0x01;
        err_code = sd_ble_gap_addr_set(&my_addr);
        APP_ERROR_CHECK(err_code);

    Note that this may mess up the DFU process in some cases, because android phones expect the address of the device to be incremented by one when in DFU mode, and it is done quite similar to this. But turn the bluetooth (or phone if that doesn't work) off and on again, and see if that helps. 

     

    Di-sheng said:
    Q1. I notice the "ble_app_buttonless_dfu" is an application code, because it occupy application area in the chips after flash it into chips. I read the some information here(Buttonless Secure DFU Service) and here(Buttonless DFU Template Application) in  Infocenter. I think it should be added to my own application project, not dfu bootloader, right? If the answer is yes,  a chip which just have BLE_DFU bootloader and SD can not implement a buttonless ble dfu procession. is it right?--which mean whether we can make a device which can implement Buttonless ble dfu function without a application project like the button ble dfu function?

     It should be added to the application, and not the bootloader project. That is correct. A chip that only has a bootloader and the softdevice will automatically enter DFU mode, since it doesn't have an application. So you don't have to press any buttons. 

     

    Di-sheng said:
    Q2. Would you like to use the sample project Light-Switch Server or ble_app_blinky as an example to show me how to add Buttonless BLE DFU to it? because I do not know how to generate the "bootloader_secure_ble_debug_without_bonds_s140.hex" which is in "nRF5_SDK_16.0.0_98a08e2\examples\dfu\secure_dfu_test_images\ble\nrf52840" and it seem do not inlude a application code.

     ble_app_blinky. The reason for this is that the light-switch server is a Bluetooth Mesh example. While you can use the "normal" BLE bootloader together with mesh, it also has it's own bootloader solution that is targeted for Mesh. 

    I have never used the precompiled .hex files for DFU. I don't really see where one would use them. I suggest you build your own bootloader. In that case, you know what private key you can use to generate application images. The .hex file that you refer to is a bootloader (and softdevice, I believe), but no application. But you do not have the private key that is used to generate the public key that is used in this hex file.

    I suggest you start with this guide:

    https://devzone.nordicsemi.com/nordic/short-range-guides/b/software-development-kit/posts/getting-started-with-nordics-secure-dfu-bootloader

     

    Di-sheng said:
    Q3. Can the "mergehex" tools  merge two or more HEX files together without conflict although  their  "SES-->Code-->Linker-->Section PLacement Macros" are same ?

     You can merge .hex files using "mergehex", as long as they don't have overlapping areas. So you can merge bootloader, softdevice and application (and bootloader settings if you like), but you can not merge two applications with the same start address.

  • Thank you for your tips on this. Everything you mentioned proved to be true. I have to turn on and off my phone to refresh the GATT table, and if the Service Changed option is set from the beginning, it works as expected.

    Now that I confirmed that the default buttonless DFU example works as is, I have merged my previous ble_app_uart project with the buttonless DFU template. I have everything included and it builds/compiles without error.

    However, when I try to load this merged application onto my device, it doesnt run...something is faulting. When I try and use the debugger, it never successfully starts....usually when I run Build and Debug, it loads the code onto the device, and then prompts me with a Start button to begin Debugging. However, the issue with my merged Buttonless DFU/UART project is that the debugger never presents me with a Start button to click, as if its already running (I see the Pause button instead of Play in the Segger Embedded Studio). So this tells me that something is faulting before the Debugger can even start properly. I tried to see where this behavior is coming from since the dafault example works fine, and so I simply added the NUS Service UUID in 'm_adv_uuids[] as a first step, and this is enough to replicate the behavior Im talking about.

    static ble_uuid_t m_adv_uuids[]         = 
    {
        {BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE},
        {BLE_UUID_NUS_SERVICE, NUS_SERVICE_UUID_TYPE}
    };

    What would you recommend is the best way to resolve this issue? There must be some configuration issue that I am missing with the overlapping DFU and UART projects. When merging the 2 SDK Config files, there were only a few instances where the two files had different setting values. Specifically, these conflicting settings were:

    • #define PEER_MANAGER_ENABLED
      • 1 in the Buttonless DFU, 0 in the UART application
    • #define PM_CENTRAL_ENABLED
      • 0 in the Buttonless DFU, 1 in the UART application
    • #define BLE_DFU_ENABLED 1
      • This needs to be set to 1, so ignoring
    • #define CRC16_ENABLED
      • 1 in the Buttonless DFU, 0 in the UART application
    • #define FDS_ENABLED
      • 1 in the Buttonless DFU, 0 in the UART application
    • #define NRF_FSTORAGE_ENABLED
      • 1 in the Buttonless DFU, 0 in the UART application
    • #define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY
      • 1 in the Buttonless DFU, 0 in the UART application
    • #define NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED
      • 1 in the Buttonless DFU, 0 in the UART application
    • #define NRF_LOG_BACKEND_RTT_ENABLED
      • 0 in the Buttonless DFU, 1 in the UART application
    • #define NRF_LOG_DEFAULT_LEVEL
      • 3 in the Buttonless DFU, 4 in the UART application
    • #define NRF_SDH_BLE_GAP_DATA_LENGTH
      • 27 in the Buttonless DFU, 251 in the UART application
    • #define NRF_SDH_BLE_GATT_MAX_MTU_SIZE
      • 23 in the Buttonless DFU, 247 in the UART application

    I also changed NRF_SDH_BLE_VS_UUID_COUNT to be 2 (previously 1) for both DFU and UART, and changed NRF_SDH_BLE_SERVICE_CHANGED to 1 (previously 0).

    Does anything seem suspicious here? Thank you so much for you time and help with this.

Related