Commit graph

6,159 commits

Author SHA1 Message Date
Thorsten Klein
1c0eb01816 scripts: west_commands: runners: jlink: support --pre-script-cmd
Allow passing custom J-Link commands to the jlink runner via
--pre-script-cmd argument. The argument can be given multiple times. The
commands are prepended to runner.jlink in the given order.

Signed-off-by: Thorsten Klein <thorsten.klein@bshg.com>
2026-03-13 14:44:14 +01:00
Jordan Yates
5539556415 scripts: west_commands: completion: use --all-targets
Update completion scripts to use `west boards --all-targets` to obtain
the list of targets, instead of using shell black magic to perform
string parsing and modification. As a result, all shells get board
revision support.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-03-13 07:12:41 +01:00
Jordan Yates
4bfb5c7923 scripts: west_commands: completion: add --all-targets
Add completion information for the new `west boards` argument,
`--all-targets`.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-03-13 07:12:41 +01:00
Jordan Yates
d3897b5185 scripts: west_commands: boards: add --all-targets
Add an option to `west boards` that automatically outputs all valid
board targets as a newline separated list without requiring any post
processing.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-03-13 07:12:41 +01:00
Marc Herbert
b001dee329 scripts: empty unused .help duplicates in west extensions
Stop requesting west extension authors to "keep in sync" an unused .help
duplicate. Empty such duplicates from existing extensions. They cannot
be `None` yet because current west versions unfortunately require them.

Since the beginning of west extensions (2019 commit d3bb3cfd7a)
extension authors have been requested to provide not just a "help" field
in west-commands.yml, but also a duplicate in their WestCommmand
constructor than they should carefully "keep in sync".
While doing some unrelated extension work, I discovered by chance
that this duplicate has never been used. See detailed analysis in
https://github.com/zephyrproject-rtos/west/issues/927, shorter analysis
in https://github.com/zephyrproject-rtos/west/pull/933 and smoking gun
in the "TODO" comment added by west commit
0d39b6b77a

Signed-off-by: Marc Herbert <Marc.Herbert@gmail.com>
2026-03-12 14:05:03 -05:00
Ilia Kharin
da7d31eda1 west: rtt: Retry when socket connection fails with invalid argument
On macOS, calling socket.connect() may fail with
OSError(22, 'Invalid argument') if it occurs at a certain point after
JLinkGDBServer has started. This leaves the socket in an unrecoverable
state, meaning that all subsequent connection attempts using the same
socket fail with the same error.

The fix is to close the socket on known errors, wait, create a new
socket and try to connect again.

Signed-off-by: Ilia Kharin <akscram@gmail.com>
2026-03-12 14:04:13 -05:00
Martí Bolívar
b7ad704311 scripts: check_compliance: verify DT binding file names
Add a compliance check to make sure that the rules in
doc/build/dts/bindings-upstream.rst (section "File names") are
followed from now on.

Signed-off-by: Martí Bolívar <marti.bolivar@oss.qualcomm.com>
2026-03-12 12:07:57 -04:00
Martí Bolívar
c4b9507680 scripts: check_compliance: cosmetic DT bindings prep work
No functional changes expected; just prep work for extending these
checks.

Signed-off-by: Martí Bolívar <marti.bolivar@oss.qualcomm.com>
2026-03-12 12:07:57 -04:00
Maksim Salau
363336b999 scripts: gen_cfb_font_header.py: Improve PNG support
The commit allows matrix arrangement of glyphs in a PNG file.

Signed-off-by: Maksim Salau <maksim.salau@gmail.com>
2026-03-12 09:18:39 -05:00
Yongxu Wang
edfa8d55ac scripts: gen_device_deps: Sort supported devices by DT dependency ordinal
When generating device dependency arrays, the supported devices list
is currently sorted by device handle. This can cause child devices to
be processed before their parent devices when a power domain resumes,
leading to hardware access errors.

This fix changes the sorting key for supported devices from device
handle to dependency ordinal, ensuring that parent devices are always
processed before their children during power domain operations.

The sorting is performed at build time, so there is no runtime
overhead.

Signed-off-by: Yongxu Wang <yongxu.wang@nxp.com>
2026-03-11 23:18:03 -04:00
Nicolas Pitre
1db0458480 cmake: add zephyr_constants_library() for build-time constants
Introduce a reusable CMake function that creates an OBJECT library
from a C source file containing GEN_ABSOLUTE_SYM() declarations and
generates a header file from the resulting symbols.  This encapsulates
the boilerplate needed for the offsets-style pattern: OBJECT library
creation, LTO prohibition, gen_offset_header.py invocation, and
dependency registration.

Convert the existing offsets.h generation to use this new function.

The zephyr_generated_headers target is moved earlier in CMakeLists.txt
so that subsystem CMakeLists.txt files can register generated headers
via zephyr_constants_library().

Also update gen_offset_header.py to derive the include guard from the
output filename instead of hardcoding __GEN_OFFSETS_H__, and remove the
unused input_name parameter.  This allows multiple generated headers to
coexist with distinct include guards.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-03-11 20:52:01 -04:00
James Bennion-Pedley
18ba7b4d6e runners: wch: add wchisp and wlink runner options
Adds wlink and wchisp as optional runners for WCH boards

Signed-off-by: James Bennion-Pedley <james@bojit.org>
2026-03-11 20:51:23 -04:00
Mark Holden
302f978bb2 debug: coredump: arm: add callee-saved offset for thread debugging
Extend the ARM Cortex-M coredump arch block to version 3 with metadata
that provides the offset to the callee_saved struct within k_thread.
This enables the coredump GDB stub to accurately retrieve callee-saved
registers (r4-r11) for non-faulting threads during multi-thread
debugging.

Signed-off-by: Mark Holden <mholden@meta.com>
2026-03-11 17:56:17 +00:00
Stephanos Ioannidis
c279bedaa4 scripts: gen_image_info: Skip PT_GNU_STACK segment
When `-z nostackexec` or `-z stackexec` option is specified, GNU ld adds a
segment of type `PT_GNU_STACK` with zero VMA/LMA and size to the output ELF
file.

Since the sole purpose of `PT_GNU_STACK` segment is to mark whether the
stack should be executable and it has no loadable details, this commit
updates the gen_image_info script to omit it from the image information
header file.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2026-03-11 17:51:42 +00:00
Dhanoo Surasarang
36e26fca3a scripts: runners: nrf: Use ERASE_NONE for nrf71 family
Apply the same ERASE_NONE default as nRF54L.

Signed-off-by: Dhanoo Surasarang <dhanoo.surasarang@nordicsemi.no>
2026-03-11 17:49:34 +00:00
Georgios Vasilakis
ee6fda0311 scripts: west: nrf_common: Provision slot invalidation json
The nRF54L series devices require to reserve 2 KMU slots which are
filled with random data used for invalidating the Protected RAM.
Until now the provisioning of these slots happends in firmware which
costs in both volatile and non volatile memory.

Instead of doing this nrfutil recently added the funcionality to
provision these slots using a .json file which means that everything
can be handled by the build system now.

This is preparation work, that is needed before the full integration
arrives. The change checks if a json file with the name:
"prot_ram_inv_slots.json" exists and if it does it invokes nrfutil
with the provisioning command.

Signed-off-by: Georgios Vasilakis <georgios.vasilakis@nordicsemi.no>
2026-03-10 17:24:21 +01:00
Scott Shawcroft
72f06372bd native_simulator: Get latest from upstream
Align with native_simulator's upstream main
14bbf7010dfcde473f11a6ae5674abc1e72aa488

Which includes:
14bbf70: nct: Add function to get thread stack information

Signed-off-by: Scott Shawcroft <scott@adafruit.com>
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2026-03-10 12:35:42 +01:00
Grzegorz Chwierut
b5ba2c991e tests: twister: Update pytest tests for YAML config serialization
Update unit tests to verify YAML-based parameter serialization instead
of CLI arguments. Add tests for twister config file parsing and update
existing tests to check pytest_params object and YAML output.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2026-03-09 11:10:57 -05:00
Grzegorz Chwierut
bedba6412a twister: Add YAML config file support in pytest-harness
Add comprehensive YAML configuration support for pytest-harness
integration, replacing CLI argument approach with structured
configuration files while maintaining backward compatibility.

Key changes:
- Add --twister-config option to load test parameters from YAML
- Refactor TwisterHarnessConfig to support CLI and YAML configuration
- Move pytest parameter generation from CLI args to config files

This enables more flexible test configuration through structured YAML
files and improves the overall architecture of pytest-twister
integration.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2026-03-09 11:10:57 -05:00
Hake Huang
bd5e3f52cd tests: twister: add west_flash_cmd mock
add west_flash_cmd for debug testing

Signed-off-by: Hake Huang <hake.huang@nxp.com>
2026-03-08 22:00:45 -04:00
Hake Huang
b69a35d02a tests: scripts: add west debug support in twister
in some multi-core platform, `west flash` can not support all cores.
`west debug` is supported to test secondary core, add this to twister
such as with
`--west-flash-cmd=debug` in twister command
or with
`--west-flash-cmd: debug` in hwmap.yaml

and same with pytest

command line setting will overrid the one in hwmap

Signed-off-by: Hake Huang <hake.huang@nxp.com>
Co-authored-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2026-03-08 22:00:45 -04:00
Martí Bolívar
86d0176f5f scripts: dts: verify default #address- and #size-cells are forbidden
Make sure that we don't allow bindings which manually
specify any defaults for the #address-cells or #size-cells
properties. See DTSpec 2.3.5.

Signed-off-by: Martí Bolívar <marti.bolivar@oss.qualcomm.com>
2026-03-08 16:36:20 +01:00
Martí Bolívar
97431a02cc scripts: dts: forbid #address- and #size-cells defaults
The devicetree specification section 2.3.5 says:

    The #address-cells and #size-cells properties are not inherited
    from ancestors in the devicetree. They shall be explicitly
    defined.

    A DTSpec-compliant boot program shall supply #address-cells and
    #size-cells on all nodes that have children.

    If missing, a client program should assume a default value of 2
    for #address-cells, and a value of 1 for #size- cells.

We are currently allowing defaults -- and notably, different defaults
from those recommended in the spec -- in the zephyr bindings for these
properties to pass without complaint.

Further, allowing the user to specify a default other than the
recommendations by the spec would be a bad design decision in my
opinion.

Handle this by erroring out explicitly when we try to set these
defaults in a binding. It's fine for people to do things like define
descriptions for these properties in a binding for some specific
compatible, but it's a footgun to allow bindings that would seem to
allow overruling the specification's explicit recommendation.

Signed-off-by: Martí Bolívar <marti.bolivar@oss.qualcomm.com>
2026-03-08 16:36:20 +01:00
Tomi Fontanilles
4b9666afbe scripts: checkpatch: allow lines starting with 4 spaces and defined(
It's a pattern that exists in the codebase and makes for much more
readable multi-line `#if defined` statements.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2026-03-06 10:07:11 +01:00
Jamie McCrae
a64142b86f Revert "scripts: build: emitting syscall/subsystem metadata to JSON if commented"
This reverts commit d739a4d0ab.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-03-05 04:44:15 +01:00
Jamie McCrae
fa6c04b411 Revert "lib: heap: compute Z_HEAP_MIN_SIZE from actual struct layouts"
This reverts commit 518d8420c9.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-03-03 17:55:22 +01:00
Maciej Sobkowski
9455a002a8 scripts: instrumentation: Deduplicate code in zaru script
Removes code duplications and changes uses of Perfetto (viewer) to Trace
Event (format)

Signed-off-by: Maciej Sobkowski <msobkowski@antmicro.com>
Signed-off-by: Krzysztof Sychla <ksychla@antmicro.com>
Signed-off-by: Eryk Szpotanski <eszpotanski@antmicro.com>
2026-03-03 13:28:58 +01:00
Marc Herbert
9fd3aa04e6 west: zcmake.py: do not drop CMake outputs on failure, log them instead
When everything goes well, run_cmake() returns the combined stdout+stderr
from CMake. But when CMake fails, it was raising a Python exception with
the barely useful exit status and discarding all messages. Use log.err()
to print CMake outputs on failure.

This issue was reported on Discord: someone had a Python version lower
than the minimum currently required by listsdk.cmake and there was zero
useful message. Running listsdk.cmake directly showed the issue.  Error
handling: never tested much.

Fixes commit 31bdad5299 ("west: Implement CMake helpers in
scripts/west_commands")

Signed-off-by: Marc Herbert <marc.herbert@gmail.com>
2026-03-02 16:01:17 -08:00
Grzegorz Chwierut
be78f760e3 tests: twister: Update unit tests after changes in HardwareMap
Updated twister unit tests after refactoring of HardwareMap
class.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2026-02-27 21:02:56 +00:00
Grzegorz Chwierut
106ea725a5 twister: Remove redundant DUT storage from classes
Simplify the design by removing the `detected` attribute from
HardwareMap class and DUT storage from ProjectBuilder class.
Instead of storing detected DUTs as instance attributes, pass
them as method parameters where needed.

This eliminates data duplication since ProjectBuilder can access DUTs
directly from the environment object, and HardwareMap doesn't need to
maintain its own copy of detected DUTs. The refactoring makes the code
cleaner and reduces the risk of inconsistent state between different
objects storing the same DUT information.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2026-02-27 21:02:56 +00:00
Nicolas Pitre
518d8420c9 lib: heap: compute Z_HEAP_MIN_SIZE from actual struct layouts
Z_HEAP_MIN_SIZE and Z_HEAP_MIN_SIZE_FOR were defined in kernel.h as
hardcoded magic numbers gated by a growing tower of #ifdefs — one
per Kconfig option that happened to affect the heap struct layout.
Every internal change required manually recomputing the constants,
duplicating layout knowledge across files, and praying nobody forgot
to update the #ifdef matrix.  This is fragile and unscalable: adding
a single new heap feature (e.g. a chunk canary trailer) would add yet
another dimension to the combinatorial explosion.

Replace this with build-time computation from the actual C structures.
A new lib/heap/heap_constants.c is compiled as part of the offsets
library and uses GEN_ABSOLUTE_SYM to emit the correct values into the
generated offsets.h.  Z_HEAP_MIN_SIZE is derived through an iterative
fixed-point expansion (3 rounds, always convergent) that mirrors the
runtime logic in sys_heap_init().  Z_HEAP_MIN_SIZE_FOR overhead and
bucket sizes are also generated, keeping all internal heap layout
knowledge in one place.

Big vs small heap determination uses CONFIG_SYS_HEAP_SMALL_ONLY,
CONFIG_SYS_HEAP_BIG_ONLY, and sizeof(void *), mirroring the
big_heap_chunks() logic in heap.h.

kernel.h picks up the generated values via
__has_include(<zephyr/offsets.h>) so there is no circular dependency
with the offsets compilation itself.  The old _Z_HEAP_SIZE manual
sizeof and BUILD_ASSERT scaffolding in heap.c are removed.

gen_offset_header.py is updated to accept multiple input object files
so that the heap constants object can coexist with the per-arch offsets
object in the same offsets library.  COMMAND_EXPAND_LISTS is added to
the offsets generation custom command so that CMake correctly expands
the $<TARGET_OBJECTS:> generator expression into separate arguments
when the offsets library contains more than one object file.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-02-27 21:02:45 +00:00
Graham Roff
8894dc67b9 scripts: footprint: Optimize speed of generate_any_tree
The generate_any_tree function finds all matching nodes when inserting
into the tree, but only actually needs the first match. It also does
this search multiple times for the same node as it traverses the tree.
Optimize this in two ways: first, use an iterator that stops
after the first match, and second, cache matching nodes to avoid
repeat searches.

Signed-off-by: Graham Roff <grahamr@qti.qualcomm.com>
2026-02-27 15:30:49 +01:00
Alexey Nikolaev
d739a4d0ab scripts: build: emitting syscall/subsystem metadata to JSON if commented
Strip comments from the source files before the parser extracts syscall
and subsystem metadata. The comment removal is performed directly inside
scripts/build/parse_syscalls.py, after which the filtered source is
processed with the existing regular‑expression based parser.

The underlying problem is that metadata for syscalls and subsystem that
has been commented‑out is still extracted and written to the generated
JSON file.

Signed-off-by: Alexey Nikolaev <alexeynikzzz@gmail.com>
2026-02-27 11:51:00 +01:00
Benjamin Cabé
2c8957fa0a doc: build: ci: twister: Zephyr now requires Python 3.12 or higher
Update getting started guide, release notes, CI actions, ruff,
build system, and Python version compliance check to use Python
3.12 as minimum supported version.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-02-26 21:25:03 +00:00
Benjamin Cabé
6f14a1daae scripts: ci: refresh requirements*.txt pinned versions and SHAs
This commit refreshes the pinned versions and SHAs for the
requirements.txt files and requirements-actions.txt files.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-02-26 21:25:03 +00:00
Thomas Stranger
81c2b3ed0f scripts: kconfig: hardend: remove TEST_SHELL from file
The TEST_SHELL config was removed in commit be0dff6844
("test: remove TEST_SHELL") a while ago.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2026-02-25 13:20:19 +01:00
Thomas Stranger
6044651979 scripts: kconfig: hardened: rename ATMEL_SAME70
The config options have been renamed in commit 8dc3f85622
("hwmv2: Introduce Hardware model version 2 and convert devices"),
therefore update them in the hardend file.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2026-02-25 13:20:19 +01:00
Jan Gałda
818d9dffe0 compliance: Fix inefficient regular expression
This part of the regular expression may cause exponential backtracking
on strings containing many repetitions of '\n\r'.

Signed-off-by: Jan Gałda <jan.galda@nordicsemi.no>
2026-02-25 13:09:59 +01:00
Aksel Skauge Mellbye
a6432d7426 west: blobs: Add git lfs http(s) fetcher
Add support for fetching blobs from Git LFS HTTP(s) servers using
the LFS API to discover the blob URL.

This fetcher relies on the `sha256` and `size` fields in the blob
metadata to perform an API request to the LFS API in `url` to
get the download URL for the blob.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2026-02-24 13:51:20 +01:00
Aksel Skauge Mellbye
faf4ba3041 west: blobs: Allow explicit fetcher selection
Decouple fetcher selection from the URL by adding a new field
`fetcher` to the blob metadata. If not set, fall back to parsing
the schema from the URL.

Add an optional field `size` to declare the size of the blob in
bytes.

Update documentation to cover the new additions. Fix a typo
`uri`->`url` and document the `click-through` field together
with the new fields.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2026-02-24 13:51:20 +01:00
Aksel Skauge Mellbye
c5e2ca218a west: blobs: Give the fetcher full context
Pass the entire blob context to the fetcher instead of only
the URL to allow for fetchers that require more context than
a single URL.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2026-02-24 13:51:20 +01:00
Aksel Skauge Mellbye
bb60eee7cf west: blobs: Refactor logging to not use globals
Log using the west command instance instead of the deprecated
global in blob fetchers.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2026-02-24 13:51:20 +01:00
Kyle Bonnici
e0ca21ab5c CI: Update dts-linter to dts-linter 0.4.0
Expressions will now indent to align with the group they are in example:

Was

```devicetree
dmas = <&dma2 1 0 (STM32_DMA_MODE_NORMAL | STM32_DMA_PRIORITY_HIGH |
 		STM32_DMA_16BITS) 0>;
```

Now

```devicetree
dmas = <&dma2 1 0 (STM32_DMA_MODE_NORMAL | STM32_DMA_PRIORITY_HIGH |
				   STM32_DMA_16BITS) 0>;
```

Signed-off-by: Kyle Bonnici <kylebonnici@hotmail.com>
2026-02-23 13:31:41 -06:00
Mathieu Choplain
6bdec2471d scripts: fpdiff: don't crash when a duplicate symbol is found
The same symbol may be found multiple times when a function is declared in
a header, which causes anytree.search.find() to throw a CountError.

Catch the exception and ignore duplicate symbols instead of crashing.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-02-20 10:31:27 -08:00
Marc Herbert
f1ac9ce55e scripts: west_commands: build: rephrase the --cmake-opt help
Late review comments from #101457. Make it more formal and complete.

Add that argparse should preserve the order based on:
https://discuss.python.org/t/argparse-multiple-arguments-with-the-same-destination-left-to-right-order-guarantee/105685

Don't assume that all CMake options can be "overriden"; stick to
describing our own behavior.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2026-02-20 10:09:32 +01:00
Eryk Szpotanski
4544c98b16 scripts: instrumentation: Use elftools instead of objdump
System-wise objdump can select different target for the same zephyr.elf
file depending on e.g. operation system, which can lead to discrepancies
and error in zaru.py script.
Using elftools fixes this problem.

Signed-off-by: Eryk Szpotanski <eszpotanski@antmicro.com>
2026-02-18 14:45:12 +00:00
Mirai SHINJO
170a1fe01b scripts: coredump: update RISC-V parser for full register set
Add support for ARCH_HDR_VER 3 (RISC-V 32-bit layout) and 4
(RISC-V 64-bit layout), carrying all 33 registers in GDB order
(x0-x31 and pc).

For versions 3/4, map tuple entries directly to GDB register numbers.

Keep ARCH_HDR_VER 1/2 parsing unchanged so existing stored dumps
can be decoded as well.

Signed-off-by: Mirai SHINJO <oss@mshinjo.com>
2026-02-18 10:31:33 +00:00
Grzegorz Chwierut
69edab8c97 twister: move ZEPHYR_BASE to constants to reduce dependencies
Moving ZEPHYR_BASE from environment.py to constants.py
allows importing classes like HardwareMap in
pytest-twister-harness module without pulling in unnecessary
dependencies from environment.py.

This refactoring improves module independence and makes selective
imports cleaner across the twister Python package structure.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2026-02-17 17:41:16 -06:00
Lukasz Fundakowski
d73ea02be1 twister: Do not clean previous results for listing tests
When user only wants to list tests or tags twister should
not clean previous results.
This change improves also performance for listing tests.

Signed-off-by: Lukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
2026-02-17 13:22:35 -06:00
Zophai Liu
9ee71b498c west: runner: add realtek bee mpcli flash runner
Add support for the official realtek programming tool (CLI
version).

Signed-off-by: Zophai Liu <zophai_liu@realsil.com.cn>
2026-02-17 15:22:38 +00:00