diff --git a/applications/nrf_desktop/doc/cpu_meas.rst b/applications/nrf_desktop/doc/cpu_meas.rst index 3ba355eb5a03..6d9a3aef3e95 100644 --- a/applications/nrf_desktop/doc/cpu_meas.rst +++ b/applications/nrf_desktop/doc/cpu_meas.rst @@ -23,8 +23,7 @@ Configuration ************* To enable this module, use the :ref:`CONFIG_DESKTOP_CPU_MEAS_ENABLE ` Kconfig option. -This option selects the :kconfig:option:`CONFIG_CPU_LOAD` option. -The :kconfig:option:`CONFIG_CPU_LOAD` option enables the :ref:`cpu_load` library that is used to perform the measurements. +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. Set the time between subsequent CPU load measurements, in milliseconds, using the :ref:`CONFIG_DESKTOP_CPU_MEAS_PERIOD ` option. diff --git a/applications/nrf_desktop/src/modules/Kconfig.cpu_meas b/applications/nrf_desktop/src/modules/Kconfig.cpu_meas index 69543343b378..24f544ef937b 100644 --- a/applications/nrf_desktop/src/modules/Kconfig.cpu_meas +++ b/applications/nrf_desktop/src/modules/Kconfig.cpu_meas @@ -8,7 +8,7 @@ menu "CPU load measurement" config DESKTOP_CPU_MEAS_ENABLE bool "Enable measuring CPU load" - select CPU_LOAD + select NRF_CPU_LOAD help The CPU load is sent periodically using dedicated application event. diff --git a/applications/nrf_desktop/src/modules/cpu_meas.c b/applications/nrf_desktop/src/modules/cpu_meas.c index 942d95769879..422a79021291 100644 --- a/applications/nrf_desktop/src/modules/cpu_meas.c +++ b/applications/nrf_desktop/src/modules/cpu_meas.c @@ -40,7 +40,7 @@ static void init(void) /* When this option is enabled, CPU load measurement is periodically * resetted. Only cpu_meas module should reset the measurement. */ - BUILD_ASSERT(!IS_ENABLED(CONFIG_CPU_LOAD_LOG_PERIODIC)); + BUILD_ASSERT(!IS_ENABLED(CONFIG_NRF_CPU_LOAD_LOG_PERIODIC)); static bool initialized; diff --git a/doc/nrf/libraries/debug/cpu_load.rst b/doc/nrf/libraries/debug/cpu_load.rst index 69c55602f55d..ccdb0f7484f1 100644 --- a/doc/nrf/libraries/debug/cpu_load.rst +++ b/doc/nrf/libraries/debug/cpu_load.rst @@ -17,7 +17,7 @@ To precisely measure the sleep period, the module requires the POWER peripheral The events are connected to a TIMER peripheral using PPI/DPPI. The sleep period is measured using the TIMER peripheral, which is clocked by default by the high frequency clock. -Alternatively, it can be clocked using low frequency clock (see :kconfig:option:`CONFIG_CPU_LOAD_ALIGNED_CLOCKS`). +Alternatively, it can be clocked using low frequency clock (see :kconfig:option:`CONFIG_NRF_CPU_LOAD_ALIGNED_CLOCKS`). It is then compared against the system clock, which is clocked by the low frequency clock. The accuracy of measurements depends on the accuracy of the given clock sources. diff --git a/doc/nrf/releases_and_maturity/releases/release-notes-3.0.0-preview1.rst b/doc/nrf/releases_and_maturity/releases/release-notes-3.0.0-preview1.rst index 766babd5c0bf..9f0c839940a3 100644 --- a/doc/nrf/releases_and_maturity/releases/release-notes-3.0.0-preview1.rst +++ b/doc/nrf/releases_and_maturity/releases/release-notes-3.0.0-preview1.rst @@ -625,7 +625,9 @@ Common Application Framework Debug libraries --------------- -|no_changes_yet_note| +* :ref:`cpu_load` library: + + * Added prefix ``NRF_`` to all Kconfig options (for example, :kconfig:option:`CONFIG_NRF_CPU_LOAD`) to avoid conflict with Zephyr Kconfig option with the same name. DFU libraries ------------- diff --git a/samples/cellular/modem_trace_backend/Kconfig.trace_print_stats b/samples/cellular/modem_trace_backend/Kconfig.trace_print_stats index 2d2c7ccf3caf..dd666b4e43a0 100644 --- a/samples/cellular/modem_trace_backend/Kconfig.trace_print_stats +++ b/samples/cellular/modem_trace_backend/Kconfig.trace_print_stats @@ -11,7 +11,7 @@ choice NRF_MODEM_LIB_TRACE_BACKEND config NRF_MODEM_LIB_TRACE_BACKEND_CUSTOM bool "Count modem traces and print to terminal" - depends on CPU_LOAD + depends on NRF_CPU_LOAD depends on FPU depends on NEWLIB_LIBC_FLOAT_PRINTF || PICOLIBC_IO_FLOAT help diff --git a/samples/cellular/modem_trace_backend/prj.conf b/samples/cellular/modem_trace_backend/prj.conf index 0ee36afed65d..cc324d6d20fa 100644 --- a/samples/cellular/modem_trace_backend/prj.conf +++ b/samples/cellular/modem_trace_backend/prj.conf @@ -17,6 +17,6 @@ CONFIG_NRF_MODEM_LIB_TRACE=y CONFIG_NRF_MODEM_LIB_TRACE_BACKEND_CUSTOM=y CONFIG_CUSTOM_BACKEND_PRINT_PERIOD_MSEC=500 -CONFIG_CPU_LOAD=y +CONFIG_NRF_CPU_LOAD=y CONFIG_FPU=y CONFIG_PICOLIBC_IO_FLOAT=y diff --git a/subsys/debug/CMakeLists.txt b/subsys/debug/CMakeLists.txt index dd1468146d38..63ab545b9762 100644 --- a/subsys/debug/CMakeLists.txt +++ b/subsys/debug/CMakeLists.txt @@ -4,6 +4,6 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # -add_subdirectory_ifdef(CONFIG_CPU_LOAD cpu_load) +add_subdirectory_ifdef(CONFIG_NRF_CPU_LOAD cpu_load) add_subdirectory_ifdef(CONFIG_ETB_TRACE etb_trace) add_subdirectory_ifdef(CONFIG_PPI_TRACE ppi_trace) diff --git a/subsys/debug/cpu_load/Kconfig b/subsys/debug/cpu_load/Kconfig index 9b6250be6b0a..14e004cd71d7 100644 --- a/subsys/debug/cpu_load/Kconfig +++ b/subsys/debug/cpu_load/Kconfig @@ -4,41 +4,45 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # -menuconfig CPU_LOAD +menuconfig NRF_CPU_LOAD bool "Enable CPU load measurement" - select NRFX_PPI if HAS_HW_NRF_PPI - select NRFX_DPPI if HAS_HW_NRF_DPPIC + select NRFX_GPPI + #select NRFX_PPI if HAS_HW_NRF_PPI + #select NRFX_DPPI if HAS_HW_NRF_DPPIC depends on !SOC_SERIES_NRF51X #Lack of required HW events + depends on !SOC_SERIES_NRF54HX #Lack of required HW events + depends on !RISCV #Lack of required HW events help Enable the CPU load measurement instrumentation. This tool is using - one TIMER peripheral and PPI to perform accurate CPU load measurement. + POWER peripheral events with one TIMER peripheral and PPI to perform + accurate CPU load measurement. -if CPU_LOAD +if NRF_CPU_LOAD -module = CPU_LOAD +module = NRF_CPU_LOAD module-str = CPU load measurement source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config" -config CPU_LOAD_CMDS +config NRF_CPU_LOAD_CMDS bool "Enable shell commands" depends on SHELL default y if LOG -config CPU_LOAD_LOG_PERIODIC +config NRF_CPU_LOAD_LOG_PERIODIC bool "Periodically log current CPU load" help INFO level must be enabled to get the log. -config CPU_LOAD_LOG_INTERVAL +config NRF_CPU_LOAD_LOG_INTERVAL int "Logging interval for CPU load [ms]" - depends on CPU_LOAD_LOG_PERIODIC + depends on NRF_CPU_LOAD_LOG_PERIODIC default 2000 endif # LOG -config CPU_LOAD_ALIGNED_CLOCKS +config NRF_CPU_LOAD_ALIGNED_CLOCKS bool "Enable aligned clock sources" help After enabling this option, the sleep period measurement @@ -50,7 +54,7 @@ config CPU_LOAD_ALIGNED_CLOCKS Enabling this option allows going to low power idle mode because the high frequency clock is not used by this module. -config CPU_LOAD_USE_SHARED_DPPI_CHANNELS +config NRF_CPU_LOAD_USE_SHARED_DPPI_CHANNELS bool "Use shared DPPI channels" depends on HAS_HW_NRF_DPPIC help @@ -64,37 +68,37 @@ config CPU_LOAD_USE_SHARED_DPPI_CHANNELS choice prompt "Timer instance" - default CPU_LOAD_TIMER_2 + default NRF_CPU_LOAD_TIMER_2 -config CPU_LOAD_TIMER_0 +config NRF_CPU_LOAD_TIMER_0 depends on $(dt_nodelabel_has_compat,timer0,$(DT_COMPAT_NORDIC_NRF_TIMER)) bool "Timer 0" select NRFX_TIMER0 -config CPU_LOAD_TIMER_1 +config NRF_CPU_LOAD_TIMER_1 depends on $(dt_nodelabel_has_compat,timer1,$(DT_COMPAT_NORDIC_NRF_TIMER)) bool "Timer 1" select NRFX_TIMER1 -config CPU_LOAD_TIMER_2 +config NRF_CPU_LOAD_TIMER_2 depends on $(dt_nodelabel_has_compat,timer2,$(DT_COMPAT_NORDIC_NRF_TIMER)) bool "Timer 2" select NRFX_TIMER2 -config CPU_LOAD_TIMER_3 +config NRF_CPU_LOAD_TIMER_3 depends on $(dt_nodelabel_has_compat,timer3,$(DT_COMPAT_NORDIC_NRF_TIMER)) bool "Timer 3" select NRFX_TIMER3 -config CPU_LOAD_TIMER_4 +config NRF_CPU_LOAD_TIMER_4 depends on $(dt_nodelabel_has_compat,timer4,$(DT_COMPAT_NORDIC_NRF_TIMER)) bool "Timer 4" select NRFX_TIMER4 endchoice -config CPU_LOAD_TIMER_INSTANCE +config NRF_CPU_LOAD_TIMER_INSTANCE int - default 0 if CPU_LOAD_TIMER_0 - default 1 if CPU_LOAD_TIMER_1 - default 2 if CPU_LOAD_TIMER_2 - default 3 if CPU_LOAD_TIMER_3 - default 4 if CPU_LOAD_TIMER_4 + default 0 if NRF_CPU_LOAD_TIMER_0 + default 1 if NRF_CPU_LOAD_TIMER_1 + default 2 if NRF_CPU_LOAD_TIMER_2 + default 3 if NRF_CPU_LOAD_TIMER_3 + default 4 if NRF_CPU_LOAD_TIMER_4 -endif # CPU_LOAD +endif # NRF_CPU_LOAD diff --git a/subsys/debug/cpu_load/cpu_load.c b/subsys/debug/cpu_load/cpu_load.c index 144e2b0d95a9..6154677d8c44 100644 --- a/subsys/debug/cpu_load/cpu_load.c +++ b/subsys/debug/cpu_load/cpu_load.c @@ -5,11 +5,6 @@ */ #include #include -#ifdef DPPI_PRESENT -#include -#else -#include -#endif #include #include #include @@ -17,7 +12,7 @@ #include #include -LOG_MODULE_REGISTER(cpu_load, CONFIG_CPU_LOAD_LOG_LEVEL); +LOG_MODULE_REGISTER(cpu_load, CONFIG_NRF_CPU_LOAD_LOG_LEVEL); /* Convert event address to associated publish register */ #define PUBLISH_ADDR(evt) (volatile uint32_t *)(evt + 0x80) @@ -26,32 +21,29 @@ LOG_MODULE_REGISTER(cpu_load, CONFIG_CPU_LOAD_LOG_LEVEL); #define CH_INVALID 0xFF /* Define to please compiler when periodic logging is disabled. */ -#ifdef CONFIG_CPU_LOAD_LOG_INTERVAL -#define CPU_LOAD_LOG_INTERVAL CONFIG_CPU_LOAD_LOG_INTERVAL +#ifdef CONFIG_NRF_CPU_LOAD_LOG_INTERVAL +#define CPU_LOAD_LOG_INTERVAL CONFIG_NRF_CPU_LOAD_LOG_INTERVAL #else #define CPU_LOAD_LOG_INTERVAL 0 #endif -static nrfx_timer_t timer = NRFX_TIMER_INSTANCE(CONFIG_CPU_LOAD_TIMER_INSTANCE); +static nrfx_timer_t timer = NRFX_TIMER_INSTANCE(CONFIG_NRF_CPU_LOAD_TIMER_INSTANCE); static bool ready; static struct k_work_delayable cpu_load_log; static uint32_t cycle_ref; static uint32_t shared_ch_mask; #define IS_CH_SHARED(ch) \ - (IS_ENABLED(CONFIG_CPU_LOAD_USE_SHARED_DPPI_CHANNELS) && \ + (IS_ENABLED(CONFIG_NRF_CPU_LOAD_USE_SHARED_DPPI_CHANNELS) && \ (BIT(ch) & shared_ch_mask)) /** @brief Allocate (D)PPI channel. */ static nrfx_err_t ppi_alloc(uint8_t *ch, uint32_t evt) { - nrfx_err_t err; #ifdef DPPI_PRESENT - nrfx_dppi_t dppi = NRFX_DPPI_INSTANCE(0); - if (*PUBLISH_ADDR(evt) != 0) { - if (!IS_ENABLED(CONFIG_CPU_LOAD_USE_SHARED_DPPI_CHANNELS)) { + if (!IS_ENABLED(CONFIG_NRF_CPU_LOAD_USE_SHARED_DPPI_CHANNELS)) { return NRFX_ERROR_BUSY; } /* Use mask of one of subscribe registers in the system, @@ -59,38 +51,30 @@ static nrfx_err_t ppi_alloc(uint8_t *ch, uint32_t evt) * channel id. */ *ch = *PUBLISH_ADDR(evt) & DPPIC_SUBSCRIBE_CHG_EN_CHIDX_Msk; - err = NRFX_SUCCESS; shared_ch_mask |= BIT(*ch); - } else { - err = nrfx_dppi_channel_alloc(&dppi, ch); + return NRFX_SUCCESS; } -#else - err = nrfx_ppi_channel_alloc((nrf_ppi_channel_t *)ch); #endif - return err; + return nrfx_gppi_channel_alloc(ch); } static nrfx_err_t ppi_free(uint8_t ch) { #ifdef DPPI_PRESENT - nrfx_dppi_t dppi = NRFX_DPPI_INSTANCE(0); - - if (!IS_ENABLED(CONFIG_CPU_LOAD_USE_SHARED_DPPI_CHANNELS) - || ((BIT(ch) & shared_ch_mask) == 0)) { - return nrfx_dppi_channel_free(&dppi, ch); - } else { + if (IS_ENABLED(CONFIG_NRF_CPU_LOAD_USE_SHARED_DPPI_CHANNELS) + && ((BIT(ch) & shared_ch_mask) == 0)) { + shared_ch_mask &= ~BIT(ch); return NRFX_SUCCESS; } -#else - return nrfx_ppi_channel_free((nrf_ppi_channel_t)ch); #endif + return nrfx_gppi_channel_free(ch); } static void ppi_cleanup(uint8_t ch_tick, uint8_t ch_sleep, uint8_t ch_wakeup) { nrfx_err_t err = NRFX_SUCCESS; - if (IS_ENABLED(CONFIG_CPU_LOAD_ALIGNED_CLOCKS)) { + if (IS_ENABLED(CONFIG_NRF_CPU_LOAD_ALIGNED_CLOCKS)) { err = ppi_free(ch_tick); } @@ -147,7 +131,7 @@ int cpu_load_init(void) config.frequency = NRFX_MHZ_TO_HZ(1); config.bit_width = NRF_TIMER_BIT_WIDTH_32; - if (IS_ENABLED(CONFIG_CPU_LOAD_ALIGNED_CLOCKS)) { + if (IS_ENABLED(CONFIG_NRF_CPU_LOAD_ALIGNED_CLOCKS)) { /* It's assumed that RTC1 is driving system clock. */ config.mode = NRF_TIMER_MODE_COUNTER; err = ppi_alloc(&ch_tick, @@ -203,7 +187,7 @@ int cpu_load_init(void) cpu_load_reset(); - if (IS_ENABLED(CONFIG_CPU_LOAD_LOG_PERIODIC)) { + if (IS_ENABLED(CONFIG_NRF_CPU_LOAD_LOG_PERIODIC)) { ret = cpu_load_log_init(); if (ret >= 0) { ret = 0; @@ -223,7 +207,7 @@ void cpu_load_reset(void) static uint32_t sleep_ticks_to_us(uint32_t ticks) { - return IS_ENABLED(CONFIG_CPU_LOAD_ALIGNED_CLOCKS) ? + return IS_ENABLED(CONFIG_NRF_CPU_LOAD_ALIGNED_CLOCKS) ? (uint32_t)(((uint64_t)ticks * 1000000) / sys_clock_hw_cycles_per_sec()) : ticks; } @@ -299,5 +283,5 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_cmd_cpu_load, SHELL_SUBCMD_SET_END ); -SHELL_COND_CMD_ARG_REGISTER(CONFIG_CPU_LOAD_CMDS, cpu_load, &sub_cmd_cpu_load, +SHELL_COND_CMD_ARG_REGISTER(CONFIG_NRF_CPU_LOAD_CMDS, cpu_load, &sub_cmd_cpu_load, "CPU load", cmd_cpu_load_get, 1, 1); diff --git a/tests/subsys/debug/cpu_load/prj.conf b/tests/subsys/debug/cpu_load/prj.conf index 03875455ae25..ffce7667349a 100644 --- a/tests/subsys/debug/cpu_load/prj.conf +++ b/tests/subsys/debug/cpu_load/prj.conf @@ -1,4 +1,4 @@ CONFIG_ZTEST=y -CONFIG_CPU_LOAD=y +CONFIG_NRF_CPU_LOAD=y CONFIG_NRFX_TIMER1=y -CONFIG_CPU_LOAD_USE_SHARED_DPPI_CHANNELS=y +CONFIG_NRF_CPU_LOAD_USE_SHARED_DPPI_CHANNELS=y diff --git a/tests/subsys/debug/cpu_load/src/test_cpu_load.c b/tests/subsys/debug/cpu_load/src/test_cpu_load.c index d623c96ee757..dbd85b0164dc 100644 --- a/tests/subsys/debug/cpu_load/src/test_cpu_load.c +++ b/tests/subsys/debug/cpu_load/src/test_cpu_load.c @@ -57,7 +57,7 @@ ZTEST(cpu_load, test_cpu_load) nrfx_gppi_channel_endpoints_setup(ch, evt, tsk); nrfx_gppi_channels_enable(BIT(ch)); - if (!IS_ENABLED(CONFIG_CPU_LOAD_USE_SHARED_DPPI_CHANNELS)) { + if (!IS_ENABLED(CONFIG_NRF_CPU_LOAD_USE_SHARED_DPPI_CHANNELS)) { err = cpu_load_init(); zassert_equal(err, -ENODEV, "Unexpected err:%d", err); diff --git a/tests/subsys/debug/cpu_load/testcase.yaml b/tests/subsys/debug/cpu_load/testcase.yaml index 9ce602ac6769..47f15ab463fd 100644 --- a/tests/subsys/debug/cpu_load/testcase.yaml +++ b/tests/subsys/debug/cpu_load/testcase.yaml @@ -25,4 +25,4 @@ tests: - sysbuild - ci_tests_subsys_debug extra_configs: - - CONFIG_CPU_LOAD_USE_SHARED_DPPI_CHANNELS=y + - CONFIG_NRF_CPU_LOAD_USE_SHARED_DPPI_CHANNELS=y diff --git a/west.yml b/west.yml index 29f48e2004c3..489d52a052a5 100644 --- a/west.yml +++ b/west.yml @@ -65,7 +65,7 @@ manifest: # https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/modules.html - name: zephyr repo-path: sdk-zephyr - revision: c9113a87822e123bd287568c957d92b35502e5d1 + revision: pull/2657/head import: # In addition to the zephyr repository itself, NCS also # imports the contents of zephyr/west.yml at the above