Add a new UF2 runner, supporting only the flash capability.
Searches for FAT partitions containing `INFO_UF2.TXT` files,
and can optionally filter on a matching `Board-ID` value in
that file.
Signed-off-by: Peter Johanson <peter@peterjohanson.com>
Unlike gcc, clang splits out the flag controlling warnings about the return
type of `main' from other warnings related to that function. Add the extra
-Wno-main-return-type flag to mask these warnings when building Zephyr
without -ffreestanding, as when using picolibc.
Signed-off-by: Keith Packard <keithp@keithp.com>
This removes the enforced `-s` option and only passes in a `-gdb` only if
CONFIG_QEMU_GDBSERVER_LISTEN_DEV is set. When unset, it allows users to
utilize QEMU_EXTRA_FLAGS from environment preventing a clash that occurs
if `-s` and `-gdb` are both passed to QEMU invocation.
Signed-off-by: Alp Sayin <alpsayin@gmail.com>
Move extra warning option from generic twister script into
compiler-dependent config files.
ARCMWDT compiler doesn't support extra warning options ex.
"-Wl,--fatal-warnings". To avoid build fails flag
"disable_warnings_as_errors" should be passed to twister.
This allows all warning messages and make atomatic test useles.
Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
nostdinc_include flag needs to contain path to llvm libraries
and remove other relative paths. Change compiler flag to add
default C includes on building C++ code using xcc-clang compiler.
Fixes#54730
Signed-off-by: Aastha Grover <aastha.grover@intel.com>
This avoids a cryptic DTC failure when compiling trying to compile
native_posix with a missing gcc or clang.
REQUIRED is available since CMake 3.18
Example with clang, cryptic error without this commit:
```
ZEPHYR_TOOLCHAIN_VARIANT=llvm west build \
-p -b native_posix samples/hello_world/
-- Found toolchain: host (clang/ld) <= this is wrong
-- Found Dtc: /usr/bin/dtc (found suitable version "1.6.1", minimum ...
-- Found BOARD.dts: zephyr/boards/posix/native_posix/native_posix.dts
CMake Error at /zephyr/cmake/modules/dts.cmake:191 (message):
command failed with return code: No such file or directory
Call Stack (most recent call first):
zephyr/cmake/modules/zephyr_default.cmake:113 (include)
zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boil...
CMakeLists.txt:5 (find_package)
```
Well hidden behind the scenes, dts.cmake fails above because it invokes
`CMAKE_C_COMPILER-NOTFOUND`
With this commit:
```
ZEPHYR_TOOLCHAIN_VARIANT=llvm west build \
-p -b native_posix samples/hello_world/
-- Found toolchain: host (clang/ld) <= this is still wrong
CMake Error at zephyr/cmake/compiler/clang/generic.cmake:7 (find_program):
Could not find CMAKE_C_COMPILER using the following names: clang
```
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Clang does not have printf return value optimizations like GCC, so there's
no flag to turn them off when building against a non-standard printf
implementation (e.g., picolibc without float support).
Signed-off-by: Keith Packard <keithp@keithp.com>
Deprecate old sparse support as Zephyr now provides a proper
infrastructure for SCA tools. Set ZEPHYR_SCA_VARIANT to sparse if user
is using deprecated way.
This allows to cleanup sparse code in various places and thus have a
cleaner build system.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Sparse support was original introduced in #43776.
This commit introduces sparse support as part of Zephyr SCA tool
infrastructure.
The implementation in this commit has some benefits over existing
support:
- It does not required users to set `REAL_CC` in environment before
invoking build command.
This reduces risk of user mistakes, such as
- REAL_CC being different from CMAKE_C_COMPILER.
- User running CMake in one terminal / environment where REAL_CC is
defined but invoking the build command in a different terminal /
environment where REAL_CC is not defined or defined differently.
- It improve user experience as the user no longer has to define /
re-define REAL_CC when building for different architecture, like
switching from arm to xtensa, as this is now handled in CMake.
- CMAKE_C_COMPILER is not overwriting, this can be important for other
tools which calls the C compiler for pre-processing purposes, such
as devicetree and linker script generation.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Static code analyser (SCA) tools are important in software development.
CMake offers built-in support for some tools, such as cppcheck and
clang-tidy.
Other tools, such as sparse, are not directly supported.
This commit provides a uniform way for users to specify a supported
SCA using `ZEPHYR_SCA_VARIANT=<tool>` which is consistent with how
toolchains are specified.
ZEPHYR_SCA_VARIANT can be set using `-D` or in environment.
Support for an SCA tool is done in `cmake/sca/<tool>/sca.cmake`.
SCA_ROOT can be used to specify additional search paths when looking up
implementation for a tool. SCA_ROOT can also be specified in
`zephyr/module.yml` as setting. This makes it possible to provide SCA
tool implementation as part of a Zephyr module.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Add a compiler option to not merge globals. gen_kobject_list.py
is not capable of distinguish addresses of merged objects. The script
itself does not look wrong. The dward specification says that the
attribute DW_AT_location with opcode DW_OP_addr encodes a machine
address and whose size is the size of an address on the target machine
but for merged objects the address is longer, not clear why.
Disable global merge when userspace is enabled to avoid this problem.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Add support for Renode script overlays allowing
to tune simulation parameters for selected samples/tests.
Signed-off-by: Jan Malek <jmalek@internships.antmicro.com>
Signed-off-by: Mateusz Holenko <mholenko@antmicro.com>
When using picolibc from the toolchain, we need to use the standard include
paths to make sure the library headers are found, especially for libstdc++.
Add toolchain picolibc to the list of cases for which this is the case.
Signed-off-by: Keith Packard <keithp@keithp.com>
Update API for zephyr_code_relocate to support cmake generator expressions,
as well as relocating libraries.
zephyr_code_relocate can now accept a target name to the LIBRARY argument,
which will be converted into a set of source files from that
target to relocate.
Alternatively, files can be passed as a space separated list
or CMake generator expression. This allows users more
flexibility when relocating files. Glob matching functionality is still
available, although the preferred method to do this would now be:
file(GLOB relocate_sources "src/*.c")
zephyr_code_relocate(FILES ${relocate_sources} LOCATION <location>)
Note! This commit breaks support for zephyr_code_relocate until in tree
usages of the API are updated to the new format.
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
In some architectures the linker performs global optimization relaxing
address modes and changing intructions in the output object file. This
is a problem when userspace is enabled since it assumes that addresses
won't change after certain build stage. In no supported architectures
this option is ignored.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit updates all in-tree code to use `CONFIG_CPP_EXCEPTIONS`
instead of `CONFIG_EXCEPTIONS`, which is now deprecated.
Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
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>
Fixes: #53696
Create a BOARD_REVISION_CONFIG setting to be consistent with the
BOARD_DEFCONFIG setting.
This allows systems which re-uses the Kconfig module to overrule the
file to be used as BOARD_REVISION_CONFIG in same way as is done for
the BOARD_DEFCONFIG file.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The boards, shields, and zephyr_module CMake modules have some issues
in their comments that can be trivially fixed up.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
This replaces the requirement for applications to manually
register MCUmgr handlers by having an iterable section which
then automatically registers the handlers at boot time.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Different CMake versions can have very subtle differences, for
instance CMake 3.21 links object files in a different order compared
to CMake 3.20; this produces different binaries.
CMAKE_VERSION is required information to track binary differences
between two build systems.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
- Fix commit b2520b09a7 ("devicetree:
drop support for dts_fixup.h files"), which removed support for
shield-related fixups but forgot to update the module-level
documentation comment.
- Fix commit 61453e4a58 ("cmake: Zephyr
CMake package and CMake modules"), which contained some
BOARD-related copy/paste errors and omitted documentation for
the SHIELD_DIRS output variable (this is used in the dts
cmake module, so it's part of the shield module's contract)
- Add some other clarifying remarks and comments
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
The table of contents at the top of the file has 'Devicetree
extensions' as the name of the section containing... those things.
The actual place in the file where they are defined has a different
title, though, defeating searching in the file for that section name.
Fix it.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
"Populate" is ambiguous here: does that mean set, or append? The
answer is "append", so use that to be clearer. Be extra clear where
we're looking in as well.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
PR#51049 deprecated SOURCES but placed it below the
Deprecated_FIND_COMPONENTS check causing following message to be printed
when building for the unit_testing board:
-- The following deprecated component(s) could not be found: SOURCES
Fix this by placing the deprecated SOURCES handling at proper location
and append SOURCES to Deprecated_FIND_COMPONENTS list.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Generates XML file containing VIF policies by reading the device tree
using EDT.pickle generated during build
This script writes a subset of general and sink-pdo VIF policies in
output file
This script gets invoked during build if enabled through kconfig
The generated XML containing USB-C VIF policies could be used by
USB PD/Type-C analysers/testers to understand USB-C properties and
perform tests accordingly
Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com>
Currently we try to manually specify C/C++ headers locations
with -isystem flag which lead to issues with "include_next"
directive which is used in C/C++ headers. As advised by MWDT
R&D team let's rely on the default C/C++ include locations
which are provided by MWDT if we do build with MW C / C++
libraries. For that case we still need to manually specify
header directory to ASM builds which bay use 'stdbool.h'
In case of building with minimal libc (provided by Zephyr)
we rely on minimal libc headers and manually specify
toolchain's C header directory (as minimal libc still uses some
toolchain's C headers.
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Some missing features for getting coverage data for unit tests:
- Setting the unit_testing board to have coverage support and native
application.
- Fixing the CONFIG_COVERAGE check
Signed-off-by: Yuval Peress <peress@google.com>
See also
https://github.com/zephyrproject-rtos/zephyr/pull/38903
This is required when building tests for native_posix on ubuntu 22.04 using
clang-14 from the normal deb repository.
Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
When building with clang, the unittests were giving us an error:
```
error: undefined symbol: llvm_gcda_start_file
```
This seems to be from linking in `gcov` regardless of the toolchain.
It appears that clang doesn't need any special library for coverage.
With this change the following now produce identical coverage reports:
```
$ ZEPHYR_TOOLCHAIN_VARIANT=zephyr ./scripts/twister -p unit_testing \
--coverage -i -T tests/unit/intmath/
$ ZEPHYR_TOOLCHAIN_VARIANT=host ./scripts/twister -p unit_testing \
--coverage -i -T tests/unit/intmath/
$ ZEPHYR_TOOLCHAIN_VARIANT=llvm ./scripts/twister -p unit_testing \
--coverage -i --coverage-tool lcov \
--gcov-tool $(pwd)/scripts/utils/llvm-gcov.sh \
-T tests/unit/intmath/
```
Signed-off-by: Yuval Peress <peress@google.com>
Clang version used by ARCMWDT does not support -fno-pic and -fno-pie
flags.
Flags were added into arcmwdt branch by
commit 8259931fce ("xcc-clang: Do not used unavailable options").
Initially they were set in common CMakeLists.txt via
zephyr_cc_option() function, which filtered them out, and they
did not used in builing process.
Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
The `xtools` toolchain variant (aka. Crosstool-NG) was originally
introduced to be used with the Crosstool-NG-based Zephyr SDK
toolchains (i.e. sdk-ng).
This is no longer necessary because the current Zephyr SDK (sdk-ng)
already has its own `zephyr` toolchain variant, which fully replaces
the `xtools` toolchain variant, and the `xtools` toolchain variant
serves no purpose at all.
Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
Add support for userspace with RTIO by making rtio and rtio_iodev
k_objects. As well as adding three syscalls for copying in submissions,
copying out completions, and starting tasks with submit.
For the small devices Zephyr typically runs on one of the most important
attributes tends to be low memory usage. To maintain the low footprint of
RTIO and its current executor implementations the rings are not shared with
userspace. Sharing the rings it turns out would require copying submissions
before working with them to avoid TOCTOU issues.
The API could still support shared rings in the future so that a
kernel thread could directly poll, copy, verify, and start the submitted
work. This would require a third executor implementation that maintains its
own copy of submissions similiar to how io_uring in Linux works.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
QEMU for NIOS2 and LEON3 do not provide support for the "can-bus" object
type. Skip configuring CAN bus command line arguments for these.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Load image kconfig setting into image target properties.
This allows sysbuild to evaluate and check image configuration as part
of CMake invocation.
sysbuild_get() is updated to support reading of CMake cache or Kconfig
settings for an image.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The signature of import_kconfig() take two mandatory arguments and one
optional:
> import_kconfig(<prefix> <kconfig_fragment> [<keys>])
but has been implemented in such a way that it loops all arguments after
the two mandatory args and sets the same list on those.
Fix this error by only setting the created variables on the third and
optional argument if it exists.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Add support for configuring CAN emulation support in QEMU. For now, the
only supported CAN controller is the single-channel Kvaser PCIcan PCI card.
Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
Fixes: #51821
Set CMAKE_STRIP using `find_program(CMAKE_STRIP strip)` to support
strip when building on native posix.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
If users set SOURCES before find_package for unit tests, we'll warn them
that this code path will no longer be supported and provide the correct
way of doing things moving forward.
Signed-off-by: Yuval Peress <peress@google.com>
Downstream it's easier to write tests that use target_sources after
including the unittest package instead of specifying a list of sources
before. But if we do that, currently, main.c is added and the build
breaks because it doesn't exist.
Signed-off-by: Yuval Peress <peress@google.com>
This adds a choice of three different libc API buffer overflow detection
modes:
* None
* Compile-time
* Compile-time and Run-time
These correspond with the clang/gcc _FORTIFY_SOURCE modes (0/1/2).
_FORTIFY_SOURCE depends on compiler optimizations and require libc support
which the minimal C library doesn't include, so _FORTIFY_SOURCE is disabled
by default in those cases. Native tooling might also enable
_FORTIFY_SOURCE, so don't enable it by default in that case either.
Signed-off-by: Keith Packard <keithp@keithp.com>
Adds an iterable section in ROM to hold constant information, such as
vendor and model name, for all enabled sensor driver instances. This
will be used by the future sensor subsystem to enumerate all available
sensors in the system.
Signed-off-by: Maureen Helm <maureen.helm@intel.com>
GCC will compute expected sprintf (et al) return values internally and use
them in place of the actual return value. When the printf implementation
has reduced functionality, gcc may compute a different value.
For picolibc, this means disabling the optimization unless floating point
output is enabled.
Signed-off-by: Keith Packard <keithp@keithp.com>
Regexp suggested in #50173 PR is too strictly and
needs to be corrected. Previous regexp declines
engineering MWDT versions
(pattern ENG-2022.12-D1039-C39098348").
Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
The whole set of architecture flags must be specified together as
they might not make sense in isolation, e.g. -mfloat-abi=hard requires
a -mcpu value that might have an FPU. Use the NO_SPLIT feature to
bind all of the linker options together so that the linker can
compute the correct linker paths for toolchain-provided libraries like
libc and libgcc.
Signed-off-by: Keith Packard <keithp@keithp.com>