Use the int_literal_to_timeout Coccinelle script to convert literal
integer arguments for kernel API timeout parameters to the standard
timeout value representations.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Periodically wake up log process thread consume more power if system
already in sleep or deep sleep state. With the help of added logging
timer and semaphore, log process thread is woken up only when there
is logging message.
Signed-off-by: Wentong Wu <wentong.wu@intel.com>
Even though interrupts are locked before processing in synchronous
call, it is still possible that they will be interrupted by NMI.
In that case log_output module may assert because of buffer
overwritting.
Added flushing of log_output buffer before starting the process to
ensure that output buffer is always in reset state at the beginning.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The log mechanism, even in immediate mode, adds somewhere
between 1K-2K of footprint to applications that use it.
We want to standardize the logging APIs for all logging
within the kernel, but need to not let platforms with
very constrained RAM/ROM in the dust.
This patch introduces CONFIG_LOG_MINIMAL, which is a very
thin wrapper to printk(). It supports the APIs expressed
in logging/log.h.
This will be the new default for test cases.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Added CONIFG_LOG_BLOCK_IN_THREAD option to block until buffer for
log message is available. When log message is called in the thread
and there is no buffer available in the pool, thread will block with
configurable timeout (CONFIG_LOG_BLOCK_IN_THREAD_TIMEOUT_MS). If
buffer cannot be allocated by that time, message will be dropped.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
These functions get called from various places and
we were observing linker errors. Always build the stubs
when userspace is disabled, gc-sections will discard them
if unused anyway.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit adds basic userspace support to the logging subsystem.
With this change, the following API could be called from user mode:
- LOG_*()
- LOG_INST_*(),
- LOG_HEXDUMP_*(),
- LOG_HEXDUMP_INST_*(),
- LOG_PANIC(), LOG_PROCESS(),
- log_printk(), log_generic(), log_buffrered_cnt(),
- log_filter_set(NULL, ...)
With userspace disabled, the logger behavior and performance
is not affected. With userspace enabled, the calls from kernel
space have an additional overhead introduced by _is_user_context().
The logger behavior changes when it is called from the user context.
All strings logged using LOG_*() and LOG_INST_*() API from userspace
are rendered in place for security reasons and then placed in
log_strdup() memory pool, which should be large enough to hold bursts
of log messages.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
The number of arguments for a format string is approximated by the
number of conversion specifications. This count may exceed the maximum
supported argument count. Limit the extraction to the available space.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
With the upcoming riscv64 support, it is best to use "riscv" as the
subdirectory name and common symbols as riscv32 and riscv64 support
code is almost identical. Then later decide whether 32-bit or 64-bit
compilation is wanted.
Redirects for the web documentation are also included.
Then zephyrbot complained about this:
"
New files added that are not covered in CODEOWNERS:
dts/riscv/microsemi-miv.dtsi
dts/riscv/riscv32-fe310.dtsi
Please add one or more entries in the CODEOWNERS file to cover
those files
"
So I assigned them to those who created them. Feel free to readjust
as necessary.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Cleaning up log.h include dependencies to allow log.h including in base
headers (e.g. kernel.h).
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The log_backend_swo used system clock frequency
as a base for SWO clock calculation. This commit
corrects that by obtaining the needed value from DTS.
Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
On some SoCs the frequency of the system clock is obtained at run time
as the exact configuration of the hardware is not known at compile time.
On such platforms using CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC define
directly introduces timing errors.
This commit replaces CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC by the call
to inline function sys_clock_hw_cycles_per_sec() which always returns
correct frequency of the system clock.
Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
Simple backends, like UART or RTT, implementation is very similar.
Header has functions which can be reused by simple backends and
remove redundant code.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Logger had false assumption that once log_panic is called then
context switch will never occur and was not protecting against
reentrancy in panic mode. Added interrupt locking when accessing
unprotected part.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move uart.h to drivers/uart.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move atomic.h to sys/atomic.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The conditional CONFIG_RISCV32 was misspelled in is_rodata() resulting
in the test failing all strings that are in RODATA section.
Additionally, it was using wrong section names for riscv.
Fixes#17065
Signed-off-by: David Leach <david.leach@nxp.com>
Log records may store either data or pointers to more records. In both
cases they must have the same size. With 64-bit pointers, the amount
of data that can occupy the same space as a pointer has to be adjusted.
And storage alignment has to accommodate actual pointers not u32_t.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Log arguments were hardcoded to u32_t values. On 64-bit systems, this
is rather restrictive. To make things clear, arguments now have their
own type, log_arg_t, which now can be adjusted in only one location
if need be. It is currently defined as unsigned long whose effective
width is equivalent to u32_t on 32-bit systems, and u64_t on 64-bit
systems.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Detection of missing log_strdup call was applied to every message
while it applies only to standard messages (string + arguments).
Appling it to hexdump messages could lead to fault as seen on
nrf9160_pca10090ns board.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
If argument for log_strdup is from ro memory then there is
no point to duplicate it. This may happen if function logs
variables coming from outside, e.g. function argument.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added CONFIG_LOG_DETECT_MISSED_STRDUP (by default on) which enables
scanning of log message strings in search for %s and reports if
string address is not from strdup buffer pool and outside read only
memory section which indicates that log_strdup() wrapping is missing
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Fedora 30 uses GCC 9.1 which fails to build when loggin is enabled:
zephyr/subsys/logging/log_core.c: In function ‘log_is_strdup’:
zephyr/subsys/logging/log_core.c:665:22:
warning: array subscript -1 is outside array bounds of
‘u8_t[]’ [-Warray-bounds]
665 | ((char *)buf <= pool_last->buf);
| ^~
zephyr/subsys/logging/log_core.c:52:3:
note: while referencing ‘log_strdup_pool_buf’
52 | log_strdup_pool_buf[LOG_STRDUP_POOL_BUFFER_SIZE];
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Added option profiling instrumentation which can help determine
string duplicates pool configuration. Added shell command to
read current peak utilization of the pool.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Drop mode in RTT backend was broken. It is not the default
one so most likely it was unnoticed for a long time. Fixed
to report drop message when logs are lost.
Additionally, added assert to ensure that memmove does not
do memory overwrite.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier. Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.
By default all files without license information are under the default
license of Zephyr, which is Apache version 2.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Rename reserved function names in the subsys/ subdirectory except
for static _mod_pub_set and _mod_unbind functions in bluetooth mesh
cfg_srv.c which clash with the similarly named global functions.
Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
Replaced by the new CONFIG_LOG system.
Also remove the "Logging Options" menu and turn the LOG symbol into a
'menuconfig', with prompt "Logging", which appears in the top menu. LOG
and its dependent symbols make up all of the logging Kconfig symbols
now.
Piggyback some minor cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
RTT backend supports two modes blocking and drop. Apparently,
defines used lead to warning while clang compilation. Define
that caused warning has been changed together with clean up
which removed #ifdefs for definitions.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
If CONFIG_LOG_IMMEDIATE is enabled, then we need to handle
the output strings using a different output function.
The issue was noticed with native_posix board where no syslog
output strings were sent to network.
Fixes#14661
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
And also to the relevant callbacks.
That parameter is not used anywhere so it is useless.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Now that legacy functions are removew, let's rename the new functions by
removing the _new suffix.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Log RTT backed is using mutex for locking access to RTT data.
RTT console (which by default is used by printk) writes to
RTT data directly and it cannot use mutex because it can be
called from any context (including interrupt). If both
modules access RTT buffer 0, data can be corrupted.
This patch forces LOG_PRINTK option if RTT backend is used to
ensure single point of access to RTT buffer 0 data.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Backend was not initialized to work in synchronous mode if LOG_IMMEDIATE
was enabled. That causes use of rtt_lock which uses mutex. That lead to
assert in application.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>