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); 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 (