Skip to content
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
16 changes: 16 additions & 0 deletions include/ppr_prl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#ifndef PPR_PRL_H_
#define PPR_PRL_H_

#include <stdint.h>

void ppr_prl_configure(uint32_t max_samples, uint32_t vtim_cnttop);

void ppr_prl_start(void);

#endif /* PPR_PRL_H_ */
1 change: 1 addition & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ add_subdirectory_ifdef(CONFIG_FEM_AL_LIB fem_al)
add_subdirectory_ifdef(CONFIG_SAMPLE_RATE_CONVERTER sample_rate_converter)
add_subdirectory_ifdef(CONFIG_NCS_BOOT_BANNER boot_banner)
add_subdirectory_ifdef(CONFIG_UICC_LWM2M uicc_lwm2m)
add_subdirectory_ifdef(CONFIG_PPR_PRL ppr_prl)
1 change: 1 addition & 0 deletions lib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ rsource "fem_al/Kconfig"
rsource "sample_rate_converter/Kconfig"
rsource "boot_banner/Kconfig"
rsource "uicc_lwm2m/Kconfig"
rsource "ppr_prl/Kconfig"

endmenu
8 changes: 8 additions & 0 deletions lib/ppr_prl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright (c) 2021 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

zephyr_library()
zephyr_library_sources(ppr_prl.c)
40 changes: 40 additions & 0 deletions lib/ppr_prl/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
#Copyright(c) 2025 Nordic Semiconductor ASA
#
#SPDX - License - Identifier : LicenseRef - Nordic - 5 - Clause
#

menuconfig PPR_PRL
bool "PPR power request logger library"
help
This library provides communication with the PPR power request logger.


if PPR_PRL

config PPR_PRL_AUTO_START
bool "Auto start PPR PRL"
default y
help
If selected, the PPR power logger will be started automatically
when the application starts. Otherwise, the application must
call ppr_prl_start() to start the logger.

if PPR_PRL_AUTO_START

config PPR_PRL_AUTO_START_CONFIG_VTIM_CNTTOP
int "VTIM_CNTTOP value"
default 16000
help
The value of the VTIM_CNTTOP register for the PPR power request logger sampling timer.
The TIMER runs at 16 MHz and the value is the number of clock cycles to count before taking a sample.

config PPR_PRL_AUTO_START_CONFIG_MAX_SAMPLES
int "Number of samples the power logger should collect"
default 1024
help
The number of samples the power logger should collect before stopping.

endif # PPR_PRL_AUTO_START

endif # PPR_PRL
53 changes: 53 additions & 0 deletions lib/ppr_prl/ppr_prl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include "ppr_prl.h"

#include <zephyr/cache.h>
#include <zephyr/init.h>
#include <zephyr/sys/util.h>

#define PPR_LOAD_CONFIG_TASKS_TRIGGER *(volatile uint32_t *)(0x5F908030UL)
#define PPR_START_SAMPLING_TASKS_TRIGGER *(volatile uint32_t *)(0x5F908034UL)
#define STATE_PPR_PRL_READY 0x01

typedef struct {
uint32_t vtim_cnttop;
uint8_t state;
uint8_t rfu;
uint16_t max_samples;
} log_conf_t;

/* log_conf inside the ppr ram, just writing straight to that */
static log_conf_t *log_conf = (log_conf_t *)((uint32_t)(0x2fc00ff8));

void ppr_prl_configure(uint32_t max_samples, uint32_t vtim_cnttop)
{
log_conf->vtim_cnttop = vtim_cnttop;
log_conf->max_samples = max_samples;
log_conf->rfu = 0;
log_conf->state = 0;
sys_cache_data_flush_range(log_conf, sizeof(*log_conf));

PPR_LOAD_CONFIG_TASKS_TRIGGER = 1ul;

while (log_conf->state != STATE_PPR_PRL_READY) {
sys_cache_data_flush_and_invd_range(log_conf, sizeof(*log_conf));
}
}

void ppr_prl_start(void)
{
PPR_START_SAMPLING_TASKS_TRIGGER = 1ul;
}

#if CONFIG_PPR_PRL_AUTO_START

static int ppr_prl_auto_start(void)
{
ppr_prl_configure(CONFIG_PPR_PRL_AUTO_START_CONFIG_MAX_SAMPLES,
CONFIG_PPR_PRL_AUTO_START_CONFIG_VTIM_CNTTOP);
ppr_prl_start();
return 0;
}

SYS_INIT(ppr_prl_auto_start, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);

#endif
22 changes: 13 additions & 9 deletions samples/bluetooth/peripheral_rscs/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ tests:
- bluetooth
- ci_build
- sysbuild
harness: console
harness_config:
type: multi_line
ordered: true
regex:
- "Starting Running Speed and Cadence peripheral sample"
- "Bluetooth initialized"
- "Advertising successfully started"
timeout: 15


sample.bluetooth.peripheral_rscs.ppr_prl:
sysbuild: true
build_only: true
integration_platforms:
- nrf54h20dk/nrf54h20/cpuapp
platform_allow:
- nrf54h20dk/nrf54h20/cpuapp
required_snippets:
- haltium-ppr-power-logger
extra_configs:
- CONFIG_PPR_PRL_AUTO_START=n
19 changes: 19 additions & 0 deletions samples/bluetooth/peripheral_rscs/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@

#include <dk_buttons_and_leds.h>

#ifdef CONFIG_PPR_PRL
#include <ppr_prl.h>

static bool start_ppr_prl = false;
#endif


#define RUN_STATUS_LED DK_LED1
#define CON_STATUS_LED DK_LED2
#define RUN_LED_BLINK_INTERVAL 1000
Expand Down Expand Up @@ -110,6 +117,9 @@ void evt_handler(enum bt_rscs_evt evt)
switch (evt) {
case RSCS_EVT_MEAS_NOTIFY_ENABLE:
printk("Measurement notify enable\n");
#ifdef CONFIG_PPR_PRL
start_ppr_prl = true;
#endif
break;
case RSCS_EVT_MEAS_NOTIFY_DISABLE:
printk("Measurement notify disable\n");
Expand Down Expand Up @@ -320,6 +330,15 @@ int main(void)
k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL));

rsc_simulation(&measurement);

#ifdef CONFIG_PPR_PRL
if (start_ppr_prl) {
ppr_prl_configure(1536, 800);
ppr_prl_start();
start_ppr_prl = false;
}
#endif

bt_rscs_measurement_send(current_conn, &measurement);
}
}
11 changes: 11 additions & 0 deletions samples/nfc/system_off/Kconfig.sysbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

source "share/sysbuild/Kconfig"

config REMOTE_CORE_BOARD
string
default "nrf54h20dk/nrf54h20/cpurad" if $(BOARD) = "nrf54h20dk"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_SOC_NRF54H20_CPURAD_ENABLE=y
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

&uart136 {
zephyr,pm-device-runtime-auto;
disable-rx;
};

&nfct {
status = "okay";
memory-regions = <&cpuapp_dma_region>;
};
12 changes: 12 additions & 0 deletions samples/nfc/system_off/remote/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Copyright (c) 2025 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(nrf_system_off_remote)

target_sources(app PRIVATE src/main.c)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_PM=y
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

&uart135 {
zephyr,pm-device-runtime-auto;
disable-rx;
};
8 changes: 8 additions & 0 deletions samples/nfc/system_off/remote/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_UART_ASYNC_API=y
CONFIG_POWEROFF=y
23 changes: 23 additions & 0 deletions samples/nfc/system_off/remote/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/pm/device.h>
#include <zephyr/pm/device_runtime.h>
#include <zephyr/sys/poweroff.h>
#include <zephyr/drivers/timer/nrf_grtc_timer.h>

int main(void)
{
if (IS_ENABLED(CONFIG_CONSOLE)) {
printf("%s system off demo. Ready for system off.\n", CONFIG_BOARD_TARGET);
}

sys_poweroff();

return 0;
}
2 changes: 2 additions & 0 deletions samples/nfc/system_off/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ tests:
- nrf54l15dk/nrf54l10/cpuapp
- nrf54l15dk/nrf54l15/cpuapp
- nrf54lm20dk/nrf54lm20a/cpuapp
- nrf54h20dk/nrf54h20/cpuapp
platform_allow:
- nrf52840dk/nrf52840
- nrf52dk/nrf52832
Expand All @@ -23,6 +24,7 @@ tests:
- nrf54l15dk/nrf54l10/cpuapp
- nrf54l15dk/nrf54l15/cpuapp
- nrf54lm20dk/nrf54lm20a/cpuapp
- nrf54h20dk/nrf54h20/cpuapp
tags:
- ci_build
- sysbuild
Expand Down
20 changes: 15 additions & 5 deletions samples/nfc/system_off/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
#include <zephyr/pm/device.h>

#include <nrfx.h>
#include <hal/nrf_power.h>
#if !NRF_POWER_HAS_RESETREAS
#include <hal/nrf_reset.h>
#endif
#include <helpers/nrfx_reset_reason.h>

#include <nfc_t2t_lib.h>
#include <nfc/ndef/msg.h>
Expand Down Expand Up @@ -175,6 +172,20 @@ static void print_reset_reason(void)
printk("Power-on-reset\n");
}

#elif defined(NRF_RESETINFO)
reas = nrf_resetinfo_resetreas_global_get(NRF_RESETINFO);
if (reas & NRF_RESETINFO_RESETREAS_GLOBAL_NFC_MASK) {
printk("Wake up by NFC field detect\n");
} else if (reas & NRF_RESETINFO_RESETREAS_GLOBAL_PIN_MASK) {
printk("Reset by pin-reset\n");
} else if (reas & NRF_RESETINFO_RESETREAS_LOCAL_SREQ_MASK) {
printk("Reset by soft-reset\n");
} else if (reas) {
printk("Reset by a different source (0x%08X)\n", reas);
} else {
printk("Power-on-reset\n");
}

#else

reas = nrf_reset_resetreas_get(NRF_RESET);
Expand All @@ -194,7 +205,6 @@ static void print_reset_reason(void)
#endif
}


int main(void)
{
/* Configure LED-pins */
Expand Down
25 changes: 25 additions & 0 deletions samples/nfc/system_off/sysbuild.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

if("${SB_CONFIG_REMOTE_CORE_BOARD}" STREQUAL "")
message(FATAL_ERROR
"Target ${BOARD} not supported for this sample. "
"There is no remote board selected in Kconfig.sysbuild")
endif()

set(REMOTE_APP remote)

ExternalZephyrProject_Add(
APPLICATION ${REMOTE_APP}
SOURCE_DIR ${APP_DIR}/${REMOTE_APP}
BOARD ${SB_CONFIG_REMOTE_CORE_BOARD}
)

# Add dependencies so that the remote sample will be built first
# This is required because some primary cores need information from the
# remote core's build, such as the output image's LMA
add_dependencies(${DEFAULT_IMAGE} ${REMOTE_APP})
sysbuild_add_dependencies(CONFIGURE ${DEFAULT_IMAGE} ${REMOTE_APP})
5 changes: 5 additions & 0 deletions scripts/west-commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@ west-commands:
- name: ncs-ironside-se-update
class: NcsIronSideSEUpdate
help: IronSide SE update utility
- file: scripts/west_commands/ppr_prl.py
commands:
- name: ppr-prl
class: PPR_PRL
help: PPR power request logger utility
Loading