Skip to content

Commit 38b975a

Browse files
nika-nordickartben
authored andcommitted
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. Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
1 parent 7442302 commit 38b975a

11 files changed

+73
-182
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 GPIO_WAKEUP_ENABLE
2511
bool "Use button 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: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,18 @@ tests:
2323
- "system off demo"
2424
- "Retained data not supported"
2525
- "Entering system off; press sw0 to restart"
26-
sample.boards.nrf.system_off.nrf_retained:
26+
sample.boards.nrf.system_off.retained_mem:
2727
integration_platforms:
2828
- nrf52840dk/nrf52840
2929
platform_allow:
3030
- nrf52840dk/nrf52840
3131
- nrf52dk/nrf52832
32-
extra_configs:
33-
- CONFIG_APP_USE_NRF_RETENTION=y
34-
harness: console
35-
harness_config:
36-
type: multi_line
37-
ordered: true
38-
regex:
39-
- "system off demo"
40-
- "Retained data: INVALID"
41-
- "Boot count: 1"
42-
- "Off count: 0"
43-
- "Active Ticks:"
44-
- "Entering system off; press sw0 to restart"
45-
sample.boards.nrf.system_off.retained_mem:
46-
extra_args: DTC_OVERLAY_FILE="boards/nrf54l15dk_nrf54l15_cpuapp_retained_mem.overlay"
47-
platform_allow:
32+
- nrf54l15dk/nrf54l05/cpuapp
33+
- nrf54l15dk/nrf54l10/cpuapp
4834
- nrf54l15dk/nrf54l15/cpuapp
4935
- nrf54l20pdk/nrf54l20/cpuapp
5036
extra_configs:
5137
- CONFIG_APP_USE_RETAINED_MEM=y
52-
- CONFIG_RETAINED_MEM=y
5338
harness: console
5439
harness_config:
5540
type: multi_line
@@ -63,6 +48,8 @@ tests:
6348
- "Entering system off; press sw0 to restart"
6449
sample.boards.nrf.system_off.grtc_wakeup:
6550
platform_allow:
51+
- nrf54l15dk/nrf54l05/cpuapp
52+
- nrf54l15dk/nrf54l10/cpuapp
6653
- nrf54l15dk/nrf54l15/cpuapp
6754
- nrf54l20pdk/nrf54l20/cpuapp
6855
extra_configs:
@@ -83,15 +70,15 @@ tests:
8370
- "Retained data not supported"
8471
- "Entering system off; wait 2 seconds to restart"
8572
sample.boards.nrf.system_off.retained_mem.grtc_wakeup:
86-
extra_args: DTC_OVERLAY_FILE="boards/nrf54l15dk_nrf54l15_cpuapp_retained_mem.overlay"
8773
platform_allow:
74+
- nrf54l15dk/nrf54l05/cpuapp
75+
- nrf54l15dk/nrf54l10/cpuapp
8876
- nrf54l15dk/nrf54l15/cpuapp
8977
- nrf54l20pdk/nrf54l20/cpuapp
9078
extra_configs:
9179
- CONFIG_APP_USE_RETAINED_MEM=y
9280
- CONFIG_GRTC_WAKEUP_ENABLE=y
9381
- CONFIG_GPIO_WAKEUP_ENABLE=n
94-
- CONFIG_RETAINED_MEM=y
9582
harness: console
9683
harness_config:
9784
type: multi_line
@@ -135,7 +122,7 @@ tests:
135122
extra_args:
136123
- "DTC_OVERLAY_FILE=
137124
boards/nrf54l15dk_nrf54l15_cpuapp_comparator.overlay;
138-
boards/nrf54l15dk_nrf54l15_cpuapp_retained_mem.overlay"
125+
boards/nrf54l15dk_nrf54l15_cpuapp.overlay"
139126
platform_allow:
140127
- nrf54l15dk/nrf54l15/cpuapp
141128
extra_configs:

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

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

4141
printf("\n%s system off demo\n", CONFIG_BOARD);
4242

43-
if (IS_ENABLED(CONFIG_APP_USE_NRF_RETENTION) || IS_ENABLED(CONFIG_APP_USE_RETAINED_MEM)) {
43+
if (IS_ENABLED(CONFIG_APP_USE_RETAINED_MEM)) {
4444
bool retained_ok = retained_validate();
4545

4646
/* Increment for this boot attempt and update. */
@@ -92,7 +92,7 @@ int main(void)
9292
return 0;
9393
}
9494

95-
if (IS_ENABLED(CONFIG_APP_USE_NRF_RETENTION) || IS_ENABLED(CONFIG_APP_USE_RETAINED_MEM)) {
95+
if (IS_ENABLED(CONFIG_APP_USE_RETAINED_MEM)) {
9696
/* Update the retained state */
9797
retained.off_count += 1;
9898
retained_update();

0 commit comments

Comments
 (0)