Skip to content

Commit ed9bdb2

Browse files
pascal-nordicrlubos
authored andcommitted
samples: cellular: nrf_cloud_rest_fota: Refactor sample to use conn_mgr
Removed JITP and included Zephyr's Connection Manager Fixed SMP, it was not able to compile as BOOTUTIL library was missing. Manually tested modem, app and fmfu FOTA on nRF9160 and nRF9151. Also, tested SMP FOTA using nRF9160. IRIS-5713 Signed-off-by: Pascal Hernandez <[email protected]>
1 parent f579a57 commit ed9bdb2

File tree

9 files changed

+245
-288
lines changed

9 files changed

+245
-288
lines changed

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,9 @@ Cellular samples
388388
* :ref:`nrf_cloud_rest_fota` sample:
389389

390390
* Added support for the Thingy:91 X.
391+
* Updated the sample to use Zephyr's :ref:`zephyr:conn_mgr_docs` feature.
392+
* Fixed SMP FOTA for the nRF9160 DK.
393+
* Removed JITP.
391394

392395
Cryptography samples
393396
--------------------

samples/cellular/nrf_cloud_rest_fota/Kconfig

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,14 @@ config REST_FOTA_JOB_CHECK_RATE_MIN
1515
range 1 10080
1616
default 15
1717

18-
config REST_FOTA_ENABLE_LED
19-
depends on DK_LIBRARY
20-
bool "Turn on LED when connected to network"
21-
default y
22-
23-
if REST_FOTA_ENABLE_LED
24-
config REST_FOTA_LED_NUM
25-
int "LED number to use"
18+
config REST_FOTA_LTE_LED_NUM
19+
int "LED number to use for LTE connection status"
2620
default 0
27-
endif
2821

2922
config REST_FOTA_BUTTON_EVT_NUM
3023
int "Button number to use for device interactions"
3124
default 1
3225

33-
config REST_FOTA_DO_JITP
34-
bool "Ask to perform just-in-time provisioning (JITP) via REST on startup"
35-
help
36-
If a device has JITP certificates and has not yet been provisioned to
37-
nRF Cloud, enable this option and press the configured button when
38-
prompted after the sample starts.
39-
4026
endmenu
4127

4228
menu "Zephyr Kernel"

samples/cellular/nrf_cloud_rest_fota/README.rst

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ Cellular: nRF Cloud REST FOTA
77
:local:
88
:depth: 2
99

10-
The REST FOTA sample demonstrates how to use the `nRF Cloud REST API`_ to perform Firmware Over-the-Air (FOTA) updates on your device.
10+
The REST FOTA sample demonstrates how to use the `nRF Cloud REST API`_ to perform Firmware Over-the-Air (FOTA) updates over REST 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.
1113

1214
Requirements
1315
************
@@ -18,13 +20,19 @@ The sample supports the following development kits:
1820

1921
.. include:: /includes/tfm.txt
2022

21-
The sample requires an `nRF Cloud`_ account and modem firmware v1.3.x or later for an nRF9160 DK, or modem firmware v2.x.x for the nRF91x1 DKs.
23+
The sample requires an `nRF Cloud`_ account.
24+
25+
Your device must be onboarded to nRF Cloud.
26+
If it is not, follow the instructions in `Device on-boarding <nrf_cloud_rest_fota_onboarding_>`_.
2227

2328
.. note::
24-
Full modem FOTA requires development kit version 0.14.0 or higher if you are using an nRF9160 DK.
29+
This sample requires modem firmware v1.3.x or later for an nRF9160 SiP and v2.0.0 or later for nRF91x1 SiPs.
2530

2631
.. include:: /includes/external_flash_nrf91.txt
2732

33+
.. note::
34+
Full modem FOTA requires development kit version 0.14.0 or higher if you are using an nRF9160 DK.
35+
2836
Overview
2937
********
3038

@@ -40,14 +48,21 @@ Without a valid date and time, the modem cannot generate JWTs with an expiration
4048
User interface
4149
**************
4250

43-
If you want to perform an update check immediately, press the button configured by the Kconfig option :ref:`CONFIG_REST_FOTA_BUTTON_EVT_NUM <CONFIG_REST_FOTA_BUTTON_EVT_NUM>`.
51+
Once the device is onboarded and connected, if you want to perform an update check immediately, press **Button 1**.
4452
This will bypass the wait time specified by the :ref:`CONFIG_REST_FOTA_JOB_CHECK_RATE_MIN <CONFIG_REST_FOTA_JOB_CHECK_RATE_MIN>` option.
53+
**Button 1** is configured by the :ref:`CONFIG_REST_FOTA_BUTTON_EVT_NUM <CONFIG_REST_FOTA_BUTTON_EVT_NUM>` option.
54+
55+
The configured LTE LED (**LED 1** by default, :ref:`CONFIG_REST_FOTA_LTE_LED_NUM <CONFIG_REST_FOTA_LTE_LED_NUM>`) is lit once an LTE connection is established.
56+
57+
.. _nrf_cloud_rest_fota_onboarding:
58+
59+
Onboarding your device to nRF Cloud
60+
***********************************
4561

46-
If you have the option :ref:`CONFIG_REST_FOTA_DO_JITP <CONFIG_REST_FOTA_DO_JITP>` enabled and you press the button configured by the :ref:`CONFIG_REST_FOTA_BUTTON_EVT_NUM <CONFIG_REST_FOTA_BUTTON_EVT_NUM>` option when prompted at startup, it will request just-in-time provisioning (JITP) through REST with nRF Cloud.
47-
This is useful when initially provisioning and associating a device on nRF Cloud.
62+
You must onboard your device to nRF Cloud for this sample to function.
4863
You only need to do this once for each device.
4964

50-
If you have enabled the :ref:`CONFIG_REST_FOTA_ENABLE_LED <CONFIG_REST_FOTA_ENABLE_LED>` option, an LED configured by the :ref:`CONFIG_REST_FOTA_LED_NUM <CONFIG_REST_FOTA_LED_NUM>` option indicates the state of the connection to the LTE network.
65+
To onboard your device, install `nRF Cloud Utils`_ and follow the instructions in the README.
5166

5267
Configuration
5368
*************
@@ -61,34 +76,19 @@ Check and configure the following configuration options for the sample:
6176
.. _CONFIG_REST_FOTA_JOB_CHECK_RATE_MIN:
6277

6378
CONFIG_REST_FOTA_JOB_CHECK_RATE_MIN - Update check rate
64-
This configuration option defines how often the sample checks for FOTA updates.
79+
Defines how often the sample checks for FOTA updates.
6580
You can modify this value at runtime by adding or updating the ``"fotaInterval"`` item in the desired config section of the device's shadow.
6681
Use the `nRF Cloud`_ portal or the REST API to perform the config update.
6782

68-
.. _CONFIG_REST_FOTA_DL_TIMEOUT_MIN:
83+
.. _CONFIG_REST_FOTA_LTE_LED_NUM:
6984

70-
CONFIG_REST_FOTA_DL_TIMEOUT_MIN - Download timeout value
71-
This configuration option defines how long to wait for a download to complete.
72-
73-
.. _CONFIG_REST_FOTA_ENABLE_LED:
74-
75-
CONFIG_REST_FOTA_ENABLE_LED - Enable LED
76-
This configuration option defines if the LED will be used to indicate connection to the LTE network.
77-
78-
.. _CONFIG_REST_FOTA_LED_NUM:
79-
80-
CONFIG_REST_FOTA_LED_NUM - Enable LED
81-
This configuration option defines if the LED is to be used.
85+
CONFIG_REST_FOTA_LTE_LED_NUM - LTE LED number
86+
Defines the LED used to indicate connection to the LTE network.
8287

8388
.. _CONFIG_REST_FOTA_BUTTON_EVT_NUM:
8489

8590
CONFIG_REST_FOTA_BUTTON_EVT_NUM - Button number
86-
This configuration option defines the button to use for device interactions.
87-
88-
.. _CONFIG_REST_FOTA_DO_JITP:
89-
90-
CONFIG_REST_FOTA_DO_JITP - Enable prompt to perform JITP using REST
91-
This configuration option defines if the application will prompt the user for just-in-time provisioning on startup.
91+
Defines the button to use for manual FOTA update check.
9292

9393
.. include:: /libraries/modem/nrf_modem_lib/nrf_modem_lib_trace.rst
9494
:start-after: modem_lib_sending_traces_UART_start
@@ -101,7 +101,7 @@ Building and running
101101

102102
.. include:: /includes/build_and_run_ns.txt
103103

104-
The configuration file for this sample is located in :file:`samples/cellular/nrf_cloud_rest_fota`.
104+
The configuration files for this sample are located in :file:`samples/cellular/nrf_cloud_rest_fota`.
105105
See :ref:`configure_application` for information on how to configure the parameters.
106106

107107
To create a FOTA test version of this sample, add the following parameter to your build command:
@@ -120,11 +120,13 @@ To enable SMP FOTA (nRF9160 DK only), add the following parameters to your build
120120
* ``-DEXTRA_CONF_FILE=overlay_smp_fota.conf``
121121
* ``-DEXTRA_DTC_OVERLAY_FILE=nrf9160dk_mcumgr_client_uart2.overlay``
122122

123+
Once the nRF9160 has been flashed, change the switch **SW10** to the nRF52 position to be able to flash the nRF52840 on the DK.
123124
The nRF52840 device on your DK must be running an SMP compatible firmware, such as the :ref:`smp_svr` sample.
125+
Otherwise, the REST FOTA sample will not be able to connect to the nRF52840 and will keep trying to connect.
124126
Build the :ref:`smp_svr` sample for the ``nrf9160dk/nrf52840`` board with the following parameters:
125127

126-
* ``-DEXTRA_CONF_FILE=overlay_smp_fota.conf``
127-
* ``-DEXTRA_DTC_OVERLAY_FILE=nrf9160dk_mcumgr_client_uart2.overlay``
128+
* ``-DEXTRA_CONF_FILE=overlay-serial.conf``
129+
* ``-DEXTRA_DTC_OVERLAY_FILE=nrf9160dk_nrf52840_mcumgr_svr.overlay``
128130

129131
To change :ref:`smp_svr` sample's application version, set the :kconfig:option:`CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION` Kconfig option.
130132

samples/cellular/nrf_cloud_rest_fota/overlay_full_modem_fota.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,13 @@ CONFIG_SPI=y
99
CONFIG_SPI_NOR=y
1010
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
1111
CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y
12+
13+
# FMFU requires additional heap space.
14+
# If the heap is too small, a boot loop can occur when the full modem image is installed.
15+
CONFIG_HEAP_MEM_POOL_SIZE=47250
16+
17+
CONFIG_REST_FOTA_DL_TIMEOUT_MIN=30
18+
CONFIG_REST_FOTA_JOB_CHECK_RATE_MIN=1
19+
CONFIG_IMG_ERASE_PROGRESSIVELY=n
20+
CONFIG_SPI_NOR_SFDP_MINIMAL=n
21+
CONFIG_SPI_NOR_SFDP_DEVICETREE=y

samples/cellular/nrf_cloud_rest_fota/overlay_smp_fota.conf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ CONFIG_MCUMGR_GRP_IMG=y
99
CONFIG_MCUMGR_GRP_OS=y
1010
CONFIG_MCUMGR_TRANSPORT_UART=y
1111
CONFIG_UART_MCUMGR_RX_BUF_COUNT=4
12-
CONFIG_BOOT_IMAGE_ACCESS_HOOKS=y
1312
CONFIG_SMP_CMD_RETRY_TIME=1000
13+
14+
# Enable MCUboot util library
15+
CONFIG_MCUBOOT_IMG_MANAGER=y
16+
CONFIG_DFU_TARGET_SMP=y

samples/cellular/nrf_cloud_rest_fota/prj.conf

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
# Sample
2-
CONFIG_REST_FOTA_DO_JITP=n
32
CONFIG_NRF_CLOUD_REST_FOTA_SAMPLE_LOG_LEVEL_INF=y
43

54
# nRF Cloud REST
65
CONFIG_NRF_CLOUD=y
76
CONFIG_NRF_CLOUD_REST=y
87
CONFIG_NRF_CLOUD_CLIENT_ID_SRC_IMEI=y
9-
CONFIG_MODEM_JWT=y
8+
CONFIG_NRF_CLOUD_CHECK_CREDENTIALS=y
9+
10+
# Networking
1011
CONFIG_NETWORKING=y
1112
CONFIG_NET_SOCKETS=y
12-
CONFIG_POSIX_API=y
13-
CONFIG_NET_NATIVE=n
14-
CONFIG_NRF_CLOUD_CHECK_CREDENTIALS=y
13+
CONFIG_NET_SOCKETS_OFFLOAD=y
14+
15+
# Enable LTE Connectivity using Connection Manager
16+
CONFIG_NET_IPV4=y
17+
CONFIG_NET_IPV6=y
18+
CONFIG_NET_IPV6_NBR_CACHE=n
19+
CONFIG_NET_IPV6_MLD=n
20+
CONFIG_NET_CONNECTION_MANAGER=y
21+
CONFIG_NRF_MODEM_LIB=y
22+
CONFIG_NRF_MODEM_LIB_NET_IF=y
23+
CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_DOWN=y
24+
CONFIG_NRF_MODEM_LIB_NET_IF_DOWN_DEFAULT_LTE_DISCONNECT=y
25+
CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE=1024
26+
CONFIG_NET_MGMT_EVENT_STACK_SIZE=2048
1527

1628
# FOTA
1729
CONFIG_NRF_CLOUD_FOTA_POLL=y
@@ -21,7 +33,7 @@ CONFIG_FOTA_DOWNLOAD=y
2133
CONFIG_FOTA_DOWNLOAD_PROGRESS_EVT=y
2234
CONFIG_DFU_TARGET=y
2335
CONFIG_DOWNLOADER=y
24-
CONFIG_DOWNLOADER_STACK_SIZE=2048
36+
CONFIG_DOWNLOADER_STACK_SIZE=3072
2537

2638
# MCUBOOT
2739
CONFIG_BOOTLOADER_MCUBOOT=y
@@ -44,14 +56,14 @@ CONFIG_MPU_ALLOW_FLASH_WRITE=y
4456
# Button/LED support
4557
CONFIG_DK_LIBRARY=y
4658

47-
# Modem/LTE Link
48-
CONFIG_NRF_MODEM_LIB=y
59+
# LTE Link
4960
CONFIG_LTE_LINK_CONTROL=y
5061

5162
# AT Host library - Used to send AT commands directy from an UART terminal and to allow
5263
# integration with nRF Connect for Desktop applications.
5364
CONFIG_AT_HOST_LIBRARY=y
5465
# Extended AT host stack size since some nrf_cloud credentials are longer than 1024 bytes.
66+
CONFIG_AT_MONITOR_HEAP_SIZE=4096
5567
CONFIG_AT_HOST_STACK_SIZE=2048
5668

5769
# Modem info
@@ -64,14 +76,22 @@ CONFIG_MODEM_INFO_ADD_SIM_IMSI=y
6476

6577
# System
6678
CONFIG_HEAP_MEM_POOL_SIZE=8192
67-
CONFIG_MAIN_STACK_SIZE=8192
68-
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=8192
79+
CONFIG_MAIN_STACK_SIZE=3072
80+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
6981
CONFIG_ASSERT=y
7082
CONFIG_REBOOT=y
7183
CONFIG_FPU=y
7284
CONFIG_PICOLIBC_IO_FLOAT=y
85+
CONFIG_EVENTS=y
86+
CONFIG_POSIX_API=y
7387

7488
# Logging
7589
CONFIG_LOG=y
7690
CONFIG_LOG_MODE_IMMEDIATE=y
7791
CONFIG_UART_INTERRUPT_DRIVEN=y
92+
93+
# Modem key management
94+
CONFIG_MODEM_KEY_MGMT=y
95+
CONFIG_MODEM_JWT=y
96+
CONFIG_NRF_CLOUD_REST_AUTOGEN_JWT=y
97+
CONFIG_NRF_CLOUD_SEC_TAG=16842753

0 commit comments

Comments
 (0)