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

Write firmware to bank 1 from application

Hello.

I would like to know if its possible to preform a firmware update from the application itself like so:

1. Getting the firmware via UART in chunks of 2k (from a GSM modem).

2. Writing each chunk to Bank1.

3. Reset to DFU mode that will check if the data in Bank1 is valid.

4. If so, copy it to Bank0 and start the application.

If its possible, I would like to know how to write directly to bank1 from my application and how to reset to that DFU mode.

We are currently using SDK15.

Thanks and all the best,

Ofer.

Parents Reply Children
  • Hi Vidar,

    Thank you for the reply.

    I've read the thread you send and many others including this one. Please let me know if I got this correctly:

    From my application:

    1. Get Bank1 address by calling nrf_dfu_bank1_start_addr().

    2. Write the file I download to to that address (The file is the output of the nrfutil).

    3. Call nrf_dfu_validation_init_cmd_execute(<Bank1 address>, <file size>).

    4. If the return value is NRF_DFU_RES_CODE_SUCCESS, reset.

    In the bootloader: The nrf_bootloader_init will call nrf_bootloader_fw_activate and app_activate() the new firmware?

    All the best,
    Ofer.

  • Hi Ofer,

    The steps you outlined are not wrong, but normally you will want to decode and validate the init packet before you start receiving the FW image. What I generally recommend is to import and reuse the same DFU modules as the bootloader, same as I did in the example I uploaded to the other thread. The "nrf dfu" modules will take care of validation and storing of the new image for you. The missing piece will then be to create a custom transport to retrieve data from the modem and forward it as DFU requests to the nrf_dfu_req_handler.

    You can find the requirements for a DFU transport layer described in the "DFU protocol"chapter of the Bootloader documentation. Also, not sure if you are on SDK v.15.3.0 or v15.0.0, but note that 15.3.0 includes some bug fixes related to background DFU.

    Best regards,

    Vidar

  • Hi Vidar,

    We use SDK 15.3.0 (We are also working on moving to SDK 17).

    The reason I want to receive the file first is because I already have a file download flow implemented. So it will be easier for me to get the ZIP file and then decode and validate it, rather then getting chunks of the ZIP file (I don't know the order of the chunks so I don't know how to set the init packet from the ZIP myself).

    Is it possible to write the ZIP file to Bank1 and then decode and validate it?

    Another option that I can use is to write the ZIP file to external flash if that helps to simplify the process?

    All the best,

    Ofer.

  • Hi Ofter,

    You should extract the zip before you send it. The *.dat file contains the init data, and the *.bin file is the FW image.

    Best regards,

    Vidar

  • Hi Vidar,

    Can I simply put the files (or just the *.bin file) in Bank1 and reset?

    Will the bootloader see that it has data in Bank1, validate it and copy it to Bank0?

    All the best,
    Ofer.

Related