Commit graph

1797 commits

Author SHA1 Message Date
3468830744 arch: riscv: add support for the zmmul integer multiply extension
The QingKe V2C has an integer multiplier but no divide. Add support
for the corresponding Zmmul extension and, as the extension was added
in GCC 13.0, add a test for the compiler version.

Signed-off-by: Michael Hope <michaelh@juju.nz>
2025-05-09 01:40:22 +02:00
Luca Burelli
dbf00bfca8 yaml: save intermediate files in the build directory
Make sure to provide full paths when saving the intermediate files in
the YAML export, to prevent them from being saved in the source tree.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-05-08 19:46:18 +02:00
Armin Brauns
153be1b142 cmake: use external gen_kobject_list binary if available
e.g. https://github.com/arbrauns/gen_kobject_list

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2025-05-07 15:10:05 +02:00
Armin Brauns
d6efbc8af4 cmake: clean up gen_kobject_list.py invocations
cmake/kobj.cmake now provides nice wrappers around the script itself and
common uses.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2025-05-07 15:10:05 +02:00
Duy Nguyen
65ad2b0883 cmake: Add Renesas RX support
This commit add toolchain command line option for the RX
architecture support

Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
2025-05-02 09:18:16 +02:00
Duy Nguyen
5fabd3634a CMake: Add support for .mot binary file format
The Renesas RX support flashing .mot file for binary image
This commit target to add the .mot file output for build and
flash script

Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
2025-05-02 09:18:16 +02:00
Keith Packard
2d64237f44 cmake: Enable undefined behavior sanitizer on all targets
GCC and Clang support the undefined behavior sanitizer in any
configuration, the only restriction is that if you want to get nice
messages printed, then you need the ubsan library routines which are only
present for posix architecture or when using picolibc.

This patch adds three new compiler properties:

 * sanitizer_undefined. Enables the undefined behavior sanitizer.
 * sanitizer_undefined_library. Calls ubsan library routines on fault.
 * sanitizer_undefined_trap. Invokes __builtin_trap() on fault.

Overhead for using the trapping sanitizer is fairly low and should be
considered for use in CI once all of the undefined behavior faults in
Zephyr are fixed.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-05-02 01:16:18 +02:00
Daniel Leung
3cf5b0c8e8 cmake: toolchain/xcc,xt-clang: LD flag for multi-core env vars
When using one set of environment variables for multiple
cores compilation, we also need to supply the core name in
linker flags. So add that to TOOLCHAIN_LD_FLAGS.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-04-30 23:02:56 +02:00
Declan Snyder
7962eaeca6 dts: Move vendor-specific dtsi to dedicated folder
Move all the vendor-specific dtsi files that were in dts/common to a
new folder under dts/ designated for vendor-specific files,
since they are not common at all, except for one vendor.

Change MAINTAINERS.yml to reflect the moving of the files.

Update migration guide for this change.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-04-29 13:00:03 +02:00
Tom Hughes
78b1ad9a73 cmake clang/compiler_flags.cmake: Re-enable -Wunused-variable for clang
All warnings in the code base have been resolved.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-04-25 14:03:25 +02:00
Daniel DeGrasse
b84076a192 cmake: arm: linker: remove usage of ld-specific ADDR() function
Remove usage of ld-specific ADDR function within the cmake linker
generator scripting. Since the linker generator scripting doesn't
support MPUs, we can simply set the __ramfunc_region_start symbol to be
equal to __ramfunc_start

Fixes #87200

Signed-off-by: Daniel DeGrasse <ddegrasse@tenstorrent.com>
2025-04-24 16:54:14 +02:00
Ederson de Souza
f968d49232 cmake/emu: Use environment variable value on message about it
A message about not finding simics at SIMICS_PROJECT env var was not
showing the current value of said variable.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2025-04-24 16:54:00 +02:00
Phi Bang Nguyen
2b46cc0b78 drivers: video: Introduce video device structure
Introduce a new video device structure representing a device in a
video pipeline. Each video device embeds a pointer to its "source"
device and other "video" characteristics.

This structure give the video framework an access to all video features
of the device and a hierachical view of the video pipeline that the
device belongs to.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-04-21 20:03:31 +02:00
Björn Bergman
1e1f94405f toolchain: iar: Fix sections placed at address
zephyr_linker_section(... ADDRESS 0xF00) was broken. The fixed
placement was using their parent group address.

This also removes some dead code in config_file_script.cmake that
helped confuse what is going on with fixed sections.

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-04-15 11:25:07 +02:00
Robin Kastberg
f9ec5f86fa iar: toolchain: arm: Fix FPU settings for CM55 and CM85
Currently the FPU settings for CM55 and CM85 are not complete.
This will complete them.

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2025-04-14 13:06:41 +02:00
Luca Burelli
0f71880001 cmake: yaml: update timestamp on intermediate file save
file(GENERATE ...) does not update the output file if the content is
unchanged. Since the metadata in build_info.yml mostly depends on the
build configuration, the timestamp of the intermediate file does not get
updated on most rebuilds, while the final file does, due to immediate
file(WRITE ...) calls. Since the latter is newer, no post-process step
is executed and the file is left with commented genexes.

Touching the intermediate file ensures that the post-process step is
performed every time, even if the content is unchanged, restoring the
expected behavior.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-04-14 13:06:30 +02:00
Luca Burelli
a90870da4c cmake: yaml: improve escaping of strings with backslashes and quotes
Switching the intermediate file format from JSON to YAML has a very
significant benefit: the file is now loaded via yaml_load(), which
internally calls Python to parse the file into the JSON format that
CMake expects. This means that the file contents are now automatically
escaped properly for JSON; it is a huge improvement over the previous
implementation, which was escaping everything given as input to
to_yaml().

With the removal of the now-redundant call in to_yaml(), escaping is
applied exactly once per value or list, when it is passed to yaml_set().
This allows to convert the logic in zephyr_string(ESCAPE ...) to a more
robust "escape everything" approach.

These changes fix the handling of strings with backslashes and different
types of quotes passed either directly or via generator expression. The
existing tests are updated to cover these cases.

Two other small changes are made in this commit:

- a small check in internal_yaml_list_append() is removed, as the same
  issue is already detected by the caller yaml_set() logic.

- the to_yaml() function is modified to initialize the YAML output
  variable at the top level, which is the expected behavior. This
  resulted in genex temp files sometimes having duplicate lines.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-04-10 10:11:47 +02:00
Luca Burelli
90aa937e3a cmake: yaml: switch to yaml for intermediate file
The intermediate file used to expand the generator expressions is now in
YAML format. This allows for a more robust handling of the data, as the
single quoted strings are a lot easier to escape: inside them every
character is a literal except for two single quotes (which intuitively
map to a literal single quote).

When saving a simple YAML file without genexes, the single quotes in
strings need to be escaped. However, doing so when saving the
intermediate file would make it harder to properly escape them later,
since it could be possible that the expansion of the generator
expressions would introduce new single quotes. For this reason, when
genexes are enabled, the escaping is now done in a single pass inside
the yaml-filter.cmake script.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-04-10 10:11:47 +02:00
Luca Burelli
4a50fbf804 cmake: yaml: properly store strings
Store strings in YAML as single-quoted entries to avoid issues with
special characters. This also fixes a quirk with the current test
suite where the quotes in the expected value are filtered out by the
YAML import.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-04-10 10:11:47 +02:00
Luca Burelli
f5b3e0adf4 cmake: extensions: (cosmetic) refactor zephyr_string()
This commit refactors the zephyr_string() function to explicitly
show that ESCAPE and SANITIZE are mutually exclusive options and
that SANITIZE joins multiple arguments into a single string before
processing it.

No functional change introduced by this commit.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-04-10 10:11:47 +02:00
Luca Burelli
cab474affe cmake: yaml: (cosmetic) avoid referring to file type in variable names
To move away from the JSON/YAML terminology, rename the variables that
refer to the intermediate files to "expanded" and "output" files.

Also, clean up a few "C-style" function calls and a typo in a variable
name in the same files.

No functional change introduced in this commit.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-04-10 10:11:47 +02:00
Ederson de Souza
c9a18fd487 mcuboot: Kconfig options for single app slot RAM loading mode
MCUboot has a configuration for single application slot RAM loading, in
which the single loader (or a hook thereof) can load an application from
an arbitrary flash location to RAM. Applications that are to be loaded
in this way need to specify, in their mcuboot header, the load address
in RAM they are meant to be loaded.

This patch adds a new Kconfig for this mode. The load address used comes
from devicetree chosen property "mcuboot,ram-load-dev", if it exists,
and if not, "zephyr,sram".

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2025-04-08 16:12:33 +02:00
Tom Hughes
1415796bb2 cmake clang/compiler_flags.cmake: Re-enable Wunused-function for clang
All warnings in the code base have been resolved.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-04-08 10:50:08 +02:00
Julien Racki
6d1cb00627 arch: arm: Add Cortex-A7 support
Pass the correct -mfpu and -mcpu flags to the compiler when building
for the Cortex-A7.

Signed-off-by: Julien Racki <julien.racki@st.com>
2025-04-04 09:35:03 +02:00
Torsten Rasmussen
a713f79031 cmake: fix Zephyr module ext order
MODULE_EXT_ROOT allows Zephyr modules to provide glue code for Zephyr
modules using `cmake-ext: True` and/or `kconfig-ext:True`.

A module ext root provides a `modules.cmake` file which defines
variables like: `set(ZEPHYR_FOO_CMAKE_DIR  <glue-code-path>/foo)`

It is intended that a downstream module can replace Zephyr's default
glue code, which again can be replaced further downstream.

Setting values in first modules.cmake (Zephyr's) are replaced by later
processed modules.cmake (downstream) when the setting name is identical.

Therefore the module ext root list should not be reversed, and Zephyr
itself should be placed as first entry in the list.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2025-04-03 13:16:56 +02:00
Robin Kastberg
216ff00422 cmake: linker: dont place device tree memories at absolute addresses
Avoid placing the device tree memories at an absolute address.
This avoids placing both .rom_start AND SSRAM1 at
the same address on mps2/an521/cpu0.

This seems fine according to ld (since one placement is empty)
but causes a currently non-suppressable diag_warning

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2025-04-03 13:15:47 +02:00
Luca Burelli
652ee91b7f llext-edk: fix BOARD_TARGET variable generation to be Zephyr-compatible
The board revision is not part of the NORMALIZED_BOARD_TARGET variable
as composed by Zephyr, so it must also not be used in the EDK exported
value to avoid mismatches. The revision is exported as a separate
variable, so it can still be used to differentiate between board
revisions.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-04-02 19:02:45 +02:00
Charles Hardin
b1775914d6 cmake: mcuboot: refactor the checks for west and the key files
As of c952f09a79 the calls to west
sign were replaced with imgtool but a lingering integration with
WEST_TOPDIR was allowed to remain which is not needed when there
are absolute paths available for the configuration. So, this
attempts to refactor the code to allow a few things

- allow a search of relative paths to application config and
  then west topdir
- only fatal error when a west workspace is needed but not found,
  so if the config is all absolute files then a west workspace is
  not required

Fixes: #86438
Signed-off-by: Charles Hardin <ckhardin@gmail.com>
2025-04-02 12:53:13 +02:00
Björn Bergman
98ac4becab iar: toolchain: Enable TOOLCHAIN_HAS_BUILTIN_FFS
icc has support for __builtin_ffs() and its friends,
but it was disabled in the toolchain files.

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-04-01 11:51:41 +02:00
Robin Kastberg
2e2e3a3894 cmake: linker_script: keep .symbol_to_keep
Update to keep in sync with common-rom-misc.ld

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2025-03-31 14:31:57 +02:00
Wilfried Chauveau
fa45bebccf cmake: emu: armfvp: Only add the -a argument if not already present
Some target may need to pass in the application argument. In such case
do not override it.

Signed-off-by: Wilfried Chauveau <wilfried.chauveau@arm.com>
Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2025-03-31 11:30:55 +02:00
Björn Bergman
fe0b16583c cmake: linker generator: ld: Files for section input patterns
For CONFIG_USERSPACE the input from gen_app_partitions.py there is
a need to be able to specify input files as well as input sections
patterns for zephyr_linker_section_configure().  This is used for
app partitions from libraries (which generate input patterns like
foo.a:*(.data*)).

This adds documentation to zephyr_linker_section_configure() to clarify
what INPUT allows, and also adds some parsing tricks to ld_script.cmake
to properly add the file patterns when they are missing.

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-03-27 17:17:03 +01:00
Björn Bergman
9ac12b68b5 cmake: linker generator: ld: Fix alignment bug
It seems as if ld_script.cmake hasnt handled
zephyr_linker_section_configure( ALIGN ...) due to a typo
in a variable name,

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-03-27 17:17:03 +01:00
Björn Bergman
128698fd36 cmake: userspace: A stab at USERSPACE + CMAKE_LINKER_GENERATOR
All in all this makes cmake linker generator able to work for at least
most of the kernel tests and samples, on cortex m4.

Make the cmake linker generator have a file-structure more similar to
the ld-skeletons.

Add or edit groups, sections and logic to make the generator reflect
what the ld-skeletons do, esp. for kobjects and APP_SMEM, nonint and
some other details are also effected.

Use the new zephyr_linker_include_generated() and
zephyr_linker_include_var() functions to to handle
${DEVICE_API_LINKER_SECTIONS_CMAKE}, the kobject-prebuilt-*.h files and
APP_SMEM partition. Essentially the output from gen_app_partitions.py,
gen_kobject_placeholders.py.

Add ALIGN_WITH_INPUT on sections being put into DATA_REGION. This makes
the init layout work for ld.

This leverages the updates in gen_app_partitions.py to generate its
output as cmake linker generator sections too, and puts them into a
group defined in linker.cmake

Setup generator variables for alignment of APP_SMEM. Note that this does
not yet handle MPU_ALIGN which depends on the size of the section...

Fix broken k_object_assignment iterable section

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-03-27 17:17:03 +01:00
Björn Bergman
6f74d6fa90 cmake: linker generator: Functions for input from prev linker pass
Add methods for the linker-script generator to pick up information
from previus linkerpasses:
 * zephyr_linker_include_generated(FILE f.cmake [PASS X]  [KCONFIG])
   cmake-includes f.cmake in the relevant PASSes. This allows scripts
   to generate any content (e.g. sections or section configs) as if
   it was generated by the main cmake machiery. This is intended to
   cover the case of ld-script snippets generated by e.g.
   gen_app_partitions.py
   It can also parse KCconfig files to capture @CONFIG_FOO@ variables
 * @FOO[,undef:v]@ in an value or expression in the zephyr_linker_*
   inputs. This looks for a defintion of FOO (se below), and uses its
   value if found. If FOO is not defined, the whole @@ thing is left
   untouched, unless ,undef: is used, in which case v is used instead.
 * zephyr_linker_include_generated(FILE f.h [PASS x]) greps for f.h
   for #define FOO value to be accessed as @FOO@
 * zephyr_linker_include_var(VAR FOO VALUE V) allows the main
   cmake-script to set a @FOO@ variable.

Note that the #define support is VERY basic, and does not use a proper
pre-processor. It works for the current use of files generated by e.g.
gen_kobject_placeholders.py but is not a general solution.

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-03-27 17:17:03 +01:00
Björn Bergman
8382d67a9b cmake: linker generator: Refactor generator input file creation
Move creation of the generator arguments file from each target.cmake
into a function (zephyr_linker_generate_linker_settings_file).

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-03-27 17:17:03 +01:00
Björn Bergman
0b40dfa013 cmake: linker generator: ld: Implement MIN/MAX_SIZE for sections in ld
Implement the MIN_SIZE and MAX_SIZE options for the ld linker file
generator

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-03-27 17:17:03 +01:00
Björn Bergman
acdd816bdb cmake: linker generator: Add MIN/MAX_SIZE to zephyr_linker_section()
Add MIN_SIZE and MAX_SIZE options to zephyr_linker_section()
and zephyr_linker_section_configure().
This allows padding (for MIN_SIZE) and link-time checking (for MAX_SIZE)
of sections (and parts of sections).

Clarify comments for zephyr_linker_section_configure

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-03-27 17:17:03 +01:00
Björn Bergman
d3a88f7bfe cmake: linker generator: Handle NOT PASS and multiple PASS options
Make it possible to have multiple PASS parameters to
zephyr_linker_section() and zephyr_linker_section_configure() sections
(oring them) OR to have multiple PASS NOT p options (in which case the
sections applies in neither of the passes)

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-03-27 17:17:03 +01:00
Torsten Rasmussen
6384f28a2d cmake: support directory as argument to zephyr_library_amend()
Extend `zephyr_library_amend()` to support an optional directory
argument.
The current `zephyr_library_amend()` works well when used inside a
Zephyr module with same structure, but fails when the macro is called
from Zephyr module integration code is located in a Zephyr
`MODULE_EXT_ROOT` because in this case the CMake code being executed
is not present in the Zephyr module itself, in which case the dir name
creation based on relative to module dir give wrong result.

For this use-case then support a base directory.
This also allows for use-cases in Zephyr modules where the directory
structure matching Zephyr's own structure is placed in a sub-folder.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2025-03-26 16:26:40 +01:00
David Schneider
8b65862a83 cmake: mcuboot: Flash confirmed file if available
In case a confirmed image gets generated, it should be used during
flash process.

If there is a valid application in second image slot, flashing
*.signed.hex will result in a unconfirmed image in first slot.
After reboot MCUboot will replace the unconfirmed image by swaping
the confirmed application from the second into the first slot.

Signed-off-by: David Schneider <schneidav81@gmail.com>
2025-03-26 16:20:13 +01:00
Valerio Setti
13270a43c1 cmake: modules: dts: print error message if DTC fails
Currently stderr is printed only if dtc encounters warnings, but it's
not printed in case of errors. However this information can be useful
to quickly identify and resolve the problem.

To solve this let's add "COMMAND_ERROR_IS_FATAL ANY" to execute_process()
so that CMake will fail in case of errors and a proper message will be
printed on the output.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-03-24 19:33:18 +01:00
Jamie McCrae
cc453dfed8 cmake: Remove previously deprecated look-ups
Removes functions that would handle deprecated variables and
functionality from CMake within Zephyr that were deprecated in
Zephyr 3.1 onwards but before 3.7

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-03-24 07:53:31 +01:00
Tom Hughes
53f17c1d78 cmake clang/compiler_flags.cmake: Re-enable -Wsometimes-uninitialized
All warnings in the code base have been resolved.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-03-23 13:19:27 +01:00
Lars-Ove Karlsson
4edb8af70c cmake: linker: Removed unnecessary regexp in link generator
In the linker script generator there was one error checking
construct that used regexp and that ended up in the generated
linker file, which caused parsing problems with the IAR
linker. It was unnecessary. Also updated
common-rom-kernel-devices.ld.

Signed-off-by: Lars-Ove Karlsson <lars-ove.karlsson@iar.com>
2025-03-20 21:58:14 +01:00
Fabio Baltieri
c60ffe1e1b linker: update section names to be unambiguous
Recently 0ae0c3dc44 allowed for three digit priorities, this resulted
in objects potentially matching multiple sections, for example:

.z_init_PRE_KERNEL_2_0_0_
.z_init_PRE_KERNEL_2_?_*
.z_init_PRE_KERNEL_2_???_*

This does not seem to be detected by ld, but the IAR linker emits a
warning.

Add some extra qualifiers in the object section name to make it
unambiguous, this has the extra value of making it easier to interpret,
for example going from:

.z_init_POST_KERNEL_90_00012_

to

.z_init_POST_KERNEL_P_90_SUB_00012_

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-03-20 12:20:55 -04:00
Josh DeWitt
0ae0c3dc44 linker: Allow for 999 priority levels in init levels
Some projects may have needs for more than 99 priority levels, so add
a third linker input section for each obj level.

Signed-off-by: Josh DeWitt <josh.dewitt@garmin.com>
2025-03-19 18:53:22 -04:00
Josh DeWitt
0f46359cbf linker: Add underscore between the init level and priority
Ensure the priority is surrounded by underscores for clarity. This makes
sections show up as
z_init_PRE_KERNEL_1_0_0_ instead of
z_init_PRE_KERNEL_10_0_

Signed-off-by: Josh DeWitt <josh.dewitt@garmin.com>
2025-03-19 18:53:22 -04:00
Lars-Ove Karlsson
bd278514e7 cmake: Fix warning levels for IAR
Rewrote the warning levels for toolchain IAR as IAR tools just turn
off warnings, not on. Also did some minor cleanup for coding
guidelines.

Signed-off-by: Lars-Ove Karlsson <lars-ove.karlsson@iar.com>
2025-03-19 10:57:41 +01:00
Lars-Ove Karlsson
22c04bdc66 cmake: linker: Add support for shared sw isr to link file gen
The link file generator didn't have support for
.gnu.linkonce.shared_sw_isr_table*

Signed-off-by: Lars-Ove Karlsson <lars-ove.karlsson@iar.com>
2025-03-14 05:46:36 +01:00