diff --git a/boot/zephyr/CMakeLists.txt b/boot/zephyr/CMakeLists.txt index 2f47766e3..d5316a1c2 100644 --- a/boot/zephyr/CMakeLists.txt +++ b/boot/zephyr/CMakeLists.txt @@ -482,6 +482,12 @@ zephyr_library_sources( ) endif() +if(CONFIG_SOC_NRF54H20_PM_S2RAM_OVERRIDE) +zephyr_library_sources( + ${BOOT_DIR}/zephyr/nrf54h20_custom_s2ram.c +) +endif() + if(CONFIG_MCUBOOT_BOOT_BANNER) # Replace Zephyr's boot banner with the MCUboot one zephyr_sources(kernel/banner.c) diff --git a/boot/zephyr/nrf54h20_custom_s2ram.c b/boot/zephyr/nrf54h20_custom_s2ram.c new file mode 100644 index 000000000..0970a212b --- /dev/null +++ b/boot/zephyr/nrf54h20_custom_s2ram.c @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include "pm_s2ram.h" +#include "power.h" + +#include +#include + +int soc_s2ram_suspend(pm_s2ram_system_off_fn_t system_off) +{ + (void)(system_off); + return -1; +} + +void pm_s2ram_mark_set(void) +{ + /* empty */ +} + +struct arm_vector_table { + uint32_t msp; + uint32_t reset; +}; + +bool pm_s2ram_mark_check_and_clear(void) +{ + uint32_t reset_reason = nrf_resetinfo_resetreas_local_get(NRF_RESETINFO); + + if (reset_reason != NRF_RESETINFO_RESETREAS_LOCAL_UNRETAINED_MASK) { + // normal boot + return false; + } + + // s2ram boot + struct arm_vector_table *vt; + vt = (struct arm_vector_table *)(FIXED_PARTITION_OFFSET(slot0_partition) + 0x800); + + // Jump to application + __asm__ volatile ( + /* vt->reset -> r0 */ + " mov r0, %0\n" + /* vt->msp -> r1 */ + " mov r1, %1\n" + /* set stack pointer */ + " msr msp, r1\n" + /* jump to reset vector of an app */ + " bx r0\n" + : + : "r" (vt->reset), "r" (vt->msp) + : "r0", "r1", "memory" + ); + + while(1) + { + } + + return true; +}