-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: benchmarks: multicore: idle: Add GPIO wake-up manner
Extend the sample by adding configuration that allows wake-up using sw0 button. Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
- Loading branch information
1 parent
fa6f326
commit 1282ebb
Showing
15 changed files
with
313 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# 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_gpio) | ||
|
||
target_sources(app PRIVATE src/main.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
.. _multicore_idle_gpio_test: | ||
|
||
Multicore idle GPIO test | ||
######################## | ||
|
||
.. contents:: | ||
:local: | ||
:depth: 2 | ||
|
||
The test benchmarks the idle behavior of an application that runs on multiple cores. | ||
It uses a pin as a wake-up source. | ||
|
||
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 how to build a multicore idle application with :ref:`configuration_system_overview_sysbuild`. | ||
|
||
When building with sysbuild, the build system adds child images based on the options selected in the project's additional configuration and build files. | ||
This test shows how to inform the build system about dedicated sources for additional images. | ||
The test comes with the following additional files: | ||
|
||
* :file:`Kconfig.sysbuild` - This file is used to add :ref:`sysbuild Kconfig options <configuration_system_overview_sysbuild>` that are passed to all the images. | ||
* :file:`sysbuild.cmake` - The CMake file adds additional images using the :c:macro:`ExternalZephyrProject_Add` macro. | ||
You can also add the dependencies for the images if required. | ||
|
||
Both the application and remote cores use the same :file:`main.c` that prints the name of the DK on which the application is programmed. | ||
|
||
Building and running | ||
******************** | ||
|
||
.. |test path| replace:: :file:`tests/benchmarks/multicore/idle_gpio` | ||
|
||
.. include:: /includes/build_and_run_test.txt | ||
|
||
The remote board must be specified using ``SB_CONFIG_REMOTE_BOARD``. | ||
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_gpio.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 low current consumption as all cores are suspended. | ||
#. Press a button to execute the user callback. | ||
The device will remain in active state for 1 second. | ||
|
||
* **Button 0** - Wakes up the application core. | ||
* **Button 1** - Wakes up the radio core. |
35 changes: 35 additions & 0 deletions
35
tests/benchmarks/multicore/idle_gpio/boards/nrf54h20dk_nrf54h20_cpuapp_s2ram.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) 2024 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
/ { | ||
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>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CONFIG_PRINTK=y | ||
CONFIG_LOG=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CONFIG_PM=y | ||
CONFIG_PM_S2RAM=y | ||
CONFIG_POWEROFF=y | ||
CONFIG_PM_S2RAM_CUSTOM_MARKING=y | ||
CONFIG_CONSOLE=n | ||
CONFIG_UART_CONSOLE=n | ||
CONFIG_SERIAL=n | ||
CONFIG_GPIO=y | ||
CONFIG_BOOT_BANNER=n | ||
CONFIG_NRFS_MRAM_SERVICE_ENABLED=n | ||
CONFIG_CLOCK_CONTROL=n |
12 changes: 12 additions & 0 deletions
12
tests/benchmarks/multicore/idle_gpio/remote/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
28 changes: 28 additions & 0 deletions
28
tests/benchmarks/multicore/idle_gpio/remote/boards/nrf54h20dk_nrf54h20_cpurad_s2ram.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
sw1 = &button1; | ||
}; | ||
buttons { | ||
compatible = "gpio-keys"; | ||
button1: button_1 { | ||
gpios = <&gpio0 9 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; | ||
label = "Push button 1"; | ||
zephyr,code = <INPUT_KEY_1>; | ||
}; | ||
}; | ||
}; | ||
|
||
&gpio0 { | ||
status = "okay"; | ||
}; | ||
|
||
&gpiote130 { | ||
status = "okay"; | ||
owned-channels = <1>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CONFIG_PRINTK=y | ||
CONFIG_LOG=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CONFIG_PM=y | ||
CONFIG_POWEROFF=y | ||
CONFIG_CONSOLE=n | ||
CONFIG_UART_CONSOLE=n | ||
CONFIG_SERIAL=n | ||
CONFIG_GPIO=y | ||
CONFIG_BOOT_BANNER=n | ||
CONFIG_NRFS_MRAM_SERVICE_ENABLED=n | ||
CONFIG_CLOCK_CONTROL=n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) 2024 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/logging/log.h> | ||
#include <zephyr/drivers/gpio.h> | ||
#include <zephyr/pm/pm.h> | ||
|
||
|
||
LOG_MODULE_REGISTER(idle_gpio); | ||
|
||
#if IS_ENABLED(CONFIG_SOC_NRF54H20_CPUAPP) | ||
static const struct gpio_dt_spec sw = GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios); | ||
#elif IS_ENABLED(CONFIG_SOC_NRF54H20_CPURAD) | ||
static const struct gpio_dt_spec sw = GPIO_DT_SPEC_GET(DT_ALIAS(sw1), gpios); | ||
#else | ||
#error "Invalid core selected. " | ||
#endif | ||
|
||
static K_SEM_DEFINE(my_gpio_sem, 0, 1); | ||
|
||
void my_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) | ||
{ | ||
LOG_INF("User callback for %s\n", CONFIG_BOARD_TARGET); | ||
k_sem_give(&my_gpio_sem); | ||
} | ||
|
||
static struct gpio_callback gpio_cb; | ||
|
||
int main(void) | ||
{ | ||
unsigned int cnt = 0; | ||
int rc; | ||
const struct device *gpio_dev = DEVICE_DT_GET(DT_NODELABEL(gpio0)); | ||
|
||
if (!device_is_ready(gpio_dev)) { | ||
return -ENODEV; | ||
} | ||
|
||
rc = gpio_pin_configure_dt(&sw, GPIO_INPUT); | ||
if (rc < 0) { | ||
LOG_ERR("Could not configure sw GPIO (%d)\n", rc); | ||
return 0; | ||
} | ||
|
||
rc = gpio_pin_interrupt_configure(sw.port, sw.pin, GPIO_INT_LEVEL_ACTIVE); | ||
if (rc < 0) { | ||
LOG_ERR("Could not configure sw GPIO interrupt (%d)\n", rc); | ||
return 0; | ||
} | ||
gpio_init_callback(&gpio_cb, my_gpio_callback, 0xFFFF); | ||
gpio_add_callback(gpio_dev, &gpio_cb); | ||
LOG_INF("Multicore idle_gpio test on %s", CONFIG_BOARD_TARGET); | ||
while (1) { | ||
LOG_INF("Multicore idle_gpio test iteration %u", cnt++); | ||
if (k_sem_take(&my_gpio_sem, K_FOREVER) != 0) { | ||
LOG_ERR("Failed to take a semaphore"); | ||
return 0; | ||
} | ||
k_busy_wait(1000000); | ||
/* De-bounce when button is used. Reset a semaphores count to 0. */ | ||
k_sem_reset(&my_gpio_sem); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# | ||
# Copyright (c) 2024 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
|
||
if("${SB_CONFIG_REMOTE_BOARD}" STREQUAL "") | ||
message(FATAL_ERROR "REMOTE_BOARD must be set to a valid board name") | ||
endif() | ||
|
||
# Add remote project | ||
ExternalZephyrProject_Add( | ||
APPLICATION remote | ||
SOURCE_DIR ${APP_DIR}/remote | ||
BOARD ${SB_CONFIG_REMOTE_BOARD} | ||
BOARD_REVISION ${BOARD_REVISION} | ||
) | ||
|
||
# Add a dependency so that the remote image will be built and flashed first | ||
add_dependencies(idle_gpio remote) | ||
# Add dependency so that the remote image is flashed first. | ||
sysbuild_add_dependencies(FLASH idle_gpio remote) |
1 change: 1 addition & 0 deletions
1
tests/benchmarks/multicore/idle_gpio/sysbuild/nrf54h20dk_nrf54h20_cpurad.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SB_CONFIG_REMOTE_BOARD="nrf54h20dk/nrf54h20/cpurad" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
common: | ||
sysbuild: true | ||
tags: ci_build ci_tests_benchmarks_multicore | ||
harness_config: | ||
type: multi_line | ||
ordered: true | ||
regex: | ||
- "Multicore idle_gpio test on" | ||
- "Multicore idle_gpio test iteration 0" | ||
|
||
tests: | ||
benchmarks.multicore.idle_gpio.nrf54h20dk_cpuapp_cpurad.s2ram: | ||
platform_allow: | ||
- nrf54h20dk/nrf54h20/cpuapp | ||
integration_platforms: | ||
- nrf54h20dk/nrf54h20/cpuapp | ||
extra_args: | ||
FILE_SUFFIX=s2ram | ||
SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf | ||
DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_s2ram.overlay" | ||
remote_DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpurad_s2ram.overlay" | ||
harness: pytest | ||
harness_config: | ||
fixture: ppk_power_measure | ||
pytest_root: | ||
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_power_consumption_simple" |