diff --git a/cmake/sysbuild/image_signing_nrf54h20.cmake b/cmake/sysbuild/image_signing_nrf54h20.cmake index 2a258ac7c3cf..5ecb88307dfb 100644 --- a/cmake/sysbuild/image_signing_nrf54h20.cmake +++ b/cmake/sysbuild/image_signing_nrf54h20.cmake @@ -9,7 +9,11 @@ if(CONFIG_BOOTLOADER_MCUBOOT) cmake_path(GET app_binary_dir PARENT_PATH app_build_dir) cmake_path(GET app_build_dir PARENT_PATH sysbuild_build_dir) cmake_path(APPEND sysbuild_build_dir "zephyr" OUTPUT_VARIABLE sysbuild_binary_dir) - cmake_path(APPEND sysbuild_binary_dir ${KERNEL_NAME} OUTPUT_VARIABLE output) + if (CONFIG_MCUBOOT_APPLICATION_FIRMWARE_UPDATER) + cmake_path(APPEND sysbuild_binary_dir "firmware_updater" OUTPUT_VARIABLE output) + else() + cmake_path(APPEND sysbuild_binary_dir ${KERNEL_NAME} OUTPUT_VARIABLE output) + endif() if(CONFIG_BUILD_OUTPUT_BIN) get_target_property(bin_file runners_yaml_props_target "bin_file") diff --git a/cmake/sysbuild/mcuboot_nrf54h20.cmake b/cmake/sysbuild/mcuboot_nrf54h20.cmake index 37b2641429c6..a36bb822fb33 100644 --- a/cmake/sysbuild/mcuboot_nrf54h20.cmake +++ b/cmake/sysbuild/mcuboot_nrf54h20.cmake @@ -26,4 +26,15 @@ if(SB_CONFIG_MCUBOOT_SIGN_MERGED_BINARY) disable_programming_nrf54h20("${variants}") mcuboot_sign_merged_nrf54h20(${MERGED_IMAGES_SECONDARY_HEX} "mcuboot_secondary_app") endif() + + set(MERGED_IMAGES_FIRMWARE_UPDATER_HEX "mcuboot_merged_firmware_updater.hex") + FirmwareUpdaterImage_Get(firmware_updater) + + if(firmware_updater) + check_merged_slot_boundaries("slot1_partition" "${firmware_updater}") + merge_images_nrf54h20(${MERGED_IMAGES_FIRMWARE_UPDATER_HEX} "${firmware_updater}") + list(REMOVE_ITEM firmware_updater "${SB_CONFIG_FIRMWARE_LOADER_IMAGE_NAME}") + disable_programming_nrf54h20("${firmware_updater}") + mcuboot_sign_merged_nrf54h20(${MERGED_IMAGES_FIRMWARE_UPDATER_HEX} "${SB_CONFIG_FIRMWARE_LOADER_IMAGE_NAME}") + endif() endif() diff --git a/cmake/sysbuild/modules/ncs_sysbuild_extensions.cmake b/cmake/sysbuild/modules/ncs_sysbuild_extensions.cmake index e70ac3c4fad8..4e37932c5ad6 100644 --- a/cmake/sysbuild/modules/ncs_sysbuild_extensions.cmake +++ b/cmake/sysbuild/modules/ncs_sysbuild_extensions.cmake @@ -126,3 +126,25 @@ function(ExternalNcsVariantProject_Add) # Configure variant image after application so that the configuration is present sysbuild_add_dependencies(CONFIGURE ${VBUILD_VARIANT} ${VBUILD_APPLICATION}) endfunction() + +# Usage: +# FirmwareUpdaterImage_Get() +# +# This function returns a list of images, configured as firmware loader images. +# +# : Name of variable to set. +function(FirmwareUpdaterImage_Get outvar) + set(fw_loader_images) + get_property(images GLOBAL PROPERTY sysbuild_images) + + foreach(image ${images}) + set(app_type) + get_property(app_type TARGET ${image} PROPERTY APP_TYPE) + + if("${app_type}" STREQUAL "FIRMWARE_LOADER") + list(APPEND fw_loader_images ${image}) + endif() + endforeach() + + set(${outvar} "${fw_loader_images}" PARENT_SCOPE) +endfunction() diff --git a/cmake/sysbuild/sign_nrf54h20.cmake b/cmake/sysbuild/sign_nrf54h20.cmake index 0e693a315edb..f765c7ed8b02 100644 --- a/cmake/sysbuild/sign_nrf54h20.cmake +++ b/cmake/sysbuild/sign_nrf54h20.cmake @@ -206,12 +206,18 @@ function(mcuboot_sign_merged_nrf54h20 merged_hex main_image) set(CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION) set(CONFIG_MCUBOOT_GENERATE_CONFIRMED_IMAGE) set(CONFIG_NCS_IS_VARIANT_IMAGE) + set(CONFIG_MCUBOOT_APPLICATION_FIRMWARE_UPDATER) + set(CONFIG_MCUBOOT_IMGTOOL_OVERWRITE_ONLY) sysbuild_get(CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION IMAGE ${main_image} VAR CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION KCONFIG) sysbuild_get(CONFIG_MCUBOOT_GENERATE_CONFIRMED_IMAGE IMAGE ${main_image} VAR CONFIG_MCUBOOT_GENERATE_CONFIRMED_IMAGE KCONFIG) sysbuild_get(CONFIG_NCS_IS_VARIANT_IMAGE IMAGE ${main_image} VAR CONFIG_NCS_IS_VARIANT_IMAGE CACHE) + sysbuild_get(CONFIG_MCUBOOT_APPLICATION_FIRMWARE_UPDATER IMAGE ${main_image} VAR + CONFIG_MCUBOOT_APPLICATION_FIRMWARE_UPDATER KCONFIG) + sysbuild_get(CONFIG_MCUBOOT_IMGTOOL_OVERWRITE_ONLY IMAGE ${main_image} VAR + CONFIG_MCUBOOT_IMGTOOL_OVERWRITE_ONLY KCONFIG) # Fetch devicetree details for flash and slot information. dt_chosen(flash_node TARGET mcuboot PROPERTY "zephyr,flash") @@ -255,11 +261,26 @@ function(mcuboot_sign_merged_nrf54h20 merged_hex main_image) # Adjust start offset, based on the active slot and code partition address. math(EXPR start_offset "${start_offset} + ${code_addr} - ${slot_addr}") set(imgtool_rom_command --rom-fixed ${slot_addr}) + elseif(SB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER) + if (CONFIG_MCUBOOT_APPLICATION_FIRMWARE_UPDATER) + set(slot_size ${slot1_size}) + set(slot_addr ${slot1_addr}) + else() + set(slot_size ${slot0_size}) + set(slot_addr ${slot0_addr}) + endif() + # Adjust start offset, based on the active slot and code partition address. + math(EXPR start_offset "${start_offset} + ${code_addr} - ${slot_addr}") + set(imgtool_rom_command --rom-fixed ${slot_addr}) else() - message(FATAL_ERROR "Only Direct XIP MCUboot modes are supported.") + message(FATAL_ERROR "Only Direct XIP and firmware updater MCUboot modes are supported.") return() endif() + if(CONFIG_MCUBOOT_IMGTOOL_OVERWRITE_ONLY) + set(imgtool_args --overwrite-only ${imgtool_args}) + endif() + # Basic 'imgtool sign' command with known image information. set(imgtool_sign ${PYTHON_EXECUTABLE} ${IMGTOOL} sign --version ${CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION} --header-size ${start_offset} --slot-size ${slot_size} @@ -272,11 +293,12 @@ function(mcuboot_sign_merged_nrf54h20 merged_hex main_image) CONFIG_KERNEL_BIN_NAME KCONFIG) cmake_path(GET BINARY_DIR PARENT_PATH sysbuild_build_dir) if(CONFIG_NCS_IS_VARIANT_IMAGE) - cmake_path(APPEND sysbuild_build_dir "zephyr" - "${BINARY_BIN_FILE}_secondary_app" OUTPUT_VARIABLE output) + cmake_path(APPEND sysbuild_build_dir "zephyr" "${BINARY_BIN_FILE}_secondary_app" OUTPUT_VARIABLE + output) + elseif (CONFIG_MCUBOOT_APPLICATION_FIRMWARE_UPDATER) + cmake_path(APPEND sysbuild_build_dir "zephyr" "firmware_updater" OUTPUT_VARIABLE output) else() - cmake_path(APPEND sysbuild_build_dir "zephyr" "${BINARY_BIN_FILE}" - OUTPUT_VARIABLE output) + cmake_path(APPEND sysbuild_build_dir "zephyr" "${BINARY_BIN_FILE}" OUTPUT_VARIABLE output) endif() # List of additional build byproducts. diff --git a/cmake/sysbuild/zip.cmake b/cmake/sysbuild/zip.cmake index 961ab7631b48..bfe13f15f08b 100644 --- a/cmake/sysbuild/zip.cmake +++ b/cmake/sysbuild/zip.cmake @@ -135,6 +135,8 @@ function(dfu_app_zip_package) if(SB_CONFIG_BOOT_ENCRYPTION) list(APPEND bin_files "${CMAKE_BINARY_DIR}/${DEFAULT_IMAGE}/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.encrypted.bin") set(exclude_files EXCLUDE ${CMAKE_BINARY_DIR}/${DEFAULT_IMAGE}/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.encrypted.bin) + elseif(SB_CONFIG_MCUBOOT_SIGN_MERGED_BINARY) + list(APPEND bin_files "${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin") else() list(APPEND bin_files "${CMAKE_BINARY_DIR}/${DEFAULT_IMAGE}/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin") set(exclude_files EXCLUDE ${CMAKE_BINARY_DIR}/${DEFAULT_IMAGE}/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin) diff --git a/samples/dfu/single_slot/CMakeLists.txt b/samples/dfu/single_slot/CMakeLists.txt new file mode 100644 index 000000000000..ff3bec84679c --- /dev/null +++ b/samples/dfu/single_slot/CMakeLists.txt @@ -0,0 +1,12 @@ +# +# Copyright (c) 2025 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(single_slot) + +target_sources(app PRIVATE src/main.c) diff --git a/samples/dfu/single_slot/Kconfig.sysbuild b/samples/dfu/single_slot/Kconfig.sysbuild new file mode 100644 index 000000000000..64765bb97f2c --- /dev/null +++ b/samples/dfu/single_slot/Kconfig.sysbuild @@ -0,0 +1,16 @@ +# +# Copyright (c) 2025 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +config MCUBOOT_SIGNATURE_USING_KMU + default y if SOC_SERIES_NRF54LX + +config MCUBOOT_GENERATE_DEFAULT_KMU_KEYFILE + default y if SOC_SERIES_NRF54LX + +config MCUBOOT_IMAGES_ROM_END_OFFSET_AUTO + default "single_slot;smp_svr_mini_boot_ipc_radio" if MCUBOOT_SIGN_MERGED_BINARY && SUPPORT_NETCORE + +source "share/sysbuild/Kconfig" diff --git a/samples/dfu/single_slot/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/samples/dfu/single_slot/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 000000000000..f186cade624a --- /dev/null +++ b/samples/dfu/single_slot/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include "../sysbuild/nrf54h20.overlay" diff --git a/samples/dfu/single_slot/boards/nrf54l15dk_nrf54l15_cpuapp.overlay b/samples/dfu/single_slot/boards/nrf54l15dk_nrf54l15_cpuapp.overlay new file mode 100644 index 000000000000..d0a6c09f4242 --- /dev/null +++ b/samples/dfu/single_slot/boards/nrf54l15dk_nrf54l15_cpuapp.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include "../sysbuild/nrf54l15.overlay" diff --git a/samples/dfu/single_slot/prj.conf b/samples/dfu/single_slot/prj.conf new file mode 100644 index 000000000000..b2a4ba591044 --- /dev/null +++ b/samples/dfu/single_slot/prj.conf @@ -0,0 +1 @@ +# nothing here diff --git a/samples/dfu/single_slot/src/main.c b/samples/dfu/single_slot/src/main.c new file mode 100644 index 000000000000..45b2f6897242 --- /dev/null +++ b/samples/dfu/single_slot/src/main.c @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include + +int main(void) +{ + printk("Hello World! %s\n", CONFIG_BOARD_TARGET); + + /* using __TIME__ ensure that a new binary will be built on every + * compile which is convenient when testing firmware upgrade. + */ + printk("build time: " __DATE__ " " __TIME__ "\n"); + + return 0; +} diff --git a/samples/dfu/single_slot/sysbuild.cmake b/samples/dfu/single_slot/sysbuild.cmake new file mode 100644 index 000000000000..f9d54f6f0c67 --- /dev/null +++ b/samples/dfu/single_slot/sysbuild.cmake @@ -0,0 +1,31 @@ +# +# Copyright (c) 2025 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + +# If a device support network core as a separate image, include it manually, +# so the sysbuild logic that counts the number of updatable binaries is not +# affected. +if(SB_CONFIG_SUPPORT_NETCORE) + # Calculate the network board target + string(REPLACE "/" ";" split_board_qualifiers "${BOARD_QUALIFIERS}") + list(GET split_board_qualifiers 1 target_soc) + list(GET split_board_qualifiers 2 target_cpucluster) + set(board_target_netcore "${BOARD}/${target_soc}/${SB_CONFIG_NETCORE_REMOTE_BOARD_TARGET_CPUCLUSTER}") + set(target_soc) + set(target_cpucluster) + set(netcore_image_path ${ZEPHYR_NRF_MODULE_DIR}/applications/ipc_radio) + set(radio_image_name ${SB_CONFIG_FIRMWARE_LOADER_IMAGE_NAME}_ipc_radio) + + ExternalZephyrProject_Add( + APPLICATION ${radio_image_name} + SOURCE_DIR ${netcore_image_path} + BOARD ${board_target_netcore} + BOARD_REVISION ${BOARD_REVISION} + APP_TYPE FIRMWARE_LOADER + ) + add_overlay_config( + ${radio_image_name} + ${netcore_image_path}/overlay-bt_hci_ipc.conf + ) +endif() diff --git a/samples/dfu/single_slot/sysbuild.conf b/samples/dfu/single_slot/sysbuild.conf new file mode 100644 index 000000000000..9e7e23a3dcbf --- /dev/null +++ b/samples/dfu/single_slot/sysbuild.conf @@ -0,0 +1,12 @@ +# +# Copyright (c) 2025 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +SB_CONFIG_BOOTLOADER_MCUBOOT=y +SB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER=y +SB_CONFIG_FIRMWARE_LOADER_IMAGE_SMP_SVR_MINI_BOOT=y + +# Disable partition manager +SB_CONFIG_PARTITION_MANAGER=n diff --git a/samples/dfu/single_slot/sysbuild/mcuboot/boards/nrf54h20dk_nrf54h20_cpuapp.conf b/samples/dfu/single_slot/sysbuild/mcuboot/boards/nrf54h20dk_nrf54h20_cpuapp.conf new file mode 100644 index 000000000000..e4634533fca5 --- /dev/null +++ b/samples/dfu/single_slot/sysbuild/mcuboot/boards/nrf54h20dk_nrf54h20_cpuapp.conf @@ -0,0 +1,7 @@ +# +# Copyright (c) 2025 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_POWER_DOMAIN=n diff --git a/samples/dfu/single_slot/sysbuild/mcuboot/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/samples/dfu/single_slot/sysbuild/mcuboot/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 000000000000..b5c60e826829 --- /dev/null +++ b/samples/dfu/single_slot/sysbuild/mcuboot/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include "../../nrf54h20.overlay" + +/ { + chosen { + zephyr,code-partition = &boot_partition; + }; + + aliases { + mcuboot-button0 = &button0; + }; +}; + +&gdpwr { + status = "disabled"; +}; + +&gdpwr_fast_active_0 { + status = "disabled"; +}; + +&gdpwr_fast_active_1 { + status = "disabled"; +}; + +&gdpwr_fast_main { + status = "disabled"; +}; + +&gdpwr_slow_active { + status = "disabled"; +}; + +&gdpwr_slow_main { + status = "disabled"; +}; + +&gpio_pad_group0 { + status = "disabled"; +}; + +&gpio_pad_group1 { + status = "disabled"; +}; + +&gpio_pad_group2 { + status = "disabled"; +}; + +&gpio_pad_group6 { + status = "disabled"; +}; + +&gpio_pad_group7 { + status = "disabled"; +}; + +&gpio_pad_group9 { + status = "disabled"; +}; diff --git a/samples/dfu/single_slot/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp.overlay b/samples/dfu/single_slot/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp.overlay new file mode 100644 index 000000000000..026564b2bacc --- /dev/null +++ b/samples/dfu/single_slot/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp.overlay @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include "../../nrf54l15.overlay" + +/ { + chosen { + zephyr,code-partition = &boot_partition; + }; + + aliases { + mcuboot-button0 = &button0; + }; +}; diff --git a/samples/dfu/single_slot/sysbuild/mcuboot/prj.conf b/samples/dfu/single_slot/sysbuild/mcuboot/prj.conf new file mode 100644 index 000000000000..3eb20d56cbee --- /dev/null +++ b/samples/dfu/single_slot/sysbuild/mcuboot/prj.conf @@ -0,0 +1,36 @@ +# +# Copyright (c) 2025 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_BOOT_FIRMWARE_LOADER_ENTRANCE_GPIO=y +CONFIG_BOOT_FIRMWARE_LOADER_NO_APPLICATION=y + +CONFIG_PM=n + +CONFIG_MAIN_STACK_SIZE=10240 + +CONFIG_BOOT_SWAP_SAVE_ENCTLV=n +CONFIG_BOOT_ENCRYPT_IMAGE=n + +CONFIG_BOOT_UPGRADE_ONLY=n +CONFIG_BOOT_BOOTSTRAP=n + +CONFIG_FLASH=y + +CONFIG_LOG=y +CONFIG_LOG_MODE_MINIMAL=y # former CONFIG_MODE_MINIMAL +### Ensure Zephyr logging changes don't use more resources +CONFIG_LOG_DEFAULT_LEVEL=0 +### Use info log level by default +CONFIG_MCUBOOT_LOG_LEVEL_INF=y +### Decrease footprint by ~4 KB in comparison to CBPRINTF_COMPLETE=y +CONFIG_CBPRINTF_NANO=y +### Use picolibc to reduce flash usage +CONFIG_PICOLIBC=y +### Disable malloc arena because we don't need it +CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=0 + +# NCS boot banner +CONFIG_NCS_APPLICATION_BOOT_BANNER_STRING="MCUboot" diff --git a/samples/dfu/single_slot/sysbuild/nrf54h20.overlay b/samples/dfu/single_slot/sysbuild/nrf54h20.overlay new file mode 100644 index 000000000000..c3c0d6167fc8 --- /dev/null +++ b/samples/dfu/single_slot/sysbuild/nrf54h20.overlay @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/* On nRF54H20 the FW loader mode is supported in the merged slot configuration + * Extend slot0_partition and slot1_partition to cover both application and + * radio images, as well as MCUboot image metadata (header and trailer). + * Those partitions will be used by MCUboot to verify the merged image to boot. + * Apart from that, they will be used by the MCUmgr subsystem to correctly + * handle flags, stored inside the MCUboot image trailer. + * Use cpu_slot<0|1>_partition as zephyr,code-partition, so the + * application and radio sizes are correctly reported. + */ +/delete-node/&cpuapp_slot0_partition; +/delete-node/&cpuapp_slot1_partition; +/delete-node/&cpurad_slot0_partition; +/delete-node/&cpurad_slot1_partition; + +/delete-node/ &cpuppr_code_partition; +/delete-node/ &cpuflpr_code_partition; + +/* Remove the undefined property value from the disabled VPR cores to prevent build errors. */ +&cpuflpr_vpr { + /delete-property/ source-memory; +}; + +&cpuppr_vpr { + /delete-property/ source-memory; +}; + +&mram1x { + partitions { + boot_partition: partition@30000 { + label = "mcuboot"; + reg = <0x30000 DT_SIZE_K(36)>; + }; + + /* Main application with the MCUboot header. */ + slot0_partition: partition@39000 { + reg = <0x39000 DT_SIZE_K(1284)>; + }; + + /* Main application without the MCUboot metadata. + * Offset by the MCUboot header size (2048 bytes). + */ + cpuapp_slot0_partition: partition@39800 { + reg = <0x39800 DT_SIZE_K(1282)>; + }; + + /* Merged partition used by the FW loader. */ + slot1_partition: partition@17a000 { + reg = <0x17a000 DT_SIZE_K(268)>; + }; + + /* Application code partition (part of the FW loader). + * Offset by the MCUboot header size (2048 bytes). + */ + fw_loader_partition: partition@17a800 { + reg = <0x17a800 DT_SIZE_K(166)>; + }; + + /* Radio code partition (part of the FW loader). */ + cpurad_slot0_partition: partition@18b000 { + reg = <0x18b000 DT_SIZE_K(100)>; + }; + }; +}; diff --git a/samples/dfu/single_slot/sysbuild/nrf54l15.overlay b/samples/dfu/single_slot/sysbuild/nrf54l15.overlay new file mode 100644 index 000000000000..e18d44be97e2 --- /dev/null +++ b/samples/dfu/single_slot/sysbuild/nrf54l15.overlay @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/delete-node/ &boot_partition; +/delete-node/ &slot0_partition; +/delete-node/ &slot1_partition; + +&cpuapp_rram { + partitions { + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x0 DT_SIZE_K(48)>; + }; + + slot0_partition: partition@c000 { + reg = <0xc000 DT_SIZE_K(1220)>; + }; + + slot1_partition: firmware_loader: partition@13d000 { + reg = <0x13d000 DT_SIZE_K(124)>; + }; + }; +}; diff --git a/samples/dfu/single_slot/sysbuild/smp_svr_mini_boot/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/samples/dfu/single_slot/sysbuild/smp_svr_mini_boot/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 000000000000..cd537d53cb44 --- /dev/null +++ b/samples/dfu/single_slot/sysbuild/smp_svr_mini_boot/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include "../../nrf54h20.overlay" + +/* The zephyr,code-partition is always set to fw_loader_partition in firmware + * loader image(s). + */ +/delete-node/ &slot1_partition; +slot1_partition: &fw_loader_partition {}; diff --git a/samples/dfu/single_slot/sysbuild/smp_svr_mini_boot/boards/nrf54l15dk_nrf54l15_cpuapp.overlay b/samples/dfu/single_slot/sysbuild/smp_svr_mini_boot/boards/nrf54l15dk_nrf54l15_cpuapp.overlay new file mode 100644 index 000000000000..6dd11b132bef --- /dev/null +++ b/samples/dfu/single_slot/sysbuild/smp_svr_mini_boot/boards/nrf54l15dk_nrf54l15_cpuapp.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include "../../nrf54l15.overlay" diff --git a/samples/dfu/single_slot/sysbuild/smp_svr_mini_boot/prj.conf b/samples/dfu/single_slot/sysbuild/smp_svr_mini_boot/prj.conf new file mode 100644 index 000000000000..495a9c1db284 --- /dev/null +++ b/samples/dfu/single_slot/sysbuild/smp_svr_mini_boot/prj.conf @@ -0,0 +1,103 @@ +# +# Copyright (c) 2025 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Enable MCUmgr and dependencies. +CONFIG_NET_BUF=y +CONFIG_ZCBOR=y +CONFIG_MCUMGR=y + +# Ensure an MCUboot-compatible binary is generated. +CONFIG_BOOTLOADER_MCUBOOT=y + +# Enable flash operations. +CONFIG_FLASH=y +CONFIG_STREAM_FLASH=y +CONFIG_FLASH_MAP=y + +# Enable most core commands. +CONFIG_IMG_MANAGER=y +CONFIG_MCUMGR_GRP_IMG=y +CONFIG_MCUMGR_GRP_OS=y +CONFIG_MCUMGR_GRP_OS_BOOTLOADER_INFO=y +CONFIG_MCUMGR_GRP_OS_ECHO=n +CONFIG_MCUMGR_GRP_OS_INFO=n + +# Enable the bluetooth MCUmgr transport. +CONFIG_BT=y +CONFIG_BT_PERIPHERAL=y + +# 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 + +# Enable the Bluetooth mcumgr transport (unauthenticated). +CONFIG_MCUMGR_TRANSPORT_BT=y +CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL=y + +# Enable the serial MCUmgr transport. +CONFIG_BASE64=y +CONFIG_CRC=y +CONFIG_MCUMGR_TRANSPORT_UART=y +CONFIG_CONSOLE=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 +CONFIG_BT_DEVICE_NAME="FW loader" + +# Enable the storage erase command. +CONFIG_MCUMGR_GRP_ZBASIC=y +CONFIG_MCUMGR_GRP_ZBASIC_STORAGE_ERASE=y + +######## + +# Disable unneeded drivers, peripherals and features to optimize for size +CONFIG_SIZE_OPTIMIZATIONS=y + +# Enable LTO +CONFIG_LTO=y +CONFIG_ISR_TABLES_LOCAL_DECLARATION=y + +CONFIG_I2C=n +CONFIG_WATCHDOG=n +CONFIG_SPI=n +CONFIG_GPIO=n + +CONFIG_FPU=n + +CONFIG_BOOT_BANNER=n +CONFIG_NCS_BOOT_BANNER=n +CONFIG_BOOT_DELAY=0 +CONFIG_PRINTK=n + +CONFIG_ARM_MPU=n + +CONFIG_TIMESLICING=n +CONFIG_COMMON_LIBC_MALLOC=y +CONFIG_LOG=n +CONFIG_ASSERT=n + +CONFIG_BT_HCI_VS=n + +CONFIG_BT_DEBUG_NONE=y +CONFIG_BT_ASSERT=n +CONFIG_BT_DATA_LEN_UPDATE=n +CONFIG_BT_PHY_UPDATE=n +CONFIG_BT_GATT_CACHING=n + +CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION=n +CONFIG_BT_GATT_READ_MULTIPLE=n +CONFIG_BT_GATT_READ_MULT_VAR_LEN=n +CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n + +CONFIG_BT_CTLR_PRIVACY=n +CONFIG_BT_CTLR_PHY_2M=n +CONFIG_BT_CTLR_LE_PING=n diff --git a/samples/dfu/single_slot/sysbuild/smp_svr_mini_boot_ipc_radio.conf b/samples/dfu/single_slot/sysbuild/smp_svr_mini_boot_ipc_radio.conf new file mode 100644 index 000000000000..b397d1c46219 --- /dev/null +++ b/samples/dfu/single_slot/sysbuild/smp_svr_mini_boot_ipc_radio.conf @@ -0,0 +1,57 @@ +# +# Copyright (c) 2025 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_BT_BUF_ACL_RX_SIZE=502 +CONFIG_BT_BUF_ACL_TX_SIZE=502 + +# Kconfigs for optimization +CONFIG_LOG=n +CONFIG_LOG_PRINTK=n +CONFIG_UART_CONSOLE=n +CONFIG_SOC_FLASH_NRF_RADIO_SYNC_RPC_CONTROLLER=n + +CONFIG_BT_CENTRAL=n +CONFIG_BT_OBSERVER=n +CONFIG_BT_REMOTE_VERSION=n +CONFIG_BT_PHY_UPDATE=n +CONFIG_BT_DATA_LEN_UPDATE=n + +CONFIG_BT_ASSERT=n +CONFIG_BT_ASSERT_VERBOSE=n +CONFIG_ASSERT_VERBOSE=n +CONFIG_ASSERT=n + +CONFIG_BOOT_BANNER=n +CONFIG_EARLY_CONSOLE=n +CONFIG_PRINTK=n + +CONFIG_SIZE_OPTIMIZATIONS=y + +# Enable LTO +CONFIG_LTO=y +CONFIG_ISR_TABLES_LOCAL_DECLARATION=y + +CONFIG_BT_CTLR_CRYPTO=n +CONFIG_ENTROPY_GENERATOR=y + +CONFIG_BT_CTLR_LE_ENC=n +CONFIG_BT_CTLR_EXT_REJ_IND=n +CONFIG_BT_CTLR_CONN_RSSI=n +CONFIG_BT_CTLR_FILTER_ACCEPT_LIST=n +CONFIG_BT_CTLR_PRIVACY=n +CONFIG_BT_CTLR_AD_DATA_BACKUP=n +CONFIG_BT_HCI_VS=n + +CONFIG_ARM_MPU=n +CONFIG_MPU=n +CONFIG_BUILTIN_STACK_GUARD=n + +CONFIG_TIMESLICING=n +CONFIG_BT_HCI_ACL_FLOW_CONTROL=n +CONFIG_NCS_BOOT_BANNER=n + +CONFIG_PM=n +CONFIG_POWER_DOMAIN=n diff --git a/samples/dfu/single_slot/sysbuild/smp_svr_mini_boot_ipc_radio.overlay b/samples/dfu/single_slot/sysbuild/smp_svr_mini_boot_ipc_radio.overlay new file mode 100644 index 000000000000..db622ef0f317 --- /dev/null +++ b/samples/dfu/single_slot/sysbuild/smp_svr_mini_boot_ipc_radio.overlay @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include "nrf54h20.overlay" + +/* The zephyr,code-partition is always set to fw_loader_partition in firmware + * loader image(s). + */ +/delete-node/ &slot1_partition; +slot1_partition: &cpurad_slot0_partition {}; + +&gdpwr { + status = "disabled"; +}; + +&gdpwr_fast_active_0 { + status = "disabled"; +}; + +&gdpwr_fast_active_1 { + status = "disabled"; +}; + +&gdpwr_fast_main { + status = "disabled"; +}; + +&gdpwr_slow_active { + status = "disabled"; +}; + +&gdpwr_slow_main { + status = "disabled"; +}; + +&gpio_pad_group0 { + status = "disabled"; +}; + +&gpio_pad_group1 { + status = "disabled"; +}; + +&gpio_pad_group2 { + status = "disabled"; +}; + +&gpio_pad_group6 { + status = "disabled"; +}; + +&gpio_pad_group7 { + status = "disabled"; +}; + +&gpio_pad_group9 { + status = "disabled"; +}; diff --git a/sysbuild/CMakeLists.txt b/sysbuild/CMakeLists.txt index f7c0d34a32c8..7a7c9de1e920 100644 --- a/sysbuild/CMakeLists.txt +++ b/sysbuild/CMakeLists.txt @@ -252,16 +252,39 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_pre_cmake) endif() endforeach() - if(SB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER AND SB_CONFIG_BOOT_SIGNATURE_TYPE_ED25519) - set_config_bool(${SB_CONFIG_FIRMWARE_LOADER_IMAGE_NAME} CONFIG_MCUBOOT_BOOTLOADER_SIGNATURE_TYPE_ED25519 y) + if(SB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER) + FirmwareUpdaterImage_Get(fw_loader_images) + foreach(image ${fw_loader_images}) + if(SB_CONFIG_BOOT_SIGNATURE_TYPE_ED25519) + set_config_bool(${image} CONFIG_MCUBOOT_BOOTLOADER_SIGNATURE_TYPE_ED25519 y) + + if(SB_CONFIG_BOOT_SIGNATURE_TYPE_PURE) + set_config_bool(${image} CONFIG_MCUBOOT_BOOTLOADER_SIGNATURE_TYPE_PURE y) + endif() - if(SB_CONFIG_BOOT_SIGNATURE_TYPE_PURE) - set_config_bool(${SB_CONFIG_FIRMWARE_LOADER_IMAGE_NAME} CONFIG_MCUBOOT_BOOTLOADER_SIGNATURE_TYPE_PURE y) - endif() + if(SB_CONFIG_BOOT_IMG_HASH_ALG_SHA512) + set_config_bool(${image} CONFIG_MCUBOOT_BOOTLOADER_USES_SHA512 y) + endif() + endif() - if(SB_CONFIG_BOOT_IMG_HASH_ALG_SHA512) - set_config_bool(${SB_CONFIG_FIRMWARE_LOADER_IMAGE_NAME} CONFIG_MCUBOOT_BOOTLOADER_USES_SHA512 y) - endif() + if(SB_CONFIG_MCUBOOT_SIGN_MERGED_BINARY AND SB_CONFIG_SOC_NRF54H20) + set(${image}_SIGNING_SCRIPT + "${ZEPHYR_NRF_MODULE_DIR}/cmake/sysbuild/image_signing_nrf54h20.cmake" CACHE INTERNAL + "MCUboot signing script" FORCE) + else() + set(${image}_SIGNING_SCRIPT + "${ZEPHYR_NRF_MODULE_DIR}/cmake/sysbuild/image_signing_firmware_loader.cmake" CACHE + INTERNAL "MCUboot signing script" FORCE) + endif() + set_target_properties(${image} PROPERTIES IMAGE_CONF_SCRIPT + ${ZEPHYR_NRF_MODULE_DIR}/sysbuild/image_configurations/firmware_loader_image_default.cmake + ) + + if(NOT ${image} STREQUAL ${SB_CONFIG_FIRMWARE_LOADER_IMAGE_NAME}) + add_dependencies(${SB_CONFIG_FIRMWARE_LOADER_IMAGE_NAME} ${image}) + sysbuild_add_dependencies(FLASH ${SB_CONFIG_FIRMWARE_LOADER_IMAGE_NAME} ${image}) + endif() + endforeach() endif() # The NRF54LX goes with PSA crypto by default @@ -373,14 +396,6 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_pre_cmake) set(${image}_SIGNING_SCRIPT "${ZEPHYR_NRF_MODULE_DIR}/cmake/sysbuild/image_signing.cmake" CACHE INTERNAL "MCUboot signing script" FORCE) set_config_bool(${image} CONFIG_MCUMGR_GRP_IMG_QSPI_XIP_SPLIT_IMAGE n) endforeach() - - if(SB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER) - set(${SB_CONFIG_FIRMWARE_LOADER_IMAGE_NAME}_SIGNING_SCRIPT "${ZEPHYR_NRF_MODULE_DIR}/cmake/sysbuild/image_signing_firmware_loader.cmake" CACHE INTERNAL "MCUboot signing script" FORCE) - - set_target_properties(${SB_CONFIG_FIRMWARE_LOADER_IMAGE_NAME} PROPERTIES - IMAGE_CONF_SCRIPT ${ZEPHYR_NRF_MODULE_DIR}/sysbuild/image_configurations/firmware_loader_image_default.cmake - ) - endif() endif() if(SB_CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK) diff --git a/sysbuild/Kconfig.mcuboot b/sysbuild/Kconfig.mcuboot index f13ccef4a9b5..ff2e543dcf9e 100644 --- a/sysbuild/Kconfig.mcuboot +++ b/sysbuild/Kconfig.mcuboot @@ -8,6 +8,7 @@ menu "MCUboot configuration" config MCUBOOT_SIGN_MERGED_BINARY bool "Sign single, merged update package [EXPERIMENTAL]" default y if (MCUBOOT_MODE_DIRECT_XIP || MCUBOOT_MODE_DIRECT_XIP_WITH_REVERT) + default y if MCUBOOT_MODE_FIRMWARE_UPDATER depends on SOC_NRF54H20 select EXPERIMENTAL diff --git a/sysbuild/image_configurations/firmware_loader_image_default.cmake b/sysbuild/image_configurations/firmware_loader_image_default.cmake index 0cc5ebadffe2..2172b9582188 100644 --- a/sysbuild/image_configurations/firmware_loader_image_default.cmake +++ b/sysbuild/image_configurations/firmware_loader_image_default.cmake @@ -7,6 +7,7 @@ if(SB_CONFIG_BOOTLOADER_MCUBOOT) set_config_bool(${image} CONFIG_BOOTLOADER_MCUBOOT y) set_config_bool(${image} CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER y) + set_config_bool(${image} CONFIG_MCUBOOT_APPLICATION_FIRMWARE_UPDATER y) set_config_string(${image} CONFIG_MCUBOOT_SIGNATURE_KEY_FILE "${SB_CONFIG_BOOT_SIGNATURE_KEY_FILE}") set_config_string(${image} CONFIG_MCUBOOT_ENCRYPTION_KEY_FILE "${SB_CONFIG_BOOT_ENCRYPTION_KEY_FILE}")