samples: net: zperf: Use highest frequency for nRF5340

When running Wi-Fi benchmarks on nRF7002DK use the highest CPU
frequency 128MHz.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
This commit is contained in:
Chaitanya Tata 2024-12-30 19:39:15 +05:30 committed by Benjamin Cabé
commit c456d913dc
3 changed files with 43 additions and 0 deletions

View file

@ -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()

View file

@ -12,6 +12,8 @@
#include <zephyr/usb/usbd.h>
#include <zephyr/net/net_config.h>
LOG_MODULE_REGISTER(zperf, CONFIG_NET_ZPERF_LOG_LEVEL);
#ifdef CONFIG_NET_LOOPBACK_SIMULATE_PACKET_DROP
#include <zephyr/net/loopback.h>
#endif

View file

@ -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 <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <nrfx_clock.h>
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);