-
Notifications
You must be signed in to change notification settings - Fork 1.4k
samples: Add sample to verify bootloader requests #23452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tomchy
merged 1 commit into
nrfconnect:main
from
tomchy:feature/zephyr/NCSDK-NONE_boot_requests_nrf
Aug 29, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
13 changes: 13 additions & 0 deletions
13
samples/zephyr/subsys/mgmt/mcumgr/smp_svr/boards/nrf54h20dk_nrf54h20_cpuapp_requests.overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
49
samples/zephyr/subsys/mgmt/mcumgr/smp_svr/prj_requests.conf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
samples/zephyr/subsys/mgmt/mcumgr/smp_svr/sysbuild/mcuboot_requests.conf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
13 changes: 13 additions & 0 deletions
13
samples/zephyr/subsys/mgmt/mcumgr/smp_svr/sysbuild/mcuboot_requests.overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
}; |
48 changes: 48 additions & 0 deletions
48
...s/zephyr/subsys/mgmt/mcumgr/smp_svr/sysbuild/nrf54h20dk_nrf54h20_memory_map_requests.dtsi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.