nRF9160 modem firmware upgrade (programmatic)

I'm attempting to send OTA modem upgrades to the nRF9160, from v1.3.3 to 1.3.4 and then 1.3.5.  Our application code is built on nRF Connect SDK version 2.4.2.

So far I'm able to send the firmware image (1.3.3 to 1.3.4), and eventually restart the 9160 by calling sys_reboot(SYS_REBOOT_COLD).  When the micro comes back up I call nrf_modem_lib_init() followed by lte_lc_init().  The latter fails with the following:

00> [00:01:20.790,924] <err> lte_lc: Failed to get system mode, error: -1
00> [00:01:20.791,351] <err> lte_lc: Could not get current system mode, error: -14

I've found that after a power cycle the modem starts up and works normally, with the new modem firmware.

Can you please advise what are the proper steps to bring the new modem firmware online without a power cycle?  We have equipment in the field and they are inaccessible in many cases.

Thanks,

  Frog

Parents Reply Children
  • Hi Didrik,

      Thanks for your quick response.  However I'm not accessing nrfxlib directly but using the nRF Connect SDK.  Now that I have a better idea what to look for I found this

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/dfu/dfu_target.html

    which says that the modem attempts to apply the patch on the next reboot.

    This may be a clue to what's going wrong - I wonder if the modem is still updating as my application code starts up.  It appears that doing another processor reset and initialising the modem a second time is successful.  That seems to work consistently.  Is that the optimal solution, or is there a way to determine that the modem is still updating and make the application code wait until it's ready?  Or am I doing something completely wrong?

  • What library do you use for the upgrades?

    Regardless, when the update is scheduled (which library you use will dictate how you get to this point), you can call nrf_modem_lib_shutdown() and nrf_modem_lib_init() to reboot the modem (this would be your first reboot in your current implementation).

    If nrf_modem_lib_init() returns NRF_MODEM_DFU_RESULT_OK, you can call nrf_modem_lib_shutdown and nrf_modem_lib_init() again, to re-start the modem in "normal mode" (as opposed to bootloader mode). This would replace the second reboot.

    So two "reboots" are still necessary, but you only need to reboot the modem, and not the whole chip.

Related