LwM2M FOTA Download Stalls at 1–2% on nRF9160 over NB-IoT/LTE-M

I am using nRF9160 DK with nRF Connect SDK v2.9 and the LwM2M client sample (/samples/cellular/lwm2m_client/), converted from PSK to X.509 certificates.

The device connects successfully to my custom Leshan server on AWS, and works with Onomondo SIM cards. Security handshake with X.509 works fine after adjusting the server settings.

However, firmware update over-the-air (FOTA) fails:

  • The download starts and reports 1–2% progress.

  • After that, the download stalls and no more CoAP requests are observed on the server.

  • This happens even when testing with PSK against the demo LwM2M server.

  • Network connection seems stable, no obvious LTE disconnects, and device registration updates continue.

Also, on the server UI, I see it show me "Request Timeout."

[00:00:15.417,205] <inf> app_lwm2m_client: LwM2M is connected to server
[00:00:15.417,266] <inf> app_lwm2m_client: Obtained date-time from modem
[00:00:38.783,386] <inf> app_lwm2m_client: FOTA download started for instance 0
[00:00:38.784,667] <inf> lwm2m_firmware: Image type 1
[00:00:38.787,139] <inf> lwm2m_firmware: Application firmware download started.
[00:00:57.482,666] <inf> lwm2m_firmware: Downloaded 1%
[00:00:59.722,747] <inf> lwm2m_firmware: Downloaded 2%
[00:01:15.415,527] <dbg> app_lwm2m_client: rd_client_event: Registration update started
[00:01:15.810,852] <inf> net_lwm2m_rd_client: Update callback (code:2.4)
[00:01:15.810,882] <dbg> app_lwm2m_client: rd_client_event: Registration update complete
[00:01:15.810,974] <inf> net_lwm2m_rd_client: Update Done

CONFIG_LWM2M=y
CONFIG_LWM2M_COAP_BLOCK_SIZE=1024
CONFIG_LWM2M_COAP_MAX_MSG_SIZE=2048
CONFIG_LWM2M_CLIENT_UTILS=y
CONFIG_LWM2M_ENGINE_MAX_MESSAGES=15
CONFIG_LWM2M_ENGINE_MAX_PENDING=15
CONFIG_LWM2M_ENGINE_MAX_REPLIES=15

Questions:

  1. Is there a recommended configuration for LwM2M FOTA over NB-IoT/LTE-M for large firmware images?

  2. Should PSM/eDRX be disabled during FOTA, or is there a way to pause registration updates to avoid blocking the download?

  3. What are the recommended CoAP block sizes and engine parameters to reliably transfer large images?

  4. Are there known limitations when using Onomondo SIM + AWS Leshan for large firmware downloads?

Additional Info:

  • MCUboot v2.1.0

  • Zephyr OS v3.7.99

  • LTE-M/NB-IoT tested with Onomondo SIM

  • Hi.

    From the config you shared, I would first of all recommend you to try CONFIG_LWM2M_COAP_BLOCK_SIZE=512 and retest as there is a limitation mentioned here

    1. It is recommended to use pull delivery mode with CoAP or HTTP and starting from the lwm2m_client sample, enabling the overlay-fota_helper.conf overlay, which improves responsiveness in queue mode by using a 60-second update period.

    For large firmware downloads over LTE-M/NB-IoT, you may tune LwM2M queue-mode and timing parameters so the device stays online and listening long enough to complete the transfer. This includes increasing CONFIG_LWM2M_QUEUE_MODE_UPTIME, using a shorter CONFIG_LWM2M_UPDATE_PERIOD (similar to what overlay-fota_helper.conf does), and selecting an idle mode such as CONFIG_LWM2M_RD_CLIENT_LISTEN_AT_IDLE so the client keeps its socket open while the download is in progress.

    2. You do not have to disable PSM/eDRX for FOTA, as Nordic’s own lwm2m_client FOTA setup runs with PSM and eDRX enabled. However, aggressive PSM/eDRX or short queue-mode uptime can cause long block-wise transfers to stall. For large FOTA transfers, it is recommended to avoid very aggressive power-saving settings (like overlay-aggressive-psm.conf overlay file).

    And there are no specific limitations to Onomondo SIMs or AWS-hosted Leshan servers for LwM2M FOTA. You may try out the above mentioned configurations and check if it works.

    Best Regards,
    Syed Maysum

  • Hi Syed,

    I've applied all your recommended configurations to the samples/cellular/lwm2m_client sample but FOTA still fails.

    Applied configs:

    • CONFIG_LWM2M_COAP_BLOCK_SIZE=512
    • CONFIG_LWM2M_UPDATE_PERIOD=60
    • CONFIG_LWM2M_QUEUE_MODE_UPTIME=600000
    • CONFIG_LWM2M_RD_CLIENT_LISTEN_AT_IDLE=y
    • PSM/eDRX enabled (not using aggressive overlay)

    Issues:

    • Push mode fails most of the time - Resource /5/0/9 shows 2 (both modes supported) but writing firmware to /5/0/0 (Package resource) usually returns error 501 or times out.
    • Some time Downloads stall at 5-8% - On rare occasions when FOTA starts, it downloads 5-8% then stops completely. Device remains connected and sends registration updates every 60 seconds. No error messages in logs.

    Setup:

    • SDK v3.2.1, nRF9151DK
    • Onomondo SIM (blocks TCP/HTTPS, allows CoAP/UDP)
    • Public Leshan server (coaps://leshan.eclipseprojects.io:5684)
    • Firmware: zephyr.signed.bin (841 Kb)

    Questions:

    1. What's the recommended way to test FOTA with the lwm2m_client sample and public Leshan demo server?
    2. Any additional configs or logging to debug why downloads stall?
  • Hi,

    Thanks for testing and sharing the details.

    For FOTA testing with the lwm2m_client sample and the Leshan demo server, we recommend focusing on pull mode (writing the firmware URI to /5/0/1). Although /5/0/9 reports that both modes are supported, push mode (writing the firmware directly to /5/0/0) is more sensitive to network conditions when transferring large images over cellular/UDP. The Leshan project also notes this limitation for large payload transfers over CoAP block-wise, and therefore recommends using a URI-based download when possible:

    https://github.com/eclipse-leshan/leshan/wiki/Using-CoAP-Block-Wise-to-transfer-large-file-%3F

    And to get more insight into where the download may be stalling, you can also enable more verbose logging if not already enabled:

    CONFIG_LOG=y
    CONFIG_LWM2M_LOG_LEVEL_DBG=y
    CONFIG_COAP_LOG_LEVEL_DBG=y

    Best Regards,
    Syed Maysum

  •  i'am currently working on a FOTA implementation I am using nRF9160 DK with nRF Connect SDK  v3.1.1 and the LwM2M client sample (/samples/cellular/lwm2m_client/). I am using LwM2M with the Leshan server over the CoAP protocol.

    I am facing an issue: the app_update.bin file is no longer generated. I replaced it with zephyr.signed.bin in the update URL, but no FOTA update is triggered.

    this is my configuration 

    #MCUboot
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_BUILD_OUTPUT_BIN=y
    CONFIG_IMG_MANAGER=y
    CONFIG_MCUBOOT_IMG_MANAGER=y
    
    #Flash support
    CONFIG_FLASH=y
    CONFIG_FLASH_MAP=y
    CONFIG_STREAM_FLASH=y
    
    #LwM2M firmware object
    CONFIG_LWM2M_FIRMWARE_UPDATE_OBJ_SUPPORT=y
    
    CONFIG_POSIX_API=y
    
    # Allow FOTA downloads using download-client
    CONFIG_DOWNLOADER=y
    CONFIG_DOWNLOADER_STACK_SIZE=4096
    CONFIG_FOTA_DOWNLOAD=y

    Here are the logs I am getting

    00:07:16.822,967] fota_download_util: Download url https://xxxxxx/zephyr.signed.bin
    [00:07:16.823,028] fota_download_util: Download Path zephyr.signed.bin host https://leshan.xxxxxx
    [00:07:16.826,782] downloader: Host lookup failed for hostname leshan.xxxxxx on IPv6 (err -22), attempting IPv4
    [00:07:16.980,712] downloader: Setting up TLS credentials, sec tag count 1
    [00:07:16.980,834] downloader: Connecting to 91.134.59.209
    [00:07:18.089,569] downloader: Failed to connect, err -111
    [00:07:18.089,599] fota_download: Downloader error event -111
    [00:07:18.089,630] lwm2m_firmware: FOTA_DOWNLOAD_EVT_ERROR
    [00:07:18.089,630] lwm2m_firmware: FOTA download failed, target 0
    [00:07:18.092,742] app_lwm2m_client: FOTA failure 0 by status 4

    you can send me your configuration you added to upload FOTA 

    because i try and so manyt times and nothing works 

  • Hi,

    Your error indicates the downloader is attempting a TLS connection but failing. As the error -111 is ECONNREFUSED which means Connection refused that it indicates an error with the configured certificates. 

    So either no valid certificate is provisioned for the Leshan HTTPS server on the security tag or the certificate stored in the modem does not match the one the server presents

    So can you try this out:

    1. Get the CA certificate (or self signed cert) that the Leshan server uses for HTTPS. If Leshan is using a self signed certificate, you can extract it with:

    openssl s_client -showcerts -connect leshan.example.com:443

    2. Provision that CA certificate into a security tag in the modem. You can do this with the Cellular Monitor app or using modem_key_mgmt_write() with credential type MODEM_KEY_MGMT_CRED_TYPE_CA_CHAIN as shown here.

    3. Then add the Kconfig option that points the FOTA downloader to that security tag:

    CONFIG_LWM2M_CLIENT_UTILS_DOWNLOADER_SEC_TAG=<your_chosen_sec_tag>

    Best Regards,
    Syed Maysum

Related