Commit graph

6,360 commits

Author SHA1 Message Date
Yves Wang
88e7b3b451 scripts: build: Accept python object in Domain's constructor
Make Domain's class constructor accept python object to avoid redundant
YAML serialize and unserialize which may introduce potential yaml type
errors.

Signed-off-by: Yves Wang <zhengjia.wang@nxp.com>
2026-01-07 14:51:44 -06:00
Lukasz Fundakowski
2e36f57e8d scripts: Improve handling exceptions in compliance check script
When output from ruff check subprocess is not in JSON format
compliance script raises an exception without any useful information
about the error. This commit improves that by printing output from
subprocess in case of error.

Signed-off-by: Lukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
2026-01-07 19:37:26 +01:00
Guðni Már Gilbert
465150d796 twister: avoid scanning subcases for unselected test suites
Optimize testsuite discovery by skipping subcase scans for filtered suites

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2026-01-07 07:44:44 +01:00
Mike Szczys
06d5728d07 twister: fix --keep-artifacts
use the allow-list generated by --keep-artifacts whenever
cleanup_artifacts() is called. This resolves an issue where this allow-list
was not being honored when using the --prep-artifacts-for-testing flag.

Signed-off-by: Mike Szczys <mike@golioth.io>
2026-01-06 11:18:11 -05:00
Guðni Már Gilbert
28fe8d5c87 scripts: tests: twister: mock listed serial port
Reduce the test time by ~300 seconds by mocking the listed serial port

Result from running:
pytest --durations=0 ./scripts/tests/twister/test_handlers.py

Before:
60.12s test_devicehandler_handle[valid pty]
60.12s test_devicehandler_handle[communicate timeout]
60.06s test_devicehandler_handle[popen called process error]
60.05s test_devicehandler_handle[valid dev]
60.03s test_devicehandler_handle[nonzero returncode]
0.01s  test_devicehandler_handle[create serial failure]

After:
0.01s test_devicehandler_handle[valid dev]
0.01s test_devicehandler_handle[valid pty]
0.01s test_devicehandler_handle[nonzero returncode]
0.01s test_devicehandler_handle[create serial failure]
0.01s test_devicehandler_handle[communicate timeout]
0.01s test_devicehandler_handle[popen called process error]

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2026-01-06 16:07:24 +00:00
Thamaraimanalan M
450096dc77 scripts: check_compliance: fix broken URL in ruff compliance error
Add a trailing space to the Ruff error message string in the compliance
checking script. Previously, the error message concatenated the URL and
the description with a colon (e.g., ".../unsorted-imports:Import").
This caused the terminal to interpret the description as part of the URL,
resulting in a 404 error when clicked.

Signed-off-by: Thamaraimanalan M <devthamaraimanalan.m@gmail.com>
2026-01-06 16:04:24 +00:00
Pieter De Gendt
e81bacd361 scripts: west_commands: Extend ruff config in pyproject.toml
Now that the west_commands directory has a pyproject.toml configuration
file, it should consider local packages for first party imports.

Make sure the top-level ruff config is extended, and fix some import
sorting.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-01-06 10:30:32 +01:00
Zhaoxiang Jin
965e921aea scripts: check_compliance: read text files as UTF-8 on Windows
KeepSorted can fail on Windows when the active code page is
not UTF-8 (e.g. GBK), because text files in the Zephyr tree
are UTF-8. Detect file type via libmagic and only process
text/* files, avoiding attempts to decode binary content.
Open text files via GIT_TOP / <path> with encoding="utf-8"
(and errors="surrogateescape") to prevent UnicodeDecodeError
during local compliance runs without changing the KeepSorted
sorting rules.

Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
2025-12-23 07:54:10 +01:00
Grzegorz Chwierut
4b6ad9db3c tests: twister: Update unit tests to support miltiple ports
Updated unit tests from pytest-twister-harness
with wupport of multiple connextions.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2025-12-22 20:36:34 +01:00
Grzegorz Chwierut
1b7810f0cb scripts: twister: Support multiple ports in pytest-twister-harness
Add support for multiple connections (e.g. UART) from one device,
enabling communication with second core UARTs. Feature implemented
by extracting connection logic from DeviceAdapter to new
DeviceConnection class with specialized implementations:
- SerialConnection for hardware UART ports
- ProcessConnection for native simulation
- FifoConnection for QEMU communication
Each connection maintains separate log files (handler.log,
handler_1.log, etc.) and can be accessed via connection_index
parameter in device methods like readline() and write().
This enables testing multi-core applications where different
cores communicate through separate UART interfaces.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2025-12-22 20:36:34 +01:00
Pieter De Gendt
7f97d3dd0a scripts: west: packages: Print warning on windows or run new command
On non-Windows systems execute a new program, replacing the west packages
call, when trying to install packages using pip.
For Windows, update the documented way of installing python packages,
or using 'west packages pip --install' print a warning.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-12-19 13:55:11 -05:00
Grzegorz Chwierut
96985a32e8 twister: pytest: fix duplicate log lines from pytest
The combination of pytest's `-s` (--capture=no) option and
`--log-cli-level=DEBUG` was causing duplicate log output.
Fixed by replacing `--log-cli-level=DEBUG` with `--log-level=DEBUG`.
`--log-cli-format` removed as is not used.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2025-12-19 07:51:49 -06:00
Grzegorz Chwierut
8827ea2643 twister: prevent infinite loop in required app resolution
When using --only-failed with required applications, twister could enter
an infinite loop during application dependency resolution.

Fixes #100808

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2025-12-19 07:51:23 -06:00
Pieter De Gendt
56a84e8111 scripts: ci: Add ignorecase option to zephyr-keep-sorted
Allow making the zephyr-keep-sorted check ignore cases, for example:

// zephyr-keep-sorted-start ignorecase
....
// zephyr-keep-sorted-stop

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-12-18 18:50:54 +00:00
Benjamin Cabé
29059ec3d6 scripts: ci: refresh requirements-actions.txt pinned versions and SHAs
Refresh pinned dependencies to pick filelock 3.20.1 version since 3.20.0
is subject to CVE-2025-68146.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-12-17 14:35:20 -08:00
Hake Huang
64eba11ee7 scripts: west: runners: add option for debug batch mode
when in batch mode, we do not need manually 'go'.
with this, we can use `west debug` in twister run test
enable for jlink and linkserver which is tested

example:

west debug --runner jlink -- --batch

Signed-off-by: Hake Huang <hake.huang@nxp.com>
2025-12-16 10:16:22 -06:00
Kyle Bonnici
d726022f83 CI: Update dts-linter to 0.3.7-hotfix2
dts-linter 0.3.7-hotfix2 Security Updates:
- Update `glob` to address CVE-2025-64756
- Update `js-yaml` to address CVE-2025-64718

Formatting updates:
- Ensure that properties have 2 new lines when node is above it.
- Enures that 1 new line is required between a node and #if/#ifdef...
- Enures that 2 new line are required between #endif and node.
- Wraps property values that exceed 100 characters in length.

Signed-off-by: Kyle Bonnici <kylebonnici@hotmail.com>
2025-12-12 15:38:31 -05:00
Jamie McCrae
a4e2a38370 scripts: zephyr_module: Skip writing output on no change
Skips updating files if the output already matches the file
contents, this prevents a random occurance whereby sysbuild
reconfigures itself after a reconfiguration for no known
discernable reason

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2025-12-12 09:57:48 -05:00
Pieter De Gendt
82845973a6 scripts: footprint: size_report: Close ELF file
Use the ELFFile context manager to open/close an input file.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-12-11 05:48:23 -05:00
Mathieu Choplain
cb27d92c0c scripts: build: check_init_prio: take deferred-init into account
A device with zephyr,deferred-init is initialized by the application, so
we cannot check if it is initialized in "the correct order". On the other
hand, a non-deferred device must not depend on a deferred-init device: this
is guaranteed to be initialized out of order.

Also adjust existing test cases and add a new test case to validate this
behavior.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-12-10 17:37:27 +00:00
Mathieu Choplain
ed182a89cd scripts: build: check_init_prio: create dedicated "flag errors" function
There is a bit of logic to run every time an error is reported. Factor it
out into a dedicated function.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-12-10 17:37:27 +00:00
Daniel Leung
bf44a017a6 coredump: fix ruff warnings on gdbstuc scripts
This fixes ruff warnings on coredump gdbstuc scripts.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-12-09 17:09:41 -05:00
Daniel Leung
9ace08210e coredump: fix ruff warnings on parser scripts
This fixes ruff warnings on coredump parser scripts.

Note SIM115 is not fixed yet as it requires more intrusive
changes to handle opened file with context manager.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-12-09 17:09:41 -05:00
Daniel Leung
79a5783a4b coredump: fix ruff warnings on top level scripts
This fixes ruff warnings on top level coredump scripts.
This is done via "ruff check --fix" without manual editing.

Note SIM115 is not fixed yet as it requires more intrusive
changes to handle opened file with context manager.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-12-09 17:09:41 -05:00
Daniel Leung
37b8402668 coredump: run ruff format on scripts
This is done via "ruff format" without any manual editing.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-12-09 17:09:41 -05:00
Daniel Leung
67e6720b31 coredump: gdbstubs: x86: disable pylint duplicate code warnings
This disables the duplicate code warnings on x86 and x86_64
gdbstubs. The exception vector tables may look the same now but
can deviate depending on supported features on architecture.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-12-09 17:09:41 -05:00
Benjamin Cabé
223e521275 scripts: ci: refresh requirements-actions.txt pinned versions and SHAs
This ensures, we pick a `urllib` version >2.6.0.
See:
- CVE-2025-66418 High severity
- CVE-2025-66471 High severity

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-12-09 09:49:26 -05:00
Mateusz Junkier
fb8a1ec9f3 Twister: fix serial port timeout
Fix for 1d70b70. Original code used start_time (set before flashing)
to calculate serial port wait timeout, which caused wait loop
to include flash duration, leading to exceed overall timeout.
Added serial_wait_start timestamp for avoid
including flash time in serial port enumeration timeout.
Make timeout dynamic (20% of flash_timeout, minimum 10s).

Signed-off-by: Mateusz Junkier <mateusz.junkier@intel.com>
2025-12-08 13:19:16 -05:00
Hake Huang
b3dff9bbbc tests: twister: using --no-rebuild in west flash
west flash deprecates --skip-rebuild to --no-rebuild

Signed-off-by: Hake Huang <hake.huang@nxp.com>
2025-12-08 13:12:04 -05:00
Jordan Yates
d020049f01 scripts: twisterlib: main: trim run duration
Display the total run duration to two decimal points instead of ~14,
similar to the other displayed timestamps.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-12-08 13:11:44 -05:00
Jordan Yates
d1cd982f8f scripts: twisterlib: display testplan build duration
Display how long it takes to build the testplan in the logs. This can
be useful since the duration to bulid the plan can vary wildly depending
on the arguments given. Without this information, it is difficult to
tell (from CI logs) whether a long execution time is from actually
building and running the tests, or just generating the testplan.

For example, in a downstream repo:
```
./zephyr/scripts/twister --integration -iv -T . --dry-run

INFO    - Building initial testsuite list...
INFO    - Built testsuite list in 10.58 seconds
```
vs
```
./zephyr/scripts/twister --integration -iv -T . --dry-run \
--vendor nordic --vendor zephyr

INFO    - Building initial testsuite list...
INFO    - Built testsuite list in 201.01 seconds
```

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-12-08 13:11:44 -05:00
Pieter De Gendt
91278bdddf devicetree: Add DT_CHILD_BY_UNIT_ADDR_INT
Allow fetching child node identifiers by integer unit address.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-12-08 13:09:24 -05:00
Anas Nashif
021fd07448 Revert "scripts: checkpatch: fix missing blank line detection"
This reverts commit c310133b3e.

randomly asking for Missing a blank line after declarations.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-12-06 11:41:00 -05:00
Lucien Zhao
98673d0aad scripts: ... :edtlib.py: update edtlib.py to generate some warning messages
During the actual development process, it was discovered that the
controller/device' would describe the bus type in the binding. However,
when the two sides did not match, the generated process would not be
affected and there were no any prompts. This made it very difficult for
developers to identify the problem.

I've updated the implementation to:
1. Add a `warn_bus_mismatch` kwarg to `edtlib.EDT()` constructor
   (default: False)
2. Add a `--warn-bus-mismatch` flag to gen_edt.py
3. Only show the warning when explicitly opted in
4. Add some checks in the edtlib. When the bus type of the node
   does not match the binding requirements, provide some auxiliary
   judgment information:
     a. bus position of the node
     b. available binding types
     c. expected binding type.

Signed-off-by: Lucien Zhao <lucien.zhao@nxp.com>
2025-12-06 11:39:17 -05:00
Jamie McCrae
546adfa555 scripts: snippets: Use temp buffer and only output on change
Stores data to output in a temporary buffer and only outputs data
to a file if the data is different to the file's existing data
(assuming it exists). This prevents a random occurance whereby
sysbuild reconfigures itself after a reconfiguration for no known
discernable reason

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2025-12-06 11:38:26 -05:00
Vignesh Pandian
c310133b3e scripts: checkpatch: fix missing blank line detection
Fix checkpatch not warning when blank line after declaration
is removed. Updated regexes to also handle context lines,
ensuring consistent detection.

Fixes: #98976

Signed-off-by: Vignesh Pandian <vignesh@aerlync.com>
2025-12-04 14:04:45 -05:00
Yves Wang
67e0217399 drivers: edac: Add NXP EDAC driver
Add edac driver for NXP's ERM and EIM peripherals. It can inject ECC
error to specific channel within EIM and then report the error address,
syndrome and count within ERM.

Signed-off-by: Yves Wang <zhengjia.wang@nxp.com>
2025-12-04 05:24:28 -05:00
Mathieu Choplain
636df434b9 twister: device-handler: use --dev-id for STM32CubeProgrammer runner
Now that the STM32CubeProgrammer runner supports the standard `--dev-id`
argument, replace usage of `--tool-opt` in the Twister device handler code.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-12-03 09:12:09 -05:00
Mathieu Choplain
aaaf1d3992 scripts: pytest: hw_adapter: use --dev-id for STM32CubeProgrammer runner
Now that the STM32CubeProgrammer runner supports the standard `--dev-id`
argument, replace usage of `--tool-opt` in the pytest harness hardware
adapter.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-12-03 09:12:09 -05:00
Mathieu Choplain
f1a75d75c7 runners: stm32cubeprogrammer: add support for --dev-id
Add support for the standard `--dev-id` argument used to select
target ST-Link debug probe based on serial number. Note that this
could already be achieved using custom argument `--conn-modifiers`.
(`--dev-id <XXX>` is equivalent to `--conn-modifiers sn=<XXX>`)

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-12-03 09:12:09 -05:00
Mathieu Choplain
5f67dfdf41 twister: device-handler: silence no-name-in-module warning
Silence CI warning caused by line "from . import ZEPHYR_BASE". This is a
legitimate pattern, but pylint seems unable to deduce so. Many other
scripts perform a similar silencing.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-12-03 09:12:09 -05:00
Pieter De Gendt
7e4235ff21 scripts: ci: check_compliance: Skip generated Devicetree Kconfig symbols
Do not generate a compliance error when referring to generated Kconfig
symbols from Devicetree.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-12-03 11:45:00 +01:00
James Roy
44106ac05f edtlib: binding: Add a examples keyword
Add an `examples` keyword to the binding to
provide a minimal example node for the binding.

Signed-off-by: James Roy <rruuaanng@outlook.com>
2025-12-02 20:53:01 -05:00
Anton Puppe
043a725b1f edtlib: Fix unformatted error message
Adds a missing f in the second line of a multiline f-string.
Previously, having the wrong top-level keys in a DTS binding YAML file
could cause a partially unformatted error message to be printed.

Signed-off-by: Anton Puppe <anton-noel-flynn.puppe@zeiss.com>
on-behalf-of: @ZEISS anton-noel-flynn.puppe@zeiss.com
2025-12-02 20:52:34 -05:00
Yves Wang
bf9f4c0cee ci: compliance: Correct dts-linter install cmd
Install dts-linter requires prefix for package.json

Signed-off-by: Yves Wang <zhengjia.wang@nxp.com>
2025-12-02 15:18:43 -05:00
Yangbo Lu
840d464ffb samples: net: move Ethernet samples to folder
Moved current Ethernet samples to folder ethernet,
as there will be more samples added in the future.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-12-02 11:45:19 +01:00
Haoran Jiang
8454f91e39 scripts: west_commands: runners: sftool: Add flash_files param
In addition to Zephyr's default build artifacts, other build processes
may generate additional images. Therefore, we have added the
`--flash-file` parameter to flash these supplementary images


Signed-off-by: Haoran Jiang <halfsweet@halfsweet.cn>
2025-11-28 17:25:27 +00:00
Kyle Bonnici
589be43e2e devicetree: remaining files
Applying dts-linter results for remaining format files

Signed-off-by: Kyle Bonnici <kylebonnici@hotmail.com>
2025-11-28 10:09:39 +00:00
Thorsten Klein
69536a6811 scripts: zephyr_module: ignore empty paths in extra modules env variables
Ignore empty paths in environment variables ZEPHYR_EXTRA_MODULES or
EXTRA_ZEPHYR_MODULES.

Signed-off-by: Thorsten Klein <thorsten.klein@bshg.com>
2025-11-27 14:48:13 +01:00
Nikodem Kastelik
ad1e5ac253 nordic: update and align to nrfx 4.0.1
New nrfx release contains major rework of nrfx drivers
instantiation making it easier to integrate with dts nodes.
Now, nrfx driver instances can no longer be `const`
because they contain driver runtime state.
Additionally, all nrfx drivers return `errno` error codes
instead of deprecated `nrfx_err_t`.

Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
2025-11-27 14:45:17 +01:00