Skip to content

WIP [nrf noup] boot/zephyr: nRF54h20 resume from S2RAM #489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions boot/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
64 changes: 64 additions & 0 deletions boot/zephyr/nrf54h20_custom_s2ram.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
* SPDX-License-Identifier: Apache-2.0
*/

#include <stdbool.h>
#include <zephyr/arch/common/pm_s2ram.h>
#include <hal/nrf_resetinfo.h>
#include "pm_s2ram.h"
#include "power.h"

#include <zephyr/devicetree.h>
#include <zephyr/storage/flash_map.h>

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;
}