Commit graph zephyr/scripts
Author SHA1 Message Date
Andres Hernandez
dab4e3abba scripts: runners: blackmagicprobe: drop local check_call_ignore_sigint()
The local check_call_ignore_sigint() method is an exact duplicate
of the same-named method in ZephyrBinaryRunner. Remove the
local definition and rely on the base implementation.

Signed-off-by: Andres Hernandez <andres.a.h@outlook.com>
2026-04-14 22:35:44 -04:00
Andres Hernandez
c3bccd4269 scripts: runners: core: rename run_client() to check_call_ignore_sigint()
Renaming run_client() to check_call_ignore_sigint() makes its purpose
clearer and consistent with the pattern already established in the
blackmagicprobe runner.

Then, update all callers with the new name.

run_client() is kept as a deprecated function, wrapping
check_call_ignore_sigint() for backwards compatibility.

Signed-off-by: Andres Hernandez <andres.a.h@outlook.com>
2026-04-14 22:35:44 -04:00
Graham Roff
ef3da069cf scripts: snippets: Support file lists
Add support for providing multiple .conf and .overlay files for a given
snippet. This uses the standard syntax of a space or semi-colon
separated list in the snippets.yml file for EXTRA_CONF_FILE,
EXTRA_DTC_OVERLAY_FILE, and SB_EXTRA_CONF_FILE. In other areas of the
build system these variables already take such a list, so this provides
a more consistent syntax in the snippets case.

Signed-off-by: Graham Roff <grahamr@qti.qualcomm.com>
2026-04-14 22:35:11 -04:00
Taha Momayiz
9ad32f47c3 runners: uf2: use copyfile() to avoid copymode() crash on Windows
shutil.copy() calls copyfile() then copymode(). On Windows the UF2
bootloader resets the MCU (unmounting the drive) after receiving the
file, before copymode() runs, raising OSError: [WinError 433]. FAT
filesystems also do not support Unix permission bits. Replace copy()
with copyfile() to transfer data only and avoid the failing chmod.

Fixes zephyrproject-rtos#107165

Signed-off-by: Taha Momayiz <momayita@mail.uc.edu>
2026-04-14 22:32:23 -04:00
Jeppe Odgaard
afc92ea7a1 scripts: west_commands: move zspdx to pylib
Allow twister to make use of zspdx by moving it to pylib to prevent code
duplication.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2026-04-14 22:27:52 -04:00
Martí Bolívar
9b7779b1b3 scripts: dashboard: add DT binding information to nodes
When information about the node's matching binding is available, add
it to the dashboard. Knowing which binding matched a node is a common
source of confusion, so this hopefully is helpful additional context.

Adding this information has officially made the dt-prop-info field a
bit too complex to render inline. To avoid confusing people with the
extra info, re-work the CSS to display this new information in a grid
of key/value pairs associated with each node or property.

Signed-off-by: Martí Bolívar <mbolivar@oss.qualcomm.com>
2026-04-14 22:23:08 -04:00
Pete Johanson
7eb8cf1709 west: runners: openocd: Add flash-specific pre inits
Add the ability to specify different pre init commands for flashing, in the
case flashing needs to use a different transport/target than other
operations like debug for heterogeneous targets.

Signed-off-by: Pete Johanson <pete.johanson@analog.com>
2026-04-14 22:06:58 -04:00
Jeppe Odgaard
de590614e9 scripts: tracing: trace_capture_uart: disable on exit
Before a capture is started "enable" is sent to the device in case
`CONFIG_TRACING_HANDLE_HOST_CMD` is enabled to start the transmission of
tracing data from the device. However it is never stopped.

Send "disable" when the capture is stopped to stop the transmission from
the device.

Also `ser.close()` was unreachable which is also fixed.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2026-04-14 22:06:14 -04:00
Martin Moya
ba480d810b twister: add support for gtest parametrized tests
Parametrized tests in gtest are shown as the following example in a log:

[  FAILED  ] FooTest/FooTypedTest/0.TypedTestFoo, where TypeParam = <type>

current regex of the gtest harness didn't detect such test so it marks
this as pass or that the result wasn't found. This commit extends the
regex to detect such behavior and adds unit test to verify that.

Signed-off-by: Martin Moya <moyamartin1@gmail.com>
2026-04-14 22:04:44 -04:00
Anas Nashif
b474cfc2b6 posix: move posix to subsys/portability
Posix is not a library per the definition of libraries in Zephyr. It
always has been a portability layer and shall reside with other
portability layers under subsys/portability.

Addresses #99250

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-04-14 22:03:46 -04:00
Carlo Caione
8a729f5ea9 scripts: ci: disable DeviceMmioCheck pending community discussion
Disable the DeviceMmioCheck compliance check while documentation and
community discussion are ongoing. The check code is kept in place and
can be re-enabled by removing the self.skip() call.

See https://github.com/zephyrproject-rtos/zephyr/issues/106966

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-04-11 10:14:18 -04:00
Chase Philport
afcfbf6dee scripts: west_commands: build: fix syntax error in west build --help
There is an extra close bracket after board revision. Remove it.

Signed-off-by: Chase Philport <cproo12@pm.me>
2026-04-07 15:41:00 -04:00
Carlo Caione
a068728578 scripts: ci: DeviceMmioCheck: only flag newly added lines
The check was scanning the entire file content, causing CI failures
for PRs that touch any line in an existing non-compliant driver, even
if the change is completely unrelated to the violation.

Fix this by parsing git diff -U0 hunk headers to determine which
lines were actually added in the changeset, and only flag
RAW_REG_ADDR_RE matches on those lines. The MMIO_API_RE suppression
still scans the whole file so that files already using the MMIO API
are correctly excluded.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-04-07 15:33:48 -04:00
Carlo Caione
2281f537f6 scripts: ci: DeviceMmioCheck: fix regex and extend to headers
The RAW_REG_ADDR_RE pattern used \w+ for the cast type, which only
matches single-word types like (uint32_t *). This misses the most
common pattern in Zephyr drivers:

    .base = (struct foo_regs *)DT_INST_REG_ADDR(n),

Replace \w+ with [^)]* to match any cast expression including struct,
volatile, and multi-word types.

Also extend the pattern to catch DT_[INST_]REG_ADDR_BY_NAME() casts,
which are equally broken on MMU platforms, and scan .h files in
addition to .c files since some drivers define their config structs
in companion headers.

Before: 554 flagged lines across drivers/
After:  694 flagged lines across drivers/ (+140 newly caught)

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-04-07 15:33:48 -04:00
Pieter De Gendt
fa0c841540 scripts: ci: check_compliance.py: Add doc link to Github annotation
Append the documentation link to Github annotation. This make it easier for
users to go directly to the relevant page from a pull request.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-04-07 08:28:45 -05:00
Sylvio Alves
1b170ffc2f runners: openocd: fix logger access in classmethod
do_create() is a classmethod and cannot access self.logger.
Use a module-level _logger instead, consistent with core.py
and __init__.py in the runners package.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-04-06 10:33:17 -05:00
Pieter De Gendt
1c6c57f4d8 scripts: ci: check_compliance.py: Add --all-commits argument
Besides a custom range to run the compliance checks, allow to run on all
commits to HEAD.
This is useful when testing locally, to verify existing files in tree.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-04-03 14:52:51 -05:00
Carlo Caione
1a2d905469 scripts: ci: add compliance check for device MMIO API usage
Add a DeviceMmioCheck to check_compliance.py that flags driver files
casting DT_REG_ADDR() or DT_INST_REG_ADDR() to a pointer without
using the device MMIO API.

    .base = (SomeType *)DT_INST_REG_ADDR(n),

This stores the raw physical address and dereferences it directly. On
systems with an MMU, the physical address has no page table entry and
the access will fault unless someone else has created an identity
mapping (typically via mmu_regions.c).

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-04-03 14:51:27 -05:00
Lucas Romero
32f7b0f231 twister: fix harmful wait on virtual com port
that can never succeed because it is not in the com port filter list.
This would trigger every time that a combination of --flash-before and
--serial-pty is used.

The list of monitored serial ports - at least on linux - does not contain
/dev/pts but that list is constantly checked if the /dev/pts/X device might
magically appear some day.

This is the proper fix instead of adding /dev/pts/* to the monitor list
because the reason why we need to wait is because in the codepath without
serial_pty, we might be resetting the target device, causing the dev node
to disappear/reappear. This is not the case for the virtual ports created
for serial_pty.

Signed-off-by: Lucas Romero <lucas.romero@a-labs.io>
2026-04-03 23:14:12 +09:00
Pieter De Gendt
9f043928c0 scripts: ci: check_compliance.py: Speedup adding testcase results
The result property getter rebuilds the list from XML children every
access, and the setter removes all existing results then re-appends them
all. So self.case.result += [res] is O(n²) over time.

self.case.append(res) directly appends to the underlying XML element in
O(1), bypassing the expensive property entirely.

Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-04-03 23:12:51 +09:00
Łukasz Fundakowski
e3c03691a7 twister: minor improvement for sys.path
Moved all `sys.path.insert` from twister's modules
to `twisterlib.__init__.py` to have only one place where all paths
are added.

Signed-off-by: Łukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
2026-04-02 08:45:58 -05:00
Pieter De Gendt
67af7d2366 scripts: ci: check_compliance.py: Add check for DEVICE_API usage
Add a compliance test for device driver APIs to make sure API
<class>_driver_api struct variables are put in the corresponding linker
section using the DEVICE_API macro.

Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-04-01 15:08:09 -05:00
Benjamin Cabé
09a1273cba scripts: dashboard: drop monkey-patching of pygments devicetree lexer
Latest pygments release ships with the fix that this commit can now
safely drop.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-04-01 11:53:29 -05:00
Kyle Bonnici
94ed499c2c scripts: dts: verify default status is forbidden
Make sure that we don't allow bindings which manually
specify any defaults for the status
properties. See DTSpec 2.3.4.

Signed-off-by: Kyle Bonnici <kylebonnici@hotmail.com>
2026-03-27 20:22:23 -04:00
Kyle Bonnici
1e3aa2ae79 scripts: dts: forbid status defaults
The status property indicates the operational status of a device.
    The lack of a status property should be treated as
    if the property existed with the value of "okay".

We are currently allowing defaults.

This is a continuation of
https://github.com/zephyrproject-rtos/zephyr/pull/104931

Signed-off-by: Kyle Bonnici <kylebonnici@hotmail.com>
2026-03-27 20:22:23 -04:00
Łukasz Fundakowski
79f47b7a5f twister: write unit tests to increase code coverage
Added unit tests for `twister_main.py` module to increase code coverage.
Did minor refactoring in `twister_main.py`.
Fixed type hints and added type ignores.
Removed unused variables.

Signed-off-by: Łukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
Signed-off-by: Lukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
2026-03-27 20:19:21 -04:00
Benjamin Cabé
2a6a9257e1 scripts: requirements: actions: refresh pinned versions
Run the uv command to update the pinned version in
scripts/requirements-actions.txt and doc/requirements.txt.
This picks up requests>=2.33.0, mitigating CVE-2026-25645.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-03-26 10:43:23 -04:00
Mirai SHINJO
9197a00a88 scripts: west: sdk: fail cleanly if the host bundle checksum is missing
'west sdk install' assumes the host-specific minimal SDK archive
always has a matching entry in sha256.sum and aborts with a Python
KeyError when it does not.

Detect the missing checksum entry and report a normal
west fatal error instead.

Without this patch:

west sdk install --install-base ../
KeyError: 'zephyr-sdk-1.0.0_macos-x86_64_minimal.tar.xz'

With this patch:

west sdk install --install-base ../
FATAL ERROR: No Zephyr SDK 1.0.0 bundle found for host
macos-x86_64.

Signed-off-by: Mirai SHINJO <oss@mshinjo.com>
2026-03-25 07:55:24 -04:00
Henrik Brix Andersen
b6164ed8f3 scripts: requirements: actions: refresh pinned versions
Run the uv command to update the pinned version in
requirements-actions.txt.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2026-03-24 15:44:43 -05:00
Yves Wang
b104f826ca scripts: dts: edtlib: improve dts binding path formatting
Add quotes around binding file paths in error messages for better
readability and consistency. Also normalize paths using os.path.normpath
to ensure consistent path separators across platforms.

Signed-off-by: Yves Wang <zhengjia.wang@nxp.com>
2026-03-24 07:26:21 +01:00
Daniel Leung
223876cba4 twister: fix unnecessary trailing slash for toolchain variant
When TOOLCHAIN_VARIANT_COMPILER is empty, we should not append
a trailing slash (/) to ZEPHYR_TOOLCHAIN_VARIANT. Or else any
matching of ZEPHYR_TOOLCHAIN_VARIANT would be incorrect.

For example, ZEPHYR_TOOLCHAIN_VARIANT == 'xt-clang' and west
build would have it correct, while twister would have it as
'xt-clang/'. This prevents kconfig from matching correctly
(possibly among other things).

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2026-03-23 14:58:50 -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
Graham Roff
3637b3be8f scripts: check_init_priorities: Expose initlevels.
To allow other scripts to use the initlevel information determined
by the Validator class, expose an API to get them.

Signed-off-by: Graham Roff <grahamr@qti.qualcomm.com>
2026-03-23 13:57:34 -04:00
Graham Roff
fb613bfa53 scripts: footprint: Make plot.py useable by other scripts
In order to allow the plot.py functionality to be used by other
scripts, move the code into a separate function that can be
imported.

Signed-off-by: Graham Roff <grahamr@qti.qualcomm.com>
2026-03-23 13:57:34 -04:00
Oleksii Moisieiev
9f37bb0059 devicetree: add macros for reg property iteration
Introduce DT_FOREACH_REG and DT_INST_FOREACH_REG macros to enable
iteration over reg entries in devicetree nodes by invoking a user-
supplied macro per entry. Add support for macros accepting a
separator and variadic arguments with the new DT_FOREACH_REG_SEP,
DT_FOREACH_REG_VARGS, and DT_FOREACH_REG_SEP_VARGS macros, as well
as their DT_INST_ variants.

The DT_FOREACH_REG macro mirrors the behavior of the ranges property.

Update the devicetree macro generation logic in gen_defines.py to
emit the new macro variants. Document the additions by expanding the
Augmented Backus-Naur Form grammar in macros.bnf. Add detailed
comments with usage examples and parameter details for all new macros.

Expand test coverage with new overlay nodes and dedicated tests to
verify macro correctness and behavior, across various node scenarios
including multi-register, single-register, and nodes lacking reg
properties.

Signed-off-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Signed-off-by: Svitlana Drozd <svitlana_drozd@epam.com>
2026-03-23 12:30:30 -05:00
Michał Bogdziewicz
d456ef71a5 runners: probe-rs: migrate to standard --file/--file-type interface
The runner always selected elf_file, ignoring hex_file and bin_file from
RunnerConfig. This broke MCUBoot support since the bootloader
requires hex/bin format and the build system sets hex_file to
signed images (zephyr.signed.hex).

Fixes commit 3c7d973 ("west: runners: probe-rs: Add enhanced
functionality")

Signed-off-by: Michał Bogdziewicz <michal@bogdziewicz.xyz>
2026-03-23 08:58:33 -04:00
Daniel Leung
f225fd06e9 twister: add support for whisper simulator
This adds support for running with whisper simulator under
twister.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2026-03-23 08:56:34 -04:00
Nancy Sangani
752cd19e04 scripts: west: commands: completion: fish: update completions
Add Fish shell completion entries that are already present in the
Bash completion script but were missing from the Fish one:

- Add __zephyr_west_complete_shield for cached shield completion
- Add --shield argument completion to west build
- Add completion entries for the west shields subcommand
- Add completion entries for the west twister subcommand

Fixes #73128

Signed-off-by: Nancy Sangani <9d.24.nancy.sangani@gmail.com>
2026-03-23 10:25:04 +01:00
Joel Holdsworth
09cd8302ef scripts: twister: Add OpenRISC as a supported test platform
Adds the openrisc CPU architecture to the twister platform definitions.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2026-03-21 07:50:57 -05:00
Joel Holdsworth
01d4ea6d2b scripts: logging: Add openrisc to ARCHS
The OpenRISC CPU architecture is signified by the CONFIG_OPENRISC Kconfig
option. This patch adds this information to the log database ARCHS table.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2026-03-21 07:50:57 -05:00
Ilia Kharin
15c27c378b west: rtt: jlink: Add ability to select RTT channel
When the `west rtt --runner=jlink` command is executed, the client is
attached to the channel number 0 by default.. However, if several
subsystems are configured to use different RTT channels, e.g. shell to
the channel 0 and logging to the channel 1, it's currently impossible
to attach to any channel other than 0.

The `west rtt` command for the `jlink` runner is extended by a new
argument called `--rtt-channel=<channel>` where `<channel>` is an
integer, e.g. 0, 1, etc. Usage example:

    west rtt --runner=jlink --rtt-channel=1

When the channel is specified, once the client is connected, it sends the
following configuration sequence:

    $$SEGGER_TELNET_ConfigStr=RTTCh;<channel>$$

This configuration sequence instructs the server to send data associated
only to the given channel. This string must be send within 100 ms after
establishing a connection, otherwise it would be ignored.

The following is an example of a configuration where shell uses channel 0
and logging - channel 1:

    CONFIG_SHELL=y
    CONFIG_SHELL_BACKEND_RTT=y
    CONFIG_SHELL_BACKEND_RTT_BUFFER=0
    CONFIG_SHELL_BACKEND_SERIAL=n
    CONFIG_SHELL_LOG_BACKEND=n

    CONFIG_LOG=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_RTT_BUFFER=1
    CONFIG_LOG_BACKEND_UART=n

Signed-off-by: Ilia Kharin <akscram@gmail.com>
2026-03-20 12:36:16 -05:00
Mathieu Choplain
aea7120dab scripts: kconfig: add function to obtain highest IRQn on a controller
Add a custom Kconfig preprocessor option to obtain the highest IRQn on a
controller. This can be useful to compute CONFIG_NUM_IRQS automatically at
build time.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-03-20 12:34:28 -05:00
Josuah Demangeon
ca3991d150 west: blobs: support fallback URLs
Allow fallback URLs to select a different back-end.
The "url:" field can now take a list of URLs so that if an
URL fails, the next one can be fetched (i.e. a remote host is down).

Error handling is refactored to let blobs.py call os.exit(), with a
new ZephyrBlobException used for the purpose of catching blob-fetching
related errors, and still allow i.e. KeyboardInterrupt to be raised.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2026-03-20 18:19:06 +09:00
Pieter De Gendt
3bcf145bac scripts: requirements: Generate actions dependencies
Run the uv command to update requirements-actions.txt.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-03-20 18:16:57 +09:00
Kyle Bonnici
eecf59716c dts: address dtslib unambiguous path matching
The spec makes it clear that node address can be omitted from node path
if not unambiguous see 2.2.3. Path Names

> A unit address may be omitted if the full path to the node is
unambiguous.

e.g.
````
/ {
foo@10 {};
}
```

both paths -> /foo and /foo@10 should work.

Signed-off-by: Kyle Bonnici <kylebonnici@hotmail.com>
2026-03-20 07:11:12 +01:00
Kyle Bonnici
82a84d628c dts: address dtslib address case sensitivity
IMO the spec is clear about the case insensitivity. The node address
must be match the reg value see 2.2.1.1. Node Name Requirements

> The unit-address must match the first address specified in the reg
property of the node.

reg property is a prop-encoded array and by definition.
reg = <0xA> or reg = <0xa> are the same. hence Both foo@a and foo@A
are the same.

Signed-off-by: Kyle Bonnici <kylebonnici@hotmail.com>
2026-03-20 07:11:12 +01:00
dependabot[bot]
b990e62c93 build(deps): bump pyasn1 from 0.6.2 to 0.6.3 in /scripts
Bumps [pyasn1](https://github.com/pyasn1/pyasn1) from 0.6.2 to 0.6.3.
- [Release notes](https://github.com/pyasn1/pyasn1/releases)
- [Changelog](https://github.com/pyasn1/pyasn1/blob/main/CHANGES.rst)
- [Commits](https://github.com/pyasn1/pyasn1/compare/v0.6.2...v0.6.3)

---
updated-dependencies:
- dependency-name: pyasn1
  dependency-version: 0.6.3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-19 17:12:19 -05:00
Dmitrii Sharshakov
f2dd01fd84 soc: raspberrypi: rp2350: add west sign for secure boot
Wrap the picotool sign command (requires recent picotool) to build
signed ELF files (which can be later converted to UF2 as well).

The resulting files boot, yet this has not been tested with actual
Secure Boot yet.

Signed-off-by: Dmitrii Sharshakov <d3dx12.xx@gmail.com>
2026-03-19 17:06:17 -05:00
Dmitrii Sharshakov
e19a8ff6b6 west: sign: abstract out common operations
Share code for locating tools and Zephyr binaries.

Signed-off-by: Dmitrii Sharshakov <d3dx12.xx@gmail.com>
2026-03-19 17:06:17 -05:00
Jjateen Gundesha
7386141720 scripts: twister: fix monitor_serial writing handler.log in binary mode
- monitor_serial() opens handler.log in binary mode (\"wb\") and writes
re-encoded bytes. When the runner (e.g. linkserver for frdm-mcxn947)
produces serial output that is not cleanly decodable as UTF-8, the
decode('utf-8', 'ignore') silently drops bytes and the resulting
handler.log is unreadable.

- Fix by opening handler.log in text mode with explicit UTF-8 encoding,
consistent with BinaryHandler.handle_serial() which uses open(\"w\").
Change the decode error handler from 'ignore' to 'replace' so
corruption becomes visible as replacement characters rather than
silently dropped bytes.

Signed-off-by: Jjateen Gundesha <jjateen97@gmail.com>
2026-03-19 14:53:58 -05:00