Commit Graph

141 Commits

Author SHA1 Message Date
Andreas Sandberg
8ae5031aa5 samples: Add an SWO logger configuration fragment
The subsys/logging/logger example can be used to demonstrate how to
use SWO for logging. Add a configuration fragment that enables the
logger's SWO backend. The default SWO frequency in this example is set
to 2 MHz to ensure a well-defined output bit rate instead of the
highest possible.

Signed-off-by: Andreas Sandberg <andreas@sandberg.uk>
2023-12-12 10:56:44 +01:00
Hake Huang
27d519b260 samples: logging: disable usermode for rtt platfroms
Those platfroms using rtt as debug port,
are conflicted with usermode. same with
163e9ba9a3

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2023-12-07 21:11:01 +01:00
Alberto Escolar Piedras
b02fc27464 samples/subsys/logging/multidomain: Reduce sysbuild boilerplate
Reduce the sysbuild boilerplate required for
the nrf5340bsim targets

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-12-02 07:53:11 -05:00
Alberto Escolar Piedras
196341c18b samples: Switch integration_platforms from native_posix to native_sim
For all remaining samples which now set their integration platform
as native_posix(_64) switch them to native_sim(_64)

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-20 12:02:48 +01:00
Alberto Escolar Piedras
c6fab4ac77 samples logger multidomain: Add run test for simulated target
Add a runtest for the simulated target.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-27 10:51:36 +02:00
Alberto Escolar Piedras
b9023d3885 samples logger multidomain: Add support for nrf5340bsim
Add support for this sample on the simulated nrf5340

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-27 10:51:36 +02:00
Alberto Escolar Piedras
ee7e6d47d1 samples logger multidomain: Convert to sysbuild
Convert this sample application build to sysbuild.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-27 10:51:36 +02:00
Alberto Escolar Piedras
886d6a9f1f samples subsys logger: Exclude some subtests from posix arch
Two substests (userspace and rtt) cannot be run in the posix
architecture.
Today they are filtered by kconfig, which works but spends
time running cmake.
As native_posix is a default test platform it is better
to filter it alltogether by arch, which saves quite a lot
of time.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-24 09:05:29 +02:00
Benjamin Cabé
4f1cd0e428 doc: Migrate subsys/ code samples to new Sphinx extension
This migrates the subsys code samples to the new Sphinx code-sample
extension, making it easier to find relevant samples when browsing
API reference.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-09-21 09:28:31 +02:00
Witold Lukasik
2530b85932 samples: subsys: logging: logger: remove nRF MDK-based code
k_cycle_get_32() expands to RTC->COUNTER in nrf_rtc_counter_get(),
sys_clock_hw_cycles_per_sec() expands also properly.

Signed-off-by: Witold Lukasik <witold.lukasik@nordicsemi.no>
2023-08-31 20:18:45 +02:00
Ryan McClelland
8023d59509 samples: logging: dictionary: fix double-promotion warning
Double promotion warnings are generated with the flag -Wdouble-promotion

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2023-08-23 16:13:48 -04:00
Florian Grandel
781b6d7b0a samples/doc: segger: rtt: enhanced tracing/logging
Fixes a minor documentation issue and suggests/documents additional RTT
tracing and logging options.

Showcases logging via RTT UART which is now available w/o restrictions
due to the preceding change. This has been tested on CC13/26xx hardware.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-08-06 07:44:06 -04:00
Victor Chavez
bee43bd972 logging: Fixed BLE backend buffer size independent of MTU
The BLE backend has a bug that when the MTU size is less than
the buffer the notification always fails and does not allow
to flush the buffer.

This fix checks for the MTU size of the current connection
and adjusts it. In addition, the buffer size is no longer
settable by the user and depends on the transmission size
of MTU set with CONFIG_BT_L2CAP_TX_MTU.

Signed-off-by: Victor Chavez <chavez-bermudez@fh-aachen.de>
2023-06-19 08:38:08 +02:00
Anas Nashif
b835b02136 tests: cleanup metadata and filtering
- Add integration_platforms to avoid excessive filtering
- Make sure integration platforms are actually part of the filter
- Fix some tags and test meta data

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-06-13 09:38:27 -04:00
Gerard Marull-Paretas
93b63df762 samples, tests: convert string-based twister lists to YAML lists
Twister now supports using YAML lists for all fields that were written
as space-separated lists. Used twister_to_list.py script. Some artifacts
on string length are due to how ruamel dumps content.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-10 09:52:37 +02:00
Keith Packard
973dc2a7a4 samples/logging/syst: Use FULL_LIBC_SUPPORTED helper Kconfig symbol
This symbol detects whether there is any available full libc for a
particular target, allowing tests to filter on this condition.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-27 20:18:11 +09:00
Keith Packard
1d5e644d12 samples, tests: Switch main return type from void to int
This applies the coccinelle script to another set of files:

   samples/bluetooth/bthome_sensor_template/src/main.c
   samples/boards/stm32/power_mgmt/standby_shutdown/src/main.c
   samples/drivers/smbus/src/main.c
   samples/drivers/virtualization/ivshmem/doorbell/src/ivshmem.c
   samples/fuel_gauge/max17048/src/main.c
   samples/hello_world/src/main.c
   samples/sensor/proximity_polling/src/main.c
   samples/subsys/logging/ble_backend/src/main.c
   tests/drivers/build_all/mfd/src/main.c

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-14 07:49:41 +09:00
Keith Packard
0b90fd5adf samples, tests, boards: Switch main return type from void to int
As both C and C++ standards require applications running under an OS to
return 'int', adapt that for Zephyr to align with those standard. This also
eliminates errors when building with clang when not using -ffreestanding,
and reduces the need for compiler flags to silence warnings for both clang
and gcc.

Most of these changes were automated using coccinelle with the following
script:

@@
@@
- void
+ int
main(...) {
	...
-	return;
+	return 0;
	...
}

Approximately 40 files had to be edited by hand as coccinelle was unable to
fix them.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-14 07:49:41 +09:00
Victor Chavez
a18aa915ce logging: Added BLE Backend Service
Added a new logger backend to recieve data over a BLE
notification characteristic.
The characteristic is based on the UUID from the Nordic connect SDK
service NUS, which allows to have a UART shell over BLE.
The idea behind this, is that this logger can be used directly
with the NRF apps or any other BLE UART terminal app.

Signed-off-by: Victor Chavez <chavez-bermudez@fh-aachen.de>
2023-04-03 15:17:57 +02:00
Alberto Escolar Piedras
a2541d6c82 util: Replace all POSIX arch busy_waits with Z_SPIN_DELAY
A new Z_SPIN_DELAY() macro has been added which
can be used to reduce a bit the amount of noise
due to the POSIX arch need to break busy loops with
k_busy_wait().
Use it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-04 22:14:04 +01:00
Stephanos Ioannidis
4a64bfe351 treewide: Use CONFIG_CPP instead of CONFIG_CPLUSPLUS
This commit updates all in-tree code to use `CONFIG_CPP` instead of
`CONFIG_CPLUSPLUS`, which is now deprecated.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05:00
Fabio Baltieri
792469aae9 yamllint: indentation: fix files in samples/
Fix the YAML files indentation for files in samples/.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 14:23:53 +01:00
Nikolay Agishev
5b6f2f4fb6 twister: Add fiters to SYS-T related tests
New filter "TOOLCHAIN_HAS_NEWLIB == 1" was applied
because of following chain of dependencies:
LOG_MIPI_SYST_ENABLE=y --> CONFIG_MIPI_SYST_LIB --> \
--> REQUIRES_FULL_LIBC --> NEWLIB_LIBC.

Not all compillers announced in Zephyr support NewLib.

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2022-10-27 11:03:30 +02:00
Krzysztof Chruscinski
7e71bb7089 samples: subsys: logging: Add multidomain logging sample
Add sample which demonstrates multidomain logging.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-17 10:16:53 +02:00
Krzysztof Chruscinski
e322447109 logging: Initial multidomain support
Adding multidomain support by introducing log_link module which
acts as a receiver of log messages created by another domain.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-17 10:16:53 +02:00
Gerard Marull-Paretas
79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
Anas Nashif
31e0d86484 samples: do not use CONFIG_TEST_EXTRA_STACK_SIZE
samples should not use CONFIG_TEST_EXTRA_STACK_SIZE, instead, they
should set the recommended stack size directly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-08-03 11:22:20 +02:00
Ryan Erickson
fb34a9749f logging: add log_source_id_get
Add API to get the logging module source ID from the
module name;

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2022-07-01 16:30:30 +02:00
Krzysztof Chruscinski
9833ca61c9 logging: Removing v2 suffix from logging names
Renaming objects which had 2 in the name to indicate that
it is v2 specific. Once logging v1 has been removed such
suffixes are redundant.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-23 15:46:37 -04:00
Krzysztof Chruscinski
041f0e5379 all: logging: Remove log_strdup function
Logging v1 has been removed and log_strdup wrapper function is no
longer needed. Removing the function and its use in the tree.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-23 13:42:23 +02:00
Krzysztof Chruscinski
c5f2cdef09 logging: Remove logging v1 from the logging
Remove v1 implementation from log_core and all references in the tree.
Remove modules used by v1: log_list and log_msg.
Remove Kconfig v1 specific options.
Remove Kconfig flags used for distinction between v1 and v2.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-16 10:51:15 -04:00
Krzysztof Chruscinski
85f202744d samples: logging: syst: Remove support for logging v1
Remove references to logging v1.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski
6ec4aba841 samples: logging: logger: Remove logging v1 support
Remove v1 case from the logger sample.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:54:49 -04:00
Keith Packard
de7a944f40 samples/logging: Make logging sample 'main' return int
POSIX main is supposed to return int, and there's no reason not to have
this example do that.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-14 01:50:36 +09:00
Daniel Leung
cf5a6e816d samples: syst: exclude XCC from C++ tests
The logging subsys has evolved to a point where XCC/GCC cannot
compile anymore as it only supports C++98. So exclude C++
samples from build. And just use XCC/Clang instead for C++.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-09 11:34:41 +02:00
Daniel Leung
fbf0fddbe2 samples: logging/syst: exclude XCC from logging v2 tests
XCC does not support _Generic as it is being used by the runtime
tagged argument feature. So exclude them.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-08 09:31:42 -04:00
Daniel Leung
de4f21c75b samples: logging/syst: catalog msg now support 64-bit arch
This adds to the usual qemu_x86_64 and qemu_cortex_a53 to
the entries for Sys-T catalog message in sample.yaml.
As the Sys-T backend has been updated to support 64-bit
for catalog messages.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-08 00:15:55 +09:00
Daniel Leung
fee58e8bf7 samples: logging/syst: convert to use integration_platforms
Convert the remaining platform_allow into
integration_platforms so to be consistent.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-08 00:15:55 +09:00
Anas Nashif
bfe16bdc17 samples: logging: fix filtering in yaml file
integration platforms should not be in common section if we have
scenarios with different set of integration platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 17:25:56 -07:00
Gerard Marull-Paretas
c7b5b3c419 samples: migrate includes to contain <zephyr/...> prefix
In order to bring consistency in-tree, migrate all samples to the use
the new prefix <zephyr/...>. Note that the conversion has been scripted:

```python
from pathlib import Path
import re

EXTENSIONS = ("c", "h", "cpp", "rst")

for p in Path(".").glob("samples/**/*"):
    if not p.is_file() or p.suffix and p.suffix[1:] not in EXTENSIONS:
        continue

    content = ""
    with open(p) as f:
        for line in f:
            m = re.match(r"^(.*)#include <(.*)>(.*)$", line)
            if (m and
                not m.group(2).startswith("zephyr/") and
                (Path(".") / "include" / "zephyr" / m.group(2)).exists()):
                content += (
                    m.group(1) +
                    "#include <zephyr/" + m.group(2) +">" +
                    m.group(3) + "\n"
                )
            else:
                content += line

    with open(p, "w") as f:
        f.write(content)
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 11:29:59 +02:00
Daniel Leung
c5244ffa2b samples: logging/syst: build for C++ too
This extends the samples to build for C++ using the same code.
This shows MIPI Sys-T can work C++ too.

The change to main.c regarding to the struct log_msg_ids is
simply that the compiler errored out complaining the members
must be initialized the same order as the declaration.

Also C++ dislikes a string literal being assigned to char*,
so assign them to const char* instead.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-21 11:38:42 -04:00
Peter Mitsis
195072dcd1 samples: syst: Update sample.yaml
Updates the sample.yaml file to exclude problem architectures
from this sample project. SYS-T does not support 64-bit or
big endian architectures. The posix arch is excluded as it
is generating numerous anomolous runtime messages because it
does have the means to determine when data resides in the
rodata section.

It also converts the list of allowed platforms to lists of
platforms to use for integration testing. This helps to increase
general testing coverage.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-04-20 10:25:16 -04:00
Aastha Grover
7141c8763f sample: syst: Add intel_adsp_cavs support
Adding configurations for enabling this sample project on cavs
platforms. This patch also contains a fix to mipi_syst library
which resolves the memory alignment issue across different
architectures.

Fixes #43344

Signed-off-by: Aastha Grover <aastha.grover@intel.com>
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-04-20 10:25:16 -04:00
Anas Nashif
2d97bdd85d samples: add module requirement into samples
Do not build those samples if the needed modules are not available in
the workspace.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-19 09:38:55 -04:00
Krzysztof Chruscinski
b9a25568aa samples: logging: dictionary: Add frontend support
Extended sample to support UART dictionary frontend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-04-13 13:45:36 -07:00
Daniel Leung
5e9f1722a9 samples: logging/syst: add README
Add a README.rst on how to build the MIPI Sys-T logging sample
and how to parse the output.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-01 13:29:45 +02:00
Daniel Leung
97dd0ec684 samples: logging/syst: build for catalog messages
This adds to sample.yaml to build for MIPI Sys-T catalog message
support.

Note that the current implementation of emitting Sys-T
catalog messages does not support 64-bit and architectures
having additional alignment requirements. So only allow qemu_x86
and mps2_an385 at the moment.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-01 13:29:45 +02:00
Daniel Leung
a3b31149cb samples: syst: allow some 64-bit boards
This adds qemu_x86_64 and qemu_cortex_a53 to make sure 64-bit
support for Sys-T is not broken in the future.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-01 13:29:45 +02:00
Daniel Leung
f7047c4026 samples: logging/syst: update sample for combined strings
Compilers often combine strings to conserve space, if one string is
a perfect substring of another one towards the end. So add another
string in the test to make sure sys-t with catalog messages is still
working correctly under this scenario.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-01 13:29:45 +02:00
Daniel Leung
2e859368bd tests: logging/dictionary: update test for combined strings
Compilers often combine strings to conserve space, if one string is
a perfect substring of another one towards the end. So add another
string in the test to make sure dictionary logging is still working
correctly under this scenario.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-01 13:29:45 +02:00