Skip to content

Commit 42e5838

Browse files
nordic-krchrlubos
authored andcommitted
debug: cpu_load: Add NRF_ prefix to CPU load module
Zephyr is getting generic CPU load module and it is using same Kconfig name. NCS CPU load module is Nordic specific because it is using POWER SLEEPENTER,SLEEPEXIT events to track idle state and CPU load. It is also not support on all targets (nrf54h20, nRF54L Series). Add note about added prefix to cpu_load Kconfig options in the changelog. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 6180f1d commit 42e5838

File tree

13 files changed

+60
-50
lines changed

13 files changed

+60
-50
lines changed

applications/nrf_desktop/doc/cpu_meas.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ Configuration
2323
*************
2424

2525
To enable this module, use the :ref:`CONFIG_DESKTOP_CPU_MEAS_ENABLE <config_desktop_app_options>` Kconfig option.
26-
This option selects the :kconfig:option:`CONFIG_CPU_LOAD` option.
27-
The :kconfig:option:`CONFIG_CPU_LOAD` option enables the :ref:`cpu_load` library that is used to perform the measurements.
26+
This option selects the :kconfig:option:`CONFIG_NRF_CPU_LOAD` option, which enables the :ref:`cpu_load` library that is used to perform the measurements.
2827

2928
Set the time between subsequent CPU load measurements, in milliseconds, using the :ref:`CONFIG_DESKTOP_CPU_MEAS_PERIOD <config_desktop_app_options>` option.
3029

applications/nrf_desktop/src/modules/Kconfig.cpu_meas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ menu "CPU load measurement"
88

99
config DESKTOP_CPU_MEAS_ENABLE
1010
bool "Enable measuring CPU load"
11-
select CPU_LOAD
11+
select NRF_CPU_LOAD
1212
help
1313
The CPU load is sent periodically using dedicated application event.
1414

applications/nrf_desktop/src/modules/cpu_meas.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static void init(void)
4040
/* When this option is enabled, CPU load measurement is periodically
4141
* resetted. Only cpu_meas module should reset the measurement.
4242
*/
43-
BUILD_ASSERT(!IS_ENABLED(CONFIG_CPU_LOAD_LOG_PERIODIC));
43+
BUILD_ASSERT(!IS_ENABLED(CONFIG_NRF_CPU_LOAD_LOG_PERIODIC));
4444

4545
static bool initialized;
4646

doc/nrf/libraries/debug/cpu_load.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To precisely measure the sleep period, the module requires the POWER peripheral
1717
The events are connected to a TIMER peripheral using PPI/DPPI.
1818

1919
The sleep period is measured using the TIMER peripheral, which is clocked by default by the high frequency clock.
20-
Alternatively, it can be clocked using low frequency clock (see :kconfig:option:`CONFIG_CPU_LOAD_ALIGNED_CLOCKS`).
20+
Alternatively, it can be clocked using low frequency clock (see :kconfig:option:`CONFIG_NRF_CPU_LOAD_ALIGNED_CLOCKS`).
2121
It is then compared against the system clock, which is clocked by the low frequency clock.
2222
The accuracy of measurements depends on the accuracy of the given clock sources.
2323

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,10 @@ Debug libraries
423423
* Added an experimental :ref:`Zephyr Core Dump <zephyr:coredump>` backend that writes a core dump to an internal flash or RRAM partition.
424424
To enable this backend, set the :kconfig:option:`CONFIG_DEBUG_COREDUMP_BACKEND_OTHER` and :kconfig:option:`CONFIG_DEBUG_COREDUMP_BACKEND_NRF_FLASH_PARTITION` Kconfig options.
425425

426+
* :ref:`cpu_load` library:
427+
428+
* Added prefix ``NRF_`` to all Kconfig options (for example, :kconfig:option:`CONFIG_NRF_CPU_LOAD`) to avoid conflicts with Zephyr Kconfig options with the same names.
429+
426430
DFU libraries
427431
-------------
428432

samples/cellular/modem_trace_backend/Kconfig.trace_print_stats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ choice NRF_MODEM_LIB_TRACE_BACKEND
1111

1212
config NRF_MODEM_LIB_TRACE_BACKEND_CUSTOM
1313
bool "Count modem traces and print to terminal"
14-
depends on CPU_LOAD
14+
depends on NRF_CPU_LOAD
1515
depends on FPU
1616
depends on NEWLIB_LIBC_FLOAT_PRINTF || PICOLIBC_IO_FLOAT
1717
help

samples/cellular/modem_trace_backend/prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ CONFIG_NRF_MODEM_LIB_TRACE=y
1717
CONFIG_NRF_MODEM_LIB_TRACE_BACKEND_CUSTOM=y
1818
CONFIG_CUSTOM_BACKEND_PRINT_PERIOD_MSEC=500
1919

20-
CONFIG_CPU_LOAD=y
20+
CONFIG_NRF_CPU_LOAD=y
2121
CONFIG_FPU=y
2222
CONFIG_PICOLIBC_IO_FLOAT=y

subsys/debug/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
#
66

77
add_subdirectory(coredump)
8-
add_subdirectory_ifdef(CONFIG_CPU_LOAD cpu_load)
8+
add_subdirectory_ifdef(CONFIG_NRF_CPU_LOAD cpu_load)
99
add_subdirectory_ifdef(CONFIG_ETB_TRACE etb_trace)
1010
add_subdirectory_ifdef(CONFIG_PPI_TRACE ppi_trace)

subsys/debug/cpu_load/Kconfig

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,44 @@
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
#
66

7-
menuconfig CPU_LOAD
7+
menuconfig NRF_CPU_LOAD
88
bool "Enable CPU load measurement"
9-
select NRFX_PPI if HAS_HW_NRF_PPI
10-
select NRFX_DPPI if HAS_HW_NRF_DPPIC
11-
depends on !SOC_SERIES_NRF51X #Lack of required HW events
9+
select NRFX_GPPI
10+
depends on !SOC_SERIES_NRF51X # Lack of required HW events
11+
depends on !SOC_SERIES_NRF54HX # Lack of required HW events
12+
depends on !SOC_SERIES_NRF54LX # Not ported
13+
depends on !RISCV # Lack of required HW events
1214
help
1315
Enable the CPU load measurement instrumentation. This tool is using
14-
one TIMER peripheral and PPI to perform accurate CPU load measurement.
16+
POWER peripheral events with one TIMER peripheral and PPI to perform
17+
accurate CPU load measurement.
1518

16-
if CPU_LOAD
19+
if NRF_CPU_LOAD
1720

18-
module = CPU_LOAD
21+
module = NRF_CPU_LOAD
1922
module-str = CPU load measurement
2023
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"
2124

22-
config CPU_LOAD_CMDS
25+
config NRF_CPU_LOAD_CMDS
2326
bool "Enable shell commands"
2427
depends on SHELL
2528
default y
2629

2730
if LOG
2831

29-
config CPU_LOAD_LOG_PERIODIC
32+
config NRF_CPU_LOAD_LOG_PERIODIC
3033
bool "Periodically log current CPU load"
3134
help
3235
INFO level must be enabled to get the log.
3336

34-
config CPU_LOAD_LOG_INTERVAL
37+
config NRF_CPU_LOAD_LOG_INTERVAL
3538
int "Logging interval for CPU load [ms]"
36-
depends on CPU_LOAD_LOG_PERIODIC
39+
depends on NRF_CPU_LOAD_LOG_PERIODIC
3740
default 2000
3841

3942
endif # LOG
4043

41-
config CPU_LOAD_ALIGNED_CLOCKS
44+
config NRF_CPU_LOAD_ALIGNED_CLOCKS
4245
bool "Enable aligned clock sources"
4346
help
4447
After enabling this option, the sleep period measurement
@@ -50,7 +53,7 @@ config CPU_LOAD_ALIGNED_CLOCKS
5053
Enabling this option allows going to low power idle mode
5154
because the high frequency clock is not used by this module.
5255

53-
config CPU_LOAD_USE_SHARED_DPPI_CHANNELS
56+
config NRF_CPU_LOAD_USE_SHARED_DPPI_CHANNELS
5457
bool "Use shared DPPI channels"
5558
depends on HAS_HW_NRF_DPPIC
5659
help
@@ -64,37 +67,41 @@ config CPU_LOAD_USE_SHARED_DPPI_CHANNELS
6467

6568
choice
6669
prompt "Timer instance"
67-
default CPU_LOAD_TIMER_2
70+
default NRF_CPU_LOAD_TIMER_2
6871

69-
config CPU_LOAD_TIMER_0
72+
config NRF_CPU_LOAD_TIMER_0
7073
depends on $(dt_nodelabel_has_compat,timer0,$(DT_COMPAT_NORDIC_NRF_TIMER))
7174
bool "Timer 0"
7275
select NRFX_TIMER0
73-
config CPU_LOAD_TIMER_1
76+
77+
config NRF_CPU_LOAD_TIMER_1
7478
depends on $(dt_nodelabel_has_compat,timer1,$(DT_COMPAT_NORDIC_NRF_TIMER))
7579
bool "Timer 1"
7680
select NRFX_TIMER1
77-
config CPU_LOAD_TIMER_2
81+
82+
config NRF_CPU_LOAD_TIMER_2
7883
depends on $(dt_nodelabel_has_compat,timer2,$(DT_COMPAT_NORDIC_NRF_TIMER))
7984
bool "Timer 2"
8085
select NRFX_TIMER2
81-
config CPU_LOAD_TIMER_3
86+
87+
config NRF_CPU_LOAD_TIMER_3
8288
depends on $(dt_nodelabel_has_compat,timer3,$(DT_COMPAT_NORDIC_NRF_TIMER))
8389
bool "Timer 3"
8490
select NRFX_TIMER3
85-
config CPU_LOAD_TIMER_4
91+
92+
config NRF_CPU_LOAD_TIMER_4
8693
depends on $(dt_nodelabel_has_compat,timer4,$(DT_COMPAT_NORDIC_NRF_TIMER))
8794
bool "Timer 4"
8895
select NRFX_TIMER4
8996

9097
endchoice
9198

92-
config CPU_LOAD_TIMER_INSTANCE
99+
config NRF_CPU_LOAD_TIMER_INSTANCE
93100
int
94-
default 0 if CPU_LOAD_TIMER_0
95-
default 1 if CPU_LOAD_TIMER_1
96-
default 2 if CPU_LOAD_TIMER_2
97-
default 3 if CPU_LOAD_TIMER_3
98-
default 4 if CPU_LOAD_TIMER_4
101+
default 0 if NRF_CPU_LOAD_TIMER_0
102+
default 1 if NRF_CPU_LOAD_TIMER_1
103+
default 2 if NRF_CPU_LOAD_TIMER_2
104+
default 3 if NRF_CPU_LOAD_TIMER_3
105+
default 4 if NRF_CPU_LOAD_TIMER_4
99106

100-
endif # CPU_LOAD
107+
endif # NRF_CPU_LOAD

subsys/debug/cpu_load/cpu_load.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <debug/ppi_trace.h>
1818
#include <zephyr/logging/log.h>
1919

20-
LOG_MODULE_REGISTER(cpu_load, CONFIG_CPU_LOAD_LOG_LEVEL);
20+
LOG_MODULE_REGISTER(cpu_load, CONFIG_NRF_CPU_LOAD_LOG_LEVEL);
2121

2222
/* Convert event address to associated publish register */
2323
#define PUBLISH_ADDR(evt) (volatile uint32_t *)(evt + 0x80)
@@ -26,20 +26,20 @@ LOG_MODULE_REGISTER(cpu_load, CONFIG_CPU_LOAD_LOG_LEVEL);
2626
#define CH_INVALID 0xFF
2727

2828
/* Define to please compiler when periodic logging is disabled. */
29-
#ifdef CONFIG_CPU_LOAD_LOG_INTERVAL
30-
#define CPU_LOAD_LOG_INTERVAL CONFIG_CPU_LOAD_LOG_INTERVAL
29+
#ifdef CONFIG_NRF_CPU_LOAD_LOG_INTERVAL
30+
#define CPU_LOAD_LOG_INTERVAL CONFIG_NRF_CPU_LOAD_LOG_INTERVAL
3131
#else
3232
#define CPU_LOAD_LOG_INTERVAL 0
3333
#endif
3434

35-
static nrfx_timer_t timer = NRFX_TIMER_INSTANCE(CONFIG_CPU_LOAD_TIMER_INSTANCE);
35+
static nrfx_timer_t timer = NRFX_TIMER_INSTANCE(CONFIG_NRF_CPU_LOAD_TIMER_INSTANCE);
3636
static bool ready;
3737
static struct k_work_delayable cpu_load_log;
3838
static uint32_t cycle_ref;
3939
static uint32_t shared_ch_mask;
4040

4141
#define IS_CH_SHARED(ch) \
42-
(IS_ENABLED(CONFIG_CPU_LOAD_USE_SHARED_DPPI_CHANNELS) && \
42+
(IS_ENABLED(CONFIG_NRF_CPU_LOAD_USE_SHARED_DPPI_CHANNELS) && \
4343
(BIT(ch) & shared_ch_mask))
4444

4545

@@ -51,7 +51,7 @@ static nrfx_err_t ppi_alloc(uint8_t *ch, uint32_t evt)
5151
nrfx_dppi_t dppi = NRFX_DPPI_INSTANCE(0);
5252

5353
if (*PUBLISH_ADDR(evt) != 0) {
54-
if (!IS_ENABLED(CONFIG_CPU_LOAD_USE_SHARED_DPPI_CHANNELS)) {
54+
if (!IS_ENABLED(CONFIG_NRF_CPU_LOAD_USE_SHARED_DPPI_CHANNELS)) {
5555
return NRFX_ERROR_BUSY;
5656
}
5757
/* Use mask of one of subscribe registers in the system,
@@ -75,7 +75,7 @@ static nrfx_err_t ppi_free(uint8_t ch)
7575
#ifdef DPPI_PRESENT
7676
nrfx_dppi_t dppi = NRFX_DPPI_INSTANCE(0);
7777

78-
if (!IS_ENABLED(CONFIG_CPU_LOAD_USE_SHARED_DPPI_CHANNELS)
78+
if (!IS_ENABLED(CONFIG_NRF_CPU_LOAD_USE_SHARED_DPPI_CHANNELS)
7979
|| ((BIT(ch) & shared_ch_mask) == 0)) {
8080
return nrfx_dppi_channel_free(&dppi, ch);
8181
} else {
@@ -90,7 +90,7 @@ static void ppi_cleanup(uint8_t ch_tick, uint8_t ch_sleep, uint8_t ch_wakeup)
9090
{
9191
nrfx_err_t err = NRFX_SUCCESS;
9292

93-
if (IS_ENABLED(CONFIG_CPU_LOAD_ALIGNED_CLOCKS)) {
93+
if (IS_ENABLED(CONFIG_NRF_CPU_LOAD_ALIGNED_CLOCKS)) {
9494
err = ppi_free(ch_tick);
9595
}
9696

@@ -147,7 +147,7 @@ int cpu_load_init(void)
147147
config.frequency = NRFX_MHZ_TO_HZ(1);
148148
config.bit_width = NRF_TIMER_BIT_WIDTH_32;
149149

150-
if (IS_ENABLED(CONFIG_CPU_LOAD_ALIGNED_CLOCKS)) {
150+
if (IS_ENABLED(CONFIG_NRF_CPU_LOAD_ALIGNED_CLOCKS)) {
151151
/* It's assumed that RTC1 is driving system clock. */
152152
config.mode = NRF_TIMER_MODE_COUNTER;
153153
err = ppi_alloc(&ch_tick,
@@ -203,7 +203,7 @@ int cpu_load_init(void)
203203

204204
cpu_load_reset();
205205

206-
if (IS_ENABLED(CONFIG_CPU_LOAD_LOG_PERIODIC)) {
206+
if (IS_ENABLED(CONFIG_NRF_CPU_LOAD_LOG_PERIODIC)) {
207207
ret = cpu_load_log_init();
208208
if (ret >= 0) {
209209
ret = 0;
@@ -223,7 +223,7 @@ void cpu_load_reset(void)
223223

224224
static uint32_t sleep_ticks_to_us(uint32_t ticks)
225225
{
226-
return IS_ENABLED(CONFIG_CPU_LOAD_ALIGNED_CLOCKS) ?
226+
return IS_ENABLED(CONFIG_NRF_CPU_LOAD_ALIGNED_CLOCKS) ?
227227
(uint32_t)(((uint64_t)ticks * 1000000) / sys_clock_hw_cycles_per_sec()) :
228228
ticks;
229229
}
@@ -299,5 +299,5 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_cmd_cpu_load,
299299
SHELL_SUBCMD_SET_END
300300
);
301301

302-
SHELL_COND_CMD_ARG_REGISTER(CONFIG_CPU_LOAD_CMDS, cpu_load, &sub_cmd_cpu_load,
302+
SHELL_COND_CMD_ARG_REGISTER(CONFIG_NRF_CPU_LOAD_CMDS, cpu_load, &sub_cmd_cpu_load,
303303
"CPU load", cmd_cpu_load_get, 1, 1);

0 commit comments

Comments
 (0)