diff --git a/samples/net/zperf/CMakeLists.txt b/samples/net/zperf/CMakeLists.txt index dd1a09bbb22..9b3b5084b39 100644 --- a/samples/net/zperf/CMakeLists.txt +++ b/samples/net/zperf/CMakeLists.txt @@ -26,3 +26,9 @@ endif() if (CONFIG_USB_DEVICE_STACK_NEXT) include(${ZEPHYR_BASE}/samples/subsys/usb/common/common.cmake) endif() + +if (CONFIG_SOC_NRF5340_CPUAPP) + target_sources(app PRIVATE + src/nrf5340_cpu_boost.c + ) +endif() diff --git a/samples/net/zperf/src/main.c b/samples/net/zperf/src/main.c index 86e6ea2f0c1..648adacf223 100644 --- a/samples/net/zperf/src/main.c +++ b/samples/net/zperf/src/main.c @@ -12,6 +12,8 @@ #include #include +LOG_MODULE_REGISTER(zperf, CONFIG_NET_ZPERF_LOG_LEVEL); + #ifdef CONFIG_NET_LOOPBACK_SIMULATE_PACKET_DROP #include #endif diff --git a/samples/net/zperf/src/nrf5340_cpu_boost.c b/samples/net/zperf/src/nrf5340_cpu_boost.c new file mode 100644 index 00000000000..0eff58c32e3 --- /dev/null +++ b/samples/net/zperf/src/nrf5340_cpu_boost.c @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file + * @brief CPU frequency boost for nRF53 series + */ + +#include +#include + +#include + +LOG_MODULE_DECLARE(zperf, CONFIG_NET_ZPERF_LOG_LEVEL); + +static int nrf53_cpu_boost(void) +{ + int err; + + /* For optimal performance, the CPU frequency should be set to 128 MHz */ + err = nrfx_clock_divider_set(NRF_CLOCK_DOMAIN_HFCLK, NRF_CLOCK_HFCLK_DIV_1); + err -= NRFX_ERROR_BASE_NUM; + if (err != 0) { + LOG_WRN("Failed to set 128 MHz: %d", err); + } + + LOG_INF("Starting %s with CPU frequency: %d MHz", CONFIG_BOARD, SystemCoreClock/MHZ(1)); + + return err; +} + +SYS_INIT(nrf53_cpu_boost, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);