Skip to content

Commit 70b82fb

Browse files
committed
[nrf noup] boot/zephyr: nRF54h20 resume from S2RAM
Application need special support in the bootloader in order to resume for suspend to RAM. Signed-off-by: Andrzej Puzdrowski <[email protected]> Signed-off-by: Karol Lasończyk <[email protected]>
1 parent d69621e commit 70b82fb

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

boot/zephyr/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,12 @@ zephyr_library_sources(
482482
)
483483
endif()
484484

485+
if(CONFIG_SOC_NRF54H20_PM_S2RAM_OVERRIDE)
486+
zephyr_library_sources(
487+
${BOOT_DIR}/zephyr/nrf54h20_custom_s2ram.c
488+
)
489+
endif()
490+
485491
if(CONFIG_MCUBOOT_BOOT_BANNER)
486492
# Replace Zephyr's boot banner with the MCUboot one
487493
zephyr_sources(kernel/banner.c)

boot/zephyr/nrf54h20_custom_s2ram.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <stdbool.h>
7+
#include <zephyr/arch/common/pm_s2ram.h>
8+
#include <hal/nrf_resetinfo.h>
9+
#include "pm_s2ram.h"
10+
#include "power.h"
11+
12+
#include <zephyr/devicetree.h>
13+
#include <zephyr/storage/flash_map.h>
14+
15+
int soc_s2ram_suspend(pm_s2ram_system_off_fn_t system_off)
16+
{
17+
(void)(system_off);
18+
return -1;
19+
}
20+
21+
void pm_s2ram_mark_set(void)
22+
{
23+
/* empty */
24+
}
25+
26+
struct arm_vector_table {
27+
uint32_t msp;
28+
uint32_t reset;
29+
};
30+
31+
bool pm_s2ram_mark_check_and_clear(void)
32+
{
33+
uint32_t reset_reason = nrf_resetinfo_resetreas_local_get(NRF_RESETINFO);
34+
35+
if (reset_reason != NRF_RESETINFO_RESETREAS_LOCAL_UNRETAINED_MASK) {
36+
// normal boot
37+
return false;
38+
}
39+
40+
// s2ram boot
41+
struct arm_vector_table *vt;
42+
vt = (struct arm_vector_table *)(FIXED_PARTITION_OFFSET(slot0_partition) + 0x800);
43+
44+
// Jump to application
45+
__asm__ volatile (
46+
/* vt->reset -> r0 */
47+
" mov r0, %0\n"
48+
/* vt->msp -> r1 */
49+
" mov r1, %1\n"
50+
/* set stack pointer */
51+
" msr msp, r1\n"
52+
/* jump to reset vector of an app */
53+
" bx r0\n"
54+
:
55+
: "r" (vt->reset), "r" (vt->msp)
56+
: "r0", "r1", "memory"
57+
);
58+
59+
while(1)
60+
{
61+
}
62+
63+
return true;
64+
}

0 commit comments

Comments
 (0)