I'm implementing the full modem firmware update as demonstrated by the sample located at /samples/nrf9160/http_update/full_modem_update.
A bunch of it works. I'm able to trigger an update, see the download occur, and the update be triggered.
However, I've noted the following problem. The update doesn't seem to work the first time it's applied. Instead it seems that the update fails, and the subsequent call to re-enable the modem fails. I then reboot the device, and the check at startup that tries to init the modem catches the fact that the modem firmware is dead, and loads the new firmware. The relevant sections of code are:
void apply_fmfu_from_ext_flash(bool valid_init) { int err; LOG_DBG("Applying full modem firmware update from external flash"); if (valid_init) { err = nrf_modem_lib_shutdown(); if (err != 0) { LOG_DBG("nrf_modem_lib_shutdown() failed: %d", err); return; } } err = nrf_modem_lib_init(FULL_DFU_MODE); if (err != 0) { LOG_DBG("nrf_modem_lib_init(FULL_DFU_MODE) failed: %d", err); return; } err = fmfu_fdev_load(fmfu_buf, sizeof(fmfu_buf), flash_dev, 0); if (err != 0) { LOG_DBG("fmfu_fdev_load failed: %d", err); return; } err = nrf_modem_lib_shutdown(); if (err != 0) { LOG_DBG("nrf_modem_lib_shutdown() failed: %d", err); return; } k_sleep(K_SECONDS(10)); err = nrf_modem_lib_init(NORMAL_MODE); if (err != 0) { LOG_DBG("nrf_modem_lib_init() failed: %d", err); return; } LOG_DBG("Modem firmware update completed"); }
I see this error message:
[00:31:10.056,701] [0m<dbg> azure_iot_hub_wrapper.apply_fmfu_from_ext_flash: nrf_modem_lib_init() failed: -60
Which translates as a "timed out" error.
I then force a reboot, the device boots normally, and runs this snippet:
err = nrf_modem_lib_init(NORMAL_MODE); if (err) { LOG_DBG("Failed to initialize modem lib, err: %d", err); LOG_DBG("This could indicate that an earlier update failed"); LOG_DBG("Trying to apply modem update from ext flash"); apply_fmfu_from_ext_flash(false); }
And that works. Any idea what might be going wrong? It seems likely that either the first time of writing to the modem flash area fails, and hence the new firmware can't be booted. This idea is bolstered by the fact that the test for (err) in the above snippet is true, meaning the modem didn't initialize at boot. The question is though, why it fails in the first place, and how to narrow it down.
Any ideas I could try to gain some insight into what's happening?
Regards,
Josh