Too many times, code is pushed that includes floats that really
becomes doubles and C implicit promotion rules will want to make
floats into doubles very easily. As zephyr primarily targets
low-end process that may not have a double precision floating
point unit, enable this flag globally for now.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
If an ld file is included multiple times using `zephyr_linker_sources`,
only the last occurrence is actually used. Everything else is removed
again from the generated snippet files.
This allows to relocate certain blocks, e.g. the vector table, in an
application-specific CMakeLists.txt (or for an arch or soc).
Fixes: #66315
Signed-off-by: Greter Raffael <rgreter@baumer.com>
Enable GCC builtin static analysis in Zephyr's static code analysis
(SCA) infra.
When this option is enabled GCC performs a static analysis and
can point problems like:
sample.c
+ int *j;
+
+ if (j != NULL) {
+ printf("j != NULL\n");
output:
${ZEPHYR_BASE}/samples/userspace/hello_world_user/src/main.c:30:12:
warning: use of uninitialized value 'j' [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
30 | if (j != NULL) {
| ^
'main': events 1-2
|
| 25 | int *j;
| | ^
| | |
| | (1) region created on stack here
|......
| 30 | if (j != NULL) {
| | ~
| | |
| | (2) use of uninitialized value 'j' here
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This tests whether there actually is an itcm or dtcm in the device tree.
Otherwise a FATAL_ERROR is generated.
Signed-off-by: Greter Raffael <rgreter@baumer.com>
This allows to link code and data blocks, e.g. the vector table, into
tightly coupled memory using `zephyr_linker_sources`.
Signed-off-by: Greter Raffael <rgreter@baumer.com>
Since v3.13, CMake has supported math(... OUTPUT_FORMAT <format>), which
will perform the same functionality as to_hex().
Signed-off-by: Attie Grande <attie.grande@argentum-systems.co.uk>
Since v3.13, CMake has supported math(... OUTPUT_FORMAT <format>) and 0x
prefixes on numbers, which together provides the same functionality as
to_hex() and from_hex() that we've previously maintained.
Users should switch to using math() instead, and our functions are now
marked as deprecated.
Signed-off-by: Attie Grande <attie.grande@argentum-systems.co.uk>
Previously, `to_hex(0 output)` would have placed `0x` into the `output`
variable, which is undesirable... this fix ensures that `0x0` is placed
into this variable if the input is zero.
Signed-off-by: Attie Grande <attie.grande@argentum-systems.co.uk>
Minimize the amount of flags that are hardcoded in the llext.cmake
module by moving them to the compiler specific cmake files.
The llext.cmake module will now use the new LLEXT_REMOVE_FLAGS and
LLEXT_APPEND_FLAGS global variables to adjust the set of flags used
to compile the llext code. This will make it easier to add support
for new architectures and compilers.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
Separate the compilation of the source file from the conversion to an
llext file. This allows to reuse the include directories and macro
definitions of the current Zephyr build while compiling the llext source.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
This patch defines a generic function that encapsulates all the
architecture-specific machinery needed to compile llexts from source
files. Current tests are updated to use this function.
Output and source files must be specified using the OUTPUT and SOURCES
arguments. Only one source file is currently supported.
Arch-specific flags will be added automatically. The C_FLAGS argument
can be used to pass additional compiler flags to the compilation of
the source file.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
8cc716792a renamed this variable to lower
case to indicate it's only used locally however WEST_ARG is used as a
parameter of zephyr_module.py in CMakeLists.txt when
CONFIG_BUILD_OUTPUT_META is enabled.
This variable was used when west had some limitation. It does not
really make sense now, so it has been removed and content of west_arg
variable has been added by default.
Signed-off-by: Thomas Gagneret <tgagneret@witekio.com>
Fix an issue where updating a `zephyr_code_relocate()` call in CMake
didn't trigger regeneration of `code_relocation.c` and linker scripts.
The generation command was missing a dependency on the aforementioned
input text file, where the outcome of each call is cached.
Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
When using the code and data relocation feature, every relocated symbol
would be marked with `KEEP()` in the generated linker script. Therefore,
if any input files contained unused code, then it wouldn't be discarded
by the linker, even when invoked with `--gc-sections`.
This can cause unexpected bloat, or other link-time issues stemming from
some symbols being discarded and others not.
On the other hand, this behavior has been present since the feature's
introduction, so it should remain default for the users who rely on it.
This patch introduces support for `zephyr_code_relocate(... NOKEEP)`.
This will suppress the generation of `KEEP()` statements for all symbols
in a particular library or set of files.
Much like `NOCOPY`, the `NOKEEP` flag is passed to `gen_relocate_app.py`
in string form. The script is now equipped to handle multiple such flags
when passed from CMake as a semicolon-separated list, like so:
"SRAM2:NOCOPY;NOKEEP:/path/to/file1.c;/path/to/file2.c"
Documentation and tests are updated here as well.
Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
There are some situations like #67035 where sparse aborts and returns an
error code before the compiler has generated the .obj file; without any
clear indication that the .obj is missing (in normal situations sparse
prints warnings and _does_ creates the .obj file)
Also, builds are parallel by default and sparse runs tend to be massive
walls of text which all conspires to make it totally impossible to find
the relevant error message. Instead, we get an link-time error.
The only clear indication is the exit code. So catch it and abort the
build ASAP thanks to COMMAND_ERROR_IS_FATAL.
More generally speaking, the default behavior of execute_process() to
ignore errors is crazy. How frequently does a build system run commands
that do NOT matter?
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Set align to 1 for CONFIG_MCUBOOT_IMGTOOL_OVERWRITE_ONLY,
used by non-swap update modes.
Fix imgtool error message for device with write size > 32B.
Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
_FORTIFY_SOURCE=1 differs from _FORTIFY_SOURCE=2 only in the bounds
checking mode that it uses.
With _FORTIFY_SOURCE=1, bounds checks are 'loose', allowing access to the
whole underlying object, not just the subset referenced in the expression
(e.g, the bounds of a struct member is the whole struct, not just the
member).
With _FORTIFY_SOURCE=2, bounds checks are strict, meaning that the bounds
of an expression are limited to the referenced value.
Both of these perform their checks at runtime, calling _chk_fail if the
bounds check fails. That's done in the __*_chk functions included in the C
library. These are always called when _FORTIFY_SOURCE > 0, unless the
compiler replaces the call with inline code.
GCC already does all of the compile-time bounds checking for string and mem
functions when not using -ffreestanding, so there's nothing we need to add
for that to work. That means the security_fortify_compile_time property
should be empty.
Signed-off-by: Keith Packard <keithp@keithp.com>
Changes shield processing order from being on a root-by-root
basis to being order they were supplied to cmake
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Replace mutexes with semaphores to protect the channels in conjunction with
a priority boost algorithm based on the observers' priority.
Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
Update description of board_runner_args() function so that it is
described that app_set_runner_args macro must be defined before the call
to `find_package(Zephyr)`.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
ERROR_QUIET should be used only when the command is actually expected to
fail, otherwise discarding stderr can be extremely time-consuming. See
recent example of time lost in commit 40c2e08e82 ("xcc/cmake: don't
discard stderr; don't (ever!) use ERROR_QUIET")
If some Python interpreter cannot even evaluate `sys.version_info[:2]`,
then we definitely don't want to hide what its stderr says about that.
Fixes commit 94de3e9f60 ("cmake: FindPython3: Adjust python3 program
search")
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Fixes a mismatch between the cmake and ld linker scripts whereby
the cmake script was missing using the flash load size Kconfig
option (if it was said), which would result in images far larger
than they should have allowed to be
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Removes support for the deprecated features of having a prj file
which has the board name on the end of it. Board Kconfig fragments
should be used instead.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Commit 40c2e08e82 ("xcc/cmake: don't discard stderr; don't (ever!) use
ERROR_QUIET") fixed xcc but the corresponding code is duplicated. Fix
the duplicates too.
See that commit for the issue description, longer commit message and
rationale.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Remove ERROR_QUIET which is a bad idea 99.9% of the time. When any
program makes the effort of using stderr, we _really_ don't want to lose
those error messages.
Using ERROR_QUIET in XCC is even worse because of how high maintenance
XCC is; see another example in 4cba9e6d42 ("cmake: warn the user that
the toolchain cache hides errors")
No one expects error messages to be silently discarded and especially
not people not familiar with CMake (= most people); so hiding the
following error stalled progress for a couple days:
```
Error: there is no Xtensa core registered as the default.
You need to either specify the name of a registered Xtensa core (with
the --xtensa-core option or the XTENSA_CORE environment variable) or
specify a different registry of Xtensa cores (with the --xtensa-system
option or the XTENSA_SYSTEM environment variable).
Executing the below command failed. Are permissions set correctly?
```
Also capture stdout and print it on failure because you never know.
Indent the ` ${CMAKE_C_COMPILER} --version` line in the error message so
CMake does not split that line.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Add support for mutable devices. Mutable devices are those which
can be modified after declaration, in-place, in kernel mode.
In order for a device to be mutable, the following must be true
* `CONFIG_DEVICE_MUTABLE` must be y-selected
* the Devicetree bindings for the device must include
`mutable.yaml`
* the Devicetree node must include the `zephyr,mutable` property
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Add MCUBOOT_IMGTOOL_OVERWRITE_ONLY Kconfig option which
passes the --overwrite-only option to imgtool to avoid
adding the swap status area size when calculating overflow.
It is used by non-swap update modes.
Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
Fixes an issue whereby a board revision is 0 and the overlay file
exists but would not be included
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Change CROSS_COMPILE_TARGET to be defined based on CONFIG_SOC_SERIES.
This fix adjusts CROSS_COMPILE_TARGET to ensure compatibility
with the 'espressif' toolchain variant, following the changes in
commit 6b57b3b786.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Add a CMake zephyr library extension for add_dependencies, similar
to the target_<func> functions.
This avoids using ${ZEPHYR_CURRENT_LIBRARY} directly.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Replace the TLS base address pointer from TPIDRURO to TPIDRURW.
The difference between them is that TPIDRURO is read-only in user mode
but TPIDRURW isn't. So TPIDRURO is much more suitable for store
the address of _kernel.CPU[n]. For this reason, this commit replaces
the base pointer of the TLS area.
Signed-off-by: Huifeng Zhang <Huifeng.Zhang@arm.com>
Issue reported on Discord.
Safeguard cmake_path() for SOC_LINKER_SCRIPT so that the path is only
processed when SOC_LINKER_SCRIPT is defined.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit updates the handling of board and SoC linker scripts.
Several SoCs creates a linker.ld file which sole purpose is to include
another arch common linker script, often with content like this:
#include <arch>/linker.ld
instead of 100+ SoC specific linker.ld files containing just a single
include line of above structure, then this commit introduces two now
CMake variables, BOARD_LINKER_SCRIPT and SOC_LINKER_SCRIPT.
This allows the board and SoC CMake code to point directly to a common
linker script instead of creating a dummy linker.ld file doing this.
This removes the need for several dummy linker.ld file.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit adds the public header for the GNSS API, along
with the initial GNSS Kconfig file and an entry in the
common linker file for registered GNSS data callbacks.
A very naive implementation of the GNSS data callback is
provided as well in drivers/gnss/gnss_publish.c
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
Generate ZEPHYR_{MODULE_NAME}_MODULE for existent modules
for unittests as well since they may be using Zephyr modules.
Fixes: 64348
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This allows users to set `EXTRA_*FLAGS` variables when using sysbuild.
If these flags are provided in both local and global sysbuild scopes,
then only the local ones will be used for a given image. This is to
circumvent issues with mixing space-separated and `;`-separated lists.
Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
File gcc-m-fpu.cmake is responsible for determining what should be
passed to -mfpu option. Fortunately GCC and Clang options are compatible
so we can use the file for clang.
The list of supported -mfpu options can be found at
https://github.com/llvm/llvm-project in
llvm/include/llvm/TargetParser/ARMTargetParser.def file.
Signed-off-by: Patryk Duda <pdk@semihalf.com>
HAS_DTS has become a redundant option. All Zephyr architectures now
select this option, meaning devicetree has become a de-facto
requirement. In fact, if any board does not provide a devicetree
source, the build system uses an empty stub, meaning the devicetree
machinery always runs.
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
By providing a devicetree stub file, we make sure some internal macros
required by devicetree.h are generated in devicetree_generated.h. This
makes sure that systems without devicetree can continue working without
extra ifdeffery.
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
Add QEMU_EXTRA_FLAGS as QEMU board config option.
This allows Twister tests to provide additional device setup
commands to QEMU in prj.conf or testcase.yaml configuration files.
Example use case: to setup TCP or UDP network interfaces
with non-conflicting port numbers in different test suites
to avoid conflicts when Twister run tests in parallel on the
same host.
Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>