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 Vidar,

    I have good news. Indeed, it seems it is working now :) 

    I started with copying the .bin into bank 1 (i'm using nrf_dfu_bank1_start_addr() to get the start address)

    Then, once i retrieve the .dat file, I had to add the following lines : 

            if (m_data_file_read_len < INIT_COMMAND_MAX_SIZE) {
                memcpy(s_dfu_settings.init_command, m_data_file_read, m_data_file_read_len);
            }
            s_dfu_settings.bank_current = NRF_DFU_CURRENT_BANK_1;
            s_dfu_settings.progress.command_size = ctx->file_read_size;
            s_dfu_settings.progress.command_offset = ctx->file_read_size;
            s_dfu_settings.write_offset = m_bank1_addr;
            sd_softdevice_disable();
            uint32_t err_code = nrf_dfu_settings_write(NULL);

    (for example, I needed to disable the softdevice before calling nrf_dfu_settings_write) 

    If you see any corner cases, don't hesitate to tell me.

    By the way i have one question : Since I added nrf_dfu_settings.h in my code, my application is now linking some code into the bootloader memory segments (in particular the dfu settings structure in the end of the flash) but I guess it does not bother the ZIP generation. nrf_utils will take into account only the first memory segment , right and will dump the others ?

    Now, I need to make some cleaning in my code and some tests to check if everything is still working as expected, especially regarding DFU over BLE and FDS ...

  • Hello Aurélien,

    I'm glad to hear it's working now. I don't see any obvious problems with the approach you have described.

    Aurele said:
    Since I added nrf_dfu_settings.h in my code, my application is now linking some code into the bootloader memory segments (in particular the dfu settings structure in the end of the flash) but I guess it does not bother the ZIP generation

    This is fine. The application hex will include address references to the bootloader settings page, but it won't include data outside of its memory range in flash.

  • Hello Vidar,

    Ok that's great, thank you very much !

    I have just noticed that I'm also able to update the bootloader with the same method ! Smiley

    So, everything looks good, 

    thank you again for the help

    Regards

Related