From 88db62238cb32d8778fd79028a5b2227c3b9ecf4 Mon Sep 17 00:00:00 2001 From: Piotr Krzyzanowski Date: Thu, 9 Jan 2025 23:54:59 +0100 Subject: [PATCH] tests: benchmarks: multicore: Add leds Add leds indicating particular core activity to simplify the analysis of measurements Signed-off-by: Piotr Krzyzanowski --- .../nrf54h20dk_nrf54h20_cpuapp.overlay} | 17 ++++++----- .../multicore/idle_outside_of_main/prj.conf | 1 - .../remote/CMakeLists.txt | 2 +- .../boards/nrf54h20dk_nrf54h20_cpurad.overlay | 26 +++++++++++++++++ .../idle_outside_of_main/remote/prj.conf | 2 +- .../multicore/idle_outside_of_main/src/main.c | 28 ++++++++++++++++++- .../boards/nrf54h20dk_nrf54h20_cpuapp.overlay | 16 +++++++++++ ...f54h20dk_nrf54h20_cpuapp_fast_p7_0.overlay | 4 +++ .../boards/nrf54h20dk_nrf54h20_cpurad.overlay | 17 +++++++++++ .../multicore/idle_pwm_led/remote/prj.conf | 1 + .../idle_pwm_led/remote/prj_s2ram.conf | 1 + .../multicore/idle_pwm_led/src/main.c | 23 +++++++++------ .../boards/nrf54h20dk_nrf54h20_cpuapp.overlay | 8 ++++++ ...f54h20dk_nrf54h20_cpuapp_fast_p7_1.overlay | 7 +++++ .../boards/nrf54h20dk_nrf54h20_cpurad.overlay | 16 +++++++++++ .../multicore/idle_pwm_loopback/src/main.c | 16 +++++++++++ 16 files changed, 164 insertions(+), 21 deletions(-) rename tests/benchmarks/multicore/idle_outside_of_main/{remote/src/main.c => boards/nrf54h20dk_nrf54h20_cpuapp.overlay} (57%) create mode 100644 tests/benchmarks/multicore/idle_outside_of_main/remote/boards/nrf54h20dk_nrf54h20_cpurad.overlay create mode 100644 tests/benchmarks/multicore/idle_pwm_led/boards/nrf54h20dk_nrf54h20_cpuapp.overlay diff --git a/tests/benchmarks/multicore/idle_outside_of_main/remote/src/main.c b/tests/benchmarks/multicore/idle_outside_of_main/boards/nrf54h20dk_nrf54h20_cpuapp.overlay similarity index 57% rename from tests/benchmarks/multicore/idle_outside_of_main/remote/src/main.c rename to tests/benchmarks/multicore/idle_outside_of_main/boards/nrf54h20dk_nrf54h20_cpuapp.overlay index 744bcbb53cfe..43f62aaf213b 100644 --- a/tests/benchmarks/multicore/idle_outside_of_main/remote/src/main.c +++ b/tests/benchmarks/multicore/idle_outside_of_main/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -4,12 +4,11 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ -#include - -int main(void) -{ - - k_msleep(2000); - - return 0; -} +/ { + aliases { + led = &led0; + /delete-property/ led1; + }; +}; + +/delete-node/ &led1; diff --git a/tests/benchmarks/multicore/idle_outside_of_main/prj.conf b/tests/benchmarks/multicore/idle_outside_of_main/prj.conf index d9e7894c6bf0..faa8eb88a186 100644 --- a/tests/benchmarks/multicore/idle_outside_of_main/prj.conf +++ b/tests/benchmarks/multicore/idle_outside_of_main/prj.conf @@ -12,4 +12,3 @@ CONFIG_PRINTK=n CONFIG_LOG=n CONFIG_CONSOLE=n CONFIG_UART_CONSOLE=n -CONFIG_GPIO=n diff --git a/tests/benchmarks/multicore/idle_outside_of_main/remote/CMakeLists.txt b/tests/benchmarks/multicore/idle_outside_of_main/remote/CMakeLists.txt index 97caab4871c3..3f79e49afb26 100644 --- a/tests/benchmarks/multicore/idle_outside_of_main/remote/CMakeLists.txt +++ b/tests/benchmarks/multicore/idle_outside_of_main/remote/CMakeLists.txt @@ -9,4 +9,4 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(remote) -target_sources(app PRIVATE src/main.c) +target_sources(app PRIVATE ../src/main.c) diff --git a/tests/benchmarks/multicore/idle_outside_of_main/remote/boards/nrf54h20dk_nrf54h20_cpurad.overlay b/tests/benchmarks/multicore/idle_outside_of_main/remote/boards/nrf54h20dk_nrf54h20_cpurad.overlay new file mode 100644 index 000000000000..1c90bf2655a3 --- /dev/null +++ b/tests/benchmarks/multicore/idle_outside_of_main/remote/boards/nrf54h20dk_nrf54h20_cpurad.overlay @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/ { + aliases { + led = &led1; + }; + leds { + compatible = "gpio-leds"; + led1: led_1 { + gpios = <&gpio9 1 GPIO_ACTIVE_HIGH>; + label = "Green LED 1"; + }; + }; +}; + +&gpio9 { + status = "okay"; +}; + +&gpiote130 { + status = "okay"; +}; diff --git a/tests/benchmarks/multicore/idle_outside_of_main/remote/prj.conf b/tests/benchmarks/multicore/idle_outside_of_main/remote/prj.conf index 153d14f104ad..2a78231f8fb7 100644 --- a/tests/benchmarks/multicore/idle_outside_of_main/remote/prj.conf +++ b/tests/benchmarks/multicore/idle_outside_of_main/remote/prj.conf @@ -3,6 +3,6 @@ CONFIG_POWEROFF=y CONFIG_CONSOLE=n CONFIG_UART_CONSOLE=n CONFIG_SERIAL=n -CONFIG_GPIO=n +CONFIG_GPIO=y CONFIG_NCS_BOOT_BANNER=n CONFIG_BOOT_BANNER=n diff --git a/tests/benchmarks/multicore/idle_outside_of_main/src/main.c b/tests/benchmarks/multicore/idle_outside_of_main/src/main.c index 744bcbb53cfe..f901d71ee672 100644 --- a/tests/benchmarks/multicore/idle_outside_of_main/src/main.c +++ b/tests/benchmarks/multicore/idle_outside_of_main/src/main.c @@ -5,11 +5,37 @@ */ #include +#include +#include +#include + + +LOG_MODULE_REGISTER(idle_outside_of_main); + + +static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(led), gpios); + int main(void) { + int rc; - k_msleep(2000); + rc = gpio_is_ready_dt(&led); + if (rc < 0) { + LOG_ERR("GPIO Device not ready (%d)\n", rc); + return 0; + } + rc = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE); + if (rc < 0) { + LOG_ERR("Could not configure led GPIO (%d)\n", rc); + return 0; + } + + gpio_pin_set_dt(&led, 0); + k_msleep(2000); + gpio_pin_set_dt(&led, 1); + k_usleep(5); + gpio_pin_set_dt(&led, 0); return 0; } diff --git a/tests/benchmarks/multicore/idle_pwm_led/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/benchmarks/multicore/idle_pwm_led/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 000000000000..8d95424daee6 --- /dev/null +++ b/tests/benchmarks/multicore/idle_pwm_led/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include + +/ { + aliases { + led = &led0; + /delete-property/ led1; + }; +}; + +/delete-node/ &led1; diff --git a/tests/benchmarks/multicore/idle_pwm_led/boards/nrf54h20dk_nrf54h20_cpuapp_fast_p7_0.overlay b/tests/benchmarks/multicore/idle_pwm_led/boards/nrf54h20dk_nrf54h20_cpuapp_fast_p7_0.overlay index cd26bcf83d33..0529e43ab6c4 100644 --- a/tests/benchmarks/multicore/idle_pwm_led/boards/nrf54h20dk_nrf54h20_cpuapp_fast_p7_0.overlay +++ b/tests/benchmarks/multicore/idle_pwm_led/boards/nrf54h20dk_nrf54h20_cpuapp_fast_p7_0.overlay @@ -8,6 +8,8 @@ / { aliases { + led = &led0; + /delete-property/ led1; pwm-led0 = &pwm120_gpio; }; @@ -19,6 +21,8 @@ }; }; +/delete-node/ &led1; + &pinctrl { /omit-if-no-ref/ pwm120_default: pwm120_default { group1 { diff --git a/tests/benchmarks/multicore/idle_pwm_led/remote/boards/nrf54h20dk_nrf54h20_cpurad.overlay b/tests/benchmarks/multicore/idle_pwm_led/remote/boards/nrf54h20dk_nrf54h20_cpurad.overlay index 5fcd71d3a39c..1dd90464ecda 100644 --- a/tests/benchmarks/multicore/idle_pwm_led/remote/boards/nrf54h20dk_nrf54h20_cpurad.overlay +++ b/tests/benchmarks/multicore/idle_pwm_led/remote/boards/nrf54h20dk_nrf54h20_cpurad.overlay @@ -6,9 +6,18 @@ / { aliases { + led = &led1; pwm-led0 = &pwm_gpio; }; + leds { + compatible = "gpio-leds"; + led1: led_1 { + gpios = <&gpio9 1 GPIO_ACTIVE_HIGH>; + label = "Green LED 1"; + }; + }; + pwmleds { compatible = "pwm-leds"; pwm_gpio: pwm_gpio { @@ -32,6 +41,14 @@ }; }; +&gpio9 { + status = "okay"; +}; + +&gpiote130 { + status = "okay"; +}; + &pwm131 { status = "okay"; pinctrl-0 = <&pwm131_default>; diff --git a/tests/benchmarks/multicore/idle_pwm_led/remote/prj.conf b/tests/benchmarks/multicore/idle_pwm_led/remote/prj.conf index bbe2b1d251b5..936da443e4a7 100644 --- a/tests/benchmarks/multicore/idle_pwm_led/remote/prj.conf +++ b/tests/benchmarks/multicore/idle_pwm_led/remote/prj.conf @@ -1,3 +1,4 @@ CONFIG_PRINTK=y CONFIG_LOG=y CONFIG_PWM=y +CONFIG_GPIO=y diff --git a/tests/benchmarks/multicore/idle_pwm_led/remote/prj_s2ram.conf b/tests/benchmarks/multicore/idle_pwm_led/remote/prj_s2ram.conf index 0563d3ce33d5..4d5a9c6f26f1 100644 --- a/tests/benchmarks/multicore/idle_pwm_led/remote/prj_s2ram.conf +++ b/tests/benchmarks/multicore/idle_pwm_led/remote/prj_s2ram.conf @@ -7,3 +7,4 @@ CONFIG_SERIAL=n CONFIG_BOOT_BANNER=n CONFIG_PWM=y +CONFIG_GPIO=y diff --git a/tests/benchmarks/multicore/idle_pwm_led/src/main.c b/tests/benchmarks/multicore/idle_pwm_led/src/main.c index 3c4d72acebe1..9066c1b20cdd 100644 --- a/tests/benchmarks/multicore/idle_pwm_led/src/main.c +++ b/tests/benchmarks/multicore/idle_pwm_led/src/main.c @@ -9,18 +9,13 @@ LOG_MODULE_REGISTER(idle_pwm_led, LOG_LEVEL_INF); #include #include +#include #include -#if IS_ENABLED(CONFIG_SOC_NRF54H20_CPUAPP_COMMON) -/* Alias pwm-led0 = &pwm_led2 */ +static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(led), gpios); static const struct pwm_dt_spec pwm_led = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led0)); -#elif IS_ENABLED(CONFIG_SOC_NRF54H20_CPURAD_COMMON) -/* Alias pwm-led0 = &pwm_led3 */ -static const struct pwm_dt_spec pwm_led = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led0)); -#else -#error "Invalid core selected." -#endif + #define PWM_STEPS_PER_SEC (50) @@ -35,6 +30,16 @@ int main(void) int32_t pulse_step; uint32_t current_pulse_width; + if (!gpio_is_ready_dt(&led)) { + LOG_ERR("GPIO Device not ready"); + return 0; + } + + if (gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE) != 0) { + LOG_ERR("Could not configure led GPIO"); + return 0; + } + if (!pwm_is_ready_dt(&pwm_led)) { LOG_ERR("Device %s is not ready.", pwm_led.dev->name); return -ENODEV; @@ -110,7 +115,9 @@ int main(void) #endif /* Sleep / enter low power state */ + gpio_pin_set_dt(&led, 0); k_msleep(CONFIG_TEST_SLEEP_DURATION_MS); + gpio_pin_set_dt(&led, 1); } return 0; diff --git a/tests/benchmarks/multicore/idle_pwm_loopback/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/benchmarks/multicore/idle_pwm_loopback/boards/nrf54h20dk_nrf54h20_cpuapp.overlay index 51506a10816a..6d0db37ace0c 100644 --- a/tests/benchmarks/multicore/idle_pwm_loopback/boards/nrf54h20dk_nrf54h20_cpuapp.overlay +++ b/tests/benchmarks/multicore/idle_pwm_loopback/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -13,6 +13,12 @@ */ / { + + aliases { + led = &led0; + /delete-property/ led1; + }; + pwm_to_gpio_loopback: pwm_to_gpio_loopback { compatible = "test-pwm-to-gpio-loopback"; pwms = <&pwm130 0 PWM_USEC(200) PWM_POLARITY_NORMAL>; @@ -20,6 +26,8 @@ }; }; +/delete-node/ &led1; + &pinctrl { /omit-if-no-ref/ pwm130_default: pwm130_default { group1 { diff --git a/tests/benchmarks/multicore/idle_pwm_loopback/boards/nrf54h20dk_nrf54h20_cpuapp_fast_p7_1.overlay b/tests/benchmarks/multicore/idle_pwm_loopback/boards/nrf54h20dk_nrf54h20_cpuapp_fast_p7_1.overlay index 07e2f6e47486..39938da50dd4 100644 --- a/tests/benchmarks/multicore/idle_pwm_loopback/boards/nrf54h20dk_nrf54h20_cpuapp_fast_p7_1.overlay +++ b/tests/benchmarks/multicore/idle_pwm_loopback/boards/nrf54h20dk_nrf54h20_cpuapp_fast_p7_1.overlay @@ -13,6 +13,11 @@ */ / { + aliases { + led = &led0; + /delete-property/ led1; + }; + pwm_to_gpio_loopback: pwm_to_gpio_loopback { compatible = "test-pwm-to-gpio-loopback"; pwms = <&pwm120 1 PWM_USEC(200) PWM_POLARITY_NORMAL>; @@ -20,6 +25,8 @@ }; }; +/delete-node/ &led1; + &pinctrl { /omit-if-no-ref/ pwm120_default: pwm120_default { group1 { diff --git a/tests/benchmarks/multicore/idle_pwm_loopback/remote/boards/nrf54h20dk_nrf54h20_cpurad.overlay b/tests/benchmarks/multicore/idle_pwm_loopback/remote/boards/nrf54h20dk_nrf54h20_cpurad.overlay index f10e4f79f1f7..46faa45926c6 100644 --- a/tests/benchmarks/multicore/idle_pwm_loopback/remote/boards/nrf54h20dk_nrf54h20_cpurad.overlay +++ b/tests/benchmarks/multicore/idle_pwm_loopback/remote/boards/nrf54h20dk_nrf54h20_cpurad.overlay @@ -13,6 +13,18 @@ */ / { + aliases { + led = &led1; + }; + + leds { + compatible = "gpio-leds"; + led1: led_1 { + gpios = <&gpio9 1 GPIO_ACTIVE_HIGH>; + label = "Green LED 1"; + }; + }; + pwm_to_gpio_loopback: pwm_to_gpio_loopback { compatible = "test-pwm-to-gpio-loopback"; pwms = <&pwm131 0 PWM_USEC(200) PWM_POLARITY_NORMAL>; @@ -20,6 +32,10 @@ }; }; +&gpio9 { + status = "okay"; +}; + &pinctrl { /omit-if-no-ref/ pwm131_default: pwm131_default { group1 { diff --git a/tests/benchmarks/multicore/idle_pwm_loopback/src/main.c b/tests/benchmarks/multicore/idle_pwm_loopback/src/main.c index 9f330a66cf71..c64c35621ec9 100644 --- a/tests/benchmarks/multicore/idle_pwm_loopback/src/main.c +++ b/tests/benchmarks/multicore/idle_pwm_loopback/src/main.c @@ -21,6 +21,8 @@ LOG_MODULE_REGISTER(idle_pwm_loop, LOG_LEVEL_INF); #error "Unsupported board: pwm_to_gpio_loopback node is not defined" #endif +static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(led), gpios); + static const struct gpio_dt_spec pin_in = GPIO_DT_SPEC_GET_BY_IDX( DT_NODELABEL(pwm_to_gpio_loopback), gpios, 0); @@ -97,8 +99,20 @@ int main(void) uint32_t tolerance; int ret; + if (!gpio_is_ready_dt(&led)) { + LOG_ERR("GPIO Device not ready"); + return 0; + } + + if (gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE) != 0) { + LOG_ERR("Could not configure led GPIO"); + return 0; + } + #if defined(CONFIG_CLOCK_CONTROL) + gpio_pin_set_dt(&led, 0); k_msleep(1000); + gpio_pin_set_dt(&led, 1); set_global_domain_frequency(); #endif @@ -226,7 +240,9 @@ int main(void) __ASSERT_NO_MSG(low >= edges - tolerance); /* Sleep / enter low power state */ + gpio_pin_set_dt(&led, 0); k_msleep(CONFIG_TEST_SLEEP_DURATION_MS); + gpio_pin_set_dt(&led, 1); } return 0;