|
| 1 | +.. _nrf_cloud_mqtt_fota: |
| 2 | + |
| 3 | +Cellular: nRF Cloud MQTT FOTA |
| 4 | +############################# |
| 5 | + |
| 6 | +.. contents:: |
| 7 | + :local: |
| 8 | + :depth: 2 |
| 9 | + |
| 10 | +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. |
| 11 | +This covers modem, application, and full modem FOTA updates (FMFU). |
| 12 | +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). |
| 13 | + |
| 14 | +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`. |
| 15 | + |
| 16 | +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. |
| 17 | + |
| 18 | +Requirements |
| 19 | +************ |
| 20 | + |
| 21 | +The sample supports the following development kits: |
| 22 | + |
| 23 | +.. table-from-sample-yaml:: |
| 24 | + |
| 25 | +.. include:: /includes/tfm.txt |
| 26 | + |
| 27 | +The sample requires an `nRF Cloud`_ account. |
| 28 | + |
| 29 | +Your device must be onboarded to nRF Cloud. |
| 30 | +If it is not, follow the instructions in `Device onboarding <nrf_cloud_mqtt_fota_sample_onboarding_>`_. |
| 31 | + |
| 32 | +.. note:: |
| 33 | + This sample requires modem firmware v1.3.x or later for an nRF9160 SiP and v2.0.0 or later for nRF9161 and nRF9151 SiPs. |
| 34 | + |
| 35 | +.. include:: /includes/external_flash_nrf91.txt |
| 36 | + |
| 37 | +.. note:: |
| 38 | + Full modem FOTA requires development kit version 0.14.0 or higher if you are using an nRF9160 DK. |
| 39 | + |
| 40 | +Overview |
| 41 | +******** |
| 42 | + |
| 43 | +You can update your device firmware on the `nRF Cloud`_ portal or directly through the `nRF Cloud MQTT API`_. |
| 44 | +See the `nRF Cloud Getting Started FOTA documentation`_ for details. |
| 45 | + |
| 46 | + |
| 47 | +User interface |
| 48 | +************** |
| 49 | + |
| 50 | +Button 1: |
| 51 | + Check for a FOTA update right away without waiting for the timeout. |
| 52 | + |
| 53 | +.. _nrf_cloud_mqtt_fota_sample_onboarding: |
| 54 | + |
| 55 | +Setup |
| 56 | +===== |
| 57 | + |
| 58 | +You must onboard your device to nRF Cloud for this sample to function. |
| 59 | +You only need to do this once for each device. |
| 60 | + |
| 61 | +To onboard your device, install `nRF Cloud Utils`_ and follow the instructions in the README. |
| 62 | + |
| 63 | +Configuration |
| 64 | +************* |
| 65 | + |
| 66 | +|config| |
| 67 | + |
| 68 | +Configuration options |
| 69 | +===================== |
| 70 | + |
| 71 | +Check and configure the following configuration options for the sample: |
| 72 | + |
| 73 | +.. _CONFIG_CLOUD_CONNECTION_RETRY_TIMEOUT_S: |
| 74 | + |
| 75 | +CONFIG_CLOUD_CONNECTION_RETRY_TIMEOUT_S - Cloud connection retry timeout (seconds) |
| 76 | + Sets the cloud connection retry timeout in seconds. |
| 77 | + |
| 78 | +.. _CONFIG_CLOUD_READY_TIMEOUT_S: |
| 79 | + |
| 80 | +CONFIG_CLOUD_READY_TIMEOUT_S - Cloud readiness timeout (seconds) |
| 81 | + Sets the cloud readiness timeout in seconds. |
| 82 | + If the connection to nRF Cloud does not become ready within this timeout, the sample will reset its connection and try again. |
| 83 | + |
| 84 | +.. include:: /libraries/modem/nrf_modem_lib/nrf_modem_lib_trace.rst |
| 85 | + :start-after: modem_lib_sending_traces_UART_start |
| 86 | + :end-before: modem_lib_sending_traces_UART_end |
| 87 | + |
| 88 | +Building and running |
| 89 | +******************** |
| 90 | + |
| 91 | +.. |sample path| replace:: :file:`samples/cellular/nrf_cloud_mqtt_fota` |
| 92 | + |
| 93 | +.. include:: /includes/build_and_run_ns.txt |
| 94 | + |
| 95 | +The configuration files for this sample are located in the :file:`samples/cellular/nrf_cloud_mqtt_fota` folder. |
| 96 | +See :ref:`configure_application` on how to configure the parameters. |
| 97 | + |
| 98 | +To create a FOTA test version of this sample, change the ``PATCHLEVEL`` in the :file:`VERSION` file. |
| 99 | + |
| 100 | +To enable full modem FOTA, add the following parameter to your build command: |
| 101 | + |
| 102 | +``-DEXTRA_CONF_FILE=full_modem_fota.conf`` |
| 103 | + |
| 104 | +Also, if you are using an nRF9160 DK, specify your development kit version by appending it to the board name. |
| 105 | +For example, if you are using version 1.0.1, use the board name ``nrf9160dk@1.0.1/nrf9160/ns`` in your build command. |
| 106 | + |
| 107 | +To enable SMP FOTA (nRF9160 DK only), add the following parameters to your build command: |
| 108 | + |
| 109 | +* ``-DEXTRA_CONF_FILE=smp_fota.conf`` |
| 110 | +* ``-DEXTRA_DTC_OVERLAY_FILE=nrf9160dk_mcumgr_client_uart2.overlay`` |
| 111 | + |
| 112 | +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. |
| 113 | +The nRF52840 device on your DK must be running firmware compatible with SMP, such as the :ref:`smp_svr` sample. |
| 114 | +Otherwise, the MQTT FOTA sample cannot connect to the nRF52840 and will keep trying to connect. |
| 115 | +Build the :ref:`smp_svr` sample for the ``nrf9160dk/nrf52840`` board with the following parameters: |
| 116 | + |
| 117 | +* ``-DEXTRA_CONF_FILE=overlay-serial.conf`` |
| 118 | +* ``-DEXTRA_DTC_OVERLAY_FILE=nrf9160dk_nrf52840_mcumgr_svr.overlay`` |
| 119 | + |
| 120 | +To change :ref:`smp_svr` sample's application version, set the :kconfig:option:`CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION` Kconfig option. |
| 121 | + |
| 122 | +Testing |
| 123 | +======= |
| 124 | + |
| 125 | +|test_sample| |
| 126 | + |
| 127 | +#. |connect_kit| |
| 128 | +#. |connect_terminal| |
| 129 | +#. Reset the development kit. |
| 130 | +#. Observe in the terminal window that the application starts. |
| 131 | + This is indicated by output similar to the following (there is also a lot of additional information about the LTE connection): |
| 132 | + |
| 133 | + .. code-block:: console |
| 134 | +
|
| 135 | + *** Booting My Application v1.0.0-f135319f826e *** |
| 136 | + *** Using nRF Connect SDK v3.1.99-f135319f826e *** |
| 137 | + *** Using Zephyr OS v4.2.99-be1a9fd0eeca *** |
| 138 | + [00:00:00.255,889] <inf> nrf_cloud_mqtt_fota: nRF Cloud MQTT FOTA Sample, version: 1.0.0 |
| 139 | + [00:00:00.255,920] <inf> nrf_cloud_mqtt_fota: Reset reason: 0x1 |
| 140 | + [00:00:00.828,735] <inf> nrf_cloud_credentials: Sec Tag: 16842753; CA: Yes, Client Cert: Yes, Private Key: Yes |
| 141 | + [00:00:00.828,765] <inf> nrf_cloud_credentials: CA Size: 1824, AWS: Likely, CoAP: Likely |
| 142 | + [00:00:00.828,796] <inf> nrf_cloud_mqtt_fota: nRF Cloud credentials detected! |
| 143 | + [00:00:00.829,589] <inf> nrf_cloud_mqtt_fota: Enabling connectivity... |
| 144 | + +CGEV: EXCE STATUS 0 |
| 145 | + +CEREG: 2,"81A6","03229B10",7 |
| 146 | + %MDMEV: PRACH CE-LEVEL 0 |
| 147 | + +CSCON: 1 |
| 148 | + +CGEV: ME PDN ACT 0 |
| 149 | + %MDMEV: SEARCH STATUS 2 |
| 150 | + +CEREG: 1,"81A6","03229B10",7,,,"11100000","11100000" |
| 151 | + [00:00:02.471,496] <inf> nrf_cloud_mqtt_fota: Connected to LTE |
| 152 | + +CGEV: IPV6 0 |
| 153 | + [00:00:05.473,724] <inf> nrf_cloud_info: Device ID: 12345678-1234-5678-9abc-def012345678 |
| 154 | + [00:00:05.474,395] <inf> nrf_cloud_info: IMEI: 359404230026479 |
| 155 | + [00:00:05.474,575] <inf> nrf_cloud_info: UUID: 12345678-1234-5678-9abc-def012345678 |
| 156 | + [00:00:05.474,822] <inf> nrf_cloud_info: Modem FW: mfw_nrf91x1_2.0.3 |
| 157 | + [00:00:05.474,853] <inf> nrf_cloud_info: Protocol: MQTT |
| 158 | + [00:00:05.474,884] <inf> nrf_cloud_info: Download protocol: HTTPS |
| 159 | + [00:00:05.474,884] <inf> nrf_cloud_info: Sec tag: 16842753 |
| 160 | + [00:00:05.474,914] <inf> nrf_cloud_info: Host name: mqtt.nrfcloud.com |
| 161 | + [00:00:05.474,945] <inf> nrf_cloud_mqtt_fota: Connecting to nRF Cloud... |
| 162 | + [00:00:08.681,701] <inf> nrf_cloud_mqtt_fota: Connection to nRF Cloud ready |
| 163 | + [00:00:08.681,793] <inf> nrf_cloud_info: Team ID: 12345678-1234-5678-9abc-def012345670 |
| 164 | +
|
| 165 | +Dependencies |
| 166 | +************ |
| 167 | + |
| 168 | +This sample uses the following |NCS| libraries: |
| 169 | + |
| 170 | +* :ref:`lib_nrf_cloud` |
| 171 | +* :ref:`lte_lc_readme` |
| 172 | +* :ref:`dk_buttons_and_leds_readme` |
| 173 | +* :ref:`modem_info_readme` |
| 174 | +* :ref:`lib_at_host` |
| 175 | + |
| 176 | +In addition, it uses the following secure firmware component: |
| 177 | + |
| 178 | +* :ref:`Trusted Firmware-M <ug_tfm>` |
0 commit comments