Skip to content

Commit 0a2e205

Browse files
nika-nordicjukkar
authored andcommitted
[nrf fromlist] samples: nordic: system_off: use retained_mem on all targets
Using bare-metal approach for retention configuration is no longer compatible with sys_poweroff() implementation. Upstream PR #: 82262 Signed-off-by: Nikodem Kastelik <[email protected]> (cherry picked from commit 15ffa30)
1 parent 49e3fe1 commit 0a2e205

11 files changed

+72
-181
lines changed

samples/boards/nordic/system_off/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
55
project(nrf_system_off)
66

77
target_sources(app PRIVATE src/main.c)
8-
if (CONFIG_APP_USE_NRF_RETENTION OR CONFIG_APP_USE_RETAINED_MEM)
8+
if (CONFIG_APP_USE_RETAINED_MEM)
99
target_sources(app PRIVATE src/retained.c)
1010
endif()

samples/boards/nordic/system_off/Kconfig

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,9 @@
33

44
mainmenu "Nordic SYSTEM_OFF demo"
55

6-
choice
7-
prompt "Use retention"
8-
optional
9-
10-
config APP_USE_NRF_RETENTION
11-
bool "Use state retention in system off using nRF POWER"
12-
depends on SOC_COMPATIBLE_NRF52X && CRC
13-
help
14-
On some Nordic chips this application supports retaining
15-
memory while in system off using POWER peripheral.
16-
Select this to enable the feature.
17-
186
config APP_USE_RETAINED_MEM
197
bool "Use state retention in system off using retained_mem driver"
20-
depends on RETAINED_MEM
21-
22-
endchoice
8+
select RETAINED_MEM
239

2410
config GRTC_WAKEUP_ENABLE
2511
bool "Use GRTC to wake up device from system off"

samples/boards/nordic/system_off/README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ deep sleep on Nordic platforms.
1313
RAM Retention
1414
=============
1515

16-
This sample can also can demonstrate RAM retention. By selecting
17-
``CONFIG_APP_USE_NRF_RETENTION=y`` or ``CONFIG_APP_USE_RETAINED_MEM=y``
18-
state related to number of boots, number of times system off was entered,
19-
and total uptime since initial power-on are retained in a checksummed data structure.
16+
This sample can also demonstrate RAM retention.
17+
By selecting ``CONFIG_APP_USE_RETAINED_MEM=y`` state related to number of boots,
18+
number of times system off was entered, and total uptime since initial power-on
19+
are retained in a checksummed data structure.
2020
RAM is configured to keep the containing section powered while in system-off mode.
2121

2222
Requirements
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/ {
2+
sram0@2003f000 {
3+
compatible = "zephyr,memory-region", "mmio-sram";
4+
reg = <0x2003f000 DT_SIZE_K(4)>;
5+
zephyr,memory-region = "RetainedMem";
6+
status = "okay";
7+
8+
retainedmem0: retainedmem {
9+
compatible = "zephyr,retained-ram";
10+
status = "okay";
11+
};
12+
};
13+
14+
aliases {
15+
retainedmemdevice = &retainedmem0;
16+
};
17+
};
18+
19+
&sram0 {
20+
/* Shrink SRAM size to avoid overlap with retained memory region */
21+
reg = <0x20000000 DT_SIZE_K(252)>;
22+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/ {
2+
sram0@20007000 {
3+
compatible = "zephyr,memory-region", "mmio-sram";
4+
reg = <0x20007000 DT_SIZE_K(4)>;
5+
zephyr,memory-region = "RetainedMem";
6+
status = "okay";
7+
8+
retainedmem0: retainedmem {
9+
compatible = "zephyr,retained-ram";
10+
status = "okay";
11+
};
12+
};
13+
14+
aliases {
15+
retainedmemdevice = &retainedmem0;
16+
};
17+
};
18+
19+
&sram0 {
20+
/* Shrink SRAM size to avoid overlap with retained memory region */
21+
reg = <0x20000000 DT_SIZE_K(28)>;
22+
};

samples/boards/nordic/system_off/sample.yaml

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,17 @@ tests:
2222
- "system off demo"
2323
- "Retained data not supported"
2424
- "Entering system off; press sw0 to restart"
25-
sample.boards.nrf.system_off.nrf_retained:
25+
sample.boards.nrf.system_off.retained_mem:
2626
integration_platforms:
2727
- nrf52840dk/nrf52840
2828
platform_allow:
2929
- nrf52840dk/nrf52840
3030
- nrf52dk/nrf52832
31-
extra_configs:
32-
- CONFIG_APP_USE_NRF_RETENTION=y
33-
harness: console
34-
harness_config:
35-
type: multi_line
36-
ordered: true
37-
regex:
38-
- "system off demo"
39-
- "Retained data: INVALID"
40-
- "Boot count: 1"
41-
- "Off count: 0"
42-
- "Active Ticks:"
43-
- "Entering system off; press sw0 to restart"
44-
sample.boards.nrf.system_off.retained_mem:
45-
extra_args: DTC_OVERLAY_FILE="boards/nrf54l15dk_nrf54l15_cpuapp_retained_mem.overlay"
46-
platform_allow:
4731
- nrf54l15dk/nrf54l15/cpuapp
32+
- nrf54l15dk/nrf54l10/cpuapp
33+
- nrf54l15dk/nrf54l05/cpuapp
4834
extra_configs:
4935
- CONFIG_APP_USE_RETAINED_MEM=y
50-
- CONFIG_RETAINED_MEM=y
5136
harness: console
5237
harness_config:
5338
type: multi_line
@@ -62,6 +47,8 @@ tests:
6247
sample.boards.nrf.system_off.grtc_wakeup:
6348
platform_allow:
6449
- nrf54l15dk/nrf54l15/cpuapp
50+
- nrf54l15dk/nrf54l10/cpuapp
51+
- nrf54l15dk/nrf54l05/cpuapp
6552
extra_configs:
6653
- CONFIG_GRTC_WAKEUP_ENABLE=y
6754
harness: console
@@ -79,13 +66,13 @@ tests:
7966
- "Retained data not supported"
8067
- "Entering system off; wait 2 seconds to restart"
8168
sample.boards.nrf.system_off.retained_mem.grtc_wakeup:
82-
extra_args: DTC_OVERLAY_FILE="boards/nrf54l15dk_nrf54l15_cpuapp_retained_mem.overlay"
8369
platform_allow:
8470
- nrf54l15dk/nrf54l15/cpuapp
71+
- nrf54l15dk/nrf54l10/cpuapp
72+
- nrf54l15dk/nrf54l05/cpuapp
8573
extra_configs:
8674
- CONFIG_APP_USE_RETAINED_MEM=y
8775
- CONFIG_GRTC_WAKEUP_ENABLE=y
88-
- CONFIG_RETAINED_MEM=y
8976
harness: console
9077
harness_config:
9178
type: multi_line

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int main(void)
3535

3636
printf("\n%s system off demo\n", CONFIG_BOARD);
3737

38-
if (IS_ENABLED(CONFIG_APP_USE_NRF_RETENTION) || IS_ENABLED(CONFIG_APP_USE_RETAINED_MEM)) {
38+
if (IS_ENABLED(CONFIG_APP_USE_RETAINED_MEM)) {
3939
bool retained_ok = retained_validate();
4040

4141
/* Increment for this boot attempt and update. */
@@ -81,7 +81,7 @@ int main(void)
8181
return 0;
8282
}
8383

84-
if (IS_ENABLED(CONFIG_APP_USE_NRF_RETENTION) || IS_ENABLED(CONFIG_APP_USE_RETAINED_MEM)) {
84+
if (IS_ENABLED(CONFIG_APP_USE_RETAINED_MEM)) {
8585
/* Update the retained state */
8686
retained.off_count += 1;
8787
retained_update();

0 commit comments

Comments
 (0)