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

Firmware update (DFU) from server or cloud.

Hello to all,

We are using nRF52840 with SDK v15.0 using SES, Our application is we have sensor devices with interface WiFi module. Sensor device will wake up as predefined time interval and send data to cloud using WiFi connectivity. 

Now we want to update this sensor devices firmware from server. Currently we are able to update firmware using secure_ble via android app. But our requirements and few questions as below:

  1. How I can download program zip file from server using WiFi and store it in flash memory? (We know how to store data array into flash using FDS but not understand how to store and read this zip file in nordic internal flash)
  2. What is best way to do as per following flow:

get zip file from sever --> store in flash --> switch application to DFU / boot-loader mode using button less --> read this file from flash --->send this file for upgrade firmware and replace with existing firmware.

For implement as per above will you please provide me sample example code and some tutorial for how to do that?

Looking forward your response..!!!

Thanks in Advanced..!!

Parents
  • Hi Vidar,

    Thanks for providing this very useful thread link. I have read this thread and also download source code as attached there.

    But I am not understand How i can start to implement this?  For your information the below our current existing working application in brief:

    We have used external WiFi module and interfaced with nRF52840 via UART. This WiFi module is communicate with nordic controller via AT command for sending our data to server as predefined interval set.  

    Now my question is How i can download or get program zip file from server with chunks via uart_event_handler in nRF52840 buffer. For that can you provide me sample program snippet to know better understanding.

    Thanks for supporting....!!!!

  • Hi,

    It may be a bit complicated. Basically what you need to do is to replace the existing UART transport layer with a custom one that retrieves new updates via your Wifi module and generate requests to the nrf_dfu_req_handler. General requirements and flow is explained in the SDK documentation here: https://devzone.nordicsemi.com/f/nordic-q-a/40476/unable-to-convert-to-long-range-after-looking-at-umpteen-examples--/157300#157300

    The existing transport layers are good as a reference to get started on your own. The main difference is probably that you don't have a DFU controller controlling the update. Also, the server should extract the zip and send the binary data of the init command and FW image on request, not the entire zip file. 

  • Thanks for your fast response..

    you need to do is to replace the existing UART transport layer with a custom one

    Can you please tell Is this possible to make custom boot-loader as per below work flow:

    1. Our device used nRF52840 and interfaced external Wi-Fi module using UART and communicate via standard AT command.
    2. We have written our application program in nRF52840 SoC not any program into WiFi module.
    3. We have able to update our firmware using mobile app, But our requirement as like if having 100 devices and update available. That time user need to go near by device and connect with mobile then update firmware manually. 
    4. This process is more time consuming to avoid this we are thinking about auto firmware update without DFU controller.

    Lets know about to you our auto firmware requirement and is this possible to implement:

    1. Device will woke up and connect with server if update available, download zip file and store it in device flash memory.
    2. Once zip flash storage process completed enter device into DFU mode.
    3. Now device in DFU mode read that stored zip file from internal flash memory.
    4. Write this zip file to dfu_request handler.
    5. Once new firmware transport successfully completed.
    6. Reset device and switch into updated firmware application.

    Will you please tell me How much difficult to implement above requirement.

    Thanks...!!!

Reply
  • Thanks for your fast response..

    you need to do is to replace the existing UART transport layer with a custom one

    Can you please tell Is this possible to make custom boot-loader as per below work flow:

    1. Our device used nRF52840 and interfaced external Wi-Fi module using UART and communicate via standard AT command.
    2. We have written our application program in nRF52840 SoC not any program into WiFi module.
    3. We have able to update our firmware using mobile app, But our requirement as like if having 100 devices and update available. That time user need to go near by device and connect with mobile then update firmware manually. 
    4. This process is more time consuming to avoid this we are thinking about auto firmware update without DFU controller.

    Lets know about to you our auto firmware requirement and is this possible to implement:

    1. Device will woke up and connect with server if update available, download zip file and store it in device flash memory.
    2. Once zip flash storage process completed enter device into DFU mode.
    3. Now device in DFU mode read that stored zip file from internal flash memory.
    4. Write this zip file to dfu_request handler.
    5. Once new firmware transport successfully completed.
    6. Reset device and switch into updated firmware application.

    Will you please tell me How much difficult to implement above requirement.

    Thanks...!!!

Children
  • vishal said:
    Can you please tell Is this possible to make custom boot-loader as per below work flow

     Yes, this should work. I cannot think of any potential blockers.

    1. Yes, the application can check if there is a newer version of the app available on the server and initiate DFU by starting the download of the init command and app image. However, you can't store the zip file in flash as that would require you to have a decompression library in your FW. I.e., the zip must be extracted on the server.  Use the message sequence charts for the serial DFU as a reference to see how the init command on FW data should be received.  

    2. Yes. The bootloader will activate the new image if both init data and FW data are stored correctly.

    3/4 You should split the download into multiple requests to the server, then generate a request to dfu_request handler for each response. Note that the init packet must be validated before proceeding with the FW update. 

    5/6. The bootloader will activate the new application on subsequent boot. 

  • Thanks for great information..!!

    Regarding your ans of my 1 point will you please provide me sample example program snippet OR useful tutorial links.

    How I can send multiple request to the server in DFU mode for that should I need to implement server connectivity program in our existing boot-loader program. Because to get Firmware image without BLE connection. 

    Thanks........

  • How you implement this will depend on the Wifi module you use and how the server is set up. I'm afraid I don't have enough information or knowledge to help you with that part. 

    vishal said:
    How I can send multiple request to the server in DFU mode for that should I need to implement server connectivity program in our existing boot-loader program. Because to get Firmware image without BLE connection. 

    The DFU is handled by the application in this case, the bootloader is only responsible for activating the new image. So the bootloader will not require support for Wifi connectivity. 

  • Hi Vidar,

    I have stored binary raw data of program zip into nRF52840 internal flash memory. Switch device into DFU mode and in DFU main.c file I have added fds.c and fds.h libraries to read this stored file from internal flash memory.

    Now I read this program zip from flash using specific file_ID and address in DFU mode. To implement next I am little bit confused and some questions:

    1. Where should i need to send this zip file buffer in dfu_request_handler?
    2. Which function need to pass this zip file buffer from main.c(secure_bootloader_uart_debug)?

    I required to update firmware without DFU controller, hence our device is act as DFU target as well as DFU controller.

    Looking forward your response..!!!

    Thanks..

  • Looking forward your response....!!

    Thanks..!!!!!

Related