Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmake/sysbuild/image_signing_nrf54h20.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
11 changes: 11 additions & 0 deletions cmake/sysbuild/mcuboot_nrf54h20.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
22 changes: 22 additions & 0 deletions cmake/sysbuild/modules/ncs_sysbuild_extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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(<outvar>)
#
# This function returns a list of images, configured as firmware loader images.
#
# <outvar>: 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()
32 changes: 27 additions & 5 deletions cmake/sysbuild/sign_nrf54h20.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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}
Expand All @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions cmake/sysbuild/zip.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions samples/dfu/single_slot/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 16 additions & 0 deletions samples/dfu/single_slot/Kconfig.sysbuild
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include "../sysbuild/nrf54h20.overlay"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include "../sysbuild/nrf54l15.overlay"
1 change: 1 addition & 0 deletions samples/dfu/single_slot/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# nothing here
19 changes: 19 additions & 0 deletions samples/dfu/single_slot/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include <zephyr/kernel.h>

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;
}
31 changes: 31 additions & 0 deletions samples/dfu/single_slot/sysbuild.cmake
Original file line number Diff line number Diff line change
@@ -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()
12 changes: 12 additions & 0 deletions samples/dfu/single_slot/sysbuild.conf
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_POWER_DOMAIN=n
Original file line number Diff line number Diff line change
@@ -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";
};
Original file line number Diff line number Diff line change
@@ -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;
};
};
36 changes: 36 additions & 0 deletions samples/dfu/single_slot/sysbuild/mcuboot/prj.conf
Original file line number Diff line number Diff line change
@@ -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"
Loading
Loading