Skip to content
Merged
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
29 changes: 29 additions & 0 deletions modules/mcuboot/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,32 @@ config MCUBOOT_USE_ALL_AVAILABLE_RAM
By default MCUBoot uses only the secure RAM partition.

endmenu

config NRF_MCUBOOT_BOOT_REQUEST
bool "MCUboot bootloader requests"
help
Handle bootloader requests.

if NRF_MCUBOOT_BOOT_REQUEST

choice NRF_MCUBOOT_BOOT_REQUEST_IMPL
prompt "Shared memory backend"
default NRF_MCUBOOT_BOOT_REQUEST_IMPL_RETENTION if RETENTION

DT_CHOSEN_BOOTLOADER_REQUEST := nrf,bootloader-request

config NRF_MCUBOOT_BOOT_REQUEST_IMPL_RETENTION
bool "Retention"
depends on RETENTION
depends on $(dt_chosen_enabled,$(DT_CHOSEN_BOOTLOADER_REQUEST))
help
Use zephyr,bootloader-request chosen node compatible with the
zephyr,retention driver as the memory area to store and read from the
bootloader requests.
The built-in prefix property should be used to indicate the request
structure version to ensure compatibility between the bootloader and
the application.

endchoice

endif # NRF_MCUBOOT_BOOT_REQUEST
8 changes: 8 additions & 0 deletions modules/mcuboot/boot/zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,11 @@ config BOOT_SERIAL_IMG_GRP_HASH
config BOOT_SERIAL_IMG_GPR_SLOT_INFO
bool
default n

config FIND_NEXT_SLOT_HOOK_BOOT_REQ
bool "Enable default hook that uses bootloader requests module"
default y if NRF_MCUBOOT_BOOT_REQUEST
depends on FIND_NEXT_SLOT_HOOKS
help
This will read the image preference from the bootloader requests
module and if found, alter the Direct XIP slot selection.
8 changes: 8 additions & 0 deletions modules/mcuboot/hooks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ if(CONFIG_BOOT_IMAGE_ACCESS_HOOKS)
zephyr_library_link_libraries(MCUBOOT_BOOTUTIL)
endif()
endif()

if(CONFIG_FIND_NEXT_SLOT_HOOKS)
if(CONFIG_FIND_NEXT_SLOT_HOOK_BOOT_REQ)
zephyr_library()
zephyr_library_sources(hooks_find_next_slot.c)
zephyr_library_link_libraries(MCUBOOT_BOOTUTIL)
endif()
endif()
34 changes: 34 additions & 0 deletions modules/mcuboot/hooks/hooks_find_next_slot.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include <../../bootutil/src/bootutil_priv.h>
#ifdef CONFIG_NRF_MCUBOOT_BOOT_REQUEST
#include <bootutil/boot_request.h>
#endif /* CONFIG_NRF_MCUBOOT_BOOT_REQUEST */

/**
* Finds the preferred slot containing the image based on bootloader requests.
*/
int boot_find_next_slot_hook(struct boot_loader_state *state, uint8_t image, uint32_t *active_slot)
{
#ifdef CONFIG_NRF_MCUBOOT_BOOT_REQUEST
uint32_t slot = BOOT_REQUEST_NO_PREFERRED_SLOT;

if (active_slot == NULL) {
return BOOT_HOOK_REGULAR;
}

slot = boot_request_get_preferred_slot(image);
if (slot != BOOT_REQUEST_NO_PREFERRED_SLOT) {
if (state->slot_usage[image].slot_available[slot]) {
*active_slot = slot;
return 0;
}
}
#endif /* CONFIG_NRF_MCUBOOT_BOOT_REQUEST */

return BOOT_HOOK_REGULAR;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include "../sysbuild/nrf54h20dk_nrf54h20_memory_map_requests.dtsi"

/ {
chosen {
zephyr,boot-mode = &boot_request;
};
};
49 changes: 49 additions & 0 deletions samples/zephyr/subsys/mgmt/mcumgr/smp_svr/prj_requests.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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

# 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

# Enable boot requests through retained memory.
CONFIG_RETAINED_MEM=y
CONFIG_RETENTION=y
CONFIG_NRF_MCUBOOT_BOOT_REQUEST=y

CONFIG_RETENTION_BOOT_MODE=y
CONFIG_MCUMGR_GRP_OS_RESET_BOOT_MODE=y
14 changes: 14 additions & 0 deletions samples/zephyr/subsys/mgmt/mcumgr/smp_svr/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,17 @@ tests:
- nrf54h20dk/nrf54h20/cpuapp
integration_platforms:
- nrf54h20dk/nrf54h20/cpuapp
sample.mcumgr.smp_svr.bt.nrf54h20dk.direct_xip_withrequests:
sysbuild: true
extra_args:
- FILE_SUFFIX="requests"
- EXTRA_CONF_FILE="overlay-bt.conf"
- SB_CONFIG_NETCORE_IPC_RADIO=y
- SB_CONFIG_NETCORE_IPC_RADIO_BT_HCI_IPC=y
- SB_CONFIG_MCUBOOT_MODE_DIRECT_XIP_WITH_REVERT=y
- mcuboot_CONFIG_NRF_SECURITY=y
- mcuboot_CONFIG_MULTITHREADING=y
platform_allow:
- nrf54h20dk/nrf54h20/cpuapp
integration_platforms:
- nrf54h20dk/nrf54h20/cpuapp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Enable boot requests through retained memory.
CONFIG_RETAINED_MEM=y
CONFIG_RETENTION=y
CONFIG_NRF_MCUBOOT_BOOT_REQUEST=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include "nrf54h20dk_nrf54h20_memory_map_requests.dtsi"

/ {
chosen {
zephyr,code-partition = &boot_partition;
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/* On nRF54H20 the Direct XIP mode is supported in the merged slot configuration
* Merge application and radio slots by extending the application parition.
*/
&cpuapp_slot0_partition {
reg = <0x40000 DT_SIZE_K(656)>;
};

&cpuapp_slot1_partition {
reg = <0x100000 DT_SIZE_K(656)>;
};

/ {
chosen {
nrf,bootloader-request = &boot_request;
};
};

/ {
reserved-memory {
cpuapp_retained_mem: memory@e1ad000 {
compatible = "zephyr,memory-region";
reg = <0xe1ad000 DT_SIZE_K(4)>;
zephyr,memory-region = "RetainedMem";
status = "okay";

retainedmem {
compatible = "zephyr,retained-ram";
status = "okay";
#address-cells = <1>;
#size-cells = <1>;

boot_request: boot_request@0 {
compatible = "zephyr,retention";
status = "okay";
reg = <0x0 16>;
prefix = [0B 01];
checksum = <4>;
};
};
};
};
};
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ manifest:
compare-by-default: true
- name: mcuboot
repo-path: sdk-mcuboot
revision: 285fd59f4386a0317e476da5484f67b906073296
revision: e1f2ab3806ce7ebc7ef34b3fc04272e747590745
path: bootloader/mcuboot
- name: qcbor
url: https://github.com/laurencelundblade/QCBOR
Expand Down
Loading