When LOG2 is enabled, timestamp func which was just set
according to various conditions, is overwritten using sysclock.
Since sysclock is very fast, it will cause uint32_t to wrap very
fast and cause the time to start over from 0 often.
This commit combines the two statements doing the same thing,
to one statement.
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
Asynchronous API may utilize DMA and significantly reduce
CPU load during outputing to UART.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
A variable is tracking number of buffered messages. This is used
to trigger processing thread in certain cases. Counter was not
handled correctly when message was dropped. In certain cases that
can lead to hanging of log processing.
Added counter decrementation in the callback called whenever
message is dropped.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Remove LOG_MINIMAL kconfig option which was confusing
since LOG_MODE_MINIMAL existed. LOG_MINIMAL was used to
force minimal mode but because of invalid dependencies
it was leading to issues.
Refactored code to use LOG_MODE_MINIMAL everywhere and
renamed LOG_MINIMAL to LOG_DEFAULT_MINIMAL which has impact
on defualt logging mode (which still can be later changed
in conf file or in menuconfig).
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Previously, a `uint32_t` was aliased as an `atomic_t`. However,
with #39531, `atomic_t` is now a `long` under the hood, which
is 64-bit on 64-bit platforms.
Fixes#40369
Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
If source_id is -1, which is a valid value, it will be
converted to unsigned since it's compared with an unsigned
which means it will be huge and asserts will trigger. To avoid
this, we typecast the unsigned part to signed.
Resolves#40115
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
Fixes#39538
RTT_UNLOCK() uses a variable defined in RTT_LOCK() making mandatory
to use both function in the same block
Signed-off-by: Guillaume Lager <g.lager@innoseis.com>
There were some leftovers in logging after attempt to use
logging as tracing backend. Removing all references since it
lead to test compilation failures.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added log_internal.h for internal APIs. Move functions out of
log_core.h. Log_core.h shall have only macros and functions related
to logging message creation. Log_core.h is included by log.h thus
number of dependencies in that headers must be limited to minimum
to allow including without risk of circular dependencies.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Info log messages don't have dedicated color which
makes them harder to separate from debug logs.
Introduce green color in log output for info level
so it stands out like error and warning messages do.
Signed-off-by: Marin Jurjević <marin.jurjevic@hotmail.com>
In order to be able to make a "choice" from any other
Kconfig.defconfig (-ish) file, the choice needs to be named.
This commit names a few choices.
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
Remove littlefs dependency as FS backend works with any file system as
long as it is (manually or automatically) mounted.
Fixes#36851
Signed-off-by: Markus Fuchs <markus.fuchs@ch.sauter-bc.com>
Cleanup and preparation commit for linker script generator.
Zephyr linker scripts provides start and end symbols for each larger
areas in the linker script.
The symbols _image_rom_start and _image_rom_end corresponds to the group
ROMABLE_REGION defined in the ld linker scripts.
The symbols _image_rodata_start and _image_rodata_end is not placed as
independent group but covers common-rom.ld, thread-local-storage.ld,
kobject-rom.ld and snippets-rodata.ld.
This commit align those names and prepares for generation of groups in
linker scripts.
The symbols describing the ROMABLE_REGION will be renamed to:
_image_rom_start -> __rom_region_start
_image_rom_end -> __rom_region_end
The rodata will also use the group symbol notation as:
_image_rodata_start -> __rodata_region_start
_image_rodata_end -> __rodata_region_end
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Remove device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME)
and use DEVICE_DT_GET(DT_CHOSEN(zephyr_console)) to get
chosen "zephyr,console" node.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Rework NCP interface configuration and NCP sample. Remove
CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_DEV_NAME and
CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM Kconfig
options in favor of chosen node zephyr,ot-uart usage.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add the number of strdup buffers currently in use to the
`log strdup_utilization` shell command.
Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
It is mainly for testing purposes where logging is multiple times
reinitialized.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Extract functions which are managing logging sources
and backends into separate file: log_mgmt.
So far those functions were in log_core mixed with functions
specific to log message creation and log processing.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Increase LOG_PROCESS_THREAD_STACK_SIZE for ARCv3 64 bit to
fix failing test
tests/subsys/logging/log_core_additional/logging.add.async
due to stack overflow.
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Added support for conversion from a standard package which contains
pointers to read only strings to fully self-contained (fsc) package.
Fsc package contains all strings associated with the package thus
access to read only strings is not needed to format a string.
In order to allow conversion to fsc package, standard package must
contain locations of all string pointers within the package. Appending
that information is optional and is controlled by flags parameter
which was added to packaging API. If option flag is set then
package contains header, arguments, locations of read only strings and
transient strings (each prefixed with string argument location).
Package header has been extended with field which contains number of
read only string locations.
A function for conversion to fsc package has been added
(cbprintf_fsc_package()).
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
So far the maximum configurable file size was limited to 16KB (2^14).
This might be enough for small partitions on internal flash. For
external QSPI memories however, this is certainly too restrictive.
Change maximum configurable file size to be 1GB, which is 2^30. Such
value will prevent signed integers overflow on 32-bit platforms, while
giving user full flexibility on how big log files should be.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Opened directory descriptor is leaked when returning 1. Fix that by
utilizing goto in function return path.
Fixes: 6b18e6992d ("subsys/loggin/log_backend_fs: added recovery after
file lost")
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Even though it's highly unlikely that a component of time
would ever approach INT_MAX, use the unsigned specifier to mitigate
any unexpected behaviour.
Fixes#36814
Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
FS backend is no different when it comes to producing human readable
timestamp. Allow to select it when FS is the only enabled logging
backend.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Fixes#36667
If you had a single log file with index 0 created and you reboot
the log backend wasn't counting it and was overwiting it.
If you filled that file up before rebooting then it worked as
expected, creating a new file at the next index on each boot.
Signed-off-by: Elliot Revell-Nash <elliot.revell-nash@wdtl.com>
Some commands shell not be present when shell is not acting as
a log backend. Use of them lead to crash in that case.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Add the option to send logs to fs backend using new dictionary
formatting
This can result in much better use of filesystem space
Signed-off-by: Elliot Revell-Nash <elliot.revell-nash@wdtl.com>
Variable "level" in function z_vrfy_log_filter_set() has type unsigned.
But it is been checked if "level >=LOG_LEVEL_NONE" and
LOG_LEVEL_NONE is 0. It means check if unsigned is ">= 0" in Z_OOPS().
That is logically wrong, because unsigned is ">=0" by default.
Remove that check, to avoid static analysis tool raise
violation
Found as a coding guideline violation (MISRA R14.3) by static
coding scanning tool.
Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
The final else {} in the if...else if is missing required
comment (non-empty, ';' is not sufficient). This adds a comment
to comply with CG 15.7.
Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
The final else {} in the if...else if is missing required
comment (non-empty, ';' is not sufficient). This adds a comment
to comply with CG 15.7.
Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
RTT_LOCK/UNLOCK in certain configuration creates code block (curly
braces). In that case variables declared inside are local to that
block. Moved declaration of ret variable before the block. Updated
code to ensure that RTT_LOCK/UNLOCK are in the same code block.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Make custom RTT locking configurable and select it where it is needed.
When using RTT for tracing we want to use the default locking.
Update both segger and tracerecorder modules to support that.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Add panic_mode flag reset to log_core_init(). It allows full logging
reinitialization which is useful for testing.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
OpenThread modified its NCP API, so we need to align with these changes
in Zephyr.
One of the major changes was removal of UART from the platform APIs.
`openthread/platform/uart.h` header file was moved to
`examples/platforms/util/uart.h` so we need to use the new location in
Zephyr. This means that OpenThread no longer impose the UART API but for
the simplicity of the upmerge I've kept the UART APIs as they are for
now.
The NCP initialization function have now to register a send handler,
and the appropriate transport driver have to call NCP callbacks when
transmission/reception is done. For now, re-use the existing code of
the UART driver, just as the upstream NCP application does.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>