-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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: add test kernel_freq_change #19850
Open
nordic-piks
wants to merge
1
commit into
nrfconnect:main
Choose a base branch
from
nordic-piks:kernel_and_freq_changing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+171
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# | ||
# 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(kernel_freq_change) | ||
|
||
FILE(GLOB app_sources src/main.c) | ||
target_sources(app PRIVATE ${app_sources}) |
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,4 @@ | ||
CONFIG_ZTEST=y | ||
CONFIG_NRFS=y | ||
CONFIG_CLOCK_CONTROL=y | ||
CONFIG_ASSERT=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,142 @@ | ||
/* | ||
* Copyright (c) 2024 Nordic Semiconductor ASA | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2025 😄 |
||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/ztest.h> | ||
#include <zephyr/devicetree/clocks.h> | ||
#include <zephyr/drivers/clock_control/nrf_clock_control.h> | ||
|
||
struct timer_data { | ||
int duration_count; | ||
int stop_count; | ||
}; | ||
static void duration_expire(struct k_timer *timer); | ||
static void stop_expire(struct k_timer *timer); | ||
|
||
/** TESTPOINT: init timer via K_TIMER_DEFINE */ | ||
K_TIMER_DEFINE(ktimer, duration_expire, stop_expire); | ||
|
||
static ZTEST_BMEM struct timer_data tdata; | ||
|
||
#define DURATION 100 | ||
#define LESS_DURATION 70 | ||
|
||
|
||
/* | ||
* Set Global Domain frequency (HSFLL120) | ||
*/ | ||
static void set_global_domain_frequency(uint32_t freq_mhz) | ||
{ | ||
int err; | ||
int res; | ||
struct onoff_client cli; | ||
const struct nrf_clock_spec clk_spec_global_hsfll = { | ||
.frequency = freq_mhz | ||
}; | ||
const struct device *hsfll_dev = DEVICE_DT_GET(DT_NODELABEL(hsfll120)); | ||
|
||
TC_PRINT("Requested frequency [Hz]: %d\n", clk_spec_global_hsfll.frequency); | ||
sys_notify_init_spinwait(&cli.notify); | ||
err = nrf_clock_control_request(hsfll_dev, &clk_spec_global_hsfll, &cli); | ||
TC_PRINT("Return code: %d\n", err); | ||
__ASSERT_NO_MSG(err < 3); | ||
__ASSERT_NO_MSG(err >= 0); | ||
do { | ||
err = sys_notify_fetch_result(&cli.notify, &res); | ||
k_yield(); | ||
} while (err == -EAGAIN); | ||
TC_PRINT("Clock control request return value: %d\n", err); | ||
TC_PRINT("Clock control request response code: %d\n", res); | ||
__ASSERT_NO_MSG(err == 0); | ||
__ASSERT_NO_MSG(res == 0); | ||
} | ||
|
||
/* | ||
*help function | ||
*/ | ||
static void duration_expire(struct k_timer *timer) | ||
{ | ||
tdata.duration_count++; | ||
} | ||
|
||
static void stop_expire(struct k_timer *timer) | ||
{ | ||
tdata.stop_count++; | ||
} | ||
|
||
static void init_data_count(void) | ||
{ | ||
tdata.duration_count = 0; | ||
tdata.stop_count = 0; | ||
} | ||
|
||
/** | ||
* @brief Test millisecond time duration | ||
* | ||
* @details initialize a timer, then providing time duration in | ||
* millisecond, and check the duration time whether correct. | ||
* | ||
* @see k_timer_init(), k_timer_start(), k_timer_stop(), | ||
* k_busy_wait() | ||
* | ||
* | ||
*/ | ||
static void test_ms_time_duration(void) | ||
{ | ||
init_data_count(); | ||
k_timer_start(&ktimer, K_MSEC(DURATION), K_NO_WAIT); | ||
|
||
/** TESTPOINT: waiting time less than duration and check the count*/ | ||
k_busy_wait(LESS_DURATION * 1000); | ||
zassert_true(tdata.duration_count == 0); | ||
zassert_true(tdata.stop_count == 0); | ||
|
||
/** TESTPOINT: proving duration in millisecond */ | ||
init_data_count(); | ||
k_timer_start(&ktimer, K_MSEC(100), K_MSEC(50)); | ||
|
||
/** TESTPOINT: waiting time more than duration and check the count */ | ||
k_usleep(1); /* align to tick */ | ||
k_busy_wait((DURATION + 1) * 1000); | ||
zassert_true(tdata.duration_count == 1, "duration %u not 1", | ||
tdata.duration_count); | ||
zassert_true(tdata.stop_count == 0, | ||
"stop %u not 0", tdata.stop_count); | ||
|
||
/** cleanup environment */ | ||
k_timer_stop(&ktimer); | ||
} | ||
|
||
ZTEST(clock, test_ms_time_duration_gd_no_scalling) | ||
{ | ||
test_ms_time_duration(); | ||
} | ||
|
||
ZTEST(clock, test_ms_time_duration_gd_320MHz) | ||
{ | ||
set_global_domain_frequency(MHZ(320)); | ||
test_ms_time_duration(); | ||
} | ||
|
||
ZTEST(clock, test_ms_time_duration_gd_256MHz) | ||
{ | ||
set_global_domain_frequency(MHZ(256)); | ||
test_ms_time_duration(); | ||
} | ||
|
||
ZTEST(clock, test_ms_time_duration_gd_128MHz) | ||
{ | ||
set_global_domain_frequency(MHZ(128)); | ||
test_ms_time_duration(); | ||
} | ||
|
||
ZTEST(clock, test_ms_time_duration_gd_64MHz) | ||
{ | ||
set_global_domain_frequency(MHZ(64)); | ||
test_ms_time_duration(); | ||
} | ||
|
||
ZTEST_SUITE(clock, NULL, NULL, NULL, NULL, NULL); |
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 @@ | ||
common: | ||
tags: | ||
- ci_tests_benchmarks_peripheral_load | ||
harness: ztest | ||
|
||
tests: | ||
benchmarks.kernel_freq_change: | ||
platform_allow: | ||
- nrf54h20dk/nrf54h20/cpuapp | ||
- nrf54h20dk/nrf54h20/cpurad | ||
integration_platforms: | ||
- nrf54h20dk/nrf54h20/cpuapp | ||
Check warning on line 12 in tests/benchmarks/kernel_freq_change/testcase.yaml GitHub Actions / Run compliance checks on patch series (PR)YAMLLint (new-line-at-end-of-file)
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2025 😄