Skip to content

Commit 1fae83e

Browse files
tomchyahasztag
authored andcommitted
[nrf fromtree] zephyr: Add support for slot selection boot hook
Add a Kconfig option to enable a bootloader hook to alter the logic of the active slot selection in Direct XIP modes. Signed-off-by: Tomasz Chyrowicz <[email protected]> (cherry picked from commit d5f84b4)
1 parent a26d01e commit 1fae83e

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

boot/zephyr/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,13 @@ config MCUBOOT_ACTION_HOOKS
11301130
'mcuboot_status_type_t' is listed in
11311131
boot/bootutil/include/bootutil/mcuboot_status.h
11321132

1133+
config FIND_NEXT_SLOT_HOOKS
1134+
bool "Enable hooks for finding the next active slot"
1135+
help
1136+
Allow to provide procedures for override or extend the search policy
1137+
for the best slot to boot in the Direct XIP mode.
1138+
By default a slot with the highest version is selected.
1139+
11331140
config BOOT_DISABLE_CACHES
11341141
bool "Disable I/D caches before chain-loading application"
11351142
depends on CPU_HAS_ICACHE || CPU_HAS_DCACHE

boot/zephyr/hooks_sample.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,8 @@ int boot_img_install_stat_hook(int image_index, int slot, int *img_install_stat)
9393
{
9494
return BOOT_HOOK_REGULAR;
9595
}
96+
97+
int boot_find_next_slot_hook(struct boot_loader_state *state, uint8_t image, uint32_t *active_slot)
98+
{
99+
return BOOT_HOOK_REGULAR;
100+
}

boot/zephyr/include/mcuboot_config/mcuboot_config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@
271271
#define MCUBOOT_FLASH_AREA_HOOKS
272272
#endif
273273

274+
#ifdef CONFIG_FIND_NEXT_SLOT_HOOKS
275+
#define MCUBOOT_FIND_NEXT_SLOT_HOOKS
276+
#endif
277+
274278
#ifdef CONFIG_MCUBOOT_VERIFY_IMG_ADDRESS
275279
#define MCUBOOT_VERIFY_IMG_ADDRESS
276280
#endif

0 commit comments

Comments
 (0)