Skip to content

Conversation

@pascal-nordic
Copy link
Contributor

This demonstrates how to use FOTA over MQTT with nRF Cloud

JIRA: IRIS-10200

Copilot AI review requested due to automatic review settings November 6, 2025 13:36
@pascal-nordic pascal-nordic requested review from a team as code owners November 6, 2025 13:36
@NordicBuilder NordicBuilder added the doc-required PR must not be merged without tech writer approval. label Nov 6, 2025
@NordicBuilder NordicBuilder requested review from a team November 6, 2025 13:36
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new sample demonstrating FOTA (Firmware Over-the-Air) updates over MQTT with nRF Cloud. The sample showcases application, modem, full modem (FMFU), and SMP FOTA capabilities for Nordic cellular devices.

Key Changes:

  • Implements comprehensive FOTA support including modem, application, and full modem updates
  • Adds SMP FOTA support for nRF9160 DK with nRF52840 SoC
  • Provides board-specific configurations for multiple Nordic development kits

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
samples/cellular/nrf_cloud_mqtt_fota/src/main.c Core application implementing MQTT connection, cloud event handling, and FOTA lifecycle management
samples/cellular/nrf_cloud_mqtt_fota/src/smp_reset.c SMP reset functionality for nRF52840 FOTA updates
samples/cellular/nrf_cloud_mqtt_fota/prj.conf Main project configuration enabling nRF Cloud MQTT and FOTA features
samples/cellular/nrf_cloud_mqtt_fota/README.rst Documentation covering requirements, setup, configuration, and usage
samples/cellular/nrf_cloud_mqtt_fota/Kconfig Sample-specific configuration options for timeouts and LED settings
samples/cellular/nrf_cloud_mqtt_fota/boards/*.overlay Board-specific device tree overlays for external flash configuration
samples/cellular/nrf_cloud_mqtt_fota/full_modem_fota.conf Configuration overlay for full modem FOTA support
samples/cellular/nrf_cloud_mqtt_fota/smp_fota.conf Configuration overlay for SMP FOTA support
samples/cellular/nrf_cloud_mqtt_fota/sample.yaml Test configuration for CI/CD builds across multiple platforms
doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst Release notes entry for the new sample

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@NordicBuilder
Copy link
Contributor

NordicBuilder commented Nov 6, 2025

CI Information

To view the history of this post, click the 'edited' button above
Build number: 4

Inputs:

Sources:

sdk-nrf: PR head: 9947077eb630f2bfb5d73b9a6f9102cdca146a8a

more details

sdk-nrf:

PR head: 9947077eb630f2bfb5d73b9a6f9102cdca146a8a
merge base: cc348c5e87b4d87def7a8b28f24f12b47160cd96
target head (main): ad7d9b915b4d543e00b23c7b9be6a20dad9c63fd
Diff

Github labels

Enabled Name Description
ci-disabled Disable the ci execution
ci-all-test Run all of ci, no test spec filtering will be done
ci-force-downstream Force execution of downstream even if twister fails
ci-run-twister Force run twister
ci-run-zephyr-twister Force run zephyr twister
List of changed files detected by CI (21)
doc
│  ├── nrf
│  │  ├── releases_and_maturity
│  │  │  ├── releases
│  │  │  │  │ release-notes-changelog.rst
samples
│  ├── cellular
│  │  ├── nrf_cloud_mqtt_fota
│  │  │  ├── CMakeLists.txt
│  │  │  ├── Kconfig
│  │  │  ├── README.rst
│  │  │  ├── VERSION
│  │  │  ├── boards
│  │  │  │  ├── nrf9151dk_nrf9151_ns.overlay
│  │  │  │  ├── nrf9160dk_nrf9160_ns_0_14_0.overlay
│  │  │  │  ├── nrf9161dk_nrf9161_ns.overlay
│  │  │  │  ├── nrf9161dk_nrf9161_ns_0_7_0.overlay
│  │  │  │  ├── thingy91x_nrf9151_ns.conf
│  │  │  │  │ thingy91x_nrf9151_ns.overlay
│  │  │  ├── full_modem_fota.conf
│  │  │  ├── nrf9160dk_mcumgr_client_uart2.overlay
│  │  │  ├── prj.conf
│  │  │  ├── rtt.conf
│  │  │  ├── sample.yaml
│  │  │  ├── smp_fota.conf
│  │  │  ├── src
│  │  │  │  ├── main.c
│  │  │  │  ├── smp_reset.c
│  │  │  │  │ smp_reset.h
│  │  │  │ sysbuild.conf

Outputs:

Toolchain

Version: df3cc9d822
Build docker image: docker-dtr.nordicsemi.no/sw-production/ncs-build:df3cc9d822_e595b21c39

Test Spec & Results: ✅ Success; ❌ Failure; 🟠 Queued; 🟡 Progress; ◻️ Skipped; ⚠️ Quarantine

  • ◻️ Toolchain - Skipped: existing toolchain is used
  • ❌ Build twister
    • sdk-nrf test count: 9
  • ❌ Integration tests
    • ⚠️ test-fw-nrfconnect-nrf-iot_cloud
Disabled integration tests
    • test-fw-nrfconnect-nrf_lrcs_positioning
    • desktop52_verification
    • test_ble_nrf_config
    • test-fw-nrfconnect-apps
    • test-fw-nrfconnect-ble_mesh
    • test-fw-nrfconnect-ble_samples
    • test-fw-nrfconnect-chip
    • test-fw-nrfconnect-fem
    • test-fw-nrfconnect-nfc
    • test-fw-nrfconnect-nrf-iot_libmodem-nrf
    • test-fw-nrfconnect-nrf-iot_lwm2m
    • test-fw-nrfconnect-nrf-iot_samples
    • test-fw-nrfconnect-nrf-iot_thingy91
    • test-fw-nrfconnect-nrf-iot_zephyr_lwm2m
    • test-fw-nrfconnect-nrf_crypto
    • test-fw-nrfconnect-ps-main
    • test-fw-nrfconnect-rpc
    • test-fw-nrfconnect-rs
    • test-fw-nrfconnect-tfm
    • test-fw-nrfconnect-thread-main
    • test-low-level
    • test-sdk-audio
    • test-sdk-dfu
    • test-sdk-find-my
    • test-sdk-mcuboot
    • test-sdk-wifi
    • test-secdom-samples-public

Note: This message is automatically posted and updated by the CI

@pascal-nordic pascal-nordic force-pushed the IRIS-10200-mqtt-sample-using-fota branch from e16835b to 3428a16 Compare November 6, 2025 13:55
@pascal-nordic pascal-nordic requested a review from Copilot November 6, 2025 13:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pascal-nordic pascal-nordic force-pushed the IRIS-10200-mqtt-sample-using-fota branch from 3428a16 to f277a4d Compare November 6, 2025 14:03
@pascal-nordic pascal-nordic requested a review from Copilot November 6, 2025 14:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

To enable SMP FOTA (nRF9160 DK only), add the following parameters to your build command:

* ``-DEXTRA_CONF_FILE=smp_fota.conf``
* ``-DEXTRA_DTC_OVERLAY_FILE=nrf9160dk_mcumgr_client_uart2.overlay``
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent parameter name: should be -DDTC_OVERLAY_FILE (as used in sample.yaml line 53) not -DEXTRA_DTC_OVERLAY_FILE.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bot is right

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think is correct to select DEXTRA_DTC_OVERLAY_FILE and I would need to change the reference in sample.yaml

Copy link
Contributor

@nordicjm nordicjm Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this bot is trash, the readme is fine, though there should be quotes around the files e.g. -DEXTRA_CONF_FILE="smp_fota.conf" this is a string

Build the :ref:`smp_svr` sample for the ``nrf9160dk/nrf52840`` board with the following parameters:

* ``-DEXTRA_CONF_FILE=overlay-serial.conf``
* ``-DEXTRA_DTC_OVERLAY_FILE=nrf9160dk_nrf52840_mcumgr_svr.overlay``
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent parameter name: should be -DDTC_OVERLAY_FILE not -DEXTRA_DTC_OVERLAY_FILE.

Copilot uses AI. Check for mistakes.
This sample uses the following |NCS| libraries:

* :ref:`lib_nrf_cloud`
* :ref:`lib_nrf_cloud_mqtt`
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The :ref:lib_nrf_cloud_mqtt reference is redundant since MQTT support is part of the main nRF Cloud library, not a separate library reference. This reference likely doesn't exist in the documentation.

Suggested change
* :ref:`lib_nrf_cloud_mqtt`

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The :ref:lib_nrf_cloud_mqtt library doesn't exists. Is it the MQTT helper library you wanted to link?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxd-nordic I had the impression that now all these protocols are split, this reference should exists

@@ -0,0 +1,178 @@
.. _nrf_cloud_mqtt_fota_sample:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.. _nrf_cloud_mqtt_fota_sample:
.. _nrf_cloud_mqtt_fota:

as per the above comment.

:local:
:depth: 2

The nRF Cloud MQTT FOTA sample demonstrates how to use the `nRF Cloud MQTT API`_ to perform Firmware Over-the-Air (FOTA) updates over MQTT on your device.
Copy link
Contributor

@divipillai divipillai Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The nRF Cloud MQTT FOTA sample demonstrates how to use the `nRF Cloud MQTT API`_ to perform Firmware Over-the-Air (FOTA) updates over MQTT on your device.
The nRF Cloud MQTT FOTA sample demonstrates how to use the `nRF Cloud MQTT API`_ to perform :term:`Firmware Over-the-Air (FOTA) <Firmware Over-the-Air (FOTA) update>` updates over MQTT on your device.

Incorporated Uma's suggestion.

This covers modem, application, and full modem FOTA updates (FMFU).
Also, with the nRF9160 DK, it supports SMP FOTA updates to the firmware on the nRF52840 SoC present on the DK board (not a separate device).

When using MQTT, the `FOTA update <nRF Cloud Getting Started FOTA Documentation_>`_ support is almost entirely implemented by enabling the :kconfig:option:`CONFIG_NRF_CLOUD_FOTA` option (which is implicitly enabled by :kconfig:option:`CONFIG_NRF_CLOUD_MQTT`).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When using MQTT, the `FOTA update <nRF Cloud Getting Started FOTA Documentation_>`_ support is almost entirely implemented by enabling the :kconfig:option:`CONFIG_NRF_CLOUD_FOTA` option (which is implicitly enabled by :kconfig:option:`CONFIG_NRF_CLOUD_MQTT`).
When using MQTT, the `FOTA update <nRF Cloud Getting Started FOTA Documentation_>`_ support is almost entirely implemented by enabling the :kconfig:option:`CONFIG_NRF_CLOUD_FOTA` option, which is implicitly enabled by :kconfig:option:`CONFIG_NRF_CLOUD_MQTT`.


When using MQTT, the `FOTA update <nRF Cloud Getting Started FOTA Documentation_>`_ support is almost entirely implemented by enabling the :kconfig:option:`CONFIG_NRF_CLOUD_FOTA` option (which is implicitly enabled by :kconfig:option:`CONFIG_NRF_CLOUD_MQTT`).

However, even with :kconfig:option:`CONFIG_NRF_CLOUD_FOTA` enabled, applications must still reboot themselves manually after FOTA download completion, and must still update their `Device Shadow <nRF Cloud Device Shadows_>`_ to reflect FOTA support.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
However, even with :kconfig:option:`CONFIG_NRF_CLOUD_FOTA` enabled, applications must still reboot themselves manually after FOTA download completion, and must still update their `Device Shadow <nRF Cloud Device Shadows_>`_ to reflect FOTA support.
However, even with the :kconfig:option:`CONFIG_NRF_CLOUD_FOTA` Kconfig option enabled, applications must still reboot themselves manually after FOTA download completion and must still update their `Device Shadow <nRF Cloud Device Shadows_>`_ to reflect FOTA support.

Comment on lines 64 to 66
*************
|config|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*************
|config|
*************
|config|

.. _CONFIG_CLOUD_CONNECTION_RETRY_TIMEOUT_SECONDS:

CONFIG_CLOUD_CONNECTION_RETRY_TIMEOUT_SECONDS - Cloud connection retry timeout (seconds)
Sets the cloud connection retry timeout in seconds.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These configuration options are already defined in the "nRF Cloud multi-service" sample - https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/samples/cellular/nrf_cloud_multi_service/README.html#configuration_options. Hence, these Kconfig options could be removed.

We could just list these two Kconfig options like below:

Check and configure the following configuration options for the sample:

  • :ref:CONFIG_CLOUD_CONNECTION_RETRY_TIMEOUT_SECONDS <CONFIG_CLOUD_CONNECTION_RETRY_TIMEOUT_SECONDS>
  • :ref: CONFIG_CLOUD_READY_TIMEOUT_SECOND <CONFIG_CLOUD_READY_TIMEOUT_SECOND>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of the reason why we are creating this sample is to break in smaller samples the Multi Service sample and eventually delete it.

Copy link
Contributor

@divipillai divipillai Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we could remove only these two configuration options from the Multi Service sample docs (This is to avoid the doc build error), and here in this sample, could give the below configuration syntax:

.. options-from-kconfig::
:show-type:

Going forward we would be using the above syntax for the sample-specific Kconfig options. Could refer the sample template: https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/templates/sample_README.html#configuration_options

To enable SMP FOTA (nRF9160 DK only), add the following parameters to your build command:

* ``-DEXTRA_CONF_FILE=smp_fota.conf``
* ``-DEXTRA_DTC_OVERLAY_FILE=nrf9160dk_mcumgr_client_uart2.overlay``
Copy link
Contributor

@nordicjm nordicjm Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this bot is trash, the readme is fine, though there should be quotes around the files e.g. -DEXTRA_CONF_FILE="smp_fota.conf" this is a string

Once you have flashed your nRF9160 DK, change the switch **SW10** to the **nRF52** position to be able to flash the nRF52840 firmware on the DK.
The nRF52840 device on your DK must be running firmware compatible with SMP, such as the :ref:`smp_svr` sample.
Otherwise, the MQTT FOTA sample cannot connect to the nRF52840 and will keep trying to connect.
Build the :ref:`smp_svr` sample for the ``nrf9160dk/nrf52840`` board with the following parameters:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*board target

``-DEXTRA_CONF_FILE=full_modem_fota.conf``

Also, if you are using an nRF9160 DK, specify your development kit version by appending it to the board name.
For example, if you are using version 1.0.1, use the board name ``nrf9160dk@1.0.1/nrf9160/ns`` in your build command.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version 1.0.1? There is no such board target https://github.com/zephyrproject-rtos/zephyr/blob/main/boards/nordic/nrf9160dk/board.yml also this is a board target not a board/board name


# nRF Cloud MQTT
CONFIG_NRF_CLOUD=y
CONFIG_NRF_CLOUD_MQTT=y # This also enables FOTA by implicitly setting CONFIG_NRF_CLOUD_FOTA=y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CONFIG_NRF_CLOUD_MQTT=y # This also enables FOTA by implicitly setting CONFIG_NRF_CLOUD_FOTA=y
CONFIG_NRF_CLOUD_MQTT=y

LOG_DBG("NRF_CLOUD_EVT_FOTA_START");
break;
case NRF_CLOUD_EVT_FOTA_DONE: {
enum nrf_cloud_fota_type fota_type = NRF_CLOUD_FOTA_TYPE__INVALID;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are there 2 underscores?

Comment on lines +19 to +20

zephyr_include_directories(src)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
zephyr_include_directories(src)

src files can just do include "local_file.h"; it doesn't make sense to add a global zephyr include for the application directory

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(nrf_cloud_mqtt_fota_sample)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
project(nrf_cloud_mqtt_fota_sample)
project(nrf_cloud_mqtt_fota)

#include <helpers/nrfx_reset_reason.h>
#include <app_version.h>
#include <dk_buttons_and_leds.h>
#if SMP_FOTA_ENABLED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how will this ever work? Use CONFIG_NRF_CLOUD_FOTA_SMP

struct nrf_cloud_init_param params = {
.event_handler = cloud_event_handler,
.fmfu_dev_inf = get_full_modem_fota_fdev(),
#if SMP_FOTA_ENABLED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use CONFIG_NRF_CLOUD_FOTA_SMP

Comment on lines +10 to +15
#if defined(CONFIG_NRF_CLOUD_FOTA_SMP) && defined(CONFIG_BOARD_NRF9160DK_NRF9160_NS)
#define SMP_FOTA_ENABLED 1
#else
#define SMP_FOTA_ENABLED 0
#endif

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if defined(CONFIG_NRF_CLOUD_FOTA_SMP) && defined(CONFIG_BOARD_NRF9160DK_NRF9160_NS)
#define SMP_FOTA_ENABLED 1
#else
#define SMP_FOTA_ENABLED 0
#endif

This demonstrates how to use FOTA over MQTT with nRF Cloud

JIRA: IRIS-10200

Signed-off-by: Pascal Hernandez <pascal.hernandez@nordicsemi.no>
@pascal-nordic pascal-nordic force-pushed the IRIS-10200-mqtt-sample-using-fota branch from f277a4d to 9947077 Compare November 7, 2025 13:00
@github-actions
Copy link

github-actions bot commented Nov 7, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-required PR must not be merged without tech writer approval.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants