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.

    I have added buttonless function into ble_app_blinky example of nRF5_SDK_16.0.0_98a08e2  which is for PCA10056. It works very well, and past the testing of DFU without button.

    I also try to add the buttonless function to light-switch server example of nrf5_SDK_for_Mesh_v4.0.0_src which is for PCA10056. but I got  an error of building:

     

        implicit declaration of function 'NRF_LOG_INFO'; did you mean 'NRF_GPIO'? [-Wimplicit-function-declaration]

        implicit declaration of function 'NRF_LOG_ERROR'; did you mean 'NRF_LOG_DEFERRED'? [-Wimplicit-function-declaration]

        'err_code' undeclared (first use in this function)

    I think I miss some files of SDK in my project which defined error code of SDK.

    Q1: Would you help me to find which files I missed.

    Q2: Will the function of MESH be affected or destroyed if SDK files are added?

    Thanks,

    Di-Sheng

  • Hi Edvin

    Thanks for your reply.

    As I told you that I have completed to add buttonless function to into ble_app_blinky example of nRF5_SDK_16.0.0_98a08e2 for PCA10056 and PCA10059 and all of them works well.

    Because the ble of nRF5 SDK is basic of mesh, I think the buttonless function should be supported by the application project of Mesh. I do same thing on to the light-switch server example of Mesh like I did on to blinky example of nRF5 SDK. because the example of Mesh do not use more function of nRF5 SDK, so adding the buttonless function to the Light-Swtich Server example of Mesh is more operant than adding it to the blinky example of nRF5 SDK. The extra operation be showed below:

    1. When implement Buttonless Secure DFU Service initializing, because there isnot a services_init() in the main.c of light-switch server example. I add a services_init() and a call in initialize() ,like below:

    //Initializing the Buttonless Secure DFU Service

    static void services_init(void)

    {

    ret_code_t         err_code;

    ble_dfu_buttonless_init_t dfus_init =

    {

    .evt_handler = ble_dfu_buttonless_evt_handler

    };

    err_code = ble_dfu_buttonless_init(&dfus_init);

    APP_ERROR_CHECK(err_code);

    }

     

    static void initialize(void)

    {

        __LOG_INIT(LOG_SRC_APP | LOG_SRC_FRIEND, LOG_LEVEL_DBG1, LOG_CALLBACK_DEFAULT);

        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "----- BLE Mesh Light Switch Server Demo -----\n");

        ERROR_CHECK(app_timer_init());

        hal_leds_init();

    #if BUTTON_BOARD

        ERROR_CHECK(hal_buttons_init(button_event_handler));

    #endif

        ble_stack_init();

    services_init();

    #if MESH_FEATURE_GATT_ENABLED

        gap_params_init();

        conn_params_init();

    #endif

     

        mesh_init();

    }

     

    1. In mian.c file, add some include files for peer_manager , power management library and dfu driver:

    #include "nrf_dfu_ble_svci_bond_sharing.h"

    #include "nrf_svci_async_function.h"

    #include "nrf_svci_async_handler.h"

    #include "ble_dfu.h"

    #include "nrf_bootloader_info.h"

    #include "nrf_log.h"

    #include " nrf_pwr_mgmt.h

    1. In sdk_config.h file,add some code below:

    #ifndef NRF_PWR_MGMT_ENABLED

    #define NRF_PWR_MGMT_ENABLED 1

    #endif

    1. Add some include directories to optionsàcode(common)àPreprocessoràUser Include Directories:

    Add "nRF5_SDK_16.0.0_98a08e2\components\libraries\bootloader" for nrf_bootloader_info.h

    Add "nRF5_SDK_16.0.0_98a08e2\components\libraries\bootloader\ble_dfu" for nrf_dfu_ble_svci_bond_sharing.h

    Add "nRF5_SDK_16.0.0_98a08e2\components\libraries\svc" for nrf_svci.h

    Add "nRF5_SDK_16.0.0_98a08e2\components\libraries\fds" for fds.h

    Add "nRF5_SDK_16.0.0_98a08e2\components\libraries\mutex" for nrf_mtx.h

     

    I have soluted the problem which was in my last post by include "nRF_log.h" in main.c file. So the light-switch server example with buttonless DFU function past the building. It be flashed to the DK by BLE DFU in frist time, but the application do not start to work, the led1-4 kept on(nomal they should be flashing) and the application code appears to be stuck. there is not adverting.

        For this parts, I have some question below:

    Q1:  Since the Mesh protocol is based on BLE, buttonlessDFU supported by BLE should also be available for Mesh applications. Is it correct?

    Q2:  Did my above actions of adding Buttonless Dfu to the application cause some conflicts that prevented the application from running? Would you help me to find the reason?

    For find the reason, I compare the map in chips by nRFConnect àProgrammertools,please to see the picture(the both DK have been erased by "nRFjprog -e" command)

    pic 1 Chip's MAP of ble_app_blinky with buttonless DFU for PCA10056

    pic 2: Chip's MAP of light-switch server with buttonless DFU for PCA10056

    As we know, The black , red and yellow areas in pic1 and pic2 is for Setting page and MBR-P, bootloader and MBR;

    Green A area is for Software.

    The ble_app_blinky with buttonless DFU for PCA10056.bin is about 25kByte

    The light-switch server with buttonless DFU for PCA10056.bin is about 137kByte

    So the Green B area of pic1 is for application.  The green B and C of pic2 is for application.

    My question is below:

    Q3: What is for the green C of pic1?

    Q4: Why doesn't pic2 have this piece which like Green C of pic1? Is it the reason which the application do not run?

     

    Thanks

     

    Di-Sheng

  • Hello again Edvin,

    I hope you are still able to see this response even after all this time. I have been retasked to figure out whats wrong, so I am resurrecting this thread.

    I dont see any output in the Debug Terminal at all. And when the program halts in the Debugger at the NRF_BREAKPOINT_COND; in the Fault Handler of "app_eroor_weak.c", I can see that DEBUG is defined. I notice that there is technically some output in the Debug Terminal: about 6 empty lines.

    When I "Attach Debugger", I am attaching it to the device after the device has been put into DFU mode. To be specific, I flashed the DFU Secure Bootloader example and triggered DFU mode via a push button (I also tested that it could upload a previous application image correctly before putting it in DFU mode again). While its in DFU mode awaiting my new code, I attach the debugger from the SEGGER Embedded Studio IDE. Then from my iPhone, I connect to the device, and start DFU with the prepared HEX code of my own Buttonless_DFU app code (this is a merge of the standard Buttonless DFU app which has been tested and works, along with the BLE UART example code and the TWI sensor code). From the nRF Connect app on my iPhone, the DFU process finishes and I get a little message saying that the DFU was completed successfully. However, my device never starts advertising again, so I cannot connect to it and run the application. I confirm that it is an issue with the Application Code because I am able to put it back into DFU mode and successfully upload a previous Application Image without any issues and it works as expected. So I must be doing something wrong with the merged Buttonless DFU/BLE Uart/TWI Sensor code.

    What else can I do? Is there any other option for me to Debug this? Thank you so much for your help

  • ,

    Disclaimer: 
    It has been a long time since this ticket was active, and I have not read through the old replies. I'll answer based on the information from your latest reply, but for follow up questions, you should consider creating a new ticket where you summarize all your present issues.

     

    cor10 said:
    I dont see any output in the Debug Terminal at all. And when the program halts in the Debugger at the NRF_BREAKPOINT_COND; in the Fault Handler of "app_eroor_weak.c", I can see that DEBUG is defined. I notice that there is technically some output in the Debug Terminal: about 6 empty lines.

     What project did you attach the debugger to? The bootloader or the application? 

    I believe it is the application, based on the rest of your description. What you should do:

    Generate bootloader settings (use nrfutil settings generate --help, and check this description) using the application that you want to debug. 

    Program bootloader + softdevice + application + bootloader settings, and then attach the debugger to your application project in SES.

    add DEBUG to your preprocessor definitions, and disable optimizations*. Remember to re-generate your bootloader settings if whenever you update the application like this, or do any changes to the application code.

    Try to debug, and see where the application fails.

    In your application project, did you remember to include the function:

        err_code = ble_dfu_buttonless_async_svci_init();
        APP_ERROR_CHECK(err_code);

  • Thanks for the reply Edvin. I will make a new ticket and summarize my set up and my bug in more detail, but I have a couple things Id like to mention before doing so to hopefully make it as good of a ticket as possible.

    The way I am currently attaching the debugger is as follows:

    • I open the DFU secure bootloader example code from the nrf sdk, build it, and download it to my device using the Segger Embedded Studio IDE
    • When its on and advertising in DFU mode, I select "Attach Debugger"
    • Then I attempt to use the iOS nRF Connect app to write my Buttonless DFU app image .zip package to my device (I use this command "nrfutil pkg generate --hw-version 52 --application-version 1 --application Buttonless_custom.hex --sd-req 0xCB --sd-id 0xCB --key-file private.key Buttonless_custom.zip" which was described in this tutorial https://devzone.nordicsemi.com/nordic/short-range-guides/b/software-development-kit/posts/getting-started-with-nordics-secure-dfu-bootloader)
    • From the iPhone app, the Buttonless OTA DFU finishes successfully, yet the Debug Terminal shows nothing and the device never begins advertising my custom Buttonless DFU app.

    How would I attach to the bootloader? Whats the difference between attaching the debugger like I have described above and "attaching the debugger to my application project in SES" as you mention?

    I am sending only the application image .zip package via nRF Connect. I realize maybe I am making a mistake by not also sending the bootloader and softdevice and bootloader settings along with it. There is a section in the Appendix of that tutorial I linked above called "Combine Application, Bootloader and SoftDevice Image - Bootloader Setting"...I didnt implement this part because I assumed it was extra/optional as I am able to run the default Buttonless DFU app by just sending only the application image via nRF Connect. Is this Appendix Section what you mean when telling me to program the bootloader + softdevice + application + bootloader settings?

    Do I need to be sending a merged bootloader/softdevice/application/settings hex image as a combination if I want my custom Buttonless DFU app to run correctly? I am also a little confused as to what the bootloader settings are used for exactly.

    And yes, my main() function executes ble_dfu_buttonless_async_svci_init(); as one of the first function calls. Thank you for taking your time to help me with these concepts - its much appreciated

  • You should attach the debugger from the Segger Embedded Studio project running your application (the one that you udpdate to using nRF Connect for iOS. It has to do with what addresses the project is looking at. If the bootloader starts the application this is outside the bootloader project, so the bootloader project doesn't know how to handle it.

     

    cor10 said:
    I realize maybe I am making a mistake by not also sending the bootloader and softdevice and bootloader settings along with it.

     No need to do that.

     

    cor10 said:
    .I didnt implement this part because I assumed it was extra/optional as I am able to run the default Buttonless DFU app by just sending only the application image via nRF Connect.

     It is optional, but useful for debugging. If you do this, you don't have to perform the DFU every time you want to change something in your application. 

    Create a file called test.bat that does this for you, so you can just run it from a cmd window. It should look something like this:

    :: compile bootloader and application:
    make -C <bootloader_makefile_folder_path>
    make -C <application_makefile_folder_path>
    
    nrfutil settings generate <options> settings.hex
    
    nrfjprog -e
    nrfjprog --program <softdevice>.hex --verify
    nrfjprog --program bootloader.hex --verify
    nrfjprog --program application.hex --verify
    nrfjprog --program settings.hex --verify
    
    nrfjprog --reset

    You can compile using SES if you prefer that instead of the makefiles. 

    If you need help to generate the bootloader settings, use "nrfutil settings generate --help" or see the link from my previous reply.

     

    cor10 said:
    Do I need to be sending a merged bootloader/softdevice/application/settings hex image as a combination if I want my custom Buttonless DFU app to run correctly? I am also a little confused as to what the bootloader settings are used for exactly.

     The bootloader settings are not used to generate an application image. It is used if you want to flash the application directly using the programmer when a bootloader is present. The settings contains a signature that makes the bootloader accept the image. If you try to flash an application and the bootloader without settings, you will see that the application is not starting, because the signature is not present. The signature is generated automatically by the bootloader when you perform the DFU.

    This has nothing to do with the original title of this ticket. Please create a new ticket. 

  • Thank you Edvin. I finally understand what you mean. It took me a while to grasp the concept but your explanation really helped me becuase now I should be able to at least debug it properly! Sorry for not creating a new ticket on this.

Reply Children
No Data
Related