Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion boards/nordic/nrf7002dk/nrf5340_cpuapp_common_pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<NRF_PSEL(QSPI_IO3, 0, 16)>;
bias-pull-down;
};

group2 {
psels = <NRF_PSEL(QSPI_CSN, 0, 18)>;
bias-pull-up;
Expand All @@ -73,12 +74,14 @@
<NRF_PSEL(QSPI_IO2, 0, 15)>,
<NRF_PSEL(QSPI_IO3, 0, 16)>;
bias-pull-down;
low-power-enable;
};

group2 {
psels = <NRF_PSEL(QSPI_CSN, 0, 18)>;
bias-pull-up;
low-power-enable;
};
low-power-enable;
};

uart1_default: uart1_default {
Expand Down
99 changes: 99 additions & 0 deletions doc/services/logging/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Summary of the logging features:
- Support for logging floating point variables and long long arguments.
- Built-in copying of transient strings used as arguments.
- Support for multi-domain logging.
- Rate-limited logging macros to prevent log flooding when messages are generated frequently.

Logging API is highly configurable at compile time as well as at run time. Using
Kconfig options (see :ref:`logging_kconfig`) logs can be gradually removed from
Expand Down Expand Up @@ -59,6 +60,16 @@ The warning level also exposes the following additional macro:

- :c:macro:`LOG_WRN_ONCE` for warnings where only the first occurrence is of interest.

Rate-limited logging macros are also available for all severity levels to prevent log flooding:

- ``LOG_X_RATELIMIT`` for rate-limited standard printf-like messages using default rate, e.g. :c:macro:`LOG_ERR_RATELIMIT`.
- ``LOG_X_RATELIMIT_RATE`` for rate-limited standard printf-like messages with custom rate, e.g. :c:macro:`LOG_ERR_RATELIMIT_RATE`.
- ``LOG_HEXDUMP_X_RATELIMIT`` for rate-limited data dumping using default rate, e.g. :c:macro:`LOG_HEXDUMP_WRN_RATELIMIT`.
- ``LOG_HEXDUMP_X_RATELIMIT_RATE`` for rate-limited data dumping with custom rate, e.g. :c:macro:`LOG_HEXDUMP_WRN_RATELIMIT_RATE`.

The convenience macros use the default rate specified by ``CONFIG_LOG_RATELIMIT_INTERVAL_MS``,
while the explicit rate macros take a rate parameter (in milliseconds) that specifies the minimum interval between log messages.

There are two configuration categories: configurations per module and global
configuration. When logging is enabled globally, it works for modules. However,
modules can disable logging locally. Every module can specify its own logging
Expand Down Expand Up @@ -341,6 +352,94 @@ If logs are processed from a thread (user or internal) then it is possible to en
a feature which will wake up processing thread when certain amount of log messages are
buffered (see :kconfig:option:`CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD`).

.. _logging_ratelimited:

Rate-limited logging
********************

Rate-limited logging macros provide a way to prevent log flooding when messages are
generated frequently. These macros ensure that log messages are not output more
frequently than a specified interval, similar to Linux's ``printk_ratelimited``
functionality.

The rate-limited logging system provides two types of macros:

**Convenience macros (using default rate):**
- :c:macro:`LOG_ERR_RATELIMIT` - Rate-limited error messages
- :c:macro:`LOG_WRN_RATELIMIT` - Rate-limited warning messages
- :c:macro:`LOG_INF_RATELIMIT` - Rate-limited info messages
- :c:macro:`LOG_DBG_RATELIMIT` - Rate-limited debug messages
- :c:macro:`LOG_HEXDUMP_ERR_RATELIMIT` - Rate-limited error hexdump
- :c:macro:`LOG_HEXDUMP_WRN_RATELIMIT` - Rate-limited warning hexdump
- :c:macro:`LOG_HEXDUMP_INF_RATELIMIT` - Rate-limited info hexdump
- :c:macro:`LOG_HEXDUMP_DBG_RATELIMIT` - Rate-limited debug hexdump

**Explicit rate macros (with custom rate):**
- :c:macro:`LOG_ERR_RATELIMIT_RATE` - Rate-limited error messages with custom rate
- :c:macro:`LOG_WRN_RATELIMIT_RATE` - Rate-limited warning messages with custom rate
- :c:macro:`LOG_INF_RATELIMIT_RATE` - Rate-limited info messages with custom rate
- :c:macro:`LOG_DBG_RATELIMIT_RATE` - Rate-limited debug messages with custom rate
- :c:macro:`LOG_HEXDUMP_ERR_RATELIMIT_RATE` - Rate-limited error hexdump with custom rate
- :c:macro:`LOG_HEXDUMP_WRN_RATELIMIT_RATE` - Rate-limited warning hexdump with custom rate
- :c:macro:`LOG_HEXDUMP_INF_RATELIMIT_RATE` - Rate-limited info hexdump with custom rate
- :c:macro:`LOG_HEXDUMP_DBG_RATELIMIT_RATE` - Rate-limited debug hexdump with custom rate

The convenience macros use the default rate specified by :kconfig:option:`CONFIG_LOG_RATELIMIT_INTERVAL_MS`
(5000ms by default). The explicit rate macros take a rate parameter (in milliseconds) that specifies
the minimum interval between log messages. The rate limiting is per-macro-call-site, meaning
that each unique call to a rate-limited macro has its own independent rate limit.

Example usage:

.. code-block:: c

#include <zephyr/logging/log.h>
#include <zephyr/kernel.h>

LOG_MODULE_REGISTER(my_module, CONFIG_LOG_DEFAULT_LEVEL);

void process_data(void)
{
/* Convenience macros using default rate (CONFIG_LOG_RATELIMIT_INTERVAL_MS) */
LOG_WRN_RATELIMIT("Data processing warning: %d", error_code);
LOG_ERR_RATELIMIT("Critical error occurred: %s", error_msg);
LOG_INF_RATELIMIT("Processing status: %d items", item_count);
LOG_HEXDUMP_WRN_RATELIMIT(data_buffer, data_len, "Data buffer:");

/* Explicit rate macros with custom intervals */
LOG_WRN_RATELIMIT_RATE(1000, "Fast rate warning: %d", error_code);
LOG_ERR_RATELIMIT_RATE(30000, "Slow rate error: %s", error_msg);
LOG_INF_RATELIMIT_RATE(2000, "Custom rate status: %d items", item_count);
LOG_HEXDUMP_ERR_RATELIMIT_RATE(5000, data_buffer, data_len, "Error data:");
}

Rate-limited logging is particularly useful for:

- Error conditions that might occur frequently but don't need to flood the logs
- Status updates in tight loops or high-frequency callbacks
- Debug information that could overwhelm the logging system
- Network or I/O operations that might fail repeatedly

Configuration
==============

Rate-limited logging can be configured using the following Kconfig options:

- :kconfig:option:`CONFIG_LOG_RATELIMIT` - Master switch to enable/disable rate-limited logging
- :kconfig:option:`CONFIG_LOG_RATELIMIT_INTERVAL_MS` - Default interval for convenience macros (5000ms)

When :kconfig:option:`CONFIG_LOG_RATELIMIT` is disabled, the behavior of rate-limited macros is controlled
by the :kconfig:option:`CONFIG_LOG_RATELIMIT_FALLBACK` choice:

- :kconfig:option:`CONFIG_LOG_RATELIMIT_FALLBACK_LOG` - All rate-limited macros behave as regular logging macros
- :kconfig:option:`CONFIG_LOG_RATELIMIT_FALLBACK_DROP` - All rate-limited macros expand to no-ops (default)

This allows you to control whether rate-limited log macros should always print or be completely
suppressed when rate limiting is not available.

The rate limiting is implemented using static variables and :c:func:`k_uptime_get_32`
to track the last log time for each call site.

.. _logging_panic:

Logging panic
Expand Down
7 changes: 4 additions & 3 deletions drivers/wifi/nrf_wifi/Kconfig.nrfwifi
Original file line number Diff line number Diff line change
Expand Up @@ -748,11 +748,12 @@ config NRF_WIFI_RPU_RECOVERY_PS_ACTIVE_TIMEOUT_MS

config NRF_WIFI_RPU_MIN_TIME_TO_ENTER_SLEEP_MS
int "Minimum idle time to enter sleep in milliseconds"
range 100 5000
default 1000
range 100 40000
default 5000
help
Minimum time the host should de-assert WAKEUP_NOW and let RPU enter
sleep mode, assuming there is no activity.
sleep mode, assuming there is no activity. Please note that higher values
of this value may increase the power consumption.

config NRF_WIFI_RPU_RECOVERY_DEBUG
bool "RPU recovery debug logs"
Expand Down
11 changes: 11 additions & 0 deletions dts/bindings/wifi/nordic,wlan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (c) 2025 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

description: |
Nordic Wi-Fi network interface.

This binding defines a Wi-Fi network interface for Nordic nRF70 series
Wi-Fi chips. The interface is used to identify and name Wi-Fi network
interfaces like wlan0.

compatible: "nordic,wlan"
Loading
Loading