Skip to content

Commit ef22c59

Browse files
nordic-krchlstnl
authored andcommitted
samples: boards: nrf: system_off: Add nrf54h20dk support
Add support to nrf54h20dk/nrf54h20/cpuapp and cpurad in the sample. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent d7dfdf0 commit ef22c59

File tree

7 files changed

+83
-1
lines changed

7 files changed

+83
-1
lines changed

samples/boards/nordic/system_off/README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ RAM is configured to keep the containing section powered while in system-off mod
2525
Requirements
2626
************
2727

28-
This application uses nRF51 DK, nRF52 DK or nRF54L15 DK board for the demo.
28+
This application uses nRF51 DK, nRF52 DK, nRF54H20 DK or nRF54L15 DK board for the demo.
2929

3030
Sample Output
3131
=============
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
project(nrf_system_off_remote)
7+
8+
target_sources(app PRIVATE src/main.c)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_PM_DEVICE=y
2+
CONFIG_POWEROFF=y
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/device.h>
9+
#include <zephyr/pm/device.h>
10+
#include <zephyr/sys/poweroff.h>
11+
#include <hal/nrf_memconf.h>
12+
13+
int main(void)
14+
{
15+
int rc;
16+
const struct device *const cons = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
17+
18+
printf("%s system off demo. Ready for system off.\n", CONFIG_BOARD);
19+
20+
rc = pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND);
21+
if (rc < 0) {
22+
printf("Could not suspend console (%d)\n", rc);
23+
return 0;
24+
}
25+
26+
/* Turn off retention of the local radio domain RAM. */
27+
nrf_memconf_ramblock_ret_mask_enable_set(NRF_MEMCONF, 0, RAMBLOCK_RET_MASK, false);
28+
nrf_memconf_ramblock_ret_mask_enable_set(NRF_MEMCONF, 1, RAMBLOCK_RET_MASK, false);
29+
30+
sys_poweroff();
31+
32+
return 0;
33+
}

samples/boards/nordic/system_off/src/main.c

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#include <zephyr/sys/poweroff.h>
1717
#include <zephyr/sys/util.h>
1818
#include <hal/nrf_gpio.h>
19+
#if CONFIG_SOC_NRF54H20_CPUAPP
20+
#include <hal/nrf_memconf.h>
21+
#endif
1922

2023
#if IS_ENABLED(CONFIG_GRTC_WAKEUP_ENABLE)
2124
#include <zephyr/drivers/timer/nrf_grtc_timer.h>
@@ -114,6 +117,11 @@ int main(void)
114117
}
115118

116119
if (do_poweroff) {
120+
#if CONFIG_SOC_NRF54H20_CPUAPP
121+
/* Local RAM0 (TCM) is currently not used so retention can be disabled. */
122+
nrf_memconf_ramblock_ret_mask_enable_set(NRF_MEMCONF, 0, RAMBLOCK_RET_MASK, false);
123+
nrf_memconf_ramblock_ret_mask_enable_set(NRF_MEMCONF, 1, RAMBLOCK_RET_MASK, false);
124+
#endif
117125
sys_poweroff();
118126
} else {
119127
k_sleep(K_FOREVER);

samples/boards/nordic/system_off/src/retained.c

+9
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,21 @@
1616
#include <zephyr/sys/crc.h>
1717

1818
#if DT_NODE_HAS_STATUS_OKAY(DT_ALIAS(retainedmemdevice))
19+
#if CONFIG_SOC_NRF54H20_CPUAPP
20+
#include <hal/nrf_memconf.h>
21+
#else
22+
#endif
1923
const static struct device *retained_mem_device = DEVICE_DT_GET(DT_ALIAS(retainedmemdevice));
24+
#if CONFIG_SOC_NRF54H20_CPUAPP
25+
/* Core is using global RAM memory which will be retained. Nothing to be done here. */
26+
return 0;
27+
#else
2028
#else
2129
#error "retained_mem region not defined"
2230
#endif
2331

2432
struct retained_data retained;
33+
#endif
2534

2635
#define RETAINED_CRC_OFFSET offsetof(struct retained_data, crc)
2736
#define RETAINED_CHECKED_SIZE (RETAINED_CRC_OFFSET + sizeof(retained.crc))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (c) 2024 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if("${SB_CONFIG_REMOTE_CORE_BOARD}" STREQUAL "")
5+
message(FATAL_ERROR
6+
"Target ${BOARD} not supported for this sample. "
7+
"There is no remote board selected in Kconfig.sysbuild")
8+
endif()
9+
10+
set(REMOTE_APP remote)
11+
12+
ExternalZephyrProject_Add(
13+
APPLICATION ${REMOTE_APP}
14+
SOURCE_DIR ${APP_DIR}/${REMOTE_APP}
15+
BOARD ${SB_CONFIG_BOARD}/${SB_CONFIG_SOC}/cpurad
16+
)
17+
18+
# Add dependencies so that the remote sample will be built first
19+
# This is required because some primary cores need information from the
20+
# remote core's build, such as the output image's LMA
21+
add_dependencies(${DEFAULT_IMAGE} ${REMOTE_APP})
22+
sysbuild_add_dependencies(CONFIGURE ${DEFAULT_IMAGE} ${REMOTE_APP})

0 commit comments

Comments
 (0)