Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: benchmarks: multicore: Add test for S2RAM and PPR #18808

Merged
merged 1 commit into from
Nov 13, 2024
Merged
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
19 changes: 19 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

if(NOT SYSBUILD)
message(FATAL_ERROR
" This is a multi-image application that should be built using sysbuild.\n"
" Add --sysbuild argument to west build command to prepare all the images.")
endif()

project(idle_ppr)

target_sources(app PRIVATE src/main.c)
15 changes: 15 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

config TEST_SLEEP_DURATION_MS
int "Amount of time (in miliseconds) the core is sleeping"
default 1000
help
Set sleep duration to TEST_SLEEP_DURATION_MS miliseconds.
Based on the value of 'min-residency-us' specified for each power state defined in the DTS,
core enters the lowest possible power state.

source "Kconfig.zephyr"
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

&cpuppr_vpr {
nordic-segl marked this conversation as resolved.
Show resolved Hide resolved
status = "okay";
};

&cpuppr_ram3x_region {
status = "okay";
};


/ {
aliases {
/delete-property/ led1;
};
};

/delete-node/ &led1;

&gpiote130 {
status = "okay";
owned-channels = <0>;
};
8 changes: 8 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CONFIG_BOOT_BANNER=n
CONFIG_NCS_BOOT_BANNER=n

CONFIG_LOG=y
CONFIG_ASSERT=y
CONFIG_GPIO=y

CONFIG_NRF_REGTOOL_VERBOSITY=1
19 changes: 19 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/prj_s2ram.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CONFIG_PM=y
CONFIG_PM_S2RAM=y
CONFIG_PM_S2RAM_CUSTOM_MARKING=y
CONFIG_POWEROFF=y
CONFIG_SOC_NRF54H20_NO_MRAM_LATENCY=n

CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y

CONFIG_BOOT_BANNER=n
CONFIG_NCS_BOOT_BANNER=n
CONFIG_PRINTK=n
CONFIG_LOG=n
CONFIG_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_SERIAL=n

CONFIG_ASSERT=y
CONFIG_GPIO=y
17 changes: 17 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/remote/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

cmake_minimum_required(VERSION 3.20.0)

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

target_sources(app PRIVATE ../src/main.c)

if((DEFINED CONFIG_SOC_NRF54H20_CPUPPR) OR (DEFINED CONFIG_SOC_NRF54H20_ENGB_CPUPPR))
nordicjm marked this conversation as resolved.
Show resolved Hide resolved
message(STATUS "Power Mode handler for RISC V is included.")
target_sources(app PRIVATE ../src/power_off.c)
endif()
21 changes: 21 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/remote/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

config TEST_SLEEP_DURATION_MS
int "Amount of time (in miliseconds) the core is sleeping"
default 1000
help
Set sleep duration to TEST_SLEEP_DURATION_MS miliseconds.
Based on the value of 'min-residency-us' specified for each power state defined in the DTS,
core enters the lowest possible power state.

config APP_PROVIDE_PM_HOOKS
bool "Application provides PM hooks"
default y
select HAS_PM
select HAS_POWEROFF

source "Kconfig.zephyr"
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/ {
aliases {
led0 = &led3;
};

leds {
compatible = "gpio-leds";
led3: led_3 {
gpios = < &gpio9 0x3 0x0 >;
label = "Green LED 3";
};
};

cpus {
power-states {
wait: wait {
compatible = "zephyr,power-state";
power-state-name = "standby";
substate-id = <0>;
min-residency-us = <20000>;
};

hibernate: hibernate {
compatible = "zephyr,power-state";
power-state-name = "suspend-to-ram";
substate-id = <0>;
min-residency-us = <400000>;
};
};
};
};

&cpu {
cpu-power-states = <&wait &hibernate>;
};

&gpio9 {
status = "okay";
};

&gpiote130 {
status = "okay";
owned-channels = <2>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/ {
aliases {
led0 = &led1;
};

leds {
compatible = "gpio-leds";
led1: led_1 {
gpios = < &gpio9 0x1 0x0 >;
label = "Green LED 1";
};
};
};

&gpio9 {
status = "okay";
};

&gpiote130 {
status = "okay";
owned-channels = <1>;
};
12 changes: 12 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/remote/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CONFIG_LOG=n
CONFIG_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_SERIAL=n
CONFIG_BOOT_BANNER=n
CONFIG_NCS_BOOT_BANNER=n
CONFIG_PRINTK=n

CONFIG_ASSERT=y
CONFIG_GPIO=y

CONFIG_NRF_REGTOOL_VERBOSITY=1
15 changes: 15 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/remote/prj_s2ram.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CONFIG_PM=y
CONFIG_POWEROFF=y

CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y

CONFIG_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_SERIAL=n
CONFIG_BOOT_BANNER=n
CONFIG_NCS_BOOT_BANNER=n
CONFIG_SOC_NRF54H20_NO_MRAM_LATENCY=n

CONFIG_ASSERT=y
CONFIG_GPIO=y
80 changes: 80 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(idle_ppr, LOG_LEVEL_INF);

static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(led0), gpios);

/* Variables used to make CPU active for ~1 second */
static struct k_timer my_timer;
static bool timer_expired;

void my_timer_handler(struct k_timer *dummy)
{
timer_expired = true;
}

int main(void)
{
int counter = 0;
int ret;

LOG_INF("Multicore idle_ppr test on %s", CONFIG_BOARD_TARGET);
LOG_INF("Main sleeps for %d ms", CONFIG_TEST_SLEEP_DURATION_MS);

ret = gpio_is_ready_dt(&led);
if (!ret) {
LOG_ERR("LED is not ready");
}
__ASSERT(ret, "LED is not ready\n");

ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
if (ret < 0) {
LOG_ERR("Unable to configure GPIO as output");
}
__ASSERT(ret == 0, "Unable to configure GPIO as output\n");

k_timer_init(&my_timer, my_timer_handler, NULL);

/* Run test forever */
while (1) {
timer_expired = false;

/* start a one-shot timer that expires after 1 second */
k_timer_start(&my_timer, K_MSEC(1000), K_NO_WAIT);

/* Turn ON LED */
ret = gpio_pin_set_dt(&led, 1);
if (ret < 0) {
LOG_ERR("Unable to turn on LED");
}
__ASSERT(ret == 0, "Unable to turn on LED\n");

/* Keep CPU active for ~ 1 second */
while (!timer_expired) {
k_busy_wait(10000);
k_yield();
}

/* Turn OFF LED */
ret = gpio_pin_set_dt(&led, 0);
if (ret < 0) {
LOG_ERR("Unable to turn off LED");
}
__ASSERT(ret == 0, "Unable to turn off LED\n");

LOG_INF("Run %d", counter);
nordic-segl marked this conversation as resolved.
Show resolved Hide resolved
counter++;

/* Sleep / enter low power state */
k_msleep(CONFIG_TEST_SLEEP_DURATION_MS);
}

return 0;
}
Loading
Loading