Commit graph

2,014 commits

Author SHA1 Message Date
Torsten Rasmussen
bfa00dcd1f cmake: pass Python information from west build to CMake
This commit optimizes Python and west implementation and version
handling in Zephyr CMake when west is used for build invocation.

Following information are now passed from west build to CMake when
invoking CMake:
- Python properties as CMake list, this list follows the structure
  of CMake's Python module INTERPRETER_PROPERTIES setting.
- West version information
- West topdir information

This removes the need for several execute_process invocation of Python
from within CMake itself.

If any setting is unknown or the list size changes, then Zephyr CMake
will automatically fallback to the generic implementation.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2026-05-21 06:30:21 -04:00
Sudan Landge
cf90f12f55 linker: arm: fix MPU null-pointer padding
When `CONFIG_NULL_POINTER_EXCEPTION_DETECTION_MPU` is enabled,
the null-pointer region `[0x0, PAGE_SIZE)` must not contain
executable code.

The legacy linker flow enforces this via `vector_table_pad.ld`,
but the CMake linker generator does not, allowing `.text` to
start immediately after the vector table (e.g. at `0x3e0`),
inside the protected region. This leads to MPU faults at boot.

Fix by giving `.rom_start` a minimum size up to
`CONFIG_CORTEX_M_NULL_POINTER_EXCEPTION_PAGE_SIZE` when the vector table
starts inside the protected null-pointer page, ensuring `.text` starts
outside the reserved region.

Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2026-05-20 20:05:37 -04:00
Daniel Leung
ae68c997f7 cmake: emu/whisper: define our own board string
${board_string} has disappeared from the build system and
we were getting build error. So make our own to avoid
this happening again.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2026-05-20 10:58:34 +02:00
Fin Maaß
bd57635aad cmake. qemu: update error message
update error message, when there is no supported
ethernet driver available.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-05-15 12:29:28 -05:00
Fin Maaß
d692931947 cmake: qemu: move qemu network interface selection
move qemu network interface selection, because it fits better in
cmake/emu/qemu.cmake than in cmake/modules/kernel.cmake.
It is also put at the end because for usb network cards, the usb bus
must be created before the network interface can be added. Also true
for other network cards on buses. Currently we don't have usb network
cards in zephyr, but it is better to be prepared for that.

Also use the separate netdev and device option.
The combined command line option didn't work for "usb-net" for example.
For the riscv qemu the -nic option is broken acording to the qemu issue
(https://gitlab.com/qemu-project/qemu/-/work_items/691), so we need to
use the -netdev and -device options.

Because of the change to -netdev and -device options, we need a new
Kconfig option to specify the extra arguments for the network device,
so we add NET_QEMU_DEVICE_EXTRA_ARGS option.
this can be used to customise the network device, like the mac address,
or more device specific options like setting f.e. the addresss/slot of
a pci card.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-05-15 12:29:28 -05:00
Stefan Giroux
de3deb75d4 fix: DTCM section alignment for DMA TCD pool
Change DTCM sections from SUBALIGN(4) to ALIGN(4) to allow individual
objects within these sections to maintain their own alignment requirements.

This fixes the DMA TCD pool alignment regression where the 32-byte
aligned dma_tcdpool was being placed at 4-byte aligned addresses,
causing assertion failures in EDMA_TcdSetTransferConfig.

Fixes: #107058

Signed-off-by: Stefan Giroux <stefan.g@feniex.com>
2026-05-15 10:42:23 +02:00
Mayur Salve
f94efe2607 arch: riscv: address review nits on TLS canary patches
Add copyright year, reflow comments, remote duplicate __tls_end,
and remove commented-out code.

Signed-off-by: Mayur Salve <msalve@qti.qualcomm.com>
2026-05-14 21:52:56 +02:00
Mayur Salve
2d6bdab5dc arch/riscv: fix early TLS setup and save callee-saved registers
Fix the early TLS initialization sequence on RISC-V to correctly set up
the thread pointer (tp) before any C code runs, and save/restore
callee-saved registers as required by the ABI.

Signed-off-by: Mayur Salve <msalve@qti.qualcomm.com>
2026-05-14 21:52:56 +02:00
Mayur Salve
729110c12f arch: riscv: use TLS-based stack canary guard
This change enables per thread stack canary for RISC-V.

RISC-V GCC accesses the stack canary via a fixed offset from the
thread pointer (tp) when -mstack-protector-guard=tls is used. The
compiler emits code equivalent to:

  lw t0, 0(tp)   # load canary from tp+0

Additionally, tp is zeroed in arch_kernel_init() when TLS is enabled,
which means any C function called before thread setup completes (such
as z_early_rand_get or data_copy_xip_relocation) would fault trying
to access the canary.

Introduce STACK_CANARIES_TLS_PREPEND, which places the
.stack_chk.guard section at offset 0 of the TLS block, before .tdata
and .tbss. The compiler flags -mstack-protector-guard-reg=tp and
-mstack-protector-guard-offset=0 are passed so GCC generates the
correct canary access.

With STACK_CANARIES_TLS_PREPEND the per-thread TLS block layout is:

  tp --> +------------------+  offset 0
         | .stack_chk.guard |  (__stack_chk_guard)
         +------------------+
         | .tdata           |  (initialized TLS data)
         +------------------+
         | .tbss            |  (zero-initialized TLS data)
         +------------------+

The RISC-V reset path is extended to initialize tp before any C code
runs by allocating a TLS area on the boot stack and calling
arch_riscv_early_tls_stack_update(). Early boot functions that run
before tp is set up (z_early_rand_get, data_copy_xip_relocation) are
marked FUNC_NO_STACK_PROTECTOR to avoid canary access before tp is
valid.

Signed-off-by: Mayur Salve <msalve@qti.qualcomm.com>
2026-05-14 21:52:56 +02:00
Guðni Már Gilbert
4b27f05a76 cmake: modules: yaml: remove temporary file
Change the code to use zephyr_file_copy

Remove the temporary file once its no longer needed.

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2026-05-12 09:04:53 +02:00
Guðni Már Gilbert
2ebfde136c cmake: modules: hwm_v2: remove temporary files
Remove the temporary files once they are no longer needed.

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2026-05-12 09:04:53 +02:00
Jukka Rissanen
82d3218a7c cmake: extension: Add support for generating shell aliases
Create generate_shell_aliases_inc_file_for_target() function that
can be used to convert shell aliases file to a format that can be
included in the shell to support aliases.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-11 15:30:56 +01:00
Grzegorz Swiderski
ab9ce931fd cmake: kconfig: Skip creating Kconfig target on a variant image
This replaces a workaround in `ExternalZephyrVariantProject_Add()` -
setting KCONFIG_TARGETS-NOTFOUND - which turned out to be incomplete.
For example, it had no way of accounting for EXTRA_KCONFIG_TARGETS
(which could be set on the command line or through something like
`ZephyrBuildConfig.cmake`).

Instead, the creation of `menuconfig` and friends can be gated on
KCONFIG_VARIANT_SOURCE, which is the variable sysbuild uses to forward
the source configuration to the variant image. This way, both lists of
Kconfig targets are excluded reliably.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2026-05-11 13:41:35 +02:00
Jamie McCrae
1c65d60a40 cmake: Add support for dts RAM configuration
Allows using the chosen SRAM node for RAM configuration without
using Kconfig values

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-05-11 08:45:38 +02:00
Fin Maaß
721f9e7e39 cmake: qemu: virtio: mmio: force non legacy mode
Our virtio driver in the zephyr tree only supports
version 2 and not the legacy one, therefore force it
to be used. Needed for the riscv virt target.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-05-07 18:11:21 -05:00
Guðni Már Gilbert
2339819829 cmake: modules: remove edt.pickle.cmake.new
Follow the same logic as in dts.cmake, where after:

zephyr_file_copy(file.new file.old ONLY_IF_DIFFERENT)

the .new file is removed.

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2026-05-06 07:08:57 +02:00
Christoph Busold
88278fb59f drivers: entropy + random: Add implementations for ARM64 RNG
Add new implementations for entropy driver and random subsystem
based on ARM64 RNDRRS and RNDR instructions.

Signed-off-by: Christoph Busold <cbusold@qti.qualcomm.com>
2026-05-06 07:05:12 +02:00
Luca Burelli
a97b5f221b llext-edk: capture full build properties for EDK export
The current implementation of the LLEXT EDK exports only a partial set
of compiler settings to the EDK build system, specifically only the ones
defined by the Zephyr core (the 'zephyr_interface' target). Extending
this to include application and module-specific settings (from the 'app'
target and its dependencies) is tricky, because:
- while evaluating the main CMakeLists.txt, the 'app' target is not
  fully configured yet, and
- using generator expressions is not possible due to CMake not allowing
  expansion of $<COMPILE_LANGUAGE:...> outside of a proper compile
  context.

To work around this, this change introduces a new CMake subdirectory
(misc/llext_edk) that creates a dummy target which imports the build
configuration from 'app', but overrides the C compile rules to simply
output the resulting properties (defines, include directories, flags)
to text files. The EDK generation script then reads those text files
to get the full set of build properties, and includes them in the EDK
tarball.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2026-05-04 14:53:03 +02:00
Luca Burelli
1ad11e0bcf llext-edk: remove 'llext_filter_zephyr_flags' helper function
This function was introduced when the EDK was first implemented to reuse
the flag filtering code in 'add_llext_target'.

After moving the EDK filtering code to a later stage where simpler regex
eplacements can be used, the helper function is used only in its former
location and is no longer needed. Remove the otherwise-unused public
function to simplify the codebase.

This is a revert of commit dc8d7ada19
("cmake/modules: Extract flags filtering code to a function") with
minimal code style cleanups.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2026-05-04 14:53:03 +02:00
Luca Burelli
b367b34bb9 llext-edk: (refact) filter flags in post-processing step
This changes the LLEXT EDK flag filtering to be done after the main
Zephyr build is completed. Instead of filtering the flags via genexes,
the full set is passed to the script along with the set of filters to be
applied, and the filter is applied later.

No functional change is intended.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2026-05-04 14:53:03 +02:00
Torsten Rasmussen
db3f25dd2e cmake: support printing of variables in package_helper
Using package helper for running CMake for Zephyr.
This commit provides to option to also print the value of a Zephyr CMake
variable when Zephyr modules have been loaded.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2026-04-27 14:18:43 +02:00
Jamie McCrae
730b44f422 sysbuild: Add variant image CMake module file
Adds variant image handling CMake code which re-uses parts of the
original dts CMake module code but applies variant-specific parts

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-04-27 14:14:35 +02:00
Jason Yu
ad827a78ca lib: libc: iar: Fix build error when IAR_LIBC enabled.
Export the resolved K_HEAP_MEM_POOL_SIZE value to the
linker generator and evaluate it while generating the
IAR command file.

Fixes: #107234

Signed-off-by: Jason Yu <zejiang.yu@nxp.com>
2026-04-25 08:21:27 +02:00
Luca Ciucci
3930e5f9ee sca: update ECLAIR configuration hierarchy
Users may want to use a custom toolchain configuration. Moving this
inclusion to `zephyr_common_config.ecl` allows user-defined rulesets
to control this aspect.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2026-04-24 10:29:51 -04:00
Roberto Bagnara
5d91d11c50 sca: fix toolchain.ecl and stick to C18
The "used_compiler" variable name was erroneously used as a pattern
instead of being expanded and concatenated in the file_tag matcher.

Some configurations were inconsistently matching C99 and C18 standards.
With this change, the generic "c" matcher is used. References to the
standard are updated to C18 ("C_STD").

Signed-off-by: Roberto Bagnara <roberto.bagnara@bugseng.com>
Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2026-04-24 10:29:51 -04:00
Luca Ciucci
84f513e053 sca: sca_options.cmake should always be included
sca_options.cmake defines the ECLAIR-related options, so it should
always be included.
Consistency checks on these options are moved to sca.cmake. This way
they are applied after the conditional inclusion of the
ECLAIR_OPTIONS_FILE.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2026-04-24 10:29:51 -04:00
Luca Ciucci
4c3a21a570 sca: fix typo in ECLAIR option name
The typo prevented HTML output from being generated.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2026-04-24 10:29:51 -04:00
Luca Ciucci
6581f720db sca: fix target dependency
The analysis directory setup should happen before the project analysis.

This missing dependency would otherwise cause non-deterministic
failures of the analysis, as the directory could be removed while
ECLAIR is producing analysis frame files.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2026-04-24 10:29:51 -04:00
Luca Ciucci
0aef104c82 sca: fix ECLAIR options file inclusion
The options set in ECLAIR_OPTIONS_FILE would be overwritten by the
subsequent "set" commands (e.g. `set(ECLAIR_ENV_ADDITIONAL_OPTIONS "")`).

By moving the inclusion of the options file below these commands, we
avoid this unwanted behavior.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2026-04-24 10:29:51 -04:00
Luca Ciucci
40ef43feed sca: fix passing of ECLAIR_ENV_ADDITIONAL_OPTIONS
ECLAIR_ENV_ADDITIONAL_OPTIONS is a semicolon-separated list. Expanding
the variable directly would produce an invalid option for ECLAIR.

By joining the list with spaces, ECLAIR will receive the arguments
separately as expected.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2026-04-24 10:29:51 -04:00
Luca Ciucci
10959ff526 sca: fix toolchain aliases in ECLAIR configuration
This change disables ECLAIR's default toolchain aliases and sets them
to the exact toolchain paths that are used in the build.

This also simplifies ECLAIR analyses on MacOS systems, where using
ECLAIR's default path-based trap would require additional setup.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2026-04-24 10:29:51 -04:00
Jamie McCrae
709e9e4709 cmake: modules: dts: Rework functions into module
Reworks this to use modular code which can be used from other
modules

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-04-20 18:03:09 +02:00
Jamie McCrae
526f124f06 cmake: modules: zephyr_default: Add init calls
Allows calling an init function/macro inside of zephyr module
files, this allows for making it easier to reuse/override module
CMake code

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-04-20 18:03:09 +02:00
Yves Wang
2b20b92e53 scripts: dashboard: serve via http server instead of opening file path
The previous webbrowser.open(file_path) approach fails under WSL
because Windows cannot open files via UNC paths. Use a local HTTP
server instead, which works reliably across more platforms.

Also add USES_TERMINAL to the CMake dashboard target so that log
output is visible.

Signed-off-by: Yves Wang <zhengjia.wang@nxp.com>
2026-04-16 10:14:44 +02:00
Pete Johanson
ca53d65386 cmake: Handle multiple shield when running menuconfig, etc targets
Don't use COMMAND_EXPAND_LISTS for the targets added for menuconfig,
guiconfig, etc. so the list of shields is properly quoted when including
multiples with a semicolon separator.

Signed-off-by: Pete Johanson <pete.johanson@analog.com>
2026-04-14 22:35:28 -04:00
Gaetan Perrot
c215bb17a6 cmake: fix typos in comments and documentation
Fix multiple spelling mistakes and typos in CMake
and ECL files, including:

- "warnigs" -> "warnings"
- "tihs" -> "this"
- "provied" -> "provided"
- "singlular" -> "singular"
- "exchangable" -> "exchangeable"
- "desciption" -> "description"
- "initalizer" -> "initializer"
- "Identifers" -> "Identifiers"

These changes improve readability and maintain
consistency in documentation without affecting
functionality.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2026-04-14 22:26:24 -04:00
Jason Yu
6d789dd9cd cmake: toolchain: Update iar toolchain for Zephyr SDK 1.0.0
The iar toolchain fails to build after the update to the
1.0.0 Zephyr SDK. The path to the gnu toolchains
was updated to '${ZEPHYR_SDK_INSTALL_DIR}/gnu/'
in order to be compatible with the 1.0.0 SDK.

Signed-off-by: Jason Yu <zejiang.yu@nxp.com>
2026-04-07 11:44:06 -05:00
Christopher Turner
5f856e68af cmake: toolchain: Update arcmwdt toolchain for Zephyr SDK 1.0.0
The arcmwdt toolchain fails to build after the update to the
1.0.0 Zephyr SDK. The path to the generic.cmake in the toolchain
was updated to '${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/gnu/target.cmake'
in order to be compatible with the 1.0.0 SDK. This commit also
sets the required zephyr SDK to 1.0 as the SDK is no longer backwards
compatible and will fail to build with any version less than 1.0.

Signed-off-by: Christopher Turner <christopher.g.turner@intel.com>
2026-03-23 17:40:07 -05:00
Graham Roff
22c8923263 scripts: Add script to generate an HTML dashboard
This change adds a script to generate an HTML dashboard, invoked via
west, providing a consolidated and user-friendly view of various build
artifacts and metrics. This includes footprint information (as both
tables and plots), configuration tracing, sys init levels, an interactive
devicetree browser, and more.

Signed-off-by: Graham Roff <grahamr@qti.qualcomm.com>
Signed-off-by: Martí Bolívar <mbolivar@oss.qualcomm.com>
2026-03-23 13:57:34 -04:00
Tony Han
7cffa7d563 cmake: gcc-m-cpu: add compile option -mcpu=arm926ej-s for ARM926EJ-S
Add "-mcpu=arm926ej-s" to the compile option when building for
ARM926EJ-S CPUs.

Signed-off-by: Tony Han <tony.han@microchip.com>
2026-03-23 12:27:55 -05:00
Daniel Leung
2fe13e53ab cmake: emu: add support to run whisper
This adds the bits to support running whisper as simulator
so that we can do west build with debug and run targets.
The simulator is used for simulating SweRV SoCs.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2026-03-23 08:56:34 -04:00
Joel Holdsworth
eb19e96291 cmake: emu: qemu: Add binary suffix for or1k architecture
The Qemu emulator executable for the OpenRISC 1000 (or1k) architecture is
named qemu-or1k. This patch adds this information to the qemu architecture
suffix list.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2026-03-21 07:50:57 -05:00
Henrik Brix Andersen
092485f407 toolchain: add support for verilog memory hex dump output
Add support for producing a zephyr.mem binary in Verilog memory hex dump
output format. This requires binutils v2.40 or newer.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2026-03-21 00:49:20 +00:00
Jamie McCrae
96137acb4c cmake: linker_script: arm: Add support for zephyr,mapped-partition
Adds support for using this new binding

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-03-20 09:54:59 -05:00
Maximilian Zimmermann
7205044c7c drivers: display: add new driver for qemu ramfb
The driver implements the QEMU ramfb as a framebuffer-based display.
It only implements the basic capabilities necessary (ARGB8888) with
resolution configurable via DTS. For initialization it uses the fwcfg
driver.

Signed-off-by: Maximilian Zimmermann <gitmz@posteo.de>
2026-03-20 18:19:54 +09:00
Duy Nguyen
66d3edce9b compiler: gcc: Update build config for RX board
ZephyrSDK v1.0.0 is updated to support RXv2 and RXv3 instruction
this update the gcc cmake configuration for RX build on Zephyr SDK
for RXv2 and RXv3 MCU

Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
2026-03-19 15:27:18 +09:00
Sylvio Alves
d8215fe289 cmake: remove deprecated espressif toolchain variant
The espressif toolchain variant (ZEPHYR_TOOLCHAIN_VARIANT=espressif)
has not been used for years. Espressif targets are now built using the
Zephyr SDK, which bundles the required Xtensa and RISC-V toolchains.

Remove the cmake/toolchain/espressif/ directory containing generic.cmake,
target.cmake, and Kconfig files that implemented this variant. Also
clean up references in the coredump xtensa gdb stubs, removing the
ESPRESSIF toolchain enum value and related handling code.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-03-18 15:25:03 -05:00
Stephanos Ioannidis
d204d24876 cmake: Set minimum required Zephyr SDK version to 1.0
This commit updates the minimum required Zephyr SDK version to 1.0.

This is mandated by the new SDK directory layout scheme as well as the dual
(GNU and LLVM) compiler support in the SDK.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2026-03-17 15:43:52 -04:00
Keith Packard
8a6ef440c5 cmake: Support both toolchain directory layouts
Until https://github.com/zephyrproject-rtos/sdk-ng/pull/936 is merged,
SDK 0.18 is incompatible with previous versions as the paths to
find the cmake bits is different.

Deal with that by checking for files in the wrong place as well as the
right one.

Signed-off-by: Keith Packard <keithp@keithp.com>
2026-03-17 15:43:52 -04:00
Anas Nashif
bfdce6d25f cmake: toolchain: support multiple compiler types for Zephyr SDK
Support specifying compiler type for Zephyr SDK in the
ZEPHYR_TOOLCHAIN_VARIANT variable.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2026-03-17 15:43:52 -04:00