diff --git a/applications/nrf_desktop/Kconfig.sysbuild b/applications/nrf_desktop/Kconfig.sysbuild index b5db53622cd5..bab4d58cf85d 100644 --- a/applications/nrf_desktop/Kconfig.sysbuild +++ b/applications/nrf_desktop/Kconfig.sysbuild @@ -26,4 +26,7 @@ config SECURE_BOOT_APPCORE config PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY default y if BOARD_NRF52840DK_NRF52840 +config SUIT_ENVELOPE + default y if BOARD_NRF54H20DK + source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/applications/nrf_desktop/configuration/nrf54h20dk_nrf54h20_cpuapp/app.overlay b/applications/nrf_desktop/configuration/nrf54h20dk_nrf54h20_cpuapp/app.overlay index caa85784048f..16995191907a 100644 --- a/applications/nrf_desktop/configuration/nrf54h20dk_nrf54h20_cpuapp/app.overlay +++ b/applications/nrf_desktop/configuration/nrf54h20dk_nrf54h20_cpuapp/app.overlay @@ -52,3 +52,18 @@ }; }; }; + +&cpuapp_rw_partitions { + dfu_partition: partition@13c000 { + label = "dfu_partition"; + reg = <0x13c000 DT_SIZE_K(676)>; + }; +}; + +&cpusec_cpuapp_ipc { + status = "okay"; +}; + +&cpusec_bellboard { + status = "okay"; +}; diff --git a/applications/nrf_desktop/configuration/nrf54h20dk_nrf54h20_cpuapp/prj.conf b/applications/nrf_desktop/configuration/nrf54h20dk_nrf54h20_cpuapp/prj.conf index 090a591d8805..efc408e0c8a3 100644 --- a/applications/nrf_desktop/configuration/nrf54h20dk_nrf54h20_cpuapp/prj.conf +++ b/applications/nrf_desktop/configuration/nrf54h20dk_nrf54h20_cpuapp/prj.conf @@ -106,3 +106,41 @@ CONFIG_LOG_MODE_DEFERRED=y CONFIG_LOG_PRINTK=y CONFIG_LOG_BUFFER_SIZE=4096 CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=1024 + +################################################################################ +# DFU configuration + +CONFIG_SUIT=y +CONFIG_SUIT_DFU_CANDIDATE_PROCESSING_MINIMAL=y +CONFIG_ZCBOR=y +CONFIG_ZCBOR_CANONICAL=y +CONFIG_SSF_SUIT_SERVICE_ENABLED=y +CONFIG_DESKTOP_DFU_MCUMGR_ENABLE=y + +CONFIG_MGMT_SUITFU=y +CONFIG_MCUMGR_SMP_LEGACY_RC_BEHAVIOUR=y + +# Enable the Bluetooth MCUmgr transport (unauthenticated). +CONFIG_MCUMGR=y +CONFIG_MCUMGR_TRANSPORT_BT=y +CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN=n + +# 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=251 + +# 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_TRANSPORT_WORKQUEUE_STACK_SIZE=4096 + +# Allow a DFU host to retrieve information about the number and size of MCUmgr buffers. +# The nRF Connect Device Manager uses this information to speed up the DFU. +CONFIG_MCUMGR_GRP_OS=y +CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS=y + +# Extended SUIT commands over USER group +CONFIG_MGMT_SUITFU_GRP_SUIT=y diff --git a/applications/nrf_desktop/configuration/nrf54h20dk_nrf54h20_cpuapp/prj_release.conf b/applications/nrf_desktop/configuration/nrf54h20dk_nrf54h20_cpuapp/prj_release.conf index 7f90730fc752..5fc689422d11 100644 --- a/applications/nrf_desktop/configuration/nrf54h20dk_nrf54h20_cpuapp/prj_release.conf +++ b/applications/nrf_desktop/configuration/nrf54h20dk_nrf54h20_cpuapp/prj_release.conf @@ -86,3 +86,41 @@ CONFIG_BT_CONN_TX_MAX=4 CONFIG_SERIAL=n CONFIG_CONSOLE=n CONFIG_UART_CONSOLE=n + +################################################################################ +# DFU configuration + +CONFIG_SUIT=y +CONFIG_SUIT_DFU_CANDIDATE_PROCESSING_MINIMAL=y +CONFIG_ZCBOR=y +CONFIG_ZCBOR_CANONICAL=y +CONFIG_SSF_SUIT_SERVICE_ENABLED=y +CONFIG_DESKTOP_DFU_MCUMGR_ENABLE=y + +CONFIG_MGMT_SUITFU=y +CONFIG_MCUMGR_SMP_LEGACY_RC_BEHAVIOUR=y + +# Enable the Bluetooth MCUmgr transport (unauthenticated). +CONFIG_MCUMGR=y +CONFIG_MCUMGR_TRANSPORT_BT=y +CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN=n + +# 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=251 + +# 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_TRANSPORT_WORKQUEUE_STACK_SIZE=4096 + +# Allow a DFU host to retrieve information about the number and size of MCUmgr buffers. +# The nRF Connect Device Manager uses this information to speed up the DFU. +CONFIG_MCUMGR_GRP_OS=y +CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS=y + +# Extended SUIT commands over USER group +CONFIG_MGMT_SUITFU_GRP_SUIT=y diff --git a/applications/nrf_desktop/src/modules/Kconfig.dfu_mcumgr b/applications/nrf_desktop/src/modules/Kconfig.dfu_mcumgr index 0acbd7314d51..c62a48635002 100644 --- a/applications/nrf_desktop/src/modules/Kconfig.dfu_mcumgr +++ b/applications/nrf_desktop/src/modules/Kconfig.dfu_mcumgr @@ -9,7 +9,6 @@ menuconfig DESKTOP_DFU_MCUMGR_ENABLE select EXPERIMENTAL select CAF_BLE_SMP_TRANSFER_EVENTS if MCUMGR_TRANSPORT_BT select MCUMGR - select MCUMGR_GRP_IMG select MCUMGR_GRP_OS select MCUMGR_MGMT_NOTIFICATION_HOOKS select MCUMGR_GRP_IMG_MUTEX if DESKTOP_DFU_LOCK @@ -17,12 +16,9 @@ menuconfig DESKTOP_DFU_MCUMGR_ENABLE select NET_BUF select ZCBOR select CRC - select IMG_MANAGER - select MCUBOOT_BOOTUTIL_LIB select STREAM_FLASH select FLASH_MAP select FLASH - depends on BOOTLOADER_MCUBOOT help This option enables an alternative method of performing DFU using the MCUmgr module. @@ -43,6 +39,30 @@ config DESKTOP_DFU_MCUMGR_MCUBOOT_DIRECT_XIP boots the image with a higher version. The module does not confirm the newly updated image after a successful boot. +choice DESKTOP_DFU_MCUMGR_BACKEND + prompt "Choose DFU backend" + default DESKTOP_DFU_BACKEND_MCUBOOT if BOOTLOADER_MCUBOOT + default DESKTOP_DFU_BACKEND_SUIT if SUIT + +config DESKTOP_DFU_BACKEND_MCUBOOT + bool "Use MCUboot as DFU backend" + select MCUMGR_GRP_IMG + select MCUBOOT_BOOTUTIL_LIB + select IMG_MANAGER + depends on BOOTLOADER_MCUBOOT + help + This option enables the MCUboot bootloader as the backend for the MCUmgr DFU module. + +config DESKTOP_DFU_BACKEND_SUIT + bool "Use SUIT as DFU backend" + select MCUMGR_SMP_LEGACY_RC_BEHAVIOUR + select MGMT_SUITFU + depends on SUIT + help + This option enables the SUIT as the backend for the MCUmgr DFU module. + +endchoice + module = DESKTOP_DFU_MCUMGR module-str = DFU MCUmgr source "subsys/logging/Kconfig.template.log_config" diff --git a/applications/nrf_desktop/src/modules/dfu_mcumgr.c b/applications/nrf_desktop/src/modules/dfu_mcumgr.c index cf4dfd31893f..1343a55e1a2a 100644 --- a/applications/nrf_desktop/src/modules/dfu_mcumgr.c +++ b/applications/nrf_desktop/src/modules/dfu_mcumgr.c @@ -4,8 +4,15 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ +#include + +#if defined CONFIG_DESKTOP_DFU_BACKEND_MCUBOOT #include #include +#elif defined CONFIG_DESKTOP_DFU_BACKEND_SUIT +#include +#endif + #include #include #include @@ -127,6 +134,7 @@ static bool app_event_handler(const struct app_event_header *aeh) cast_module_state_event(aeh); if (check_state(event, MODULE_ID(main), MODULE_STATE_READY)) { +#if defined CONFIG_DESKTOP_DFU_BACKEND_MCUBOOT if (!IS_ENABLED(CONFIG_DESKTOP_DFU_MCUMGR_MCUBOOT_DIRECT_XIP)) { int err = boot_write_img_confirmed(); @@ -136,6 +144,27 @@ static bool app_event_handler(const struct app_event_header *aeh) } LOG_INF("MCUboot image version: %s", CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION); +#elif defined CONFIG_DESKTOP_DFU_BACKEND_SUIT + /* Manifest class ID + * nRF Desktop uses default SUIT manifest file (default namespace and name). + */ + const suit_manifest_class_id_t manifest_class_id = {{ + /* RFC4122 uuid5(uuid5(uuid.NAMESPACE_DNS, 'nordicsemi.com'), + * 'nRF54H20_sample_root') + */ + 0x3f, 0x6a, 0x3a, 0x4d, 0xcd, 0xfa, 0x58, 0xc5, + 0xac, 0xce, 0xf9, 0xf5, 0x84, 0xc4, 0x11, 0x24 + }}; + unsigned int seq_num = 0; + + int err = suit_get_installed_manifest_info((suit_manifest_class_id_t *)&manifest_class_id, + &seq_num, NULL, NULL, NULL, NULL); + if (!err) { + LOG_INF("SUIT image version: %d", seq_num); + } else { + LOG_ERR("suit_read_manifest_data failed (err: %d)", err); + } +#endif k_work_init_delayable(&dfu_timeout, dfu_timeout_handler); mgmt_callback_register(&cmd_recv_cb);