Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion boot/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@ if(CONFIG_MCUBOOT_CLEANUP_ARM_CORE)
)
endif()

if(CONFIG_SOC_NRF54H20_PM_S2RAM_OVERRIDE)
if(CONFIG_SOC_EARLY_RESET_HOOK)
zephyr_library_sources(${BOOT_DIR}/zephyr/nrf54h20_custom_s2ram.S)
zephyr_library_sources(${BOOT_DIR}/zephyr/nrf54h20_custom_s2ram.c)
endif()

Expand Down
43 changes: 43 additions & 0 deletions boot/zephyr/nrf54h20_custom_s2ram.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2025, Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @file
* @brief ARM Cortex-M suspend-to-RAM resume intermediary code (S2RAM)
*/



/*
* resume or
* reboot reboot==T
*[S2RAM sleep]---------->[ boot (reset.S) ]---->[soc_early_reset_hook]---------->[regular boot]
* |
* | resume==T
* \/
* [jump to well-known]
* [ App reset vector ]
*/



#include <zephyr/toolchain.h>
#include <zephyr/arch/cpu.h>

GTEXT(pm_s2ram_mark_check_and_mediate)

GTEXT(soc_early_reset_hook)
SECTION_FUNC(TEXT, soc_early_reset_hook)
#if DT_NODE_EXISTS(DT_NODELABEL(pm_s2ram_stack)) &&\
DT_NODE_HAS_COMPAT(DT_NODELABEL(pm_s2ram_stack), zephyr_memory_region)
ldr r0, =DT_REG_ADDR(DT_NODELABEL(pm_s2ram_stack)) + DT_REG_SIZE(DT_NODELABEL(pm_s2ram_stack))
#else
#error "The support of bridge for S2RAM resume requires dedicated small stack"
#endif
msr msp, r0
push {r0, lr}
bl pm_s2ram_mark_check_and_mediate
pop {r0, pc}
17 changes: 2 additions & 15 deletions boot/zephyr/nrf54h20_custom_s2ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,6 @@ void s2ram_designate_slot(uint8_t slot)
}
#endif

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;
Expand All @@ -66,13 +55,13 @@ struct arm_vector_table {
*/
#define APP_EXE_START_OFFSET 0x800 /* nRF54H20 */

bool pm_s2ram_mark_check_and_clear(void)
void pm_s2ram_mark_check_and_mediate(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;
return;
}

/* S2RAM resume expected, do doublecheck */
Expand Down Expand Up @@ -120,6 +109,4 @@ bool pm_s2ram_mark_check_and_clear(void)

resume_failed:
FIH_PANIC;

return true;
}
6 changes: 1 addition & 5 deletions boot/zephyr/socs/nrf54h20_cpuapp.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@
# after suspend to RAM (S2RAM) requested by the application.
# MCUboot does not support S2RAM itself, but serves as an immediate actor while waking up
# from suspension.
CONFIG_PM=y
CONFIG_PM_DEVICE=n
CONFIG_PM_S2RAM=y
CONFIG_PM_S2RAM_CUSTOM_MARKING=y
CONFIG_SOC_NRF54H20_PM_S2RAM_OVERRIDE=y
CONFIG_SOC_EARLY_RESET_HOOK=y