From e8c343b2218d0d55dbcb6ddac5b315f6d0333527 Mon Sep 17 00:00:00 2001 From: Andrzej Puzdrowski Date: Tue, 30 Sep 2025 14:22:18 +0200 Subject: [PATCH 1/2] [nrf noup] boot/zephyr/nrf54h20_custom_s2ram: direct-xip support Added direct-xip support: * new API for marking active slot to be used by boot_go() routines. * jump vector assignment which is basing on above designation. Signed-off-by: Andrzej Puzdrowski --- boot/zephyr/nrf54h20_custom_s2ram.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/boot/zephyr/nrf54h20_custom_s2ram.c b/boot/zephyr/nrf54h20_custom_s2ram.c index 7b70e22fe..51146e7b3 100644 --- a/boot/zephyr/nrf54h20_custom_s2ram.c +++ b/boot/zephyr/nrf54h20_custom_s2ram.c @@ -30,6 +30,20 @@ volatile struct mcuboot_resume_s mcuboot_resume; COND_CODE_0(DT_FIXED_PARTITION_EXISTS(DT_NODELABEL(node_label)), (0), \ (DT_REG_ADDR(DT_GPARENT(DT_NODELABEL(node_label)))))) +#define S2RAM_SLOT_INFO_A 0x37 +#define S2RAM_SLOT_INFO_B 0xA4 + +#ifdef CONFIG_BOOT_DIRECT_XIP +/* Called by the image manager when setting the image as active for current boot. */ +void s2ram_designate_slot(uint8_t slot) +{ + if (slot == 0) { + mcuboot_resume.slot_info = S2RAM_SLOT_INFO_A; + } else { + mcuboot_resume.slot_info = S2RAM_SLOT_INFO_B; + } +} +#endif int soc_s2ram_suspend(pm_s2ram_system_off_fn_t system_off) { @@ -72,8 +86,22 @@ bool pm_s2ram_mark_check_and_clear(void) /* s2ram boot */ struct arm_vector_table *vt; + +#ifdef CONFIG_BOOT_DIRECT_XIP + if (mcuboot_resume.slot_info == S2RAM_SLOT_INFO_A) { + vt = (struct arm_vector_table *) + (FIXED_PARTITION_ADDR(slot0_partition) + APP_EXE_START_OFFSET); + } else if (mcuboot_resume.slot_info == S2RAM_SLOT_INFO_B) { + vt = (struct arm_vector_table *) + (FIXED_PARTITION_ADDR(slot1_partition) + APP_EXE_START_OFFSET); + } else { + /* invalid slot info */ + goto resume_failed; + } +#else vt = (struct arm_vector_table *) (FIXED_PARTITION_ADDR(slot0_partition) + APP_EXE_START_OFFSET); +#endif /* Jump to application */ __asm__ volatile ( From 5d5f1eca06873bd9b43cce263cfb682820f129d0 Mon Sep 17 00:00:00 2001 From: Andrzej Puzdrowski Date: Tue, 30 Sep 2025 14:25:29 +0200 Subject: [PATCH 2/2] [nrf noup] bootutil/loader: integrate nRF54h S2RAM with diect-xip Added call which designate active slot so MCUBoot can jump to proper slot when CPU is resuming from S2RAM. Signed-off-by: Andrzej Puzdrowski --- boot/bootutil/src/loader.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/boot/bootutil/src/loader.c b/boot/bootutil/src/loader.c index 6c05b3b2b..b7f407e0e 100644 --- a/boot/bootutil/src/loader.c +++ b/boot/bootutil/src/loader.c @@ -84,6 +84,10 @@ int pcd_version_cmp_net(const struct flash_area *fap, struct image_header *hdr); #include "bootutil/key_revocation.h" #endif +#ifdef CONFIG_SOC_NRF54H20_PM_S2RAM_OVERRIDE +void s2ram_designate_slot(uint8_t slot); +#endif + BOOT_LOG_MODULE_DECLARE(mcuboot); static struct boot_loader_state boot_data; @@ -3600,6 +3604,11 @@ context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp) } } +#ifdef CONFIG_SOC_NRF54H20_PM_S2RAM_OVERRIDE + /* Designate the slot to be used by the PM_S2RAM resume module */ + s2ram_designate_slot((uint8_t)state->slot_usage[0].active_slot); +#endif + /* All image loaded successfully. */ #ifdef MCUBOOT_HAVE_LOGGING print_loaded_images(state);