Send dfu image between two nrf5340

Hi,

What is the best way to send image from one nrf5340 that is central to other nrf5340 that is peripheral in order to update him via 

MCUMGR
thanks
  • The solution I'm working on is intended for two chips running Zephyr/NCS, is that the case for you enpre

    MaximSh I was just able to successfully perform a dfu update using this central_smp_client_dfu and the smp_svr sample. I have not been able to implement the image list command, which is needed in order to get the hash of the new image, which is used to test and confirm the image.

    As a temporary workaround, I modifed the img_mgmt.c library in the following manner:

    diff --git a/subsys/mgmt/mcumgr/lib/cmd/img_mgmt/src/img_mgmt.c b/subsys/mgmt/mcumgr/lib/cmd/img_mgmt/src/img_mgmt.c
    index 119906204c..e12bb3f0aa 100644
    --- a/subsys/mgmt/mcumgr/lib/cmd/img_mgmt/src/img_mgmt.c
    +++ b/subsys/mgmt/mcumgr/lib/cmd/img_mgmt/src/img_mgmt.c
    @@ -448,6 +448,10 @@ img_mgmt_upload(struct mgmt_ctxt *ctxt)
     #endif
     		/* If this is the last chunk */
     		if (g_img_mgmt_state.off + req.img_data.len == g_img_mgmt_state.size) {
    +			rc = boot_set_pending_multi(0, false);
    +			if (rc != 0) {
    +				return rc;
    +			}
     			last = true;
     		}
     
    

    So on the smp_svr side, it will set the image as pending right after the update is complete. After doing this, after resetting the chip running the smp_svr sample, MCUboot saw the new update in the secondary slot and swapped it into the primary slot.

    In order for the update to not revert back, you should call boot_write_img_confirmed() from within the new updated image. Like it's done in the http application update sample

    I will continue to work with implementing the image list command.

    Best regards,

    Simon

  • Hey Simon, 

    Thank you for putting this together. Like @enpre, I was directed to this thread from another thread. 

    What Enpre and I are trying to do is download an image for nrf52840 over an LTE/WIFI chip (nrf9160 in my case) and then send it to the BLE chip over UART. I've been trying to follow this link to formulate a solution that works, but there's very little documentation that explains what's going on there. 

    So my question is - what modifications does your code need to be able to DFU over UART. I use a zephyr ncs code on my nrf9160 and an sdk17 based code on my NRF52840, but I am happy to port to ncs if it makes the OTA solution easier. 

    Also, thank you so much for helping out with this! 

  • Exactly, I have the same task to do as  
    To be honest   it's the first time I approach OTA on zephyr ( or generally linux based devices) and so I have to go deep into some topics, as MCUBoot / Images I haven't used before.

    When I asked support here I believed that OTA was a common task on a IoT device as Nordic's MCU, but I imagined wrong 

    So, what I can do, is to go deep into the main concepts and support you if you are doing something on this, I think that help one to each other in this open source world is a great opportunity to make the world better than now.

  • Okay, so let me try to clarify:

    Hash5422

    If I understand it correctly, you want to perform a DFU update in the following manner: Cloud/server-->LTE-->9160 (NCS)-->UART-->52840 (nRF5 SDK).

    It may be a good idea to port the 52840 to NCS, especially if it's a new design. If you do port to NCS, then you could look at this pull request https://github.com/nrfconnect/sdk-nrf/pull/8839 (a customer updated the solution you've been looking to NCS v2.0.0). I think my (almost complete) solution should work fine as well (if 52840 runs NCS), you just need to modify it to get the binary chunks from the library that receives the binary from the cloud, instead of reading it from flash. If you're not planning to go for my solution, please continue the discussion in this thread: Perform NRF52840 OTA over the NRF9160 and UART, since it's nice to keep the thread clean and on-topic. I have worked some with this, so I could probably re-assign the ticket to me and give more inputs

    enpre

    Is this what you're trying to achieve? Cloud/server-->WiFi-->ESP32 (SDK?)-->UART-->52840 (SDK?)

    What SDK are you using on the ESP32? What SDK are you running on the 52840? If both are running NCS/Zephyr you could use my solution, and continue the discussion in this thread.

    If the esp32 is running some other SDK and the 52840 is running NCS, I think it is easier to just skip the SMP protocol (which the solution in this thread uses) and send the binary image as raw bytes. Check out this ticket for more information, it is the opposite of your solution but should still be relevant since it explains how to send the image as raw bytes and what to do on the 9160 once the update is received (the same should be done on the 52840 if NCS is used). However, if you have more questions regarding this, please continue the discussion in Perform NRF52840 OTA over the NRF9160 and UART. I have worked some with this, so I could probably re-assign the ticket to me and give more inputs

    If the esp32 is running some other SDK and the 52840 is running nRF5SDK, I will not be of much help, since I have not touched the nRF5 SDK in many years. Then you should probably continue the discussion in Perform NRF52840 OTA over the NRF9160 and UART, or if Håkon is not familiar with the nRF5 SDK either just create a new ticket. Remember to specify in the title that the 52840 is running the nRF5 SDK and the ticket will be assigned to an engineer with knowledge about this.

    Best regards,

    Simon

  • Hi,
    Thanks. 
    Did you test it on sdk 1.9.1? 

Related