Skip to content

Commit 85dc002

Browse files
committed
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]>
1 parent 6508b54 commit 85dc002

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

boot/zephyr/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,14 @@ config MCUBOOT_ACTION_HOOKS
10961096
'mcuboot_status_type_t' is listed in
10971097
boot/bootutil/include/bootutil/mcuboot_status.h
10981098

1099+
config FIND_NEXT_SLOT_HOOKS
1100+
bool "Enable hooks for finding the next active slot"
1101+
help
1102+
This will call a handler when the MCUboot searches for the best slot
1103+
for an image. By default, a slot with the highest version is selected.
1104+
This hook allows to override this logic and provide a custom slot
1105+
selection policy.
1106+
10991107
config BOOT_DISABLE_CACHES
11001108
bool "Disable I/D caches before chain-loading application"
11011109
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
@@ -278,6 +278,10 @@
278278
#define MCUBOOT_FLASH_AREA_HOOKS
279279
#endif
280280

281+
#ifdef CONFIG_FIND_NEXT_SLOT_HOOKS
282+
#define MCUBOOT_FIND_NEXT_SLOT_HOOKS
283+
#endif
284+
281285
#ifdef CONFIG_MCUBOOT_VERIFY_IMG_ADDRESS
282286
#define MCUBOOT_VERIFY_IMG_ADDRESS
283287
#endif

0 commit comments

Comments
 (0)