From 9b003adba4d1cbebc5abd4409dcb809d445e6aa0 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 13 Nov 2024 14:00:17 +0000 Subject: [PATCH] [nrf noup] samples: mgmt: mcumgr: smp_svr: Add nrf5340dk-optimised sample Adds a configuration to this sample that is optimised for testing/usage with the nRF5340 which enables the Bluetooth transport, enables most management groups, has a static partition manager file with secondary partitions on QSPI flash, configures MCUboot in overwrite only mode with network core update support Signed-off-by: Jamie McCrae --- .../mcumgr/smp_svr/app_nrf5340_bt.overlay | 5 ++ .../mcumgr/smp_svr/pm_static_nrf5340_bt.yml | 55 ++++++++++++ .../mgmt/mcumgr/smp_svr/prj_nrf5340_bt.conf | 88 +++++++++++++++++++ .../subsys/mgmt/mcumgr/smp_svr/sample.yaml | 8 ++ .../subsys/mgmt/mcumgr/smp_svr/sysbuild.cmake | 16 ++++ .../mcumgr/smp_svr/sysbuild_nrf5340_bt.conf | 8 ++ 6 files changed, 180 insertions(+) create mode 100644 samples/subsys/mgmt/mcumgr/smp_svr/app_nrf5340_bt.overlay create mode 100644 samples/subsys/mgmt/mcumgr/smp_svr/pm_static_nrf5340_bt.yml create mode 100644 samples/subsys/mgmt/mcumgr/smp_svr/prj_nrf5340_bt.conf create mode 100644 samples/subsys/mgmt/mcumgr/smp_svr/sysbuild.cmake create mode 100644 samples/subsys/mgmt/mcumgr/smp_svr/sysbuild_nrf5340_bt.conf diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/app_nrf5340_bt.overlay b/samples/subsys/mgmt/mcumgr/smp_svr/app_nrf5340_bt.overlay new file mode 100644 index 00000000000..fcc2e240fd9 --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/app_nrf5340_bt.overlay @@ -0,0 +1,5 @@ +/ { + chosen { + nordic,pm-ext-flash = &mx25r64; + }; +}; diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/pm_static_nrf5340_bt.yml b/samples/subsys/mgmt/mcumgr/smp_svr/pm_static_nrf5340_bt.yml new file mode 100644 index 00000000000..7a48d51ec33 --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/pm_static_nrf5340_bt.yml @@ -0,0 +1,55 @@ +app: + address: 0x10200 + region: flash_primary + size: 0xdfe00 +mcuboot: + address: 0x0 + region: flash_primary + size: 0x10000 +mcuboot_pad: + address: 0x10000 + region: flash_primary + size: 0x200 +mcuboot_primary: + address: 0x10000 + orig_span: &id001 + - mcuboot_pad + - app + region: flash_primary + size: 0xe0000 + span: *id001 +mcuboot_primary_app: + address: 0x10200 + orig_span: &id002 + - app + region: flash_primary + size: 0xdfe00 + span: *id002 +settings_storage: + address: 0xf0000 + region: flash_primary + size: 0x10000 +mcuboot_primary_1: + address: 0x0 + size: 0x40000 + device: flash_ctrl + region: ram_flash +mcuboot_secondary: + address: 0x00000 + size: 0xe0000 + device: MX25R64 + region: external_flash +mcuboot_secondary_1: + address: 0xe0000 + size: 0x40000 + device: MX25R64 + region: external_flash +external_flash: + address: 0x120000 + size: 0x6e0000 + device: MX25R64 + region: external_flash +pcd_sram: + address: 0x20000000 + size: 0x2000 + region: sram_primary diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/prj_nrf5340_bt.conf b/samples/subsys/mgmt/mcumgr/smp_svr/prj_nrf5340_bt.conf new file mode 100644 index 00000000000..cb53d3e6beb --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/prj_nrf5340_bt.conf @@ -0,0 +1,88 @@ +# Enable MCUmgr and dependencies. +CONFIG_NET_BUF=y +CONFIG_ZCBOR=y +CONFIG_CRC=y +CONFIG_MCUMGR=y +CONFIG_STREAM_FLASH=y +CONFIG_FLASH_MAP=y +CONFIG_BT=y +CONFIG_BT_PERIPHERAL=y + +# Some command handlers require a large stack. +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2304 +CONFIG_MAIN_STACK_SIZE=2176 + +# Ensure an MCUboot-compatible binary is generated. +CONFIG_BOOTLOADER_MCUBOOT=y + +# Enable flash operations. +CONFIG_FLASH=y + +# Required by the `taskstat` command. +CONFIG_THREAD_MONITOR=y + +# Support for taskstat command +CONFIG_MCUMGR_GRP_OS_TASKSTAT=y + +# Enable statistics and statistic names. +CONFIG_STATS=y +CONFIG_STATS_NAMES=y + +# Enable most core commands. +CONFIG_FLASH=y +CONFIG_IMG_MANAGER=y +CONFIG_MCUMGR_GRP_IMG=y +CONFIG_MCUMGR_GRP_OS=y +CONFIG_MCUMGR_GRP_STAT=y + +# Enable logging +CONFIG_LOG=y +CONFIG_MCUBOOT_UTIL_LOG_LEVEL_WRN=y + +# Disable debug logging +CONFIG_LOG_MAX_LEVEL=3 + +# Allow for large Bluetooth data packets. +CONFIG_BT_L2CAP_TX_MTU=498 +CONFIG_BT_BUF_ACL_RX_SIZE=502 +CONFIG_BT_BUF_ACL_TX_SIZE=502 +CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 + +# Enable the Bluetooth mcumgr transport (unauthenticated). +CONFIG_MCUMGR_TRANSPORT_BT=y +CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL=y + +# Enable the Shell mcumgr transport. +CONFIG_BASE64=y +CONFIG_CRC=y +CONFIG_SHELL=y +CONFIG_SHELL_BACKEND_SERIAL=y +CONFIG_MCUMGR_TRANSPORT_SHELL=y + +# Enable the mcumgr Packet Reassembly feature over Bluetooth and its configuration dependencies. +# MCUmgr buffer size is optimized to fit one SMP packet divided into five Bluetooth Write Commands, +# transmitted with the maximum possible MTU value: 498 bytes. +CONFIG_MCUMGR_TRANSPORT_BT_REASSEMBLY=y +CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE=2475 +CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS=y +CONFIG_MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE=4608 + +# Enable the LittleFS file system. +CONFIG_FILE_SYSTEM=y +CONFIG_FILE_SYSTEM_LITTLEFS=y + +# Enable file system commands +CONFIG_MCUMGR_GRP_FS=y + +# Enable the storage erase command. +CONFIG_MCUMGR_GRP_ZBASIC=y +CONFIG_MCUMGR_GRP_ZBASIC_STORAGE_ERASE=y + +# Disable Bluetooth ping support +CONFIG_BT_CTLR_LE_PING=n + +# Disable shell commands that are not needed +CONFIG_CLOCK_CONTROL_NRF_SHELL=n +CONFIG_DEVICE_SHELL=n +CONFIG_DEVMEM_SHELL=n +CONFIG_FLASH_SHELL=n diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/sample.yaml b/samples/subsys/mgmt/mcumgr/smp_svr/sample.yaml index 38ee2c5a2c6..16526fdfe7b 100644 --- a/samples/subsys/mgmt/mcumgr/smp_svr/sample.yaml +++ b/samples/subsys/mgmt/mcumgr/smp_svr/sample.yaml @@ -217,3 +217,11 @@ tests: - nrf52840dk/nrf52840 integration_platforms: - nrf52840dk/nrf52840 + sample.mcumgr.smp_svr.bt.nrf5340dk.ext_flash: + sysbuild: true + extra_args: + - FILE_SUFFIX=nrf5340_bt + platform_allow: + - nrf5340dk/nrf5340/cpuapp + integration_platforms: + - nrf5340dk/nrf5340/cpuapp diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild.cmake b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild.cmake new file mode 100644 index 00000000000..f0a9f06df84 --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild.cmake @@ -0,0 +1,16 @@ +# +# Copyright (c) 2024 Nordic Semiconductor +# +# SPDX-License-Identifier: Apache-2.0 +# + +if(FILE_SUFFIX STREQUAL "nrf5340_bt") + if(SB_CONFIG_SOC_NRF5340_CPUAPP) + # nRF5340 with Bluetooth configuration, add partition manager configuration to MCUboot image + list(APPEND mcuboot_EXTRA_DTC_OVERLAY_FILE ${CMAKE_CURRENT_LIST_DIR}/app_nrf5340_bt.overlay) + list(REMOVE_DUPLICATES mcuboot_EXTRA_DTC_OVERLAY_FILE) + set(mcuboot_EXTRA_DTC_OVERLAY_FILE ${mcuboot_EXTRA_DTC_OVERLAY_FILE} CACHE INTERNAL "" FORCE) + else() + message(FATAL_ERROR "File suffix 'nrf5340_bt' can only be used on an nRF5340 CPUAPP board target") + endif() +endif() diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild_nrf5340_bt.conf b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild_nrf5340_bt.conf new file mode 100644 index 00000000000..16bcac179e8 --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild_nrf5340_bt.conf @@ -0,0 +1,8 @@ +# Enable MCUboot bootloader support +SB_CONFIG_BOOTLOADER_MCUBOOT=y +SB_CONFIG_MCUBOOT_MODE_OVERWRITE_ONLY=y +SB_CONFIG_NETCORE_HCI_IPC=y +SB_CONFIG_SECURE_BOOT_NETCORE=y +SB_CONFIG_NETCORE_APP_UPDATE=y +SB_CONFIG_MCUBOOT_NRF53_MULTI_IMAGE_UPDATE=y +SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y