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: benchmark: multicore: Test PWM with low power modes #17380

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@
/tests/benchmarks/multicore/ @carlescufi
/tests/benchmarks/multicore/idle/ @adamkondraciuk @nrfconnect/ncs-low-level-test
/tests/benchmarks/multicore/idle_gpio/ @adamkondraciuk @nrfconnect/ncs-low-level-test
/tests/benchmarks/multicore/idle_with_pwm/ @nrfconnect/ncs-low-level-test
/tests/benchmarks/i2c_endless/ @nrfconnect/ncs-low-level-test
/tests/benchmarks/spi_endless/ @nrfconnect/ncs-low-level-test
/tests/benchmarks/peripheral_load/ @nrfconnect/ncs-low-level-test
Expand Down

This file was deleted.

5 changes: 2 additions & 3 deletions tests/benchmarks/multicore/idle/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ tests:
remote_CONFIG_PM=y remote_CONFIG_POWEROFF=y remote_CONFIG_CONSOLE=n
remote_CONFIG_UART_CONSOLE=n remote_CONFIG_SERIAL=n remote_CONFIG_GPIO=n
remote_CONFIG_BOOT_BANNER=n remote_CONFIG_NRFS_MRAM_SERVICE_ENABLED=n
DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_s2ram.overlay"
harness: pytest
harness_config:
fixture: ppk_power_measure
Expand All @@ -98,7 +97,7 @@ tests:
remote_CONFIG_PM=y remote_CONFIG_POWEROFF=y remote_CONFIG_CONSOLE=n
remote_CONFIG_UART_CONSOLE=n remote_CONFIG_SERIAL=n remote_CONFIG_GPIO=n
remote_CONFIG_BOOT_BANNER=n remote_CONFIG_NRFS_MRAM_SERVICE_ENABLED=n
DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_s2ram.overlay;boards/nrf54h20dk_nrf54h20_cpuapp_ram_high_usage.overlay"
DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_ram_high_usage.overlay"
harness: pytest
harness_config:
fixture: ppk_power_measure
Expand All @@ -120,7 +119,7 @@ tests:
remote_CONFIG_PM=y remote_CONFIG_POWEROFF=y remote_CONFIG_CONSOLE=n
remote_CONFIG_UART_CONSOLE=n remote_CONFIG_SERIAL=n remote_CONFIG_GPIO=n
remote_CONFIG_BOOT_BANNER=n remote_CONFIG_NRFS_MRAM_SERVICE_ENABLED=n
DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_s2ram.overlay;boards/nrf54h20dk_nrf54h20_cpuapp_ram_low_usage.overlay"
DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_ram_low_usage.overlay"
harness: pytest
harness_config:
fixture: ppk_power_measure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,13 @@
*/

/ {
power-states {
idle: idle {
compatible = "zephyr,power-state";
power-state-name = "suspend-to-idle";
min-residency-us = <100000>;
};

s2ram: s2ram {
compatible = "zephyr,power-state";
power-state-name = "suspend-to-ram";
min-residency-us = <800000>;
};
};
aliases {
/delete-property/ sw1;
};
};

/delete-node/ &button1;

&cpu {
cpu-power-states = <&idle &s2ram>;
};

&gpiote130 {
status = "okay";
owned-channels = <0>;
Expand Down
19 changes: 19 additions & 0 deletions tests/benchmarks/multicore/idle_with_pwm/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(WARNING
" 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_with_pwm)

target_sources(app PRIVATE src/main.c)
15 changes: 15 additions & 0 deletions tests/benchmarks/multicore/idle_with_pwm/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 value of 'min-residency-us' specified for each power state defined in the DTS,
core will enter lowest possible power state.

source "Kconfig.zephyr"
10 changes: 10 additions & 0 deletions tests/benchmarks/multicore/idle_with_pwm/Kconfig.sysbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

source "${ZEPHYR_BASE}/share/sysbuild/Kconfig"

config REMOTE_BOARD
string "The board used for remote target"
72 changes: 72 additions & 0 deletions tests/benchmarks/multicore/idle_with_pwm/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
.. _multicore_idle_with_pwm_test:

PWM in low power states test
############################

.. contents::
:local:
:depth: 2

The test benchmarks the idle behavior of an application that runs on multiple cores and uses PWM driver to light up LED.

Test scenario
Repeat forever:
- gradually light up LED (this lasts for ~1 second),
- disable PWM (set period to 0); This will turn off LED,
- sleep for 1 second.

Requirements
************

The test supports the following development kits:

.. table-from-rows:: /includes/sample_board_rows.txt
:header: heading
:rows: nrf54h20dk_nrf54h20_cpuapp

Overview
********

The test demonstrates use of PWM with low power modes.

Code stored in :file:`main.c` is compiled for Application and Radio cores.
Application core uses pwm130 to generate PWM signal on LED2.
Radio core uses pwm131 to generate PWM signal on GPIO Port 0 pin 7.

There are three test configurations in :file:`testcase.yaml`.

#. 'benchmarks.multicore.idle_with_pwm.nrf54h20dk_cpuapp_cpurad.s2ram'
This configuration uses KConfigs that enable entering low power modes. However, logging is disabled here.
Core sleeps for time sufficient to enter "suspend-to-ram" power state.
#. 'benchmarks.multicore.idle_with_pwm.nrf54h20dk_cpuapp_cpurad.sleep'
This configuration uses KConfigs that enable entering low power modes. However, logging is disabled here.
Core sleeps for time sufficient to enter "suspend-to-idle" power state.
#. 'benchmarks.multicore.idle_with_pwm.nrf54h20dk_cpuapp_cpurad.no_sleep'
This configuration can be used for debug purposes. It has enabled logging while Power Moding is disabled.

Building and running
********************

.. |test path| replace:: :file:`tests/benchmarks/multicore/idle_with_pwm`

.. include:: /includes/build_and_run_test.txt

To build the test, use configuration setups from :file:`testcase.yaml` using the ``-T`` option.
See the following examples:

nRF54H20 DK
You can build the test for application and radio cores as follows:

.. code-block:: console

west build -p -b nrf54h20dk/nrf54h20/cpuapp -T benchmarks.multicore.idle_with_pwm.nrf54h20dk_cpuapp_cpurad.s2ram .

Testing
=======

After programming the test to your development kit, complete the following steps to test it:

#. Connect the PPK2 Power Profiler Kit or other current measurement device.
#. Reset the kit.
#. Observe the LED2 brightness (or use oscilloscope to collect PWM signal on Port 0 pin 7).
#. When LED2 is OFF power profiler shall indicate low current consumption resulting from both cores being in low power mode.
3 changes: 3 additions & 0 deletions tests/benchmarks/multicore/idle_with_pwm/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_PRINTK=y
CONFIG_LOG=y
CONFIG_PWM=y
15 changes: 15 additions & 0 deletions tests/benchmarks/multicore/idle_with_pwm/prj_s2ram.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CONFIG_PM=y
CONFIG_PM_S2RAM=y
CONFIG_POWEROFF=y
CONFIG_PM_S2RAM_CUSTOM_MARKING=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_NRFS_MRAM_SERVICE_ENABLED=n

CONFIG_PWM=y
12 changes: 12 additions & 0 deletions tests/benchmarks/multicore/idle_with_pwm/remote/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# 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)
15 changes: 15 additions & 0 deletions tests/benchmarks/multicore/idle_with_pwm/remote/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 value of 'min-residency-us' specified for each power state defined in the DTS,
core will enter lowest possible power state.

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

/ {
aliases {
pwm-led0 = &pwm_gpio;
};

pwmleds {
compatible = "pwm-leds";
pwm_gpio: pwm_gpio {
pwms = <&pwm131 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
};
};
};

&pinctrl {
/omit-if-no-ref/ pwm131_default: pwm131_default {
group1 {
psels = <NRF_PSEL(PWM_OUT0, 0, 7)>;
};
};

/omit-if-no-ref/ pwm131_sleep: pwm131_sleep {
group1 {
psels = <NRF_PSEL(PWM_OUT0, 0, 7)>;
low-power-enable;
};
};
};

&pwm131 {
status = "okay";
pinctrl-0 = <&pwm131_default>;
pinctrl-1 = <&pwm131_sleep>;
pinctrl-names = "default", "sleep";
memory-regions = <&cpurad_dma_region>;
};
3 changes: 3 additions & 0 deletions tests/benchmarks/multicore/idle_with_pwm/remote/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_PRINTK=y
CONFIG_LOG=y
CONFIG_PWM=y
10 changes: 10 additions & 0 deletions tests/benchmarks/multicore/idle_with_pwm/remote/prj_s2ram.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CONFIG_PM=y
CONFIG_POWEROFF=y

CONFIG_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_SERIAL=n
CONFIG_BOOT_BANNER=n
CONFIG_NRFS_MRAM_SERVICE_ENABLED=n

CONFIG_PWM=y
Loading
Loading