Commit graph

18 commits

Author SHA1 Message Date
Johan Hedberg f89c5ddd1a samples: chre: Fix format strings for size_t types
The correct printf format specifier for size_t is %zu. Without this
change the sample generates warnings like this:

warning: format '%u' expects argument of type 'unsigned int', but
argument 2 has type 'size_t' {aka 'long unsigned int'} [-Wformat=]

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2023-11-24 13:10:24 +02:00
Alberto Escolar Piedras 6e2deeebbc samples/modules/chre: Switch from native_posix to native_sim
In the docs replace the references to native_posix with native_sim.
And switch the default test platform to native_sim from native_posix.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-14 13:06:01 +01:00
Keith Packard 6ccdf47f60 lib/cpp: Remove CONFIG_CPP_MAIN
With Zephyr now always using `int main(void)`, there's no longer any need
for this definition. The last remaining use which gated the declaration of
_posix_zephyr_main isn't necessary as adding that declaration
unconditionally is harmless.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-05-31 06:16:35 -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 71255a210d samples/chre: Filter out targets not providing a full libc
When the only C library available is the minimal one, this test cannot
work. Accept only platforms with full C library support to prevent build
failures.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-27 20:18:11 +09:00
Keith Packard bf384bf41a samples/modules/chre: Support picolibc %p for NULL pointers
glibc and newlib print "(nil)" for NULL pointers while picolibc just prints
"0". Allow either by replacing the exact "(nil)" match with ".*" instead

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-01-26 09:12:35 -08:00
Stephanos Ioannidis cf211aa7af treewide: Update deprecated CONFIG_LIB_CPLUSPLUS usages
This commit updates all deprecated `CONFIG_LIB_CPLUSPLUS` usages to:

* check if the Zephyr minimal C++ library is enabled using
  `CONFIG_MINIMAL_LIBCPP` instead of relying on the
  `CONFIG_LIB_CPLUSPLUS`-based inference.

* select `CONFIG_REQUIRES_FULL_LIBCPP` when there exists a component-
  level C++ standard library dependency. This allows a component to
  declare C++ standard library dependency without designating a
  specific libray implementation.

* select the correct type of C++ standard library implementation to use
  through one of the `CONFIG_LIBCPP_IMPLEMENTATION` choices.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05: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
Tom Burdick 89695ddaa3 samples: tag chre sample
Tags the chre sample so it may be ignored for platforms that don't want
to build or run this sample.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-01-10 18:29:35 -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
Fabio Baltieri 2f2eba7517 samples: chre: exclude qemu_leon3
This test used to only run on native_posix due to the test filter until
e478a4e850 was merged. Now it's running on all platforms but it's failing
on qemu_leon3 for some address alignment issue.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-11-24 16:37:49 +01:00
Fabio Baltieri 80e3d68691 samples: chre: use CONFIG_LOG_MODE_MINIMAL
The sample depends on the log output to check for a successful run. This
means that with a small enough log buffer we could lose messages and
fail the run, as it's happening right now on qemu_cortex_m0.

Switching to CONFIG_LOG_MODE_MINIMAL to avoid the problem in the first
place.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-11-24 16:37:49 +01:00
Andrzej Głąbek 1ef35090d0 samples: modules: chre: Flush log messages after initialization
On targets where POST_KERNEL initialization routines, executed after
the logging thread has started, take significant amount of time,
log messages produced during CHRE initialization may collide with
printk messages output by the sample. Prevent this by flushing all
log messages right after the initialization is performed.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-11-23 17:22:16 +00:00
Stephanos Ioannidis d7f69fccc3 samples: chre: Correct main() function prototype
C++ standard requires C++ main() to have the return type of 'int'.

This commit updates the CHRE sample to define main() as
`int main(void)` and enable  `CONFIG_CPP_MAIN`, which instructs the
Zephyr kernel to call the C++ main().

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-11-05 16:41:45 +09: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
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
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
Yuval Peress aaf0c6e827 modules: chre
Add initial build rules for CHRE. This change includes a Kconfig and
CMakeLists.txt to begin compiling code from the CHRE module.
Additional files are included to bridge the APIs from CHRE's to
Zephyr's. These can be found in modules/chre/include and
modules/chre/src.

Additionally, add a sample to make sure that the module builds. It can
be built via:

```
$ west build -b native_posix -p=always samples/application_development/chre
```

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-18 13:21:52 -05:00