Skip to content

Commit da92ac1

Browse files
committed
treewide: Include FOTA support
The implementation covers the necessary changes to do the different FOTA types: - host: Update the host MCU that is connected through SMP with the modem. - mfw: Modem firmware inside the nRF91 - mfw-app: Serial model application update. This demonstrate the configuration needed for the new Clover UX/UI. Jira: CLOUDMCU-159 Signed-off-by: Pascal Hernandez <pascal.hernandez@nordicsemi.no>
1 parent 5527218 commit da92ac1

14 files changed

Lines changed: 329 additions & 0 deletions

app/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ target_sources_ifdef(CONFIG_SM_HTTPC app PRIVATE src/sm_at_httpc.c)
3434
target_sources_ifdef(CONFIG_SM_MODEM_TRACE_BACKEND_CMUX app PRIVATE src/sm_trace_backend_cmux.c)
3535
target_sources_ifdef(CONFIG_SM_MODEM_TRACE_BACKEND_UART app PRIVATE src/sm_trace_backend_uart.c)
3636
target_sources_ifdef(CONFIG_NRF_PROVISIONING app PRIVATE src/sm_at_provisioning.c)
37+
target_sources_ifdef(CONFIG_SM_SMP_CLIENT app PRIVATE src/sm_smp_client.c)
3738

3839
add_subdirectory_ifdef(CONFIG_SM_CARRIER src/lwm2m_carrier)
3940

app/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,12 @@ config UART_2_NRF_HW_ASYNC_TIMER
433433

434434
endif # UART_ASYNC_API
435435

436+
config SM_SMP_CLIENT
437+
bool "SMP client echo on boot (wired UART to host MCU)"
438+
help
439+
When enabled, initializes an MCUmgr SMP client on the UART selected by
440+
zephyr,uart-mcumgr and sends a one-shot OS echo command at boot.
441+
436442
module = SM
437443
module-str = serial modem
438444
source "$(ZEPHYR_BASE)/subsys/logging/Kconfig.template.log_config"

app/overlay-smp-client.conf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) 2026 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
3+
4+
CONFIG_SM_SMP_CLIENT=y
5+
6+
CONFIG_NET_BUF=y
7+
CONFIG_ZCBOR=y
8+
CONFIG_ZCBOR_CANONICAL=y
9+
CONFIG_CRC=y
10+
CONFIG_MCUMGR=y
11+
CONFIG_SMP_CLIENT=y
12+
13+
CONFIG_BASE64=y
14+
CONFIG_UART_MCUMGR=y
15+
CONFIG_MCUMGR_TRANSPORT_UART=y
16+
17+
CONFIG_MCUMGR_GRP_OS_CLIENT=y
18+
CONFIG_MCUMGR_GRP_OS_CLIENT_ECHO=y
19+
CONFIG_MCUMGR_GRP_OS_CLIENT_RESET=n
20+
21+
# Logs use the app's native UART backend on zephyr,console = uart1 (VCOM1).
22+
# Enable at runtime with AT#XLOG=1. The SMP transport is on its own UART
23+
# (uart2, see overlay-smp-client.overlay), so the two never collide.

app/overlay-smp-client.overlay

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2026 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/ {
8+
chosen {
9+
/* SMP transport on uart2 (SERIAL2, free because the board overlay
10+
* disables i2c2). uart1 stays as the VCOM1 console/log UART, so the
11+
* app's sm_log never suspends the SMP link.
12+
*
13+
* Pins are the free Arduino-header GPIOs D2/D3/D6/D7
14+
* (P0.02/03/06/07). The earlier P0.28/29/30/31 choice collided with
15+
* VCOM1's own console pins (P0.28/29) and the on-board TWI/I2C2 bus
16+
* (P0.30/31, with pull-ups), which corrupted the SMP framing.
17+
*/
18+
zephyr,uart-mcumgr = &uart2;
19+
};
20+
};
21+
22+
&pinctrl {
23+
uart2_smp_default: uart2_smp_default {
24+
group1 {
25+
psels = <NRF_PSEL(UART_TX, 0, 2)>,
26+
<NRF_PSEL(UART_RTS, 0, 6)>;
27+
};
28+
29+
group2 {
30+
psels = <NRF_PSEL(UART_RX, 0, 3)>,
31+
<NRF_PSEL(UART_CTS, 0, 7)>;
32+
bias-pull-up;
33+
};
34+
};
35+
36+
uart2_smp_sleep: uart2_smp_sleep {
37+
group1 {
38+
psels = <NRF_PSEL(UART_TX, 0, 2)>,
39+
<NRF_PSEL(UART_RX, 0, 3)>,
40+
<NRF_PSEL(UART_RTS, 0, 6)>,
41+
<NRF_PSEL(UART_CTS, 0, 7)>;
42+
low-power-enable;
43+
};
44+
};
45+
};
46+
47+
&uart2 {
48+
status = "okay";
49+
current-speed = <115200>;
50+
hw-flow-control;
51+
pinctrl-0 = <&uart2_smp_default>;
52+
pinctrl-1 = <&uart2_smp_sleep>;
53+
pinctrl-names = "default", "sleep";
54+
};

app/src/sm_smp_client.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) 2026 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/logging/log.h>
9+
#include <zephyr/mgmt/mcumgr/mgmt/mgmt.h>
10+
#include <zephyr/mgmt/mcumgr/smp/smp_client.h>
11+
#include <zephyr/mgmt/mcumgr/grp/os_mgmt/os_mgmt_client.h>
12+
13+
LOG_MODULE_REGISTER(sm_smp_client, CONFIG_SM_LOG_LEVEL);
14+
15+
static const char smp_echo_str[] = "SMP echo";
16+
17+
static struct smp_client_object smp_client;
18+
static struct os_mgmt_client os_client;
19+
20+
static int sm_smp_client_echo(void)
21+
{
22+
int ret;
23+
24+
for (int attempt = 1; attempt <= 3; attempt++) {
25+
ret = os_mgmt_client_echo(&os_client, smp_echo_str, sizeof(smp_echo_str));
26+
if (ret == MGMT_ERR_EOK) {
27+
LOG_INF("SMP echo round-trip ok (attempt %d)", attempt);
28+
return 0;
29+
}
30+
31+
LOG_WRN("SMP echo attempt %d failed: %d", attempt, ret);
32+
k_msleep(500);
33+
}
34+
35+
LOG_ERR("SMP echo failed after retries");
36+
return -EIO;
37+
}
38+
39+
static int sm_smp_client_init(void)
40+
{
41+
int ret;
42+
43+
ret = smp_client_object_init(&smp_client, SMP_SERIAL_TRANSPORT);
44+
if (ret) {
45+
LOG_ERR("SMP client init failed: %d", ret);
46+
return ret;
47+
}
48+
49+
os_mgmt_client_init(&os_client, &smp_client);
50+
51+
LOG_INF("SMP echo request: %s", smp_echo_str);
52+
return sm_smp_client_echo();
53+
}
54+
55+
SYS_INIT(sm_smp_client_init, APPLICATION, 95);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# Copyright (c) 2023 Nordic Semiconductor
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
10+
project(sm_fota_smp_srv)
11+
12+
target_sources(app PRIVATE src/main.c)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2026 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/ {
8+
chosen {
9+
/* SMP transport. Console/logs go over SEGGER RTT (see prj.conf), so
10+
* no zephyr,console/shell-uart here — that keeps uart20 (P1.04-07)
11+
* free for the future AT host link.
12+
*/
13+
zephyr,uart-mcumgr = &uart30;
14+
};
15+
};
16+
17+
&pinctrl {
18+
uart30_smp_default: uart30_smp_default {
19+
group1 {
20+
psels = <NRF_PSEL(UART_TX, 0, 0)>,
21+
<NRF_PSEL(UART_RTS, 0, 2)>;
22+
};
23+
24+
group2 {
25+
psels = <NRF_PSEL(UART_RX, 0, 1)>,
26+
<NRF_PSEL(UART_CTS, 0, 3)>;
27+
bias-pull-up;
28+
};
29+
};
30+
31+
uart30_smp_sleep: uart30_smp_sleep {
32+
group1 {
33+
psels = <NRF_PSEL(UART_TX, 0, 0)>,
34+
<NRF_PSEL(UART_RX, 0, 1)>,
35+
<NRF_PSEL(UART_RTS, 0, 2)>,
36+
<NRF_PSEL(UART_CTS, 0, 3)>;
37+
low-power-enable;
38+
};
39+
};
40+
};
41+
42+
&uart30 {
43+
status = "okay";
44+
current-speed = <115200>;
45+
hw-flow-control;
46+
pinctrl-0 = <&uart30_smp_default>;
47+
pinctrl-1 = <&uart30_smp_sleep>;
48+
pinctrl-names = "default", "sleep";
49+
};
50+
51+
/* Console moved to RTT; release uart20 (P1.04-07) for the future AT host link. */
52+
&uart20 {
53+
status = "disabled";
54+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CONFIG_MEMFAULT_FOTA_MODEM_UPDATE=y
2+
CONFIG_MEMFAULT_FOTA_MODEM_SOFTWARE_TYPE="host"
3+
4+
# Update with a new project key, see https://docs.memfault.com/docs/mcu/nrf-modem-fota
5+
CONFIG_MEMFAULT_FOTA_MODEM_PROJECT_KEY="YOUR_PROJECT_KEY"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CONFIG_MEMFAULT_FOTA_MODEM_UPDATE=y
2+
CONFIG_MEMFAULT_FOTA_MODEM_SOFTWARE_TYPE="mfw-app"
3+
4+
# Update with a new project key, see https://docs.memfault.com/docs/mcu/nrf-modem-fota
5+
CONFIG_MEMFAULT_FOTA_MODEM_PROJECT_KEY="YOUR_PROJECT_KEY"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_MEMFAULT_FOTA_MODEM_UPDATE=y
2+
3+
# Update with a new project key, see https://docs.memfault.com/docs/mcu/nrf-modem-fota
4+
CONFIG_MEMFAULT_FOTA_MODEM_PROJECT_KEY="YOUR_PROJECT_KEY"

0 commit comments

Comments
 (0)