nRF52840 : update from a LTEM modem

Hello,

My device is already implementing DFU over BLE and all is working fine. But now, I want to add the update over LTEM (Quectel BG77).

I want to proceed like this : 

 ('ko" means kilobyte (KB))

Step 1 => First, the current application on my host CPU (nRF52840) is dowloading the ".bin" and the ".dat" file from the last package availble by using FTP protocol and storing them into the bank2.

Step 2 => Then, the current application checks the checksum of the downloaded binary

Step 3 => Finally, if everything is ok, the application reboots and indicate to the bootloader to copy .bin into bank1 and then execute it.

Is it something that could work ? From what i understand, this is the easiest way to proceed.

Regarding step 1 and step 2, i'm not worried, it is more about step 3 where i have some questions : do I need to update the settings in the bootloader by myself ? How can i proceed ? 

Feel free to help if you have any suggestion ? 

Configuration : 

- SDK17.0.2

- nRF52840

- Soft device : S140

Regards,

Aurélien

  • Hello Aurélien,

    The bootloader supports activation of application updates which have been downloaded by the application.  To enable this, you can build the bootloader with NRF_BL_DFU_ALLOW_UPDATE_FROM_APP==1 and application with NRF_DFU_IN_APP==1. This will also allow you to import and use the same DFU modules in your application as you already use in the Bootloader. I included an example of that in this post:  RE: Background DFU application source code . 

    Regarding step 1 and step 2, i'm not worried, it is more about step 3 where i have some questions : do I need to update the settings in the bootloader by myself ? How can i proceed ? 

    Yes, the application will be responsible for updating the following elements in the settings struct: bank_current, write_offset, progress, and init_command. This will allow the bootloader to activate the image you have stored in bank 1 after you reboot.

    Regards,

    Vidar

  • Hello Vidar,


    Thank you so much for the reply.In your example, you make the upgrade in the application with the serial interface, so you are using an existing transport layer of the DFU. But according to the readme file, if I want to use an other transport layer, I need to re-write the code of nrf_dfu_serial_uart so that i can interface with the DFU stack. To do so, I need to understand the DFU transport layer in order to write new one. 

    At first glance, I was thinking of copying the binaries (.bin + .dat file) myself directly into the internal flash (bank 1) so not using any transport layer, and then rebooting so that the bootloader could finalize the update, but that's not possible, isn't it?

    Best regards,

    Aurélien

  • Hello Aurélien,

    I forgot to point out that you do not have to make a custom transport layer. The bootloader should be able to activate your application as long as you manage to store the update image to bank 1 and the received init command in the settings page. 

    Best regards,

    Vidar

  • Hello Vidar,

    Ok good, that's very interesting and it should be easier. So, in summary, I just need to do it like this : 

    - Activate NRF_BL_DFU_ALLOW_UPDATE_FROM_APP and NRF_DFU_IN_APP flag

    - Copy ".bin" file in bank1 (first 32 bits aligned address after the end of firmware)

    - Copy ".dat" file in init_command[INIT_COMMAND_MAX_SIZE] buffer + call nrf_dfu_settings_write (I guess i just need to add a few DFU file in the app to be able to retrieve the settings structure from the app firmware)

    - Then reboot and the bootloader should be able to make the update in standalone.

    I try this and I ll keep you updated.

    Best regards,

    Aurélien 

  • Hello Aurélien,

    Yes, this should work. In addition, you need to set .bank_current == NRF_DFU_CURRENT_BANK_1 to inform the bootloader that there is an image in bank 1 to be validated, and .write_offset+.progress for the app_activate() routine.

    Best regards,

    Vidar

Related