Skip to content

Commit

Permalink
tests: benchmarks: multicore: Add leds
Browse files Browse the repository at this point in the history
Add leds indicating particular core activity
to simplify the analysis of measurements

Signed-off-by: Piotr Krzyzanowski <[email protected]>
(cherry picked from commit 750ddf4)
  • Loading branch information
nordic-pikr authored and bjarki-andreasen committed Jan 13, 2025
1 parent c183191 commit 19a3df8
Show file tree
Hide file tree
Showing 78 changed files with 489 additions and 112 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/ {
aliases {
/delete-property/ led1;
};
};

/delete-node/ &led1;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if(SB_CONFIG_SOC_NRF54H20)
# Add remote project
ExternalZephyrProject_Add(
APPLICATION remote
SOURCE_DIR ${SYSBUILD_NRF_MODULE_DIR}/tests/benchmarks/power_consumption/common/remote_sleep_forever
SOURCE_DIR ${ZEPHYR_NRF_MODULE_DIR}/tests/benchmarks/power_consumption/common/remote_sleep_forever
BOARD ${SB_CONFIG_REMOTE_BOARD}
BOARD_REVISION ${BOARD_REVISION}
)
Expand Down
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
*/

#include <zephyr/dt-bindings/gpio/nordic-nrf-gpio.h>

/ {

aliases {
led = &led0;
/delete-property/ led1;
};

};

/delete-node/ &led1;
1 change: 0 additions & 1 deletion tests/benchmarks/multicore/idle_hpu_temp_meas/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y
CONFIG_POWEROFF=y

CONFIG_GPIO=n
CONFIG_BOOT_BANNER=n

CONFIG_ASSERT=y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif()
# Add remote project
ExternalZephyrProject_Add(
APPLICATION remote
SOURCE_DIR ${SYSBUILD_NRF_MODULE_DIR}/tests/benchmarks/power_consumption/common/remote_sleep_forever
SOURCE_DIR ${ZEPHYR_NRF_MODULE_DIR}/tests/benchmarks/power_consumption/common/remote_sleep_forever
BOARD ${SB_CONFIG_REMOTE_BOARD}
BOARD_REVISION ${BOARD_REVISION}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include <zephyr/kernel.h>

int main(void)
{

k_msleep(2000);

return 0;
}
/ {
aliases {
led = &led0;
/delete-property/ led1;
};
};

/delete-node/ &led1;
1 change: 0 additions & 1 deletion tests/benchmarks/multicore/idle_outside_of_main/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ CONFIG_PRINTK=n
CONFIG_LOG=n
CONFIG_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_GPIO=n
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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
*/

/ {
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";
};
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 14 additions & 1 deletion tests/benchmarks/multicore/idle_outside_of_main/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,24 @@
*/

#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/pm/pm.h>

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 ret;

ret = gpio_is_ready_dt(&led);
__ASSERT(ret, "Error: GPIO Device not ready");

k_msleep(2000);
ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
__ASSERT(ret == 0, "Could not configure led GPIO");

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include <zephyr/dt-bindings/pwm/pwm.h>

/ {
aliases {
led = &led0;
/delete-property/ led1;
};
};

/delete-node/ &led1;
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/ {
aliases {
led = &led0;
/delete-property/ led1;
pwm-led0 = &pwm120_gpio;
};

Expand All @@ -19,6 +21,8 @@
};
};

/delete-node/ &led1;

&pinctrl {
/omit-if-no-ref/ pwm120_default: pwm120_default {
group1 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -32,6 +41,14 @@
};
};

&gpio9 {
status = "okay";
};

&gpiote130 {
status = "okay";
};

&pwm131 {
status = "okay";
pinctrl-0 = <&pwm131_default>;
Expand Down
1 change: 1 addition & 0 deletions tests/benchmarks/multicore/idle_pwm_led/remote/prj.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CONFIG_PRINTK=y
CONFIG_LOG=y
CONFIG_PWM=y
CONFIG_GPIO=y
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ CONFIG_SERIAL=n
CONFIG_BOOT_BANNER=n

CONFIG_PWM=y
CONFIG_GPIO=y
23 changes: 15 additions & 8 deletions tests/benchmarks/multicore/idle_pwm_led/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ LOG_MODULE_REGISTER(idle_pwm_led, LOG_LEVEL_INF);

#include <zephyr/kernel.h>
#include <zephyr/drivers/pwm.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/pm/device_runtime.h>


#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)

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@
*/

/ {

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>;
gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>;
};
};

/delete-node/ &led1;

&pinctrl {
/omit-if-no-ref/ pwm130_default: pwm130_default {
group1 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@
*/

/ {
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>;
gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
};
};

/delete-node/ &led1;

&pinctrl {
/omit-if-no-ref/ pwm120_default: pwm120_default {
group1 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,29 @@
*/

/ {
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>;
gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>;
};
};

&gpio9 {
status = "okay";
};

&pinctrl {
/omit-if-no-ref/ pwm131_default: pwm131_default {
group1 {
Expand Down
13 changes: 13 additions & 0 deletions tests/benchmarks/multicore/idle_pwm_loopback/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -97,9 +99,18 @@ int main(void)
uint32_t tolerance;
int ret;

ret = gpio_is_ready_dt(&led);
__ASSERT(ret, "Error: GPIO Device not ready");

#if defined(CONFIG_CLOCK_CONTROL)
ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_INACTIVE);
__ASSERT(ret == 0, "Could not configure led GPIO");
k_msleep(1000);
gpio_pin_set_dt(&led, 1);
set_global_domain_frequency();
#else
ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
__ASSERT(ret == 0, "Could not configure led GPIO");
#endif

/* Set PWM fill ratio to 50% */
Expand Down Expand Up @@ -226,7 +237,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;
Expand Down
10 changes: 0 additions & 10 deletions tests/benchmarks/multicore/idle_spim/Kconfig.sysbuild

This file was deleted.

Loading

0 comments on commit 19a3df8

Please sign in to comment.