The exact set of environment variables required by xt-xcc and xt-clang
is a bit of a dark magic and error-prone. TOOLCHAIN_VER is definitely
one of them and the error message was puzzling when TOOLCHAIN_VER was
undefined or not exported.
- Add TOOLCHAIN_VER to the list of variables in the error message
- Replace the vague "toolchain not found" in the error message with the
more useful "XCC/install/tools//XtensaTools/bin/xt-xcc not found" where
the double slash and comparison with the filesystem clearly point at
where TOOLCHAIN_VER is missing.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Adds a deprecation notice if a file is found which has the build
type informing the user of the replacement
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adds supports for sysbuild loading project-specific Kconfiguration
fragments that are suffixed with the user-provided value
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adds a function that can be used to check if a file suffix is
supplied and, if so, will update a variable with these filenames
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Extend zephyr_file(CONF_FILES ...) to take a NAMES list of file names
to find instead of creating file names based on board and revision.
This allows to unify lookup prj.conf and <board>/app.overlay for
application, as well as pave the way for future enhancements to
configuration file handling.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit adds Parasoft C++test as a Static Analyser using Zephyr's SCA
framework.
By specifing -DZEPHYR_SCA_VARIANT=cpptest to west build, a cpptestscan.bdf
file will be generated under builddir/sca/cpptest/.
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
This commit enhances the clarity of the build log by adding the "SCA"
prefix to the "Found" messages generated by sca/*/sca.cmake. This change
improves the readability of the `west build` log for users who may not be
familiar with these tools, providing more informative and understandable
output.
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Fixes: #68360
This commit introduces <type>_VERSION_TWEAK_STRING which includes
the tweak field in the string, but without the extra version.
This format is used by MCUboot / imgtool, and thus makes it easier to
align code to the format used by MCUboot.
This commit also introduces <type>_VERSION_EXTENDED_STRING which
includes the tweak field in the string in addition to the extra version
field.
The new defines / variables is available in code, CMake, and Kconfig,
and it defined for KERNEL, APP, and custom types, such as MCUBOOT.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
The paths that got assigned to these variable don't quite match
the description, likely a typo, fix that.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
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>