-
Notifications
You must be signed in to change notification settings - Fork 1.4k
samples: cellular: Add nrf_cloud_mqtt_fota #25462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
samples: cellular: Add nrf_cloud_mqtt_fota #25462
Conversation
There was a problem hiding this 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.
CI InformationTo view the history of this post, click the 'edited' button above Inputs:Sources:sdk-nrf: PR head: 9947077eb630f2bfb5d73b9a6f9102cdca146a8a more detailssdk-nrf:
Github labels
List of changed files detected by CI (21)Outputs:ToolchainVersion: df3cc9d822 Test Spec & Results: ✅ Success; ❌ Failure; 🟠 Queued; 🟡 Progress; ◻️ Skipped;
|
e16835b to
3428a16
Compare
There was a problem hiding this 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.
3428a16 to
f277a4d
Compare
There was a problem hiding this 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`` |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the bot is right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it okay to use DEXTRA_DTC_OVERLAY_FILE as well? https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/app_dev/config_and_build/cmake/index.html#providing_cmake_options.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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`` |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
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.
| This sample uses the following |NCS| libraries: | ||
|
|
||
| * :ref:`lib_nrf_cloud` | ||
| * :ref:`lib_nrf_cloud_mqtt` |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
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.
| * :ref:`lib_nrf_cloud_mqtt` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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: | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .. _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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. |
| ************* | ||
| |config| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ************* | |
| |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. |
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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`` |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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; |
There was a problem hiding this comment.
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?
|
|
||
| zephyr_include_directories(src) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
| #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 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #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>
f277a4d to
9947077
Compare
|
You can find the documentation preview for this PR here. Preview links for modified nRF Connect SDK documents: https://ncsdoc.z6.web.core.windows.net/PR-25462/nrf/releases_and_maturity/releases/release-notes-changelog.html |
This demonstrates how to use FOTA over MQTT with nRF Cloud
JIRA: IRIS-10200