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

OTA Thread DFU: Merge SDK example with custom application

Hi all!

I'm able to fully test the SDK example https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_tz_v3.2.0%2Fthread_example_dfu.html and it works pretty well.

Now, the next step is the integration of this OTA DFU over Thread example in my custom application (that already exploits Thread and MQTT-SN protocol).

I haven't found a tutorial that explains step-by-step this kind of operation. 

Basically I need some help to integrate the DFU client with the user application. I think the key point is the IoT SDK CoAP library that implement a DFU algorithm that should run concurrently to the user application, but I'm a bit confused about merging process.

Thanks in advance,

Alessio

  • After some researches, I think that is a problems of keys as "prevalidation failed" probably depends on that. 

    I'm not sure about using keys. 

    What should I do with my custom app during these steps?

    In my project I just generated the public key and copy-paste it in my project explorer

  • You should include the generated public key from step 1b in your custom app (replace it with the default file containing the debug-key). When you generate the DFU-package in nrfutil, you need to provide the private key generated in step 1a. This will allow the application (DFU client) to verify the package (signed by private key) using the public key that it have available.

  • Sorry but I didn't get your point.

    I generate the priv_key as 1.a and I use it when I generate the DFU package 

    nrfutil pkg generate --hw-version 52 --sd-req 0xCA --application-version 2 --application SAMBA_Node_DFU.hex --key-file priv.pem app_dfu_package.zip

    I generate also the public_key and I drag it into my project explorer.

    I totally miss point 1.c as I don't have that path in my custom project

  • By default, the DFU client example uses our public debug-key, found in examples\dfu\dfu_public_key.c. This key only works with the test-images for BLE/serial DFU, found in examples\dfu\secure_dfu_test_images. If you did not include the file containing the debug-key in your project, it should work fine to drag in the generated public key like you describe. Including both or none of the files should give compile errors, so I guess that should not be the issue here.

  • Ah ok, I thought that the public key was used also to generate the bootloader hex file.

    I had a try generating a new  nrf52840_xxaa_mbr.hex (bootloader) file copying my new public key in examples\dfu\dfu_public_key.c but I keep having the "prevalidation failed" error.

    I'm pretty sure this error has something to do with keys.

    EDIT: I put a debug message to get which is the error cause

    From nrf_dfu_req_handler.h I can see:

    NRF_DFU_RES_CODE_INVALID_OBJECT          = 0x05,    //!< Data object does not match the firmware and hardware requirements, the signature is wrong, or parsing the command failed.

    So I think that:

    • Or it is a problem of keys and so I need some help to understand what is wrong in my approach
    • Or it is a problem of --sd-req 0xCA (I put 0xCA cause my app exploits s140_nrf52_7.0.1_softdevice.hex but I don't know if it is the right approach since DFU example used --sd-req 0x00)

    Thanks in advance,

    AS 

Related