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>
Ensure that QEMU_PIPE variable is set when using sysbuild. This is required
because twister will use the "main" sysbuild application as the target for
"ninja run" when testing QEMU targets, which means that the "main" build
must be aware of any QEMU_PIPE setting passed by twister at build time.
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Make sure the linker knows what the target is, in case it needs to find
additional target-specific libraries (like picolibc).
Signed-off-by: Keith Packard <keithp@keithp.com>
Update cmake related files that are used by simulators to use
CONFIG_MP_MAX_NUM_CPUS instead of CONFIG_MP_NUM_CPUS as we work to
phase out CONFIG_MP_NUM_CPUS.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
The commit f10fa0dea8 mapped the
Cortex-R52 processor type to use the "VFPv3" FPU type, but the
toolchain requires the "FPv5" FPU type and refuses to assemble
floating-point instructions when the "VFPv3" FPU type is specified.
This commit updates the build script to specify the FPU type of
`fpv5-sp-d16` when the processor is configured with a single-precision
FPU, and `neon-fp-armv8` when the processor is configured with a
double-precision + Advanced SIMD-capable FPU.
Note that the `fp-armv8` FPU type is an alias for double-precision FPv5
with 32 double-precision registers (refer to the GCC
`gcc/config/arm/arm-cpus.in` for more details); NEON is always
specified in case of a double-precision configuration because the
Cortex-R52 can only be configured as such.
Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
Introduce a `test_sysbuild()` function.
This function is intended to be used by samples that are dependent on
sysbuild. This function allows such samples to test if sysbuild was used
in the build process, and when sysbuild is not used, then print a
warning to the user, or even fail the build.
This is useful for samples that have two parts to function properly, for
example samples that needs to be build and flash on two or more cores.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit introduces the possibility of a sample to locate
configuration files for extra images that are used when building with
MCUboot.
This allows use-cases where a sample, A, want to include MCUboot but has
adjustments to the default MCUboot configuration.
By adding a Kconfig fragment `<sample>/sysbuild/mcuboot.conf`, then that
fragment will be used together with the default configuration for
MCUboot.
It is also possible to completely replace the MCUboot configuration.
This is done by creating `<sample>/sysbuild/mcuboot/` folder.
This folder will then be used as the `APPLICATION_CONFIG_DIR` when
building MCUboot.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Support referencing module directories by name in CONF_FILE,
OVERLAY_CONFIG, and DTC_OVERLAY_FILE so that projects can reference
overlay files in arbitrary modules.
Verified by passing all the following tests:
./scripts/twister -T tests/cmake/overlays/
Fixes#41830
Signed-off-by: Gregory Shue <gregory.shue@legrand.us>
The `ARCH` init level was added to solve a specific problem, call init
code (SYS_INIT/devices) before `z_cstart` in the `intel_adsp` platform.
The documentation claims it runs before `z_cstart`, but this is only
true if the SoC/arch takes care of calling:
```c
z_sys_init_run_level(_SYS_INIT_LEVEL_ARCH);
```
Which is only true for `intel_adsp` nowadays. So in practice, we now
have a platform specific init level. This patch proposes to do things in
a slightly different way. First, level name is renamed to `EARLY`, to
emphasize it runs in the early stage of the boot process. Then, it is
handled by the Kernel (inside `z_cstart()` before calling
`arch_kernel_init()`). This means that any platform can now use this
level. For `intel_adsp`, there should be no changes, other than
`gcov_static_init()` will be called before (I assume this will allow to
obtain coverage for code called in EARLY?).
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
We have cases where some devices needs to be initialized very early and
before c_start is call, i.e. to setup very early console or to setup
memory. Traditionally this would be hardcoded as part of the soc layer
and not using device model or the init levels.
This patch adds a new level ARCH, which will be called in early
architecture code and before we jump to the kernel code.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Clang 15 added a new warning type `-Wdeprecated-non-prototype` that
warns about the functions without prototypes, which have been
deprecated since the C89 and will not work in the upcoming C2x.
This commit disables the warning because Zephyr deliberately makes use
of the functions without prototypes to allow the use of a "generic"
function pointer (notoriously in the cbprintf implementation) and
Zephyr will not move to the C2x in the foreseeable future.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
It's useful for RAMABLE_REGION to have a uniform name when
CODE_DATA_RELOCATION is supported, because otherwise the build system
needs to be aware of how the region name differs between architectures.
Since architectures tend to prefer one of 'SRAM' or 'RAM' for that
region, prefer to use 'RAM' as the more general term.
Signed-off-by: Peter Marheine <pmarheine@chromium.org>
This commit removes the `k_mem_pool` section for the memory pool API,
which was removed in the v2.5.0 release.
Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
Fixes: #45270
Zephyr Kconfig defines the settings BIG_ENDIAN.
Propagate this setting to the corresponding CMAKE_C_BYTE_ORDER and
CMAKE_CXX_BYTE_ORDER variables.
This also ensures that the CMake function 'is_big_endian()' reports the
correct endianess.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #49587
Try to detect sysroot for cross-compile toolchain if not specified by
the user with `-DSYSROOT_DIR=<path>`.
First, the C compiler is asked if it knows its sysroot, some C compilers
are able to return the sysroot, as an example:
> $ arm-none-eabi-gcc -print-sysroot
> <path>/bin/../arm-none-eabi
> $
but majority of gcc-based C compilers seems to return empty string:
> $ arm-zephyr-eabi-gcc --print-sysroot
> $
in such cases, the cross-compiler target CMake file will try to discover
the sysroot by searching for libc.a, starting one level up from the
compiler location.
If no sysroot candidate is found, a warning will be printed to the user.
If a single sysroot candidate is found, this candidate will be selected.
If multiply sysroot candidates are found, a warning is printed, and the
first candiate in the list is selected. User may select another
candidate with `-DSYSROOT_DIR=<use-this>`.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #49116
During development of out-of-tree boards and applications it is not
uncommon to refactor / restructure code.
To allow developers more freedom, let's check that board's defconfig
still exists during a CMake re-run.
If the defconfig no longer exists, either because it's been moved or
deleted, then warn the user and set BOARD_DIR to NOTFOUND.
The NOTFOUND will request CMake to search for the new location in all
board roots. If the board has not been found, as example it's deleted,
then the existing error is printed later.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes commit 7a85ff7683 ("add sparse support")
The sparse build needs (at least) two things:
1. sparse to be in the PATH
2. the environment variable REAL_CC to be defined and to match the
value expected by CMake
Fix error messages when either condition is wrong.
- New error message when 1. is not satisfied:
```
CMake Error at zephyr/cmake/compiler/gcc/target.cmake:12 (find_program):
Could not find CMAKE_C_COMPILER using the following names: cgcc
```
- Previous error "message" when 1. is not satisfied:
```
CMake Error at zephyr/cmake/compiler/gcc/target.cmake:17 (message):
C compiler
ZSDK/xtensa-intel_s1000_zephyr-elf/bin/xtensa-intel_s1000_zephyr-elf-gcc
not found - Please check your toolchain installation
```
Note the "not found" cross-compiler actually exists!
- New error message when 2. is not satisfied:
```
Kconfig header saved to 'ws/build-tgl/zephyr/include/generated/autoconf.h'
-- Found sparse: /home/user/sparse/cgcc
CMake Error at ws/zephyr/cmake/compiler/gcc/target.cmake:25 (message):
The only way to override its 'cc' default when cross-compiling with
sparse is unfortunately an environment variable. So you _must_ set
REAL_CC at both configuration time and build time to:
$ZSDK/xtensa-intel_s1000_zephyr-elf/bin/xtensa-intel_s1000_zephyr-elf-gcc
```
- Previous error "message" when 2. is not satisfied:
```
modules/hal/xtensa/include/xtensa/config/core.h:54:10:
error:unable to open 'core-isa.h'`
```
Also: stop using the same name REAL_CC for both the internal CMake
variable and the external sparse parameter; they're two different
things so name them differently. Environment variable messes are
complicated enough.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
After recent changes Zephyr became incompatible with old
MWDT versions (older than 2022.06).
Version checking may help to avoid build errors
related this incompatibility.
Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
Fixes: #47588
Use `check_set_compiler_property(... "SHELL:-Wformat -W<format-option>")`
to ensure that compiler options requiring `-Wformat` to work properly
are tested with said option.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #47588
Kitware decided to fail compiler tests of single options if the
compiler reported only a warning and not an error:
github.com/Kitware/CMake/commit/f745e0497ee71d35fd1b3524b1636a72da76c266
which affects CMake 3.23.0 and 3.23.1
This change was later reverted in CMake >=3.23.2 and >=3.24.0
github.com/Kitware/CMake/commit/4941887d7defecb3016d2bd94d3a45754251ca56
Although the immediate issue is related to CMake, and has been fixed
reverted in later releases, then it still makes sense to be able to
group compiler options together that generally are depending on each
other to function correctly.
This commit introduces the possibility to group compiler options which
must be tested together.
It uses same approach as
> add_compile_options("SHELL:<option1> <option2> ...")
Usage:
> check_set_compiler_property(PROPERTY <property>
> "SHELL:<option1> <option2> ..."
> )
Will test the option together.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
As the TF-A was integrated into zephyr as a module. This adds necessary
CMake scripts to load BL1 and FIP binary built from TF-A.
Signed-off-by: Huifeng Zhang <Huifeng.Zhang@arm.com>
Creating a test_interface allows more complex unittest projects to
create additional libraries, for example mock libs, that can be re-used
between test projects.
To support the possibility of such libs to build with same flags as the
testbinary the test_interface is now populated with the public compile
and include flags from testbinary.
testbinary has been updated to use test_interface.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Add a user-settable configuration value indicating whether the toolchain
selected by the cross-compile variant supports thread local storage, using
the default 'n' value to preserve compatibility with existing uses.
Signed-off-by: Keith Packard <keithp@keithp.com>
The Zephyr cross tools configuration which the 'xtools' variant supports
enables TLS, so set TOOLCHAIN_SUPPORTS_THREAD_LOCAL_STORAGE when using it.
Signed-off-by: Keith Packard <keithp@keithp.com>
ARC processors are highly configurable, so ARC toolchain supports
big amount of mcpu options for all that HW configurations.
As difference in many configurations among the same processor
family usually doesn't affect Zephyr code we don't want
to create Kconfig option for each possible CPU configuration
(just to map Kconfig option to correspondent mcpu value
in 'cmake/gcc-m-cpu.cmake').
Instead we prefer being able to set proper mcpu value
individually for any ARC SoC and using 'cmake/gcc-m-cpu.cmake'
just for reasonable defaults.
To apply SoC-related changes for build-options on early stages of building
'tune_build_ops.cmake' should be created in appropriate SoC directory.
Example:
./soc/arc/snps_qemu/tune_build_ops.cmake
File content:
set(GCC_ARC_TUNED_CPU hs4xd)
Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
The current deprecation warning could give the impression that
CROSS_COMPILE is deprecated, which is not the case.
Instead it is the behavior of defaulting to `cross-compile` when
setting CROSS_COMPILE in environment without setting
ZEPHYR_TOOLCHAIN_VARIANT that is deprecated.
Not the use of `CROSS_COMPILE` setting itself.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The commit c2419fc006 introduced a change
to the CMake toolchain detection routine in which it attempts to use
the distro-provided `gdb-multiarch` GDB executable when the target-
specific GDB executable cannot be found (i.e. fallback to
`gdb-multiarch`).
This can cause many problems for the Zephyr users because the distro-
provided GDB does not contain any Zephyr-specific patches and it may
misbehave under various conditions (e.g. negative tid/pid being
displayed, Xtensa debugging mysteriously failing, ARC debugging not
working).
This commit removes the fallback mechanism to the distro-provided
`gdb-multiarch` because it is better to display an error message saying
GDB is not found than to use a wrong GDB that can give out very
confusing and misleading error messages to users.
Moreover, this fallback mechanism is no longer necessary because the
Zephyr SDK is now available on all major host operating systems and it
provides the target-specific custom GDB that contains all Zephyr-
specific patches.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
The Zephyr SDK 0.15.0 release has changed the default GDB executable to
be Python-less and introduced an alternate Python-capable variant
called `gdb-py` (note that the Zephyr SDK previously provided
`gdb-no-py` instead).
This commit updates the CMake toolchain detection routine to attempt
using the Python-capable GDB variant (gdb-py) first and, if it is not
available or fails to launch due to a missing libpython dependency,
use the Python-less GDB variant (gdb).
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
The use of `separate_arguments()` in extra_flags.cmake and
unittest.cmake prevents the use of proper CMake lists.
A CMake list can be specified on command line as:
`-DMY_LIST="itemA;itemB;itemC"`
Users are expected to be able to provide extra compile flags using CMake
lists, like `-DEXTRA_CFLAGS="--flag1;--flag2"` but also using space
separated lists, like: `-DEXTRA_CFLAGS="--flag1 --flag2"`.
However, the way FLAGS was passed to separate_arguments() would result
in a list being treated as extra arguments to the function and thus
result in a CMake error.
To allow the use of CMake lists, the length of the argument as a CMake
list is tested. This ensures that when the argument contains a
single `;` then the length is >1 and no conversion is needed.
This allows a user to freely choose between the two forms:
- `-DFLAGS="--flag1 --flag2"`
- `-DFLAGS="--flag1;--flag2"`
or when passing flags which themselves contains spaces, like:
- `-DFLAGS="--flag1 \"val1 val2\""`
- `-DFLAGS="--flag1;val1 val2"`
Note that the extra escaped qouting is no longer needed for proper CMake
lists as the `;` itself informs the system that spaces are to be kept as
spaces.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Enhance sysbuild controlled configurations.
The current scheme of passing settings using `-D` on the CMake
invocation is vulnerable to quoting and lists.
With `zephyr_get()` in place as a uniform way of handling user
controlled settings (CMake cache / environment / CMake local variable)
we have a mechanism in place for a cleaner handling of sysbuild
controlled settings.
This improves the robustness of variable passing and add the same cleans
up and simplifies the logic in sysbuild.
The Kconfig Zephyr CMake module has been updated accordingly so that
CONFIG settings are taken from the sysbuild shadow cache when sysbuild
is used as higher level build system.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #40389
This commit aligns the use of the following Zephyr build variables:
- CONF_FILE
- DTC_OVERLAY_FILE
- OVERLAY_CONFIG
- WEST_DIR
- ZEPHYR_BOARD_ALIASES
- ZEPHYR_EXTRA_MODULES
- ZEPHYR_MODULES
so that they can be set in same manner and with same order of
preference.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
A cache variable specified by the user as `-DVAR=value` will have the
type UNINITIALIZED in the CMake cache.
Later CMake re-runs will execute the line:
set(${variable} ${CACHED_${variable}} CACHE STRING
"Selected ${variable_text}" FORCE)
This will update the cache type from UNINITIALIZED to STRING and thus
may be picked up by other tools as a change.
To ensure the type is initialized to string, this is added:
set(${variable} ${${variable}} CACHE STRING "Selected ${variable_text}")
This code will not change the value of an existing CMake cache variable
because there is no FORCE, but what it will do is to update the cache
variable type to STRING.
As part of this, include the existing parent scope setting of variable
inside the `if(DEFINED ...)` as there is no reason to clear a variable
there is not having a value.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #40389
Update toolchain handling to use zephyr_get() to ensure consistent
handling of CMake cache variables, environment variable, and CMake
local variables.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #40389
This commit implements zephyr_get(<variable>).
The purpose of zephyr_get(<variable>) is to ensure a uniform way to
handle variables which can be defined as:
- CMake cache variable, for example `-D<var>=<value>`.
- Environment variable
- Locally in CMakeLists.txt file before `find_package(Zephyr)`
It furthermore ensures that if an environment setting hides a local
setting then a warning is printed.
using
zephyr_get(<var>)
removes the need for constructs like:
set_ifndef(<var> "$ENV{<var>}")
set(<var> ${<var>} CACHE PATH "")
if(NOT DEFINED <var>)
set(<var> $ENV{<var>})
endif()
if (NOT DEFINED ENV{<var>})
message(FATAL_ERROR <error>)
endif()
and also ensures identical preference order for variables used in Zephyr
1. cache
2. environment
3. local scope var
It also ensures the variables supported through environment can also be
set using `-D<var>=<value>`
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Place vector sections after ROM_START sections.
Also add init.ld script that will prevent overlapping .init sections
in telink_b91 SoC.
Fixes#49036.
Signed-off-by: Mateusz Sierszulski <msierszulski@antmicro.com>
Follow-up: #49672
Zephyr SDK and host tools detection was reworked in #49672.
That rework accidentally changed the lookup order from:
- Zephyr SDK
- Other host tools
- Generic (host) C compiler
into
- Other host tools
- Zephyr SDK
- Generic (host) C compiler
this causes host tools shipped with Zephyr SDK, such as openocd to not
be discovered unless in path.
Restore the original order so that Zephyr SDK is located first so that
host tools from the SDK can be found without having them in path.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Move deprecated XCC_USE_CLANG setting to deprecated module.
Deprecated and move the use of CROSS_COMPILE to deprecated module as we
have had ZEPHYR_TOOLCHAIN_VARIANT==cross-compile for a long time.
Deprecated code is now loaded with a single line:
> find_package(Deprecated COMPONENTS XCC_USE_CLANG CROSS_COMPILE)
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The deprecated CMake module allows Zephyr to move deprecated code to a
centralized location from where it's both easy to get an overview of
deprecated code, and remove the code when it has been deprecated long
enough.
It further improve existing code, as the real CMake code now can be
changed from n-lines of deprecated code into a single line of the form:
find_package(Deprecated COMPONENTS <deprecated_name>)
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Follow-up: #41301
This commit is a rework and cleanup of the target toolchain handling in
Zephyr CMake build system.
Instead of directly loading code a CMake modules for target toolchain
lookup, the target toolchain now follows the CMake `find_package()`
pattern for finding the target toolchain.
This makes it more clear which modules are responsible for finding tools
and which modules provides build integration / features.
The following tools can now be found using `find_package()`:
- Target toolchain: find_package(TargetTools)
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Follow-up: #41301
This commit is a rework and cleanup of the tools handling in Zephyr
CMake build system.
Instead of directly loading code a CMake modules for tool lookup, the
host tools now follows the CMake `find_package()` pattern for finding
programs / tools in module mode.
This makes it more clear which modules are responsible for finding tools
and which modules provides build integration / features.
The following tools can now be found using `find_package()`:
- Zephyr-sdk : find_package(Zephyr-sdk <version>)
- Generic host tools: find_package(HostTools)
This further allows us to decouple the `verify-toolchain` CMake script
part required by `twister` into a tool lookup module and a dedicated
CMake script which utilizes the lookup module.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Removing Zephyr-SDK code for searching and printing messages when Zephyr
SDK is not found in the system.
After Zephyr SDK has been made available on all platforms, including
MacOS and Windows, then `find_package(Zephyr-sdk)` is always invoked
and thus either `find_package(Zephyr-sdk)` will fail or
ZEPHYR_TOOLCHAIN_VARIANT will be defined.
Meaning the removed code block in this commit can no longer be reached.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Cleanup CMake code by moving devicetree compiler detection to dedicated
FindDtc.cmake module.
This allows us to re-use existing CMake find_package() functionality in
module mode and thus reduce CMake logic.
It further has the benefit of being able to directly specify dtc version
like this:
> find_package(Dtc 1.4.6)
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This moves the test of compile flags set in environment from generic
toolchain to top-level ${ZEPHYR_BASE}/CMakeLists.txt.
In order to cleanup and make Zephyr CMake modules more generic then
the testing of specific compile flags and warn user is not really a
toolchain module responsible but a implementation detail of the project
itself as to how compile flags should be applied in a project.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit sets the minimum required Zephyr SDK version to 0.15, which
is required to build the current Zephyr codebase due to the following
breaking changes:
* RISC-V ISA spec change to 20191213 requiring the Zicsr and Zifencei
extensions to be specified to the `-march` flag
* ARC64 output format name change to `elf64-littlearc64`
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
The commit 8259931fce ("xcc-clang: Do not used unavailable options")
has a side-effect that builds with xcc default to use -fno-pie. This
is not a supported compiler option for xcc, resulting in failing builds.
Use same configuration for xcc as is in place for xcc-clang, and
do not use -fno-pie.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
This PR allows the user to add symbols to the nocache
section. The use for this could be as follows
zephyr_linker_sources_ifdef(CONFIG_NOCACHE_MEMORY
NOCACHE_SECTION
nocache.ld
)
nocache.ld (as shown below) can define additional
symbols to go into the nocache section
. = ALIGN(4);
KEEP(*(NonCacheable))
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
Fixes: #48950
Kconfig requires quoted strings in its configuration files, like this:
> CONFIG_A_STRING="foo bar"
But CMake requires expects that strings are without additional qoutes,
and therefore qoutes are stripped when loading Kconfig config filers
into CMake.
This is particular important when the string in Kconfig is a path to a
file. In this case, not stripping the quotes leads to an error as the
file cannot be found.
When users pass a string to Kconfig through CMake, they are expected to
pass it so that qoutes are correct seen from Kconfig, that is:
> cmake -DCONFIG_A_STRING=\"foo bar\"
In CMake, those qoutes are written as-is to Kconfig extra config file,
and then removed in the CMake cache.
After Kconfig processing, the Kconfig settings are read back to CMake
but without quotes. Settings that was passed through the CMake cache,
for example using `-D` are written back to the cache, but this time
without the qoutes. This results in Kconfig errors on sub-sequent CMake
runs.
Instead of writing the Kconfig value setting back to the CMake cache,
introduce an internal shadow symbol in the cache prefixed with `CLI_`.
This allows the CMake cache to keep the value correctly formatted for
Kconfig extra config creation, while at the same time keep existing
behavior for CONFIG_ symbols read from Kconfig.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Given that 3.6 is now several years old and the current and previous
Ubuntu LTS ship with 3.8 or later, upgrade the minimum required Python
version from 3.6 to 3.8.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This implements support for relocating code to chosen memory regions via
the `zephyr_code_relocate` CMake function for RISC-V SoCs. ARM-specific
assumptions that were made by gen_relocate_app.py need to be corrected,
in particular not assuming any particular name for the default RAM
section (which is 'SRAM' for most ARM pltaforms) and not assuming 32-bit
pointers (so the test works on RV64).
Signed-off-by: Peter Marheine <pmarheine@chromium.org>
xcc-clang in based on clan-10 and does not support -fno-pic and
-fno-pie.
clang-10: warning: argument unused during compilation: '-fno-pic'
[-Wunused-command-line-argument]
[147/148] Linking C executable zephyr/zephyr.elf
clang-10: warning: argument unused during compilation: '-no-pie'
[-Wunused-command-line-argument]
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This had bitrotten a bit, and didn't build as shipped. Current
libasan implementations want -fsanitize=address passed as a linker
argument too. We have grown a "lld" linker variant that needs the
same cmake treatment as the "ld" binutils one, but never got it. But
the various flags had been cut/pasted around to different places, with
slightly different forms. That's really sort of a mess, as sanitizer
support was only ever support with host toolchains for native_posix
(and AFAICT no one anywhere has made this work on cross compilers in
an embedded environment). And the separate "gcc" vs. "llvm" layers
were silly, as there has only ever been one API for this feature (from
LLVM, then picked up compatibly by gcc).
Pull this stuff out and just do it in one place in the posix arch for
simplicity.
Also recent sanitizers are trying to add instrumentation padding
around data that we use linker trickery to pack tightly
(c.f. SYS_INIT, STRUCT_SECTION_ITERABLE) and we need a way
("__noasan") to turn that off. Actually for gcc, it was enough to
just make the records const (already true for most of them, except a
native_posix init struct), but clang apparently isn't smart enough.
Finally, add an ASAN_RECOVER kconfig that enables the use of
"halt_on_error=0" in $ASAN_OPTIONS, which continues execution past the
first error.
Signed-off-by: Andy Ross <andyross@google.com>
On Debian, llvm-obj{copy,dump} tools are installed with a version
suffix. Look first for a version that matches our compiler when
probing for tool paths before trying the bare version, or falling back
to GNU binutils.
Signed-off-by: Andy Ross <andyross@google.com>
This commit introduces a dedicated unit testing board.
Today, a dedicated Zephyr unit testing scheme exists but is different
from how a Zephyr build generally works.
For example Kconfig is not possible, resulting on various different
hacks to pass Kconfig settings from test cases / testcase.yaml through
CMake to the code.
Some directly as compile definitions, some as header files with forced
inclusion on sources, some with wrapper flags which again results in
different define being enabled. There is even cases where a second
forced header inclusion undefines previous defines.
Unit test often does a manual check for the right boards, like this:
> if (NOT BOARD STREQUAL unit_testing)
> message(FATAL_ERROR "This project can only be used with...")
> endif()
Introducing a dedicated unit_testing board under `tests/root` allows
us to use Kconfig in unit test samples, and thus proper `prj.conf` and
extra Kconfig fragments.
Generation of autoconf.h so the overall architecture follows regular
Zephyr builds.
Proper and uniform error messages when invalid board is selected.
The unit_testing board and arch is located under: `subsys/testsuite` so
that it is only available when find_package(Zephyr COMPONENTS unittest)
is used, and not available for regular Zephyr builds.
Kconfig generates autoconf.h which is applied as compile flag to
test binary which means that kconfig defines placed in ztest.h can now
be removed.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The Zephyr CMake module kconfig.cmake will create files inside
KCONFIG_BINARY_DIR.
In a default Zephyr build setup, this directory is created by Zephyr
CMake module zephyr_module.cmake. But Zephyr CMake modules are modular
and thus it must be possible to use kconfig module without
zephyr_module.
Thus kconfig.cmake must set and create KCONFIG_BINARY_DIR if it does not
already exists.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Remove ZEPHYR_BASE as default root in list_boards.py.
This allows list_boards.py to be used to only print boards at given
root(s) without printing Zephyr default boards.
Secondly it remove the need in list_boards.py to have any knowledge of
ZEPHYR_BASE.
The `west boards` command already has ZEPHYR_BASE knowledge and can
easily add ZEPHYR_BASE to the list of roots it is already constructing,
thus removing the need for knowing that ZEPHYR_BASE is always added.
Update boards.cmake to pass ZEPHYR_BASE as an additional arch root, as
arch.cmake has not yet been processed,which means ZEPHYR_BASE is missing
in ARCH_ROOT list at this point in time.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
ALIGN_WITH_INPUT is an argument for zephyr_linker_section, not
zephyr_linker_section_configure. Fix the calls for section .emulators
accordingly.
Signed-off-by: Abe Levkoy <alevkoy@google.com>
This reverts commit 87c6789355, restoring
commit 3b341085a2.
Restore the original change now that the underlying issue has been fixed
in 6cfb18686e.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit adds the `no_strict_aliasing` flag, which disables
the strict aliasing rule, for the ARC MetaWare compiler.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit adds the `no_strict_aliasing` flag, which disables
the strict aliasing rule, for the GCC compiler and its derivatives.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit adds a template for specifying the C/C++ compiler flag for
disabling the strict aliasing rule.
It also enables this flag globally because the Zephyr codebase does not
strictly adhere to the aliasing rules specified by the C/C++ standards
and the optimisation strategies that assume these rules may end up
generating invalid code.
For instance, GCC 11 and above tend to optimise more aggressively
assuming the strict adherence to the standard aliasing rules and may
generate invalid code, when compiling Zephyr with `-fstrict-aliasing`,
that results in various run-time failures.
Note that the footprint and performance ramifications of disabling the
strict aliasing rule are negligible.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Because the fixup files do not exist anymore, stop using "unfixed"
naming in favor of "generated".
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Devicetree fixup files existed previous to the current stable Devicetree
API. While they served their purpose, they are no longer necessary nor
used in-tree. This patch drops support for this legacy feature.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Updates the ztest_test_fail() function to allow failures in setup.
When executed, a failed assert will fail every test in the suite owning
the setup function. This was verified by adding a suite which asserts
in the setup function and has a test that should pass. During
exeuction, ztest marks the test as failing.
In order to verify exection I also added 2 new APIs:
- ZTEST_EXPECT_FAIL(suite_name, test_name)
- ZTEST_EXPECT_SKIP(suite_name, test_name)
Signed-off-by: Yuval Peress <peress@google.com>
This file is no longer used by device.h, so let's avoid spending time
generating the content formerly in it.
In order to leave a pointer in place for users who are expecting to
see it or are pulling it into their own builds, however, replace its
contents with an #error directive that tells them what happened. This
can be removed later on when we expect people are used to the
transition.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
ZEPHYR_SDK_INSTALL_DIR is set from the env if it is not passed
explicitly to cmake, but one usage was reading directly from the env,
not allowing passing the var to cmake instead.
Change find_package of Zephyr-sdk to read from cmake var not env var.
Signed-off-by: Jeremy Bettis <jbettis@google.com>
Some processors support Dual-redundant Core Lock-step
DCLS) topology but the processor still can be ran in
split-lock mode (by default or changed at flash time).
So, introduce config DCLS that is enabled by default if
config CPU_HAS_DCLS is set, it should be disabled if
processor is used in split-lock mode.
Signed-off-by: Dat Nguyen Duy <dat.nguyenduy@nxp.com>
This commit allows a project to specify a given set of Kconfig targets
prior to sourcing kconfig.cmake.
This allows for greater flexibility when re-using kconfig.cmake in
other projects.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit allows for specifying a dedicated Kconfig namespace, for
example: <namespace>_CONFIG
This namespace will then be used for handling loading of configuration
files into CMake configure scope, as well as handling of CMake cache
variables when set using `-D<namespace>_CONFIG_<var>=<value>`.
This allows greater flexibility when re-using the cmake/kconfig.cmake
in other projects.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Allow build system to define an alternative defconfig file.
This allows reusing the existing kconfig.cmake file in other projects,
such as multi image builds.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The Cortex-R52 processor supports single-precision
floating-point instructions and can optionally support
the double-precision floating-point instructions.
Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
Introduce a generated Kconfig.dts that sets a Kconfig symbol for
every compatible.
* We set DT_HAS_<compat>_ENABLED if the devicetree has a node with
<compat> enabled. (status is okay...)
We can then use the Kconfig symbol in driver Kconfig to determine
if the driver should be available, and thus enabled by default.
Signed-off-by: Kumar Gala <galak@kernel.org>
Fix for #47353 where we add and enable symbol generation,
but miss to add proper options for ARCMWDT toolchain.
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Optional way for generating symbols file using binutils. This file will
be generated on demand for tests which will then be parsed by twister to
create an accurate test plan from the listed testcase/suites.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Compilation warnings appears for C++ files, that following
options are not valid:
-ffrestanding,
-Wno-format-zero-length
-Wno-main
-fgnu89-inline
-std-gnu99
Added checks to filter out unsupported flags.
Signed-off-by: Jaroslaw Stelter <Jaroslaw.Stelter@intel.com>
As Zephyr currently requires CMake version 3.20.0, update all
occurrences of cmake_minimum_required.
Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
When using CONFIG_NPCX_IMAGE_OUTPUT_HEX, set the hex_file
runners_yaml_props_target property, so that west flash will flash the
correct file.
Change the cmake flash rules to populate the hex_file value in the
runners.yaml file if either CONFIG_BUILD_OUTPUT_HEX is enabled or some
cmake file set the runners_yaml_props_target hex_file property.
Update the npcx9m6f_evb instructions now that the filename is implicit.
Signed-off-by: Jeremy Bettis <jbettis@google.com>
DTS directories can come from multiple places. Some places like a user's
CMakeLists.txt can preserve symbolic links. Others like
`scripts/zephyr_module.py --settings-out` resolve symbolic
links.
list(REMOVE_DUPLICATES ...) does not know anything about directories;
only about strings. To fix it the de-duplication, resolve all symbolic
links in DTS_ROOT first using file(REAL_PATH ...).
Fixes this somewhat confusing error:
```
-- Found BOARD.dts: /home/proj/mymodule/boards/myboard/myboard.dts
devicetree error: both /home/proj/mymodule/dts/bindings/intel,stuff.yaml
and /disk1/home/proj/mymodule/dts/bindings/intel,stuff.yaml
have 'compatible: intel,stuff'
```
Also, print `gen_defines.py` arguments in case of an error so anyone can
see what failed and not just west+CMake experts.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Not sure why this is needed for this branch, but it pretty clearly is --
there are hundreds of set-but-unused variables in the codebase.
Signed-off-by: Keith Packard <keithp@keithp.com>
zephyr_library_compile_options() was attempting to create
unique hashes for compile options in order to prevent creating
them multiple times. However, it was only using the first
argument to create the hash, so if multiple libraries had
different compile options but the first line was the same,
the second set would be mistaken for the first set and would
actually be passed the first set during compilation instead
of its own set.
The fix should be to use the entire compile options argument
list to create the hash so they should only match if the entire
options list is exactly the same.
This is a continued fix for #43835
Signed-off-by: Nicholas Lowell <nlowell@lexmark.com>
This patch is doing several things:
- Core ISA and extension Kconfig symbols have now a formalized name
(CONFIG_RISCV_ISA_* and CONFIG_RISCV_ISA_EXT_*)
- a new Kconfig.isa file was introduced with the full set of extensions
currently supported by the v2.2 spec
- a new Kconfig.core file was introduced to host all the RISCV cores
(currently only E31)
- ISA and extensions settings are moved to SoC configuration files
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Update the new API to use K_USER as the flags for both
CONFIG_USERSPACE and CONFIG_TEST_USERSPACE. Also, fix the linker
script to properly include the suites, tests, and rules.
Fixes#44108
Signed-off-by: Yuval Peress <peress@google.com>
When SYSROOT_DIR is provided, gcc should use it through the --sysroot=
option otherwise some commands won't work as expected.
For example, in the Yocto environment when cross compiling,
--print-libgcc-file-name prints only "libgcc.a" instead of the full
path to it and the subsequent assert_exists(LIBGCC_FILE_NAME) will
fail.
Fixes#45578
Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
Current Espressif porting requires standard include as
part of hal implementation. compiler_flags.cmake checks for
variant name to keep those stdinc in build.
Instead of using variant name as check, use this new CONFIG
to make it clear and to allow having toolchain integrated
in zephyr-sdk package.
stdinc dependency in hal_espressif will be worked out and removed
soon.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
The ztest unittest module relies on some headers that fake the real
ones, e.g. <zephyr/arch/cpu.h>. When new header location was introduced,
their path was not updates. This patch fixes this problem and provides
ztest with both, legacy and new include paths so that it can keep
working on both scenarios.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
When Dual-redundant Core Lock-step (DCLS) topology is used, the VFP
registers across the two redundant cores must be manually initialised
and synchronised, and this requires the `-mfloat-abi=hard` option to
be specified.
This commit forces the use of FP "hard" ABI on the VFP-equipped cores
that are configured in DCLS topology.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit updates the Zephyr build system to support specifying
advanced floating-point compilation options derived from the newly
introduced unified floating-point configurations.
The following changes are introduced by this commit:
1. Specify architecture floating-point option to the `-mcpu` flag.
2. Specify floating-point unit (FPU) type using the `-mfpu` flag.
Note that the `-march` flag is not specified separately because the
`-mcpu` flag provides more detailed architecture options and this
makes the `-march` flag redundant.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
With this adding "-DSPARSE=y" to the "west build" command line
performs a sparse check of the project build. So far only gcc-based
builds are supported.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
The linker_script generating tool needs to ensure that .tdata gets added
to the TLS data section while .tbss is added to the TLS BSS section.
Signed-off-by: Keith Packard <keithp@keithp.com>
Scripts generated with ld_script.cmake also need to have the _align
symbols defined so that they work with TLS values.
Signed-off-by: Keith Packard <keithp@keithp.com>
Update the new API to use K_USER as the flags for both
CONFIG_USERSPACE and CONFIG_TEST_USERSPACE. Also, fix the linker
script to properly include the suites, tests, and rules.
Fixes#44108
Signed-off-by: Yuval Peress <peress@google.com>
This will generate profile data that can be analyzed using gprof. When
you build the application (currently for native_posix only), after
running the application you will get a file "gmon.out" with the call
graph which can be processed with gprof:
gprof build/zephyr/zephyr.exe gmon.out > analysis.txt
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Control the usage of semihosting with a dedicated symbol, instead of
implying semihosting from the usage of `SEMIHOST_CONSOLE`. This allows
semihosting to be used without the semihost console.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This PR allows the user to add symbols to the ramfunc
section. The use for this could be as follows:
zephyr_linker_sources_ifdef(CONFIG_ARCH_HAS_RAMFUNC_SUPPORT
RAMFUNC_SECTION
quick_access_code.ld
)
quick_access_code.ld (as shown below) can define additional
symbols to go into the ramfunc section
. = ALIGN(4);
KEEP(*(CodeQuickAccess))
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
Propagate the board revision to Kconfig via the environment.
This is useful for application code to have access to for similar
reasons that CONFIG_BOARD is useful.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Add a Kconfig to disable non prefixed includes. By setting
`CONFIG_LEGACY_INCLUDE_PATH=n` developers can disable having
`include/zephyr` in the search path. This means that includes such
as `#include <kernel.h>` will no longer work.
Internally, every header should be updated to add the `zephyr/`
prefix to the headers. Only then, will developers be able to use
this config value for their applications.
Signed-off-by: Yuval Peress <peress@google.com>
Move include paths and add new target_include_directories to support
backwards compatibility:
* /include -> /include/zephyr
example: <irq.h> -> <zephyr/irq.h>
Issue #41543
Signed-off-by: Yuval Peress <peress@google.com>
The autoconf.h macros were not passed to the CMake custom command for
linker script generation.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This patch is doing two things:
- it is removing the fallback on the path. This is not possible anymore
since the DT binding file is now actually requiring the
'zephyr,memory-region' property to be present from which the region
name is obtained.
- it is sanitizing the name when CONFIG_CMAKE_LINKER_GENERATOR is used
or not.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
New ARCv3 GNU toolchain uses hs6x mcpu value for hs6x CPUs, the older
one allows to use any mcpu value.
Update old 'arc64' mcpu to 'hs6x' to be aligned with new toolchain
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
This commit updates the Zephyr build system to use the Zephyr SDK by
default for all host operating systems, when `ZEPHYR_TOOLCHAIN_VARIANT`
environment variable is not explicitly set.
Note that the Zephyr SDK is now available on all three major host
operating systems (i.e. Linux, macOS, Windows), and there is no reason
to exclude this behaviour for non-Linux hosts anymore.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
New KConfig options for 'A' and 'M' RISC-V extensions have been
added. These are used to configure the '-march' string used by GCC
to produce a compatible binary for the requested RISC-V variant.
In order to maintain compatibility with all currently defined SoC,
default the options for HW mul / Atomics support to 'y', but allow
them to be overridden for any SoC which does not support these.
I tested this change locally via twister agaisnt a few RISC-V platforms
including some 32bit and 64bit. To verify the 4 possibilities of Atomics
& HW Mul: (No, No), (No, Yes), (Yes, No), (Yes, Yes -- current behavior),
I used an out-of-tree GCC (xPack RISC-V GCC) which has multilib support
for rv32i, rv32ia, rv32ima to test against our out-of-tree Intel Nios V/m
processor in HW. The Zephyr SDK RISCV GCC currently does not contain
multilib support for all variants exposed by these new KConfig options.
Signed-off-by: Nathan Krueger <nathan.krueger@intel.com>
COPY/NOCOPY flag was added to the end of the string with ':'
as separators. The python script then split the line on ':'
which breaks on Windows build because the string was
[MEM]:[FILE]:[COPY]
In windows you will have 'c:\' in the file path so the
line.split() in script will split on the 'c:'.
Move the COPY/NOCOPY to:
[MEM]:[COPY/NOCOPY]:[FILE]
Note that the comments at top of gen_relocate_app.py also
indicates this format.
Fixes#43950
Signed-off-by: David Leach <david.leach@nxp.com>
Currently when a node has a 'zephyr,memory-region' compatible and a
'zephyr,memory-region' string property, a new memory region is created
in the linker script.
Having a memory region without a section to place variables in could be
not that useful. With this patch we extend the memory-region mechanism
to also create sections.
The user can then place variables in the sections as usual by using for
example the GCC attributes.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Fixes: #43835
In zephyr_library_compile_options() the existence of the compile
options interface library is checked and function returns if it already
exists. This results in #43835 meaning two libraries cannot add the
same option.
This commit fixes this by re-using the already created unique interface
library and link this to the Zephyr library.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
With CMake 3.20 relative path inside DEPFILEs are treated relative to
CMAKE_CURRENT_BINARY_DIR and are transformed by CMake in its internal
dep file.
Therefore Zephyr build system must no longer add `base_name` to the
`-MT` argument for the preprocessor.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The Armv8R aarch64 is compiled with armv8.4-a, so the atomic_cas is
implemented by casal instruction, which needs FVP booting with
'-C bp.dram.enable_atomic_ops=1'
However, the FVP >= 11.17 has changed its parameters
'-C bp.dram.enable_atomic_ops' to '-C bp.s_dram.enable_atomic_ops' and
'-C bp.sram.enable_atomic_ops' to '-C bp.s_sram.enable_atomic_ops',
which is very annoying.
To fix this issue, disable LSE feature of GCC with 'armv8.4-a+nolse'.
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Print a warning message on 'west build -t run', if the FVP does not meet
the minimal requirement. The check acts as a reminder instead of an
entrance guard. So, the check won't stop executing the FVP program.
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Add a compiler property for disabling pointer arithmetic warnings,
and implement that property for GCC.
Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
Although CMake scripts already support duplicated module
names, if two modules with the same name provide different
Kconfig files, then both files will be loaded leading to
potential conflicts.
Modify zephyr_module.py to enforce that all modules are
uniquely named so that it is possbile to override some of
the built-in modules using ZEPHYR_EXTRA_MODULES variable.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
Add support for TF-M and BL2 image size reports.
This adds the following targets when TF-M or BL2 is enabled:
tfm_rom_report, tfm_ram_report, tfm_footprint
bl2_rom_report, bl2_ram_report, bl2_footprint
Example:
west build -t tfm_rom_report
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
After the fix of FVP_BaseR_AEMv8R booting issue, the minimum required
version of FVP will be 11.16.16. Add an FVP minimal required version
check in building time.
When the ARMFVP_MIN_VERSION is set in board cmake file, the version
check will be enabled and print a warning.
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Change-Id: Ibbade0c328b5e91b8830fb35cba6917f08aabbda
Fixes: #43094
This commit introduces a function which updates Zephyr_DIR to point to
the directory of the Zephyr package being loaded.
For Zephyr 3.0 and earlier, the Zephyr_DIR might in some cases be
`Zephyr_DIR-NOTFOUND` or pointing to the Zephyr package including the
boilerplate code instead of the Zephyr package of the included
boilerplate code.
This code ensures that when a package is loaded then Zephyr_DIR will
point correctly.
This ensures that when Zephyr releases <=3.0 is loaded, then Zephyr_DIR
will point correctly, see more in #43094.
Old style Zephyr package will in some cases load boilerplate.cmake
directly so to ensure proper behavior, restrict boilerplate uses of
`find_package(Zephyr)` to not use default search path, but allow only
the current Zephyr.
Of the same reason, only print warning if Zephyr_DIR is not defined as
this indicates old style inclusion.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #43378
Move the exporting of ZEPHYR_TOOLCHAIN_VARIANT from the custom target to
the COMMON_KCONFIG_ENV_SETTINGS variable.
This ensures that the setting is exported both when running the initial
kconfiglib parsing but also on later menuconfig / guiconfig invocations.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The STRUCT_SECTION_ITERABLE have been renamed to drop the Z_ prefix,
this drops the last reference in the cmake comments.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Don't translate from relative to absolute include paths.
It is lost to history why this was necessary and it is causing
problems with generator expressions so we remove the logic.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Fixes: #43099
The CMake 3.22.1 / 3.22.2 PyPI version suffers a bug in the
`cmake_path(... PARENT_PATH)` implementation.
Therefore, when CMake version 3.22.1 / 3.22.2 is detected, test if the
CMake version is suffering from the bug, and in case the bug is present,
fail with an error regarding the issue.
The reason for failing, and not implementing work arounds is that Zephyr
already uses `cmake_path()` at two locations, and we cannot prevent
contributors from adding code which uses this function.
Secondly, Zephyr modules may also use `cmake_path()`, and thus be
affected by said bug.
It is impractical to implement work arounds at all possible locations
for something that is a CMake bug.
Therefore the safest solution is to test CMake itself, to check if the
version in use suffers said bug, and fail with a proper error message
if an affected CMake version is used.
See more here:
https://gitlab.kitware.com/cmake/cmake/-/issues/23187https://github.com/scikit-build/cmake-python-distributions/issues/221
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Instead of setting XCC_USE_CLANG=1, this patch adds xcc-clang toolchain
that is basically xcc using the clang compiler.
Initially, the new toolchain simply includes files from current xcc
toolchain and (re)sets some variables. This should be a more scalable
approach to diverge the toolchains in the future than placing
"if($ENV{XCC_USE_CLANG})" at several places.
It should also help to filter tests that run (or not) exclusively with
the clang variant of XCC on twister.
The XCC_USE_CLANG flag is documented as deprecated, and a message is
emitted during build if still in use. Its new behaviour is to instruct
Zephyr to use `xcc-clang` toolchain.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
The Zephyr CMake package helper script allows to invoke Zephyr package
modules as they are invoked at configure time, up to the modules given
with `-DMODULES=<modules>`.
This allows to run the configure time part of the Zephyr build system
without generating a complete build system.
This means that for example devicetree module can be invoked for a given
sample and board to generate zephyr.dts identical to what is created
by the build system during a build.
To generate zephyr.dts for hello_world, invoke the script as:
$ cmake -DBOARD=<board> -B build -S samples/hello_world \
$ -DMODULES=dts -P <ZEPHYR_BASE>/cmake/package_helper.cmake
Other modules, for example 'kconfig' and 'zephyr_modules' can also be
invoked this way.
This will allow other tools, such as twister, to executed only a
subset of the build system like dts in order to do filtering before
determine if a complete build should be invoked.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit allows to load only subcomponents of the default Zephyr
CMake module, zephyr_default.cmake.
This allows other tools to execute Zephyr CMake build system up to a
specific module and the stop further processing.
This commit is an enabler for future support in twister to process only
devicetree or kconfig, to allow test / sample filtering before
generating a complete build system.
Sub-components can be loaded as:
> find_package(Zephyr COMPONENTS zephyr_default:<sub-component>)
for example:
> find_package(Zephyr COMPONENTS zephyr_default:dts)
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Creating a doc.cmake to the new Zephyr CMake modules dir.
This removes the need for `set(NO_BOILERPLATE TRUE)` before loading the
Zephyr CMake package.
It also removes the need within the doc/CMakeLists.txt file to manually
include individual parts of the Zephyr CMake files as this is now
controlled through a single Zephyr CMake doc module.
This aligns the way a Zephyr package is sourced with other places.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Move the unittest.cmake to the new Zephyr CMake modules dir.
This allows us to have a single Zephyr CMake package and load unittest
module as: 'find_package(Zephyr COMPONENTS unittest)'
This unifies the way Zephyr package is sourced and removes the need for
a dedicated ZephyrUnittest package.
Deprecate the use of: 'find_package(ZephyrUnittest)'
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Create a cmake/modules folder containing all Zephyr CMake modules.
All Zephyr cmake files that are included from boilerplate are now
converted into CMake modules which can be individually loaded.
The Zephyr CMake package is updated to support loading of individual
CMake modules using the COMPONENTS argument to `find_package(Zephyr)`.
If the COMPONENTS argument is not specified, the default Zephyr build
system will load.
If COMPONENTS is specified then, only those components and the
dependencies will be loaded.
If a Zephyr CMake module depends on another CMake module which has not
been loaded, it will automatically be loaded.
This allows us to modularize and reuse individual parts of the Zephyr
CMake build system in a more flexible way in future.
Such usage could be:
- Higher livel multi image build system
- Invocation of individual components, for example dts processing by
twister without loading all build code
- Doc build
- Unittesting
With this new CMake package and CMake module scheme then direct
sourcing of boilerplate.cmake has been deprecated.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The root.cmake CMake module remove boilerplate code and place
it inside a dedicated root.cmake CMake module.
This is part of a general CMake overhaul to allow better modularization
and reuse of the Zephyr build system.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The kernel.cmake CMake module remove boilerplate code and place
it inside a dedicated kernel.cmake CMake module.
This is part of a general CMake overhaul to allow better modularization
and reuse of the Zephyr build system.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The configuration_files.cmake CMake module remove boilerplate code and
place it inside a dedicated configuration_files.cmake CMake module.
This is part of a general CMake overhaul to allow better modularization
and reuse of the Zephyr build system.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The user_cache.cmake CMake module remove boilerplate code and place it
inside a dedicated user_cache.cmake CMake module.
The user cache functions has been moved to the new Zephyr CMake module.
This is part of a general CMake overhaul to allow better modularization
and reuse of the Zephyr build system.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The boards.cmake and shields.cmake has been repurposed to do board and
shield validation so that such validation code can be re-factored out
of boilerplate itself.
The boards.cmake and shields.cmake will both perform validation and
printing errors when validation fails.
Also it will specify the boards and shields build targets.
This ensures that validation code, message printing and target
specification for boards and shields are located logically together.
This is part of a general CMake overhaul to allow better modularization
and reuse of the Zephyr build system.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
To prepare for more modular approach move the compiler forced out of
boilerplate and into the specific toolchain cmake code (generic/target).
Code is added to both generic and target toolchain modules to allow
future use of one module without requiring a load of the other module.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The arch.cmake CMake module remove boilerplate code and place it inside
a dedicated arch.cmake CMake module.
This is part of a general CMake overhaul to allow better modularization
and reuse of the Zephyr build system.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The soc.cmake CMake module remove boilerplate code and place it inside
a dedicated soc.cmake CMake module.
This is part of a general CMake overhaul to allow better modularization
and reuse of the Zephyr build system.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This is a cleanup commit moves the default setting of KCONFIG_BINARY_DIR
from boilerplate.cmake to zephyr_modules.cmake to prepare for better
re-usability.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This is a cleanup commit moves the setting of AUTOCONF_H from
boilerplate.cmake to kconfig.cmake for better re-usability.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
XCC (based on GCC 4.2) doesn't recognize -Wvla (for variable-length
array), so remove it from "warning_error_misra_sane" property.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
* Use case of interest:
Some platforms are shipping in parallel to the internal FLASH some other
storage / external FLASH (usually a QSPI FLASH) that can be used to
execute (XIP) code from.
The content of this external FLASH can usually be written at flash time
using proper tools (see for example the case of the external FLASH on
the nRF5340DK that can be written at flash time using nrfjprog).
The external FLASH is a nice addition that is extremely useful when a
large application code doesn't entirely fit on the internal FLASH so
that we could want to move part of it in the auxiliary FLASH to XIP the
code from there.
* The problem:
Right now Zephyr doesn't have a formal and generic way to move at build
time part of the code to a different memory region.
* The current status:
Zephyr is indeed shipping a code_relocation feature but that doesn't
entirely match our needs.
When XIP is enabled, the code_relocation feature is used in Zephyr to
move the selected code (that is to copy text section, to initialize data
and zero bss) from FLASH to SRAM at run time and execute code from SRAM.
The relocation is done by a generated snippet of code that is
memcpy()-ing the right content to the destination region also using some
build-time generated portions of linker script to retrieve start and
destination addresses and regions.
* This patch:
This patch is leveraging the code_relocation code and adding a NOCOPY
feature. This feature is using the code_relocation feature to
dynamically build the linker script snippets but entirely skipping the
run-time code relocation so that the code can be XIP-ed from the
destination region.
* Example:
Let's say that we have a big file called `huge_file.c` that we want to
XIP from the external FLASH that is mapped in an EXTFLASH region.
In this case we should enable `CONFIG_XIP` and
`CONFIG_CODE_DATA_RELOCATION` and instruct cmake as follows:
zephyr_code_relocate(src/huge_file.c EXTFLASH_TEXT NOCOPY)
zephyr_code_relocate(src/huge_file.c SRAM_DATA)
this means that:
- The .text section of the `huge_file.c` must reside in the EXTFLASH
memory region and we do not need to copy the section there because we
are going to XIP it (and we assume that the file is going to be placed
in the external FLASH at flash time).
- The .data section of the `huge_file.c` must still reside in the SRAM
memory region.
* TODOs:
It's desirable to have the possibility to relocate libraries and
pre-build files instead of source code files.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
As already done for the regular linker script, dinamically generates the
memory regions with the 'zephyr,memory-region' compatible also when
using the cmake linker generator.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Add a new cmake extension function:
dt_comp_path(<var> COMPATIBLE <compatible> [INDEX <idx>])
to get a list of paths for the nodes with the given <compatible>. This
is useful when we have to cycle through several nodes with the same
compatible.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Zeroing the BSS and copying data to RAM with regular memset/memcpy may
cause problems when those functions are assuming a fully initialized
system for their optimizations to work e.g. some instructions require
an active MMU, but turning the MMU on needs the .bss section to be
cleared first, etc.
Commit c5b898743a ("aarch64: Fix alignment fault on z_bss_zero()")
provides a detailed explanation of such a case.
Replacing z_bss_zero() with an architecture specific one is problematic
as the former may see new sections added to it that would be missed by
the later. The same reasoning goes for z_data_copy().
Let's make maintenance much easier by providing weak versions of
memset/memcpy that can be overridden by architecture-specific safe
versions when needed.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
As part of #40167 is was discovered that devicetree headers are always
generated when CMake re-runs.
This causes all source files that directly or indirectly through
included headers to recompile when CMake re-runs, even if there are no
changes to devicetree.
This commits introduces `zephyr_file_copy(...)` similar to
`file(COPY_FILE ...)` from CMake 3.21.
However, as CMake 3.20 is supported by Zephyr we need a zephyr variant
of this function to allow usage with CMake 3.20.
This ensures that only when there are changes to devicetree headers,
then source files will recompile.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #39503Fixes: #40167
This commit moves `BUILD_VERSION` CMake variable from a compile
definition to be a define inside version.h.
Besides the benefit of having related settings grouped in a common
header, it also means that an updated `BUILD_VERSION` value does not
need to trigger re-compilation of all source files.
When using compile definitions, CMake cannot tell whether a given source
files uses the definition or not, and hence all sources must be
recompiled to be sure they are up-to-date.
Placing `BUILD_VERSION` in version.h, the source dependencies ensures
that only source files including `version.h` gets recompiled.
As part of this, version.h generation is moved so that it is now done
at build time.
This means that re-generation of version.h is no longer depending on a
CMake re-run but can have it's own dependency in `.git/index` when git
described is used to obtain `BUILD_VERSION` information.
Generation of logging dictionary database has been updated to support
BUILD_VERSION from header file instead of CMake configure time variable.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
GCC-based XCC uses GNU Assembler (xt-as). However, CMake doesn't
recognize it when invoking through xt-xcc. This results in CMake
going through all possible combinations of command line arguments
while invoking xt-xcc to determine assembler vendor. This multiple
invocation of xt-xcc unnecessarily lengthens the CMake phase of
build, especially when XCC needs to obtain license information
from remote licensing servers. So here forces the assembler ID
to be GNU to speed things up a bit.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This reverts commit deeb98da53.
A less invasive change has been implemented which does not
require changes to the GCC compiler flag file. So revert
the commit.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Some older versions of XCC Clang would result in the following
error during compilation:
/tmp/file.s: Assembler messages:
/tmp/file.s:20: Error: file number 1 already allocated
clang-3.9: error: Xtensa-as command failed with exit code 1
due to a bug in LLVM: https://bugs.llvm.org/show_bug.cgi?id=11740.
This is fixed in upstream, https://reviews.llvm.org/D20002, in 2016.
However, it seems that it is only fixed after XCC RI-2018.0.
Instead of blanket disabling usage of '-g', use an environment
variable "XCC_NO_G_FLAG" to disable usage of flag '-g' to workaround
this issue. This needs to be manually set because there is no way to
know which XCC version is being used, and compiler flag checking for
'-g' would not result in error (and thus '-g' is not ignored).
This is only needed for older XCC Clang. For sufficiently new XCC
verisons, there is no need for this.
Note that this is an alternative implementation to commit
deeb98da53. This one does not
alter the GCC flag file, and instead, simply clear the debug
compiler property so "-g" is not used.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Some older versions of XCC Clang would result in the following
error during compilation:
/tmp/file.s: Assembler messages:
/tmp/file.s:20: Error: file number 1 already allocated
clang-3.9: error: Xtensa-as command failed with exit code 1
due to a bug in LLVM: https://bugs.llvm.org/show_bug.cgi?id=11740.
This is fixed in upstream, https://reviews.llvm.org/D20002, in 2016.
However, it seems that it is only fixed after XCC RI-2018.0.
Instead of blanket disabling usage of '-g', use an environment
variable "XCC_NO_G_FLAG" to disable usage of flag '-g' to workaround
this issue. This needs to be manually set because there is no way to
know which XCC version is being used, and compiler flag checking for
'-g' would not result in error (and thus '-g' is not ignored).
This is only needed for older XCC Clang. For sufficiently new XCC
verisons, there is no need for this.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit adds support for adjust the addresses of the final image.
This is useful when the image is to be flashed at a location different
from the LMA address encoded in the ELF file by the linker.
An example use-case is multicore systems where core A might load image
from a flash partition into RAM in order for core B to execute and load,
but where the image itself is build with the RAM addresses as LMA.
It updates the zephyr_image_info.h header with information of adjustment
value.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The MIPS Malta is an ATX form factor evaluation board made by MIPS
Technologies. Malta board is the most popular platform for MIPS
full-system emulation.
See https://www.linux-mips.org/wiki/MIPS_Malta for details.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Remy Luisant <remy@luisant.ca>
This commit defines the toolchain command line options for the
Zephyr MIPS architectural port.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Remy Luisant <remy@luisant.ca>
Since CMake 3.20 DEPFILE has been supported by Makefile generators.
Simplify the CMake code by using DEPFILE for both Ninja and Makefile
generators.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
With CMake 3.20 relative path inside DEPFILEs are treated relative to
CMAKE_CURRENT_BINARY_DIR and are transformed by CMake in its internal
dep file.
Therefore Zephyr build system must no longer add `base_name` to the
`-MT` argument for the preprocessor.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The GDB check routine added in the PR #38749 does not suppress the
console outputs (stdout and stderr) and may print out a misleading
error message during a CMake configuration when the required version
of Python is not available on the system:
arm-zephyr-eabi-gdb: error while loading shared libraries:
libpython3.8.so.1.0: cannot open shared object file: No such file or
directory
This commit adds the `OUTPUT_QUIET` and `ERROR_QUIET` options when
executing the GDB process so that the console outputs during the GDB
executable validation are not displayed to the user.
In addition, this commit removes the unused `GDB_PY_NO_PY` standard
output redirection variable since it is unnecessary.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Fixes: #41435
Remove build host specific escaping of start symbol command argument.
The start symbol for armlink is: Image$$device$$Base
and were escaped as: Image\\$$\\$$device\\$$\\$$Base
However, the $ must only be escaped in Linux and MacOS, not on windows
hosts.
Instead of escaping the start symbol in the CMake code then it is better
to use the VERBATIM flag on `add_custom_command()` which ensures correct
escaping for the build host.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #41435
The use of %<symbol>% works well in Linux and MacOS but when passed
to the linker script generator in Windows the %<symbol>% is processed
by the windows shell causing the value to disappear and thus an empty
value inside the generated ld linker script or scatter file.
This is fixed by using the @ character instead of the % character.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
We used to test that the compiler works at all, before testing
compiler flags. But during some toolchain refactoring this got
re-arranged.
This commit corrects the ordering.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
The commit dee79d2b66 introduced a new
linker output section ztest_suite_node in linker/common-ram.ld but
without updating the corresponding linker_script/common/common-ram.cmake
linker script generator code.
This causes test cases for arm Compiler 6 to fail.
Add the same section to common-ram.ld.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The PR #40174 changed `configure_linker_script()` macro from handling a
single string to handle a list of strings for the
linker_pass_define argument.
This changed the armlink/target.cmake from STREQUAL to IN_LIST, however
as `configure_linker_script()` is a macro, then arguments are not
variables in the CMake sense but string replacements, and therefore
IN_LIST doesn't work directly on the argument.
Fix this by creating a true CMake list from the content of the argument
and use this list for IN_LIST checking.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The armlink/target.cmake should not source ld/target_base.cmake file
as it provides its own (empty) implementation of the
`toolchain_ld_base` macro.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit adds a change to support running west sign command even if
the keyfile is not provided. Default value of the configuration
is set to n in order to maintain backward compatibility.
Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
The CMake policies CMP0002 and CMP0116 can now safely be removed.
Setting CMake minimum version to 3.20 ensures that policies are set to
NEW per default for those two policies:
> The cmake_minimum_required() command does more than report an error
> if a too-old version of CMake is used to build a project. It also sets
> all policies introduced in that CMake version or earlier to NEW
> behavior.
CMP0002 was introduced in CMake 2.6 and was set to NEW.
CMP0116 was introduced in CMake 3.20 and set to OLD because of:
> Use the old CMake behaviour until we are updating the CMake 3.20 as
> minimum required. This ensure that CMake >=3.20 will be consistent
> with older CMakes.
and can thus be removed as we are now having 3.20 as minimum required.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Remove xtensa specific workaround as this code is now present in Zephyr
SDK cmake code.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
With the revert of commit 820d327b4618d587a9cae0d085f00c6ab9c81cf2 then
some additional code can be cleaned up.
This removes the final left-overs from Zephyr SDK 0.11.1 support and
older.
It further aligns message printing when including Zephyr SDK toolchain
to other toolchain message printing.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This reverts commit 820d327b4618d587a9cae0d085f00c6ab9c81cf2.
Commit b973cdc9e8 updated the minimum
required Zephyr SDK version to 0.13.
Therefore revert commit 820d327b4618d587a9cae0d085f00c6ab9c81cf2 as
backward support for 0.11.1 and 0.11.2 is no longer required.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fix the zephyr_linker_dts_memory to lookup the correct property name
when trying to figre the region name.
Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
After having resolved all of the instances of packed member access,
re-enable the warning.
Fixes#16587.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Remove the `NAME` function argument from `zephyr_linker_dts_memory` as
the name is now automatically derived from the devicetree node.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Update the linker script generator to automatically derive memory
region names from the devicetree node according to the same logic in
`devicetree_regions.h`.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This causes any devicetree error messages to refer to the source files
which contain the errors instead of intermediate <BOARD>.dts.pre.tmp
files in the build directory.
Do this using a new python-devicetree feature which can correctly
handle cpp's generated line marker directives.
To use this feature, rework the way that the C preprocessor is run on
devicetree inputs so that line marker directives are preserved by
removing the -P option.
This is a backwards incompatible change to the way the generated files
in the build directory used to work, as not all tools can consume line
markers. In particular, dtc can't handle these lines. We therefore
pass dtc zephyr.dts instead (the final parsed devicetree output from
python-devicetree).
Since <BOARD>.dts.pre.tmp is a publicly documented file, this is
changing existing behavior, so use a new file name for the
intermediate files to make it more obvious that something changed. In
particular, use zephyr.dts.pre instead of <BOARD>.dts.pre.tmp.
(The $BOARD.dts.pre.tmp name is a little cumbersome anyway.)
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Curently, any and all devicetree syntax errors are being handled by
dtc, because it runs before gen_defines.py. This means that any
improvements we make to devicetree error handling and reporting in
dtlib or edtlib will never be noticed by users that have dtc
installed.
(This also has the unfortunate effect of hiding dtlib error reporting
from me, since my systems all have dtc installed.)
Move dtc to after gen_defines.py, so that initial error handling and
warnings all come from python. If DTC has some additional warnings or
errors to report, let them come last. They will still halt the build
if anything is wrong.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
When multiple shields are defined, only the shield last in the -DSHIELD
list gets defined in `.config`. This is due to too many backslashes
used defining it for an env setting.
Signed-off-by: Ryan McClelland <ryanmcclelland@fb.com>
In the python APIs we use for devicetree, you can generally use an
alias interchangeably with the full path to a node.
For example, dtlib.py says:
[...] both dt.get_node("/foo/bar") and dt.get_node("bar-alias")
will return the 'bar' node below:
/dts-v1/;
/ {
foo {
bar_label: bar {
baz {
};
};
};
aliases {
bar-alias = &bar-label;
};
};
Fetching subnodes via aliases is supported:
dt.get_node("bar-alias/baz") returns the 'baz' node.
Now that we have the necessary helper functions for resolving alias
names, make the CMake APIs to devicetree behave the same way. This
improves consistency between the two sets of devicetree helpers used
by the build system, making them both match the general devicetree
practice that an alias is as good as a path. This is good for
consistency.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This is a helper function for looking up the path to a devicetree
alias. It is analogous to dt_chosen(). It has to exist as a separate
function from dt_prop() for similar reasons that dt_chosen() does:
the edtlib APIs for interacting with /aliases are special-cased in the
same way they are for /chosen.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Fixes an issue on SOF-supported boards where the build system
incorrectly believed that the rimage target was changing when rerunning
CMake, even though the user did not change any configuration. This issue
was introduced in commit 525fa76f4d.
Create initial build dir:
$ west build --board intel_adsp_cavs18 samples/subsys/audio/sof
Re-run CMake with no arguments in that build dir:
$ cd build
$ cmake .
CMake Warning at /home/mhelm/zephyrproject/zephyr/cmake/extensions.cmake:2403 (message):
The build directory must be cleaned pristinely when changing rimage target,
Current value="", Ignored value="cnl"
Call Stack (most recent call first):
/home/mhelm/zephyrproject/zephyr/cmake/extensions.cmake:829 (zephyr_check_cache)
/home/mhelm/zephyrproject/zephyr/boards/xtensa/intel_adsp_cavs18/board.cmake:6 (board_set_rimage_target)
/home/mhelm/zephyrproject/zephyr/cmake/app/boilerplate.cmake:635 (include)
/home/mhelm/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
/home/mhelm/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
CMakeLists.txt:5 (find_package)
Signed-off-by: Maureen Helm <maureen.helm@intel.com>
Create the ZEPHYR_MODULES_NAMES list of zephyr modules present in the
system before calling roots defined in `MODULE_EXT_ROOT`.
This will allow external module roots to process based on Zephyr modules
available in the system.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #40590
This commit updates gen_app_partitions.py to include only files present
in the current build by extracting the information from the CMake
generated `compile_commands.json` file.
This ensures that object files in sub-projects, such as `empty_cpu0`,
will not be considered by the script.
Using the compile_commands.json instead of walking the whole build tree
for finding object files also improves performance:
Time of executing `gen_app_partitions.py` (Old):
__________________________
Executed in 480.06 millis
usr time 425.83 millis
sys time 49.55 millis
Time of executing `gen_app_partitions.py` (New):
________________________________________________________
Executed in 76.22 millis
usr time 49.00 millis
sys time 24.59 millis
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
boilerplate.cmake contained a comment referring to CMake 3.13.1 but
minimal required version is 3.20, so update the comment to 3.20.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Removes hardcoded logic in the west signing script that translates
Zephyr board names to rimage target names. Instead, use a cached CMake
variable set at the board level to define its respective rimage target
name. This eliminates the need to modify the west signing script when
new SOF-supported boards are introduced to Zephyr.
Signed-off-by: Maureen Helm <maureen.helm@intel.com>
DTC can be built with both traditional Makefiles or Meson. When built
with Makefiles the --version output looks like 'Version: DTC
1.6.1-dirty' but when built with Meson the output is 'Version: DTC
v1.6.1+.
This fails to match the version regex and the cmake then fails:
CMake Error at cmake/host-tools.cmake:28 (if):
if given arguments:
"VERSION_GREATER" "1.4.6"
Unknown arguments specified
Expanding the regex with an optional 'v' covers both cases and the build
succeeds.
Signed-off-by: Ross Burton <ross.burton@arm.com>
This commit reworks the linker script generation and linking stages in
order to better support fixed section location as required by #38836.
Today we have the following generated linker scripts and the elf output
depending on the system configuration:
- linker_app_smem_unaligned.cmd --> app_smem_unaligned_prebuilt.elf
- linker_zephyr_prebuilt.cmd --> zephyr_prebuilt.elf
- linker.cmd --> zephyr.elf
as not all linker scripts may be created and as there is a need for the
possibility to move gen handles earlier then those stages has been
renamed into more generic names so that with this commit we have:
- linker_zephyr_pre0.cmd --> zephyr_pre0.elf
- linker_zephyr_pre1.cmd --> zephyr_pre1.elf
- linker.cmd --> zephyr.elf
This also means that is the stage zephyr_pre1 is not needed, then build
can go from `zephyr_pre0.elf` to `zephyr.elf`.
The gen_handles.py has been changed so it now uses `zephyr_pre0.elf` as
input. This ensures that the handles array are final when invoking the
next build and linking stages.
To keep the current behavior of generating the isr table and kobj hash
of what was `zephyr_prebuilt` stage the code blocks contolling isr
generation and kobj hash has been relocated to be located after
app_smem and device handle generation.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Introduce a new global property for source files that are generated from
the initial Zephyr link (app_smem_unaligned_prebuilt). This source list
is used for files which will introduce address shifts into the final
binary, which need to be present in `zephyr_prebuilt.elf` for
`CONFIG_USERSPACE` scripts to correctly generate `zephyr.elf`.
This resolves#38836.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
The previous description of the `GENERATED_KERNEL_*` cmake variables
was incorrect in that these are generated after the second link stage
when `CONFIG_USERSPACE` is enabled.
The sources in these variables are generated from `zephyr_prebuilt.elf`
for inclusion in `zephyr.elf`. However `zephyr_prebuilt.elf` is preceded
by `app_smem_unaligned_prebuilt.elf` when `CONFIG_USERSPACE` is enabled.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Currently there is no way to support running a board on multiple
emulation platforms nor to choose a desired emulation platform for the
simulation to be run on. This commit introduces a new
SUPPORTED_EMU_PLATFORMS list, which defines available emulation
platforms for a given board.
Fixes#12375.
Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
This commit is motivated by the west discussion in:
https://github.com/zephyrproject-rtos/west/issues/548
The commit provides the ability to generate a build meta info file
containing lists of:
- Zephyr: path and revision
- Zephyr modules: name, path, and revision
- West: manifest path
path and revision for each project
For Zephyr or Zephyr modules the revision will be `null` if it is not
under git version control.
If Zephyr, a modules, or a project has uncommitted changes, the revision
will be marked dirty.
If west is not installed or used for the build process, the
west-projects list will be empty.
If a project is both a Zephyr module and a west project it will show up
in both lists.
Similar to Zephyr, which is independently referred as the Zephyr in use
but also listed as west project when west is used.
This is important in case ZEPHYR_BASE was manually set and pointing to
a different Zephyr repository.
The build meta file is not created per default but can be enabled with
the BUILD_OUTPUT_META Kconfig setting.
A project using west and having an extra Zephyr module loaded not
controlled using git can look like:
zephyr:
path: /.../zephyr
revision: 863600cd0e3c0a271e86629c5089821e5e4380cc-dirty
modules:
- name: mcuboot
path: /.../bootloader/mcuboot
revision: c61538748ead773ea75a551a7beee299228bdcaf
- name: local_module
path: /.../local_module
revision: null
west:
manifest: /.../zephyr/west.yml
projects:
- path: /.../zephyr
revision: 863600cd0e3c0a271e86629c5089821e5e4380cc-dirty
- path: /.../bootloader/mcuboot
revision: c61538748ead773ea75a551a7beee299228bdcaf
- path: /.../tools/net-tools
revision: f49bd1354616fae4093bf36e5eaee43c51a55127
And without west:
zephyr:
path: /.../zephyr
revision: 863600cd0e3c0a271e86629c5089821e5e4380cc-dirty
modules:
- name: hal_nordic
path: /.../modules/hal/nordic
revision: a6e5299041f152da5ae0ab17b2e44e088bb96d6d
west: null
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
With this commit a dedicated APPLICATION_CONFIG_DIR is added to the
Zephyr build system.
Currently, the APPLICATION_SOURCE_DIR is identical also the base
location of configuration files.
This is very practical for simple samples, but also has it limitations
for more complex setups.
Introducing a dedicated APPLICATION_CONFIG_DIR allows users more
customization options in Zephyr build system.
Especially in terms of custom build configuration files unknown to
Zephyr itself.
For example, instead of all configuration files being located directly
in the application source folder, a project might prefer to organize
their configuration files on a per board basis, for example:
<app>/boards/custom_board_A/prj.conf
<app>/boards/custom_board_A/app.overlay
<app>/boards/custom_board_A/custom_file.mine
<app>/boards/custom_board_B/prj.conf
<app>/boards/custom_board_B/app.overlay
<app>/boards/custom_board_B/custom_file.mine
...
instead of n-files located in the root of the sample.
If the user / sample specifies APPLICATION_CONFIG_DIR, then this folder
will always be used instead of the default configuration folder.
As part of this extension the behaviour of
`-DCONF_FILE=<relative-path>/prj_<build>.conf` and additional Kconfig
fragments automatic sourcing has been aligned with the default behavior
of `prj.conf`.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The `merge_config_files` list contains files with both relative and
absolute paths.
Each entry is checked and files with a relative path are converted to
absolute path. This creates a `merge_config_files_with_absolute_paths`
identical to the `merge_config_files` but with absolute path on each
entry.
Afterwards it is mixed whether `merge_config_files` or
`merge_config_files_with_absolute_paths` are used creating unnecessary
risk when the list with relative path files are used.
This commit sets the content of `merge_config_files` with updated
absolute paths files, and also updates all places to use this list.
This ensures that after path conversion then only the list with absolute
paths is used.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
To prepare for linker script creation with flexible number of linker
passes depending on system configuration then the Zephyr CMake linker
script generator has been updated to use pass names instead of pass
numbers.
This allows greater flexibility as a section can now be active based on
the settings on the pass and not the linking pass index number.
As part of this, the `PASS` processing in `linker_script_common.cmake`
has been adjusted so that it properly handles when a linking pass is
handling multiple settings, such as both `LINKER_APP_SMEM_UNALIGNED`
and `DEVICE_HANDLES_PASS1` in same linking pass.
As the number of linking passes are more flexible, then the PASS
argument in `zephyr_linker_section()` and
`zephyr_linker_section_configure()` has been updated to also support
a `NOT <name>` argument, for example: `PASS NOT LINKER_ZEPHYR_FINAL`.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Currently all calls to `configure_linker_script()` specifies `-D<name>`
when calling `configure_linker_script()`.
This works well for the gcc pre-processed ld linker script templates,
but Zephyr also supports a CMake linker script generator which can be
used for ld scripts and armlink scatter files.
In this case, a `-D` must be stripped.
This commit changes this so that Zephyr CMake build system calls
`configure_linker_script()` without `-D`.
Thus the `LINKER_SCRIPT` choice can decide how this information should
be passed to underlying linker script functionality, that is `-D` for
linker script template and CMake variable for the CMake linker script
generator.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
When QEMU is running in icount mode, the behaviour regarding
the CPU being in sleep mode is configurable, with the default
value being set to 'off'. In this case, instruction counting
continues even when the CPU is sleeping or no target time is
set in the system timer. If the sleep parameter is set to
'on', instruction counting stops if the CPU is sleeping, and
the instruction count will fast-forward directly to the next
target time once it is being set.
In the Xilinx derivative of QEMU (which simulates ZynqMP and
Zynq-7000 SoCs), the default configuration causes QEMU to no
longer accept control commands via the console or remotely
whenever Zephyr enters and remains in idle mode.
Therefore, this commit makes the value of the sleep para-
meter of the icount functionality configurable, with the
default value remaining 'off'. The value can be changed at
board level alongside with the specification of the icount
shift value.
Signed-off-by: Immo Birnbaum <Immo.Birnbaum@Weidmueller.com>
This commit creates a new `zephyr_build_string()` function.
`zephyr_build_string()` provides a common way of constructing a build
string based on board name, board revision, and build type.
Having this as a function facilitate creation of names in a common way
and thus helps to ensure naming consistency, especially if newer info
is later embedded into the build string.
Initially the build string will be used to lookup configuration
fragments and devicetree overlay files.
This function is used by `zephyr_file(CONF_FILES ...)`.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This option was deprecated for the v2.6 release, and has therefore met
the 2 release deprecation cycle requirements.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Update -fno-pie to only be added when relevant. This fixes native_posix
builds on Debian hosts.
* Debian and other Linux distributions have ld with --warn-textrel as
default.
* The option generates a warning when linking on x86.
* The warning make scripts/twister fail because we treat all warnings
as error.
* The warning is issued when no PIE objects are linked against PIE
library.
* PIE (Position Independent Executable) or not can be seen with the
following command.
* When you want to generate non PIE, link with `-no-pie.`
Non PIE
$ readelf -l build/zephyr/zephyr.elf | grep 'Elf file type is'
Elf file type is EXEC (Executable file)
PIE
$ readelf -l /lib/x86_64-linux-gnu/libc.so.6 | \
grep 'Elf file type is'
Elf file type is DYN (Shared object file)
Issue #35244
Signed-off-by: Yuval Peress <peress@google.com>
Setting of DTC_OVERLAY_FILE as an environment setting was deprecated
before Zephyr 1.14 LTS.
This commit remove the support for this possibility and thus cleans up
the build system.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #36558#32577
This commit introduces CMAKE_C_COMPILE_FEATURES and
CMAKE_CXX_COMPILE_FEATURES.
This allows users to use the `target_compile_features()` in their own
code.
In Zephyr, the CMAKE_C/CXX_COMPILE_FEATURES are defined based on the
compiler and the Kconfig / CSTD setting.
Doing so ensures that a user compiling Zephyr with c99 and specifies
`target_compile_features(<target> ... c_std_11)` will get an error.
And similar if building Zephyr with C++ support and c++11, but testing
for `target_compile_features(<target> ... cxx_std_17)`.
For example in the C++ case, the user must ensure that Zephyr is
compiled with C++17, that is: CPLUSPLUS=y and STD_CPP17=y, in which case
the CMAKE_CXX_COMPILE_FEATURES will contain support for C++17 and thus
the `target_compile_features(<target> ... cxx_std_17)` will succeed.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
In order to retrieve TOOLCHAIN_NAME from Kconfig,
generic.cmake points to any toolchain as a
boilerplate implementation. Now, target.cmake file handles
proper toolchain selection.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
The root cause of #38591 was region symbols being placed before the
section description for data region.
To support both schemes with the linker generator, a new
`SYMBOL SECTION` argument has been added to the zephyr_linker_group()
function.
This commit updates the arm/linker.cmake CMake linker file to use the
new `SYMBOL SECTION` argument for the data region group and text region
group so that those two groups now behave identical to the behavior when
using the cortex_m linker.ld template.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The root cause of #38591 was region symbols being placed before the
section description for data region.
Some region start symbols are placed before section description, other
region start symbols are placed inside the first section in the region
and thus identical to the sections own first symbol.
To support both schemes with the linker generator, a new
`SYMBOL SECTION` argument has been added to the zephyr_linker_group()
function.
The ld_script.cmake linker script generator has been updated to support
the new argument so that generated ld linker script has identical
behavior to the templated ld linker scripts.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit sets the minimum required Zephyr SDK version to 0.13.1,
which fixes the following critical issues:
1. Xtensa initial malloc failure (GitHub issue #38258)
2. ARMv8-M security extension vulnerability (CVE-2021-35465)
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Fixes: #38761
The introduction of zephyr_library_property in #38347 contained a
stray function call `target_compile_definitions()` resulting in the
library property name and value to also be added compile definitions to
the Zephyr library.
The Zephyr library property is an internal property and is not supposed
to be added as compile definitions, and thus this call is removed with
this commit.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
GDB can be built with or without Python support. When built with Python
support this can cause a particular problem: The gdb executable relies
on shared libraries that are bound to a specific Python version. But
since most Linux distributions typically ship with a single version, it
is very difficult to choose which one to target when building GDB.
When GDB executes, if it fails to load the shared libraries it will exit
immediately with an error code of 127 and output resembling this:
/home/carles/bin/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb:
error while loading shared libraries: libpython3.8.so.1.0: cannot open
shared object file: No such file or directory
There are two known approaches to shipping multiple gdb executables:
- The Zephyr SDK ships a default gdb with Python enabled, and then a
separate gdb-no-py executable with Python disabled
- GNU Arm Embedded ships with a default gdb with Python disabled, and an
additional gdb-py with Python enabled
To mitigate the problem of not being able to debug, fall back to a
'gdb-no-py' if it exists whenever the standard gdb executable fails to
even run.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fixes: #38558
This commit removes: `cmake_policy(SET CMP0079 OLD)`
This means Zephyr will now allow the new CMP0079 behavior introduced
with CMake version 3.13.
Code has now been examined and no occurences has been found where the
INTERFACE keyword was used with `target_link_libraries()` outside the
CMakeLists.txt scope where the original libraries were created.
As an additional safeguard `./scripts/twister -c -N --cmake-only`
has been executed before and after this change and all `build.ninja`
files for each test / sample have been diffed.
Removing the CMP0079 policy creates identical build files, hence removal
of the old policy will not impact the build.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit adds the `nostdincxx` C++ compiler property for GCC, which
is specified when the C++ standard library (`CONFIG_LIB_CPLUSPLUS`) is
disabled.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit adds a new C++ compiler property `nostdincxx` which
specifies the C++ compiler flag for excluding the C++ standard library
include directory from the include paths.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Fixes: #37637
toolchain_parse_make_rule() parses depfiles and converted `\\` to the
CMake list separator `;`.
However, gcc -M might create depfiles with windows path separator `\`
causing this conversion to fail, as a path like:
c:\...\zephyr\samples\drivers\led_ws2812\nrf52-bindings.h
resulting in a file list as:
c:;...;zephyr;samples;drivers;led_ws2812;nrf52-bindings.h
which results in a CMake configure dependency to be added to `C:`.
As C: is always newer than the build.ninja file, this resulted in
continues CMake re-invocation.
As a small side-note, the `\` in file name did only occur in situations
where a relative past had been used elsewhere in the build system, such
as here:
https://github.com/zephyrproject-rtos/zephyr/blob/\
c3050a5aab1e86d02642eb4c6a027419e6a3a096/samples/drivers/led_ws2812/\
boards/nrf52dk_nrf52832.overlay#L9
To ensure proper handling of files, then all files are converted to
CMake paths, that is with forward slashes: `/`
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
If the BOARD_RUNNER_ARGS_${runner_id} variable contains anything, add
it to the global property of the same name with all the final runner
args from board_runner_args() and friends.
This allows use cases like this:
west build ... -- -DBOARD_RUNNER_ARGS_jlink="--some-jlink-arg"
The ${runner_id} part is the runner's name converted to a C
identifier, i.e. with special characters changed to underscores.
So e.g. the 'dfu-util' runner would use BOARD_RUNNER_ARGS_dfu_util.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Cadence XCC is based off of a very old 4.2 gcc compiler, which didn't
perfectly support C99 "inline" semantics with respect to
cross-translation-unit inline linkage (which Zephyr does not use, our
inlines are static only) and declaration order.
Fix the one spot where we were calling an inline before its
ALWAYS_INLINE definition, and add a flag to suppress the warning so
CI's trying to build with XCC and -Werror don't flip out.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This introduces a dedicated zephyr_library_property() function which
provides a common way to set Zephyr build system known properties on
Zephyr libraries.
As a first common property is the `ALLOW_EMPTY` property which allows
to create a `zephyr_library()` without putting any content inside of it.
In general libraries should not be created unless there are files to
places inside of it, however in some cases there are so many
`zephyr_library_sources_ifdef(<setting> <file.c>)`
where testing each setting before creating the library may not be
desired.
This commit allows the following construct in those cases:
```
zephyr_library()
zephyr_library_property(ALLOW_EMPTY TRUE)
zephyr_library_sources_ifdef(CONFIG_SETTING_1 file_1.c)
zephyr_library_sources_ifdef(CONFIG_SETTING_2 file_2.c)
...
zephyr_library_sources_ifdef(CONFIG_SETTING_n file_n.c)
```
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
It may be needed to run Zephyr at EL1NS level with `CONFIG_ARMV8_A_NS`
In order to run at EL1NS, you'll need a proper Firmware loaded in the
FVP model to run Zephyr at non-secure EL3.
The ARM TF-A for FVP can used to run Zephyr as preloaded BL33.
This adds the necessary cmake scripts to load the TF-A binaries and
load Zephyr as preloaded BL33 payload.
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
The `set_conf_file()` was deprecated in
6d4ba3490f
which is before Zephyr v1.14 LTS.
Let's remove the support now, before releasing a new LTS.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
For each compiler, also set a CMAKE_GCOV var referencing the appropriate
gcov tool.
Tested with gcc and host-gcc on the ChromeOS codebase.
Signed-off-by: Jeremy Bettis <jbettis@chromium.org>
__cxa_atexit implementation provided by MWDT startup code calls
malloc which isn't supported right now. As we don't support
calling static destructors in Zephyr let's provide our own
__cxa_atexit stub and get rid of MWDT startup libs
entirely.
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
This commit adds the half-precision (16-bit) floating-point
configurations to the ARM AArch32 architectures.
Enabling CONFIG_FP16 has the effect of specifying `-mfp16-format`
option (in case of GCC) which allows using the half-precision floating
point types such as `__fp16` and `_Float16`.
Note that this configuration can be used regardless of whether a
hardware FPU is available or supports half-precision operations.
When an FP16-capable FPU is not available, the compiler will
automatically provide the software emulations.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Support for ARM Compiler C library.
This commit add support for the ARM Compiler C libary in:
- Kconfig
- libc/armstdc
A new Kconfig symbol is added to allow a toolchain to specify if they
support linking with the minimal C library.
Also the CMake variable `TOOLCHAIN_HAS_NEWLIB` is exported to Kconfig
so that CONFIG_NEWLIB_LIBS can only be enabled if the toolchain has
newlib.
The armclang toolchain selects the CMake scatter file generator and
disables support for the LD linker template which is not supported by
armlink.
For the ARM Compiler C library, a corresponding lib/libc/armstc/ folder
with a minimal implementation to work with the ARM Compiler C library
is added.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit introduces armlink steering file.
A steering file in armlink allows Zephyr to keep using existing linker
symbols defined in ld scripts and used throughout the code tree.
The steering file is generated at build time in order to resolve Zephyr
linker symbols to their corresponding armlink symbols.
As example, Zephyr defines __ramfunc_start which corresponds to the
armlink auto defined Image$$ramfunc$$Base symbol.
Or __init_PRE_KERNEL_1_start which corresponds to Image$$init_0$$Base.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The default armlink signature uses `--list=<TARGET_BASE>.map`, but in
Zephyr we uses a different name for the map file, therefore we need to
specify a custom link executable signature.
This is done in the linker specific flags file:
cmake/linker/armlink/linker_flags.cmake
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
When using ARMClang linker and scatter files (armlink) then all
libraries are linked as object libraries using `$<TARGET_OBJECTS:lib>`.
CMake version 3.20 only has limited support for such linking:
> Referencing $<TARGET_OBJECTS> in target_link_libraries calls worked
> in versions of CMake prior to 3.21 for some cases, but was not fully
> supported.
One of those cases that do not work is Unix Makefiles generators.
As only Ninja is currently verified to work, this commit will check the
CMake version in use and the generator, and if CMake version <=3.21 is
used with non-Ninja generator then an error is raised informing user
to either use Ninja generator or update CMake.
As the Ninja generator has been confirmed to work as expected, then that
generator is accepted with CMake 3.20 and older.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This is the initial support for the armclang compiler together with the
armlink linker.
Introduced in this commit:
- armclang compiler support
- armlink linker support
- armlink scatter file generator for scatter loading
- dual pass linker script generation
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Initial bintools support for elfconvert
- hex, srec, bin conversion
- strip
- gap fill
Initial bintools support for readelf
Initial bintools support for disaasembly
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
A "Linker script" choice group has been added to the linker options
menu.
The existing HAVE_CUSTOM_LINKER_SCRIPT config has been relocated inside
the linker script menu.
Two new entries has been created:
- LD template, for using the old ld template files together with the C
pre-processor to create the final linker script.
- CMake linker generator, used for ARMClang / armlink toolchain.
The CMake linker generator is also supported for LD linker scripts
for the ARM architecture.
In CMake, the file cmake/linker/ld/target.cmake has been updated to
support the CMake LD linker generator.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Adding intial version of ld_script.cmake.
This script can generate ld linker script from the Zephyr CMake linker
functions.
This script is called by the build system and all linker settings, such
as memory regions, groups, output sections, linker symbols defined with
Zephyr CMake linker functions are passed to this script in order to
generate an ld linker script.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Adding intial version of linker_script_common.cmake.
This script parses memory regions, groups, sections, settings, and
symbols defined in the Zephyr CMake build system.
The linker script creates objects for each type above and groups
sections, symbols, and groups together based on their configuration.
This creates a hierarchy which the `<linker>_script.cmake`
implementations can then use during linker script generation.
linker_script_common.cmake also provides stubs for <type>_to_string()
functions which are used when generating the output script.
Each specific `<linker>_script.cmake` must implement those to_string()
functions to create the final linker script.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit add devicetree memory regions added to arm/linker.cmake.
The following memory regions are now added to the generated linker
script and scatter file if they exists in the devicetree.
- chosen: zephyr,itcm
- chosen: zephyr,dtcm
- nodelabel: ti_ccfg_partition
- nodelabel: sram1
- nodelabel: sram2
- nodelabel: sram3
- nodelabel: sram4
- nodelabel: sdram1
- nodelabel: sdram2
- nodelabel: backup_sram
Also support for the itcm and dtcm section and their placement in
corresponding memory regions has been added.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This is the initial version of a Zephyr CMake linker file for the arm
architecture.
This file defines memory regions, groups, linker sections and symbols
for the arm architecture.
It also sources the common common-ram.cmake, common-rom.cmake,
debug-sections,cmake, and thread-local-storage.cmake.
It configure sections for SoC families using zephyr_linker_sources()
functions:
- nxp_imx
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Converted existing ld script templates into CMake files.
This commit takes the common-ram.ld, common-rom.ld, debug-sections.ld,
and thread-local-storage.ld and creates corresponding CMake files for
the linker script generator.
The CMake files uses the new Zephyr CMake functions:
- zephyr_linker_section()
- zephyr_linker_section_configure()
- zephyr_linker_section_obj_level()
to generate the same linker result as the existing C preprocessor based
scheme.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit introduces zephyr_linker_dts CMake functions for creation of
linker scripts based on devicetree nodes.
The linker devicetree functions supports the following features:
- Configuration of memory sections based on devicetree nodes
Overview of functions introduced with this commit:
- zephyr_linker_dts_memory
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit introduces zephyr_linker CMake functions for creation of
linker scripts.
The linker functions supports the following features:
- Configuration of memory sections
- Configuration of memory groups
- Creation of output sections
- Configuration of input section the should go into output section and
how those should be treated, such as sorting, keep, priority.
- Defining linker symbols
- Specifying Kernel VMA to support virtual linking on x86
Overview of functions and macros introduce with this commit:
- pow2round
- zephyr_linker
- zephyr_linker_memory
- zephyr_linker_memory_ifdef
- zephyr_linker_group
- zephyr_linker_section
- zephyr_linker_section_ifdef
- zephyr_iterable_section
- zephyr_linker_section_obj_level
- zephyr_linker_section_configure
- zephyr_linker_symbol
- zephyr_linker_property_append
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The current gen_handles.py script uses linker defined symbols.
As preparation for support of more linkers the gen_tables.py now takes
the device start symbol as argument.
For example, armlink and ld uses different symbols.
With ld those can be named explicitly, but for armlink the linker
decides the names.
For ld, Zephyr defines: __device_start
For armlink, the symbol is defined as: Image$$<section name>$$Base
Therefore knowledge of the linker symbol to be used must be passed to
gen_handles.py so that the correct symbol can be used for locating
devices.
To support this change, the creation of the asm, compiler, compiler-cpp,
linker targets has been moved from target_toolchain_flags.cmake to
target_toolchain.cmake.
All linkers has been updated to support the use of the
device_start_symbol on the linker target.
List of linkers updated:
- ld
- lld
- arcmwdt
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>