Hi,
We have a working application that allows FOTA when using the SDK 15.2 bootloader.
We have recently tried to migrate this to SDK 17.0, and everything works except for the FOTA capabilities.
The ability to receive and process the new firmware still works, but the bootloader is not working properly.
Whenever we try to restart the application so the bootloader can flash the new image, nothing happens.
The device enters a reset loop where the application detects a valid cached image and resets the device for the bootloader to flash it.
A sanitised snippet of the FOTA code handling the update of the BL settings is as follows:
This code was working with the 15.2 bootloader.new_settings = *(nrf_dfu_settings_t *)(&__BlSettingsStart);
new_settings.bank_1.image_crc = fota_upgrade.crc;
new_settings.bank_1.image_size = fota_get_image_size(FOTA_FW_SLOT_ID);
new_settings.bank_1.bank_code = NRF_DFU_BANK_VALID_APP;
new_settings.progress.update_start_address = (uint32_t)&__SwapStart + FOTA_HEADER_SIZE;
new_settings.crc = calc_settings_crc(&new_settings);
flash_is_busy = true;
sd_flash_page_erase(((uint32_t)&__BlSettingsStart) >> 12);
yield(!flash_is_busy);
log("Settings page erased");
flash_is_busy = true;
num_words = (sizeof(new_settings) + 3) / sizeof(uint32_t);
sd_flash_write((uint32_t *)&__BlSettingsStart, (uint32_t *)&new_settings, num_words);
yield(!flash_is_busy);
log("New settings written");
Now, the bootloader executes, but the new firmware is not loaded. The output from debugging the bootloader is:
<info> app: Inside main
<debug> app: In nrf_bootloader_init
<debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
<debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
<debug> nrf_dfu_settings: Using settings page.
<debug> nrf_dfu_settings: Copying forbidden parts from backup page.
<debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
<info> nrf_dfu_settings: Backing up settings page to address 0xFE000.
<debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
<debug> app: Enter nrf_bootloader_fw_activate
<info> app: No firmware to activate.
<debug> app: App is valid
<info> nrf_dfu_settings: Backing up settings page to address 0xFE000.
<debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
<debug> app: Running nrf_bootloader_app_start with address: 0x00001000
<debug> app: Disabling interrupts. NVIC->ICER[0]: 0x0
We have defined NRF_BL_DFU_ALLOW_UPDATE_FROM_APP, but I think this should be causing the postvalidation routine to execute.
I have tried adding the following to the FOTA routine:
new_settings.bank_current = NRF_DFU_CURRENT_BANK_1;
but it only causes the postvalidate routine to run and skip immediately as no command is present.
Should I be configuring something else for the bootloader to pick up the new image?
Any help will be much appreciated.
Best wishes,
Alberto