Commit graph zephyr/scripts
Author SHA1 Message Date
Guðni Már Gilbert
b4108b53f6 scripts: tests: speed up test_output_levels
Assign a platform to the test so Twister doesn't
pick up multiple platforms.

This reduces the test time by ~2 minutes.

Before: 9 passed in 265.88s (0:04:25)
After: 9 passed in 140.24s (0:02:20)

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2026-02-02 14:46:53 +01:00
Guðni Már Gilbert
fc8e096ee1 scripts: twister: minor speedup in apply_filters
Move a check to run earlier in a for-loop to minimize doing unnecessary
work like creating TestInstance class instances.

This is a very minor optimization when the number of testsuites are low.
But starts to count when there are a lot of testsuites.

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2026-02-02 14:46:34 +01:00
Jon Ringle
c6c014929e scripts: footprint: size_report: Fix TLS symbol attribution
TLS sections (e.g. .tdata/.tbss) use addresses as TLS offsets and can
overlap normal VMA ranges. Avoid using TLS section address ranges for RAM
bucketing and classify TLS symbols using section flags instead.

Signed-off-by: Jon Ringle <jringle@gridpoint.com>
2026-02-02 14:44:13 +01:00
Afonso Oliveira
5c7be7ecb7 runners: Add lldbac runner for run-lldbac debugging
Introduce a new Zephyr runner, `lldbac`, providing interactive debugging
for both nSIM (simulator) and physical hardware using the run-lldbac
tool from Synopsys ARC MWDT.

This runner provides integrated debugging support:
- debug: Interactive debugging with integrated server management,
  Available for both simulator and hardware (integrated mode)
- flash: Flash and run on physical hardware,
  Available for hardware only (simulator should use arc-nsim)

Key features:
- Hardware mode: Flash and debug on physical hardware using JTAG flags
- Simulator mode: Interactive debugging on nSIM using run-lldbac with
  --nsim flag (props or --tcf). Enable with --simulator flag.
- Board-driven config: Boards can specify defaults in board.cmake
- TCF support: Optional --tcf for simulator mode (mutually exclusive
  with --nsim-props)
- GUI support: Optional --gui flag for VS Code debugging
- Postconnect support: Execute commands after connection via
  --postconnect-cmd and --postconnect-file for hardware initialization
- Board JSON: Optional --board-json for complex board configurations

Hardware configuration (flag-based):
- --jtag-device: JTAG device name (optional, auto-detected)
- --jtag: JTAG adapter type (default: jtag-digilent)
- --jtag-frequency: JTAG clock frequency (default: 500KHz)
- --postconnect-cmd: Command to execute after connection
  (can be used multiple times)
- --postconnect-file: File containing commands to execute after
  hardware initialization
- --board-json: Path to board.json file for board configuration

Simulator configuration:
- --simulator: Enable simulator mode (required)
- --nsim-props: nSIM properties file path
- --tcf: Tool Configuration File (alternative to --nsim-props)

Signed-off-by: Afonso Oliveira <afonsoo@synopsys.com>
Signed-off-by: Mohamed Moawad <moawad@synopsys.com>
2026-02-02 14:43:05 +01:00
Robert Robinson
ccf98f74bf scripts: runners: nrf: Add support for nRF7120
Add support for nrf7120 to use nrfutil runner in
upstream zephyr.

Signed-off-by: Robert Robinson <robert.robinson@nordicsemi.no>
2026-02-02 12:55:40 +01:00
Guðni Már Gilbert
58bf2dc0e6 scripts: zephyr_module: replace pykwalify with jsonschema
Replace all usage of pykwalify in zephyr_module.py with jsonschema

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2026-02-02 09:59:40 +01:00
Hake Huang
cdd9d63a46 twister: handler: add spsdk support with dev_id
spsdk now support dev_id as parameter

Signed-off-by: Hake Huang <hake.huang@nxp.com>
2026-01-31 10:56:06 +01:00
Guðni Már Gilbert
bcb00aaa9a scripts: twister: don't parse snippets multiple times
Currently apply_filters is parsing & validating a snippet YAML
file multiple times, duplicating expensive work.

Do the work once per testsuite instead of for each testsuite
multiplied by number of toolchains.

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2026-01-30 16:56:25 -06:00
Lukasz Fundakowski
2ad2ce9fe1 twister: Improve error handling for user's errors
Exit from twister in case of user's error e.g. empty list
of tests provided by user instead of throwing unhandled
exception.

Signed-off-by: Lukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
2026-01-30 16:55:29 -06:00
Piotr Kosycarz
aedada06c6 scripts: pylib: twister: twisterlib: coverage: catch hex parsing
As parsing hex was moved, move also catching its possible errors.

Signed-off-by: Piotr Kosycarz <piotr.kosycarz@nordicsemi.no>
2026-01-30 05:59:28 -06:00
Kyle Bonnici
968bd7fa6f CI: Add prefix to dts-linter npx commands
When running check_compliance downstream the prefix path is not correct.
This need to be relative to zepphyr base.

This PR ensure that the prefix is set correctly when invoking dts-linter

Signed-off-by: Kyle Bonnici <kylebonnici@hotmail.com>
2026-01-30 09:20:02 +01:00
Somil Gupta
5b8764e463 checkpatch: warn on sizeof used with character literals
In C, character literals have type int, so using sizeof() on a
character literal evaluates to sizeof(int) and can easily lead to
subtle size miscalculations.

Add a new checkpatch warning to flag sizeof() usage on character
literals and suggest using an explicit cast instead.

Signed-off-by: Somil Gupta <somil24559@iiitd.ac.in>
2026-01-30 09:18:43 +01:00
Yves Wang
181e421611 scripts: traceconfig: Improve file path display
For Windows, if the build dir is under same drive with zephyr base, the
generated link shall be relative url like posix style.
If they are in different drive, url is meaningless. So just use raw link
format so that some editors can directly jump to.

Signed-off-by: Yves Wang <zhengjia.wang@nxp.com>
2026-01-29 16:08:38 -06:00
Yves Wang
745e0b28bd scripts: guiconfig: Add dark mode
TK under Windows/Linux did not have a native support for dark mode.

Signed-off-by: Yves Wang <zhengjia.wang@nxp.com>
2026-01-29 17:17:31 +01:00
Jon Ringle
cf5deb7c6e scripts: footprint: plot: Increase label font size
Improve readability of sunburst labels in generated interactive plot.

Signed-off-by: Jon Ringle <jringle@gridpoint.com>
2026-01-29 14:26:47 +00:00
Grzegorz Chwierut
1b1e902540 Revert "twister: pytest: fix duplicate log lines from pytest"
This reverts commit 96985a32e8.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2026-01-29 14:26:41 +00:00
Jon Ringle
f6487c3b8c scripts: footprint: plot: Guard against missing total_size
When total_size is missing, skip the percentage line in hover text.

Signed-off-by: Jon Ringle <jringle@gridpoint.com>
2026-01-29 14:26:10 +00:00
Mathieu Choplain
edbdfcad8c llext: add discarded symbol groups inspector
When the LLEXT subsystem detects that a symbol is marked for export from
the main image, but the symbol group in which the export belongs is not
enabled, add a marker in a special section in addition to not placing the
symbol in the final export table.

Add a post-build script which consumes the special section as post-build to
dump information about all discarded symbols in a build artifact, and also
check for common errors (missing Kconfig symbol / improperly named groups).

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-01-29 13:42:56 +01:00
Mathieu Choplain
f2e5148dc1 scripts: build: llext: move ELF utilities to dedicated script
Move ELF-related utilities from the "llext_prepare_exptab" script to a
dedicated "llext_elf_toolkit" which can be reused by other LLEXT scripts.
While at it, also improve documentation of class SectionDescriptor.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-01-29 13:42:56 +01:00
Fin Maaß
0247086963 Kconfig: dt: add dt_node_array_prop_has_val
add dt_node_array_prop_has_val function and
extend dt_nodelabel_array_prop_has_val to be
used with string-arrays.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-01-29 13:38:01 +01:00
Jamie McCrae
27a91104c6 scripts: kconfig: Fix dt_chosen_partition_addr function
Fixes this function so that it returns the unit address of the
node, without having to rely on odd tricks to locate various parent
nodes and check that they have reg addresses and perform additions

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-01-28 10:18:57 +01:00
Benjamin Cabé
1025dcc634 scripts: edtlib: preserve hexadecimal notation for integer values
When YAML binding files specify values in hexadecimal notation, this
information was previously lost during parsing as PyYAML converts hex to
regular integers.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-01-28 08:30:32 +01:00
TOKITA Hiroshi
724c35c871 scripts: dts: devicetree: tests: Add a map property test
Add a map property test for `test_edtlib.py`.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2026-01-28 08:29:57 +01:00
TOKITA Hiroshi
5979e40d32 scripts: dts: Add handling for *-map property
This change introduces generating definitions corresponding to
`*-map` property, which was currently discarded.

For `*-map` properties are made able to be treated as a variation
of phandle-array, assign sequential cell names for each group of
specifiers (child_specifier_0, child_specifier_1, ...,
parent_specifier_0, ...).

The `*-map` data is like a two-dimensional array, so it is difficult to
handle with the existing APIs, so we will also provide new APIs.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2026-01-28 08:29:57 +01:00
Benjamin Cabé
9cfb6f50bc scripts: ci: refresh requirements-actions.txt pinned versions and SHAs
Refresh pinned dependencies to pick up security updates for:

- pyasn1
- filelock
- virtualenv
- pynacl
- urllib3

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-01-27 08:38:24 -05:00
Guðni Már Gilbert
6b9177f750 scripts: snippets: update typing for Python 3.10+
Automatically done using :
pyupgrade --py310-plus scripts/snippets.py

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2026-01-27 10:54:26 +00:00
Guðni Már Gilbert
902a8c5700 scripts: snippets: optimize parsing performance
1. Load and validate the schema only once
2. Use CSafeLoader if it's available
3. Read YAML files in binary mode

This reduces the execution time of snippets.py from ~380ms
down to ~160ms when I build samples/basic/blinky for
nrf52dk/nrf52832

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2026-01-27 10:54:26 +00:00
Torsten Rasmussen
a0983a2f91 cmake: align board qualifiers in CMake with Kconfig
The value os board qualifiers in CMake and Kconfig differs.
CMake has a leading '/', as example:
CMake:   BOARD_QUALIFIERS=/nrf52840
Kconfig: BOARD_QUALIFIERS=nrf52840

This was also discussed in
https://github.com/zephyrproject-rtos/zephyr/pull/69740

This commit aligns the value of the CMake variable BOARD_QUALIFIERS to
the value of BOARD_QUALIFIERS (CONFIG_BOARD_QUALIFIERS) in Kconfig.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2026-01-27 10:52:37 +00:00
Sylvio Alves
e5a2574eca runners: openocd: migrate to standard --file/--file-type interface
Align the OpenOCD runner with the JLink runner by adopting the
framework's standard file selection mechanism:

- Add file=True to RunnerCaps to enable --file and --file-type args
- Deprecate --use-hex, --use-elf, --use-bin flags (still work with
  warning)
- Use FileType enum instead of string comparisons
- Support --file for custom file paths (like JLink)
- Store hex_name and bin_name alongside elf_name for consistency

Also remove the framework constraint that --file-type requires --file,
allowing boards to specify a preferred file format via board.cmake
without providing a custom file path.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-01-27 08:08:19 +01:00
Pieter De Gendt
c1e2b83180 scripts: dts: gen_driver_kconfig_dts.py: Format and fix linter issue
Run ruff formatter and linter on the script file and remove exclusions.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-01-27 08:06:39 +01:00
Sharon Lin
5d56e00bfb scripts: twister: fix codec cp950 error when running on Windows
When running twister on Windows host, the build will fail from
cmakecache.py with error as:
UnicodeDecodeError: 'cp950' codec can't decode byte 0xe2 in
position 3444: illegal multibyte sequence

Signed-off-by: Sharon Lin <slin@atmosic.com>
2026-01-27 08:05:16 +01:00
Guðni Már Gilbert
e3575fc848 scripts: twister: fix issue with empty serial in hwmap
jsonschema is more strict when it comes to typing and only allows
strings for 'serial' in hwmap-schema.yaml.

Since 'serial' is not a required key in the schema, this commit
removes the 'serial' key from generated hardware maps when the
'serial' value is empty /unknown.

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2026-01-26 10:11:35 -06:00
Guðni Már Gilbert
e9f106dd7a twister: replace pykwalify with jsonschema
Usage of pykwalify is deprecated.

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2026-01-26 10:11:35 -06:00
Pieter De Gendt
4e62f0510c scripts: ci: check_compliance.py: Add DT_HAS_ to exceptions
The docs refer to an non-existing config option, add it to the checklist.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-01-26 08:48:15 -05:00
Fin Maaß
c42538600f scripts: Refactor dt_compat_any_has_prop
Refactor dt_compat_any_has_prop
to reduce its Cognitive Complexity.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-01-26 14:15:18 +01:00
Fin Maaß
3bffe47e3d scripts: Add dt_compat_all_has_prop
Add the dt_compat_all_has_prop
kconfig preprocessor function, simillar to
dt_compat_any_has_prop.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-01-26 14:15:18 +01:00
Fin Maaß
8f23fdc743 scripts: Add list array support for dt_compat_any_has_prop
Add support for arrays and string-arrays to
dt_compat_any_has_prop
kconfig preprocessor function.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-01-26 14:15:18 +01:00
Benjamin Cabé
21dcbfeb24 ci: doc: workflows: Add CI for Doxygen coverage delta analysis
This add a new script and hooks it up into the existing doc workflow so
that we can make documentation build fail if new API is added without
proper documentation coverage for it.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-01-25 14:39:53 +01:00
Peter Mitsis
3944b0cfc7 kernel: Extend thread user_options to 16 bits
Upgrades the thread user_options to 16 bits from an 8-bit value to
provide more space for future values.

Also, as the size of this field has changed, the values for the
existing architecture specific thread options have also shifted
from the upper end of the old 8-bit field, to the upper end of
the new 16-bit field.

Fixes #101034

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2026-01-22 08:40:17 +00:00
Grzegorz Chwierut
efc36d96d3 twister: refactor DUT class to dataclass for serialization support
Convert the DUT class from a traditional class to a dataclass to enable
proper serialization and support for future multi-device testing with
pytest-harness.

Key changes:
- Migrated DUT class to use `dataclass` decorator with proper type hints
- Renamed `baud` property to `serial_baud` for consistency
- Updated hardware map schema to support both `baud` (legacy) and
`serial_baud` fields for backward compatibility
- Updated tests

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2026-01-21 17:06:36 +01:00
James Roy
6524e670b3 edtlib: Fix the accidental merging of examples in the binding
Fix the example nodes in the examples block being accidentally
merged and overwritten during build.

Signed-off-by: James Roy <rruuaanng@outlook.com>
2026-01-21 17:05:41 +01:00
Guðni Már Gilbert
284a30053f scripts: twister: don't parse west modules in TestPlan
TwisterEnv already parses west modules during initialization, but TestPlan
was parsing them again via zephyr_module.parse_modules(), duplicating work.

Store the parsed module objects on TwisterEnv (self.modules) and have
TestPlan derive its module name list from env.modules instead. This drops
the redundant parse in TestPlan by removing handle_modules() and its call
site.

Each call to parse_modules() takes around 250-300ms on my end.

Update twister unit tests

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2026-01-20 20:04:37 -05:00
Guðni Már Gilbert
e19ebfb49a scripts: twister: use os.scandir for platform YAML discovery
Use a single os.scandir() pass per board directory to load twister.yaml
and collect legacy *.yaml files, replacing Path checks and globbing.

On my end this reduces execution time by ~50ms on Ubuntu 24.04 and
eliminates  ~80k Python function calls.

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2026-01-20 14:35:03 -05:00
Grzegorz Chwierut
f8e4c6cf6a twister: pytest: Fix post-script calling in initialization phase
The post-script was being called multiple times and during the
initialization phase when it should only run after the reader
thread has started and the device testing is complete.

Fixes #102386

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2026-01-20 14:34:54 -05:00
Lukasz Fundakowski
c5bc1a9779 twister: fix access to item in empty list
Fixed default argument in run_cmake_script method,
which cannot be an empty list.

Signed-off-by: Lukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
2026-01-20 14:34:05 -05:00
Grzegorz Chwierut
3881d4bad7 scripts: west: Fix sysbuild overwrite by test item parameter
When sysbuild is enabled globally and running west build with a
selected test scenario, the sysbuild setting was being overwritten
with False when sysbuild was not explicitly set in the test YAML file.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2026-01-20 15:33:30 +00:00
Grzegorz Chwierut
5d73bc00ca twister: fix --list-tests output, remove duplication in names
This fixes the issue where --list-tests and --test-tree commands
showed duplicated testsuite IDs in the output,
simplifies testcase name handling in harness and runner modules.
Removed feature to extend behaviour of --no-detailed-test-id to shorten
test case names - feature was introduced in #82302.
This makes the twister output more predictable and the codebase easier
to maintain.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2026-01-20 15:30:44 +00:00
Jamie McCrae
ac348a7ab5 scripts: dts: gen_dts_cmake: Output compatibles for no prop. nodes
Seemingly partitions (fixed-partitions) have no properties when
the edt file is loaded, work around this issue by outputting
compatibles for nodes that have them but have no properties, also
fixes some other outputs for misc. devices

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-01-20 15:30:18 +00:00
Jamie McCrae
7a18e3a8cc scripts: dts: gen_dts_cmake: Add DT_UNIT_ADDR to pickled CMake
Adds a new property which outputs the absolute address of a dts
device (if it is available) which will take the parent nodes into
consideration without a user having to manually trawl through
devices (which is error prone depending upon how they are layered)

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-01-20 13:22:53 +00:00
Jamie McCrae
a7e099f20b scripts: Update to use SOC_SERIES_NRF Kconfigs without X suffix
Updates usage of the old Kconfig to use the new Kconfig

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-01-20 13:21:38 +00:00