Commit graph

6,360 commits

Author SHA1 Message Date
Anas Nashif
641fc4a018 arch: init: rename z_early_memset -> arch_early_memset
Do not use private API prefix and move to architecture interface as
those functions are primarily used across arches and can be defined by
the architecture.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-09-08 15:51:07 -04:00
Anas Nashif
53a51b9287 kernel/arch: Move early init/boot code out of init/kernel headers
Cleanup init.c code and move early boot code into arch/ and make it
accessible outside of the boot process/kernel.

All of this code is not related to the 'kernel' and is mostly used
within the architecture boot / setup process.

The way it was done, some soc code was including kernel_internal.h
directly, which shouldn't be done.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-09-08 15:51:07 -04:00
Fabio Baltieri
9b7c4c85c8 list_backports: fix typo
Fix typo, organisation -> organization.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-09-06 06:35:37 -04:00
Fabio Baltieri
102be7bbf0 scripts: do_not_merge: take a repo and org argument
Take a repo and org argument to the do_not_merge.py script so it can be
used in the testing repository.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-09-06 06:35:37 -04:00
Marc Herbert
8ad23f8313 twister: add space in custom_flash_scripts example and test
This makes sure parsers don't trip over whitespace (as many do).

I suggested this late in #93944

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2025-09-05 17:11:51 +02:00
Krzysztof Chruściński
9f4bd38ef7 scripts: west_commands: build: Fix warning during rebuild
5718af02c5 introduced a regression where a warning was printed
about unknown BOARD when rebuilding. Commit moved _find_board()
to an earlier stage and that was failing during the rebuild. Instead
of moving board finding earlier we can move parsing of the test_item
to the later stage as it is needed only just before running cmake.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-09-05 12:28:01 +02:00
Pieter De Gendt
1e737d7a5f scripts: west_commands: twister_cmd: Fix twister wrapper
Commit 4f637258ef reworked the twister main
function. Update the west wrapper to align with that change.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-09-05 09:31:33 +02:00
Benjamin Cabé
198147a49b scripts: kconfig: use tabulate for printing hardenconfig results
Make use of `tabulate` to pretty print the results of the hardening tool
instead of custom formatting.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-09-04 21:03:57 +02:00
Benjamin Cabé
5e032d7f84 scripts: kconfig: apply ruff fixes to hardenconfig.py
Wrap long lines so that there is no need to exclude this file from ruff
anymore.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-09-04 21:03:57 +02:00
Lukasz Fundakowski
4f637258ef twister: refactor twister_main to simplify the system tests
Refactored twister_main.py module to simplify the code and system tests.
Removed the need to patch `sys.argv` in blackbox tests.

Signed-off-by: Lukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
2025-09-04 16:45:42 +02:00
Noah Pendleton
6169269da8 west: blobs: fetch --allow-regex filter
When building in CI for specific SOCs, it's useful to only have `west blobs
fetch` pull a selected set of blob objects. This is especially helpful on
`hal_espressif`, which currently has 78 blob objects.

Add a `--allow-regex` arg to the `west blobs fetch` subcommand to filter
only specified blobs, for example:

```bash
# only download esp32 blobs, skip the other variants
❯ west blobs fetch hal_espressif --allow-regex 'lib/esp32/.*'
```

Also, replace all `str.format()` invocations with f-strings per review
feedback.

Signed-off-by: Noah Pendleton <noah.pendleton@gmail.com>
2025-09-04 16:44:52 +02:00
Declan Snyder
7e92b70437 include: devicetree: Add more PHA macros
Add more macros for interacting with controller/data type of
relationships (phandle arrays / cells)

Add macros for arbitrarily iterating cells of phandle specifiers

Add tests for the new macros

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-09-04 14:43:13 +02:00
Pieter De Gendt
b42d89c67f scripts: footprint: Add a plot script for size reports
Add a helper script that can take in a size report in json and render it in
a sunburst chart.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-09-04 14:42:52 +02:00
Benjamin Cabé
0132ea07fb doc: fix spelling errors tree-wide
fix some spelling errors in code comments and Kconfig helps

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-09-03 17:04:13 +02:00
Lukasz Fundakowski
6fcb3ff219 twister: refactoring: Improve error message when test failed
Modified the assertion statements to raise informative exceptions
that indicate which lines did not pass the assertions.
Added unit tests using pytest to validate the functionality of
the modified functions.

Signed-off-by: Lukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
2025-09-03 11:03:47 +02:00
Jamie McCrae
4977c5cef9 scripts/kconfig/cmake: Generate/use env file for zephyr module paths
Adds a output env file that lists the paths of zephyr modules
which can be used in Kconfig files and uses this in Kconfig. Also
updates Kconfig doc output to generate and use this

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-09-03 11:03:40 +02:00
Sylvio Alves
4651a02ff4 twister: reset ESP32 via RTS/DTR to capture early boot logs
When testing ESP32-based platforms in CI, early boot logs can be missed
if the serial connection isn't reset properly. This patch applies the
standard RTS/DTR toggle sequence to reset the ESP32 after flashing,
ensuring consistent log capture from the very beginning.

The logic is applied conditionally when the runner is "esp32".

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-09-03 11:03:20 +02:00
Henrik Brix Andersen
36f78b52b7 scripts: valgrind: suppress missing clean-up in nct_new_thread()
Suppress memory leaks detected by valgrind originating from
nct_new_thread(), part of the native_sim CPU thread emulation.

This covers calls to posix_new_thread() as well, since this function simply
calls nct_new_thread (but may be optimized out by the compiler).

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2025-09-03 06:10:49 +02:00
Fabio Baltieri
867676c906 twister: pass flash_command to the harness
Add the necessary logic to pass the custom flash_command to the pytest
harness.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-09-03 06:10:37 +02:00
Fabio Baltieri
a31f784e95 twister: add a --flash-command flag
Currently twister requires west to flash a board, either directly using
west-flash or indirectly through the cmake flash target.

Add an option to specify a custom flash script, this is passed a
build-dir and board-id flags so it can be used to implement custom
flashing scripts in a system that does not use west.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-09-03 06:10:37 +02:00
Fabrice DJIATSA
7ff93d7454 scripts: twister: pylib: not needed board id with BOOT-SERIAL mode
STM32CubeProgrammer does not support flashing in BOOT-SERIAL mode
using the device's serial number.

Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
2025-09-02 15:54:07 +02:00
Anas Nashif
232db11f0d twister: tests: fix test output parsing
Fix test output parsing and update to what twister produces.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-09-02 10:00:24 +02:00
Anas Nashif
8d0a6b59c6 twister: do not use twister internals for reason field
Do not use twister internals for reason field.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-09-02 10:00:24 +02:00
Anas Nashif
a6277ddaef twister: remove stray debug message
Remove leftover debug message.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-09-02 10:00:24 +02:00
Sebastian Bøe
aa2a439299 west: runners: nrf_common: Delete deprecated suit handling
Delete deprecated suit handling.

SUIT is no longer supported.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2025-09-01 16:56:02 +01:00
Torsten Rasmussen
795445535d scripts: parse module.yml for dts bindings
Change BoardYml compliance check from using get_module_setting_root()
to load and parse module.yml directly.

get_module_setting_root cannot be used directly with module.yml.
Instead adjust the code so that the module.yml file is loaded locally
and the dts_root setting is extracted from the dictionary.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2025-09-01 12:00:42 +02:00
Anas Nashif
f42dc20073 twister: deal with status/reason setting in handler in one place
Multiple handlers were setting status/reason in slightly different ways,
but the code was mostly trying to do the same. Put this code in the
handler class and implement in one place.

This fixes an issue where in some cases qemu failures were not handled
correctly and status of cases was not updated, leading to multiple
failures.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-08-31 06:17:16 -04:00
Tim Pambor
375d51452e scripts: twister: Fix --flash-before with serial-pty script
Honor the --flash-before option when using a serial-pty script with
--device-serial-pty <script> and start the script only after
flashing the device.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2025-08-30 18:00:32 +01:00
Anas Nashif
de8914ddc0 twister: coverage: --gcov-object-directory works with >= gcovr 7.0
This command line option is not available in older versions of gcovr.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-08-30 18:00:09 +01:00
Anas Nashif
d175b5005d twister: tests: resolve warning about function being uncallable
Get rid of warnings about uncallable functions due to variable names
having test prefix.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-08-30 18:00:09 +01:00
Anas Nashif
d0675936da twister: tests: fix failing blackbox tests
Few tests failing and were not caught due to CI not running.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-08-30 18:00:09 +01:00
Lukasz Fundakowski
71a5f29150 twister: Add configuration reader to pytest-twister-harness
Added a class that helps to read Kconfigs from a configuration file.

Signed-off-by: Lukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
2025-08-30 12:30:26 +02:00
MA Junyi
718f0e7272 scripts: compliance: Add items to UNDEF_KCONFIG_ALLOWLIST
`BOOT_ENCRYPT_ALG_AES_128` and `BOOT_ENCRYPT_ALG_AES_256` are used in
`share/sysbuild/image_configurations/BOOTLOADER_image_default.cmake`
They were first introduced in commit 9a1fe30

Signed-off-by: MA Junyi <mjysci@live.com>
2025-08-29 13:15:09 +02:00
Peter Johanson
5eeddab167 scripts: west: flash: Fix RFP runner platform check
Adjust the RFP runner platform check to properly handle Darwin or Windows
and skip setting a default RPF port on those two platforms.

Signed-off-by: Peter Johanson <peter@peterjohanson.com>
2025-08-28 14:00:02 +02:00
Ta Minh Nhat
652d822203 west: runner: rfp: support memory partition for rfp runner
Add rfp runner support for ek_ra6m4 and ek_ra6m5.
Add memory partition for rfp runner.

Signed-off-by: Ta Minh Nhat <nhat-minh.ta.yn@bp.renesas.com>
2025-08-28 13:58:33 +02:00
Sebastian Bøe
ac851ca160 soc: nordic: uicr: Reorganize how gen_uicr.py is invoked
Reorganize how gen_uicr.py is invoked.

Instead of invoking it from one of the Zephyr images we invoke it from
a new special Zephyr image called uicr.

This uicr Zephyr image is flashed in the same way as normal Zephyr
images so special handling in the runner is no longer necessary.

Also, we simplify gen_uicr.py by moving parsing of Kconfig/DT from
gen_uicr.py to CMake.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2025-08-26 09:38:18 +02:00
Benjamin Cabé
5a1065c37f scripts: ci: differentiate warnings from failures in compliance_check
We have a few checks that report warnings, and for some of them it's
actually the _only_ type of failure they report, so it can be confusing
when the output of check_compliance.py says the "check failed" and lists
all the things that are effectively warnings as "ERROR"s.
This commit makes the output more clear by differentiating between
warnings and actual errors, both when printing out individual failures,
but also when printing the summary for each test case (ie. a test case
is said to be "failing" only when it has at least one error, and is only
showing up as having warnings if it only contains... warnings).

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-08-25 09:12:13 +02:00
Tom Burdick
9c27d72922 rtio: Add a context pool
Adds a context pool that can be used when a number of threads may be
dynamically created to use with RTIO. While the pool has a small cost to
it, the cost of verifying a statically declared kobject likely makes it
worth avoiding dynamically allocating these with the typical
kobject_alloc method. Instead this arena style pool of objects can be
used where the kobject validation uses the gperf hash created at build
time.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2025-08-22 16:45:53 +02:00
Garrett L. Ward
d8d90c087b scripts: west: runners: stm32cubeprogrammer: fix path lookup on macOS
On Windows and Linux, the stm32cubeprogrammer runner will use
STM32_Programmer_CLI from PATH if it is available, but this was not
implemented on macOS. Add PATH lookup for macOS as well, using the same
approach as Windows and Linux.

Fixes zephyrproject-rtos/zephyr#93056

Signed-off-by: Garrett L. Ward <glward@glward.net>
2025-08-22 12:35:34 +02:00
Thorsten Klein
b0f40e4dd0 scripts: zephyr_module: accept empty env vars for extra modules
Proceed if the environment variables ZEPHYR_EXTRA_MODULES or
EXTRA_ZEPHYR_MODULES are set to an empty string. Handle same way as if
the variable is unset.

Signed-off-by: Thorsten Klein <thorsten.klein@bshg.com>
2025-08-20 12:06:07 +02:00
Jamie McCrae
ea9815ff34 scripts: zephyr_module: Add variable with module path
Adds a variable that has the path of the module directory, this
is supplied as an argument when running cmake normally but is
not supplied when running the check compliance script, this
addition allows checks to be ran that use such syntax in Kconfig
files. This is then removed from cmake as the python file handles
it instead

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-08-20 12:05:41 +02:00
Krzysztof Chruściński
5718af02c5 scripts: west_command: build: Support for conditional platform configs
extra_configs or extra_args can use additional filtering which was not
supported by the west build command. West is not aware of arch so that
filter type is not supported but platform (board) is known so it can
be used to apply expected configuration.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-08-20 07:39:16 +02:00
Yasushi SHOJI
4c506c01ca scripts: west_commands: sdk: clarify toolchain selection help
Users were confused about which toolchain names to pass to
`west sdk install -t`, since the documentation did not list them.
Enhance the help text to suggest installing all toolchains if
unsure and point to the SDK release notes where the available
toolchains are listed.

ref: https://github.com/zephyrproject-rtos/zephyr/discussions/94572

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2025-08-20 02:18:12 +02:00
Omri Sarig
c712502fb9 scripts/logging: Create live_log_parser
Create a new, generic parser, that is able to parse dictionary logs live
- showing the messages as they are received from the device.

This functionality previously existed only for reading the log from a UART.
With the new script, the functionality is extended to be able to also read
the log from a file or stdin.
Additionally, the script is written in an extend-able way, making it simple
to support more input sources in the future.

The new script contains a better version of the live functionality than the
old script of log_parser_uart script, therefore, the old script has been
deprecated.
The UART script is still available, and will work by invoking the new
implementation with relevant arguments translation, however, it should
ideally not be used any longer, and should be removed from a future
release.

Signed-off-by: Omri Sarig <omsi@demant.com>
2025-08-19 11:39:49 +02:00
Omri Sarig
152e6252fe scripts/logging: Handle partly read packets
The current implementation of the serial log parser is running in a loop -
every 2 seconds it checks if there is any information ready to be read, and
in this case, it reads this information and parses it.
In case the last packet of the information is not fully available, the
script will read only the first part of the packet, and will fail when
parsing, ending the run with an error.

This should not the be the case, as it is not an error to have only part
of the packet in the buffer.
This commit fixes this problem - now, instead of failing because the parser
does not have enough information, the parser will parse all the full
packets it have, and keep the last, partial packet in the queue, to be
parsed together with the next chunk of data.

This is done by updating the log parsers to return the amount of parsed
data when trying to parse the information, and updating the calling scripts
to correctly handle this new return value.
Additionally, the parser is now quietly failing in case of having a partial
message, and throw an exception for any other kind of error in the parsing
(instead of returning a boolean return code).

In addition to the partial packet handling, the current commit also do the
following, minor improvements:
* parserlib now fails by throwing an exception, instead of exiting - this
  is done to make it possible to choose a different handling for the errors
  from the calling code, if needed.
* The dictionary and parser are now created before the parse operation.
  This makes the uart parser more efficient, and also removes the
  previously duplicated messages of build id, target architecture and
  endianess (which was printed every time new information was received from
  the UART).

Signed-off-by: Omri Sarig <omsi@demant.com>
2025-08-19 11:39:49 +02:00
Omri Sarig
cb94b1ba2a scripts/logging: Add support for numbered %ll and %hh
Python does not support values of long-long (ll) or short-short (hh) in
string-formatting. The current parser is correctly removing the first "h"
or "l" from the format, to make it possible to correctly parse these
strings when they are in the dictionary.

However, the current implementation does not correctly handle the case of
having a number before the "ll" or "hh" argument - which is supported by
both C and Python.

This commit updates the parser to correctly handle these cases, by changing
the simple replace operator with a regex replace, which is able to
correctly handle this case.

Before this commit, the string of:
    "This is my long variable: %08llX"
will stay the same, which will throw a ValueError when parsing this
dictionary message:
    "ValueError: unsupported format character 'h' (0x68) at index ".
After this commit, the string will be correctly fixed to
    "This is my long variable: %08lX"
which is parsed correctly.

Signed-off-by: Omri Sarig <omsi@demant.com>
2025-08-19 11:39:49 +02:00
Zhaoxiang Jin
bfe65a0179 scripts: compliance: Add items to UNDEF_KCONFIG_ALLOWLIST
'MCUX_HW_CORE' and 'MCUX_HW_FPU_TYPE' are used in
modules/hal_nxp/device.cmake. It is a variable used
by MCUX SDK CMake.

Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
2025-08-18 22:00:19 +02:00
Ha Duong Quang
0f0dd2774b west: update to support for S32DS3.6
S32DS3.6 requires to use python 3.10, so update
PYTHONPATH for S32DS3.6 when debug on windows.

Update to verify new behavior of supported commands
with S32D3.6 on windows.

Update to find out the usb device connected by VID
and PID instead of class "NXP Probes" on windows
Because based on the S32 Debug probe OS version the
device class of USB is changed. Therefore a reliable
way to identify the probe is check the USB VID and PID.

Signed-off-by: Ha Duong Quang <ha.duongquang@nxp.com>
2025-08-18 13:07:32 +02:00
Marco Widmer
d45985347b twister: coverage: set gcov working directory
gcovr runs gcov to generate temporary coverage files into the gcov
working directory. The working directory defaults to gcovr's -r
argument.

When running twister with the --coverage-per-instance argument, multiple
gcovr instances may run in parallel. Since they all share the same gcov
working directory, they may interfere with each other, resulting in
errors like this:

	AssertionError: Sanity check failed, output file
	spinlock.h##4167b923a06cc9590c8eef372f016a6d.gcov doesn't exist
	but no error from GCOV detected.

To fix this, specify a separate gcov working directory for every test
through gcovr's --gcov-object-directory option.

Signed-off-by: Marco Widmer <marco.widmer@bytesatwork.ch>
2025-08-14 15:49:35 +02:00
Benjamin Cabé
051a951553 scripts: west: spdx: convert datatypes.py classes to Python data classes
Remove a bit of boilerplate code and add typing in the process.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-08-14 15:48:57 +02:00