Commit graph

5406 commits

Author SHA1 Message Date
Alex Fabre
01b0dec496 west: boards: add board revision support in format string
The following board revision properties can now be used as part
of the format string in the 'west boards -f ...' command.

- board.revisions with format {revisions}
- board.revision_default with format {revision_default}

Signed-off-by: Alex Fabre <alex.fabre@rtone.fr>
2025-03-15 13:07:52 +01:00
John Barbero Unenge
53c5aa3bb0 scripts: ci: check_compliance: Fix signoff check
Use the --format flag in git rather than parsing the output of
the git log. The inspiration for this change was that the previous
implementation breaks if there's a ~/.gitconfig that changes the
git log format.

Signed-off-by: John Barbero Unenge <git@lsrkttn.com>
2025-03-13 16:56:40 +00:00
Lukasz Mrugala
ffe72a49bf scripts: Add invariant log closing
If BB tests failed, crashed, etc., log handles
could linger and crash test cleanup.
Adding log closing to a `finally` section
should prevent those issues.

Loggers should not be set up as globals,
as it makes testing much harder.
Running multiple Twisters may cause for the
logfiles to be still "in use".

When exiting main, close all logfiles
and remove their handlers from all loggers.
Do that for conftest as well.

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
2025-03-13 16:53:55 +00:00
Chris Friedt
72bc08578b scripts: utils: posix: add dry-run option and improve logging
Add a `--dry-run` (or `-d`) option to the posix kconfig
migration script for deprecated POSIX Kconfigs.

Additionally, add a set of skipped options (e.g. `TIMER`).

The `CONFIG_TIMER` option does not exist in the tree anymore
and was way too generically named previously, so the false
positive rate is astronomical, so it makes sense to skip it.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2025-03-12 19:03:52 +01:00
Gerard Marull-Paretas
b99ae6c7d9 scripts: kconfig: introduce dt_nodelabel_exists
Add a new function to check if a nodelabel exists in devicetree.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2025-03-11 18:54:57 +01:00
Alberto Escolar Piedras
cb53e40ff9 drivers uart_native_posix: rename to native_pty and support N instances
Rename the driver from uart_native_posix to uart_native_pty.
Including renaming the DTS compatible, and kconfig options, deprecating
the old ones.

And refactor the driver, generalizing it, so we can have any number of
instances.
Note that, unfortunately generalizing to N instances cannot be done
without a degree of backwards compatibility breakage: This driver was
born with all its configuration and selection of the instances based on
kconfig.
When the driver was made to use DT, it was done in a way that required
both DT and kconfig needing to manually coherently enable the 2nd UART.
This has now been fixed, which it means only DT is used to decide how
many instances are avaliable, and UART_NATIVE_POSIX_PORT_1_ENABLE is
just ignored.

Including:
* Deprecate UART_NATIVE_WAIT_PTS_READY_ENABLE: the options is always on
  now as it has no practical drawbacks.
* Deprecate UART_NATIVE_POSIX_PORT_1_ENABLE: DTS intanciation defines it
  being available now.
* Rename a few functions and in general shorten pseudo-tty/pseudo-
  terminal to PTY instead of PTTY.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-11 18:54:02 +01:00
Ederson de Souza
70c89811be scripts and soc: Mark MD5 and SHA1 usage as not for security
MD5 and SHA1 are not supposed to be used nowadays on security context.
Some ancillary scripts in tree do use them, but for verification only -
or where externally mandated, such the SPDX tool.

This patch marks those usages as `usedforsecurity=False`, which helps
clarify intent.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2025-03-11 04:52:15 +01:00
Torsten Rasmussen
63cf79bd99 scripts: support number of jobs and verbosity in west build.
Calling `west build --build-opt="-v" --build-opt="-j=<n>"`
passes the build options to `cmake --build ... -- <build-opt>` which
again is passed to the native build tool, such as ninja or make.

However, when ExternalProjects are used in CMake, such as in TF-M or
sysbuild builds then those extra build options are only passed to the
first image build and not those build as external projects.

CMake supports environment variables for those flags, so translate
verbosity and number of jobs to those environment variables and thereby
support those flags for all images when specified by the user.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2025-03-10 11:12:07 +01:00
Alberto Escolar Piedras
71b9d16558 native_simulator: Get latest from upstream
Align with native_simulator's upstream main
3ccb09ec00e291f699219c0e3f5b14b6b1c7ceb6

Which includes:
3ccb09e nsi_errno: Add new API to get the current host side errno
32eab87 Makefile: Ser a macro to distinguish build in runner context

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-10 06:52:19 +01:00
Alberto Escolar Piedras
4338122248 drivers entropy: fake_entropy_native_posix rename to _native_sim
Rename the driver files, binding and kconfig options, while deprecating
the old binding and kconfig options.

Uses in tree are replaced.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-08 03:38:13 +01:00
Grant Ramsay
4c5f858869 scripts: footprint: Exclude data section from rom_report if XIP=n
For XIP=n, the data section is only in RAM

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
2025-03-08 03:37:27 +01:00
Carles Cufi
c9151be798 west: runners: Add support for multiple device IDs
In order to enable the use case where the underlying flash tool supports
bulk-flashing using multiple device IDs, augment the core runner class
with this new runner capability and implement it in the nrfutil runner,
since the nrfutil tool supports it natively.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-03-07 20:24:23 +01:00
Martí Bolívar
2db0fb60f2 scripts: add "west gtags" command
This is an extension for indexing the source code in the workspace
with GNU Global. See the command line help for more information about
Global.

Signed-off-by: Martí Bolívar <marti.bolivar@oss.qualcomm.com>
2025-03-07 19:57:00 +01:00
Alberto Escolar Piedras
83c65e9d07 native_simulator: Get latest from upstream
Align with native_simulator's upstream main
26524aa55198807a37e012e5847f3975750d1716

Which includes:
* 26524aa Add new nsi_errno optional component
* 007a1c8 nsi_utils.h: Add NSI_ARRAY_SIZE() macro

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-07 19:56:30 +01:00
Alberto Escolar Piedras
e23d5ae996 native_simulator: Get latest from upstream
Align with native_simulator's upstream main
20d3b2b76a3bf61d35becbe17928cdf22e885b9f

Which includes:
* 20d3b2b Makefile: Support building C++ files with runner

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-07 19:56:30 +01:00
Irfan Ahmad
8d42cd078b scripts: build: Add optimizations in file2hex.py to gzip path as well
Added recently introduced optimizations - generation in string literal form
and faster generation for hexadecimal initializer list form - to gzip path
as well.

Signed-off-by: Irfan Ahmad <irfan.ahmad@siemens.com>
2025-03-07 19:53:34 +01:00
Lukasz Fundakowski
c5e8664089 twister: Refactor python module to follow PEP8 rules
Incremental refactoring.
Fix PEP8 issues to make ruff green for config_parser.py module.
Add __init__.py to twister directory to make it a proper python package,
and make modules importable.

Signed-off-by: Lukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
2025-03-07 19:49:42 +01:00
Erwan Gouriou
fb4bb5d768 scripts: west: runners: stm32cubeprogrammer: Fix stm32n6 dfu flashing
Rework of the flashing algorithm broke the STM32N6 dfu flashing.
Add the case of using usb port and download-modifier (new n6 specific
option) as a new case of using the bin file for flashing.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2025-03-06 17:18:25 +00:00
Jamie McCrae
0035449137 scripts: ci: check_compliance: Add sysbuild Kconfig exclusions
Adds some Kconfigs to the allow list which are used for
demonstration purposes in sysbuild documentation

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-03-05 09:58:26 +00:00
Anas Nashif
a7e2846a94 twister: setup logging per process
Setup logging per process to fix issue on both mac and windows where
handlers are not available to the processes.

Fixes #86237

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-02-28 14:53:38 +01:00
Declan Snyder
d46c382950 drivers: ethernet: Remove deprecated eth_mcux
This driver was deprecated and must be removed by Zephyr version
4.1 according to lifecycle/release guidelines.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-02-26 22:04:26 +00:00
Benjamin Cabé
529656e2be devicetree: Add filename and line number tracking for nodes & properties
This change enhances the devicetree library by adding support for tracking
the source filename and line number for nodes and properties.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-02-26 22:02:39 +00:00
Erwan Gouriou
b1f9428668 scripts: runners: stm32cubeprogrammer: Factorize type lambda function
Now that it is used twice, factorize lambda and comment.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2025-02-26 15:04:45 +01:00
Erwan Gouriou
3bddb13a29 scripts: test runners: stm32cubeprogrammer: Update --download-address test
Fix --download-address to expect a signed.bin file when --download-address
is provided.

To allow testing this case despite the checks put in the runner, add a
patch functions which return that zephyr.bin is actually present

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2025-02-26 15:04:45 +01:00
Erwan Gouriou
1be4025550 scripts: runners: stm32cubeprogrammer: Review f/w selection algorithm
Aim is to avoid 2 issues:
- Requesting --download-address to flash hex files
- Flashing hex files (non signed) on N6 which works but doesn't allow
persistent firmware

Hence this changes binds --download-address with usage of .bin files.
If --download-address was not provided, default to hex flashing.

File existence done with isfile() will ensure the required file
is available before flashing and report an error if this is not the
case.
Note: In specific N6 case, we're verifying zephyr.signed.bin is
available instead of zephyr.bin. This is ensure since self.cfg.bin_file
matches runners_yaml_props_target configuration (set to
zephyr.signed.bin on STM32N6).

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2025-02-26 15:04:45 +01:00
Anas Nashif
73fd29f76e twister: logging: verbose names for logging handlers
Trivial rename of variables to make them more clear.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-02-26 01:39:10 +01:00
Anas Nashif
96ab891f3a twister: filter out native_sim on ! Linux
native_sim only works and builds on Linux, when running twister on the
Mac, this platform fails to build and reports errors.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-02-26 01:39:10 +01:00
Jacob Wienecke
70f55bccf8 scripts: requirements-compliance.txt: fix windows requirements
Modify the requirements-compliance.txt to exclude python-magic from
windows system installation. On windows, the line:
""python-magic-bin; sys_platform == "win32""" already exists. Adding:
python-magic on windows creates issues where the check_compliance.py
script will either freeze or throw errors related to libmagic.

Signed-off-by: Jacob Wienecke <jacob.wienecke@nxp.com>
2025-02-24 20:20:09 +00:00
Benjamin Cabé
46782dd862 twister: harness: fix spelling of "written"
s/writen/written/

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-02-21 11:41:46 +00:00
Benjamin Cabé
09d2a6c08c twister: Add --keep-artifacts option
Introduce a new command-line option `--keep-artifacts` in twister that
allows users to specify which artifacts should be preserved
during test cleanup in addition to the default set.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Co-authored-by: Anas Nashif <anas.nashif@intel.com>
2025-02-20 15:08:50 +00:00
Benjamin Cabé
9ca11f3e9c twister: allowlist build_info.yml and zephyr.dts
These files can be useful to troubleshoot a test that's failing,
and they're really small, too.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-02-20 15:08:50 +00:00
Michael Zimmermann
76b24fac09 twister: terminate_process: fix NoSuchProcess error
NOTE: Even though previous commits indicate, that this can only happen on
MacOS, that's actually not true. It happens on Linux as well.

The constructor of `psutil.Process` can throw an exception as well, so we
need to wrap the whole loop in another try, unfortunately.

Signed-off-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
2025-02-20 06:04:31 +01:00
Michael Zimmermann
133e1278c2 twister: terminate_process: use contextlib.suppress
While it doesn't cause any issues, it's more consistent and makes future
commits which add handling for more exception types more readable.

Based on: 0df8240b49

Signed-off-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
2025-02-20 06:04:31 +01:00
Benjamin Cabé
3352c402fb scripts: fix spelling of "below"
s/bellow/below/

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-02-19 18:51:13 +01:00
Benjamin Cabé
f7c9200cc7 scripts: ci: check_compliance: inclusive language fix
use allowlist terminology

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-02-19 18:48:15 +01:00
Grzegorz Swiderski
bb8b059e23 twister: Account for board & SoC extensions
Problem
-------

Board & SoC extensions are used to define out-of-tree board variants or
SoC qualifiers. When a board is extended, it has multiple directories
associated with it (each with its own `board.yml`), where twister should
be able to find additional platform files to support these qualifiers.
Currently, this doesn't work, because twister only traverses the primary
BOARD_DIR and ignores the rest.

The fix would've been trivial in the case of "legacy" platform files,
i.e. those of the form `<normalized_board_target>.yaml`, but it's less
straightforward for the newly introduced `twister.yaml` format.

A `twister.yaml` file contains platform configuration that can be shared
by multiple board targets and tweaked for specific targets by using the
top-level `variants` key. Normally, there is at most one `twister.yaml`
per board, but the file isn't necessarily unique to one board. Instead,
it's unique to one directory, which may define multiple boards (as is
the case with e.g. `boards/qemu/x86/`).

With extensions in the picture, the goal is to initialize platforms when
given multiple `twister.yaml` per board. The OOT files are expected to
only provide information about OOT board targets, without being able to
override in-tree targets (same principle as in the Zephyr build system).

Solution
--------

The `twister.yaml` handling is broken up into multiple passes - first
loading all the files, then splitting the `variants` keys apart from the
shared configuration, before constructing the Platform instances.

The purpose of the split is to treat the variant information as global,
instead of making unnecessary or faulty assumptions about locality.
Remember that the build system can derive board target names not only
from `board.yml`, but from `soc.yml` too. Considering that any board may
end up using an OOT-extended SoC (and hence multiple `soc.yml` files),
not every board target can be said to belong to some board dir.

Unlike the variant data, the remaining top-level config is still rooted
to the primary BOARD_DIR and inherited by the extension dirs from there.
This is quite intuitive in most imagined cases, but there is a caveat:
if a `twister.yaml` resides in an extension dir, then it is allowed to
have a top-level config of its own, but it will be silently ignored.
This is to support corner cases where, much like how a single board dir
can define multiple boards, a single board dir can also extend multiple
boards, or even do both. In those cases, the primary BOARD_DIR rule
should make it unambiguous which config belongs to which board, even if
it may seem counter-intuitive at first.

For concrete examples of what this means, please see the newly added
platform unit tests.

As part of these functional changes, a good chunk of logic is moved out
of `TestPlan.add_configurations()` into a new function in `platform.py`.
This is because recombining the top-level and variant configs requires
direct manipulation of the loaded YAML contents, which would be improper
to do outside of the module responsible for encapsulating this data.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2025-02-14 21:01:33 +01:00
Grzegorz Chwierut
df40aa5574 twister: shell harness with commands alongside the harness_config
Allow user to add shell commands in testcase/sample yaml file
alongside the harness_config like in the console harness.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2025-02-14 19:14:38 +00:00
Jamie McCrae
5e1aaa5395 scripts: ci: check_compliance: Fix paths for disallowed Kconfigs
Fixes using the wrong path for checking if disallowed Kconfigs
are present, to use the zephyr base instead of the git top level
folder which caused issues for downstream manifests

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-02-14 19:13:39 +00:00
Robin Kastberg
9ab06ec667 toolchain: iar: Add experimental IAR support
This adds experimental support for the IAR toolchain.

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2025-02-14 19:12:44 +00:00
Robin Kastberg
d41da75ac4 checkpatch: Allow __BYTE_ORDER__ and __aligned__ in toolchain files
Checkpatch needs to allow toolchain headers where
these macros are defined.

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2025-02-14 19:12:44 +00:00
Anas Nashif
7b8a5ed655 twister: platforms: fix parsing testing metadata
Fix parsing of testing metadata, global defaults were being ignore in
some cases.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-02-14 17:07:24 +01:00
Armin Kessler
20b1dddce5 scripts: twister: fix flash to esp32 using esp32 runner
Twister and pytest now flash to the device specified with board_id.

Signed-off-by: Armin Kessler <ake@espros.com>
2025-02-14 17:06:46 +01:00
Dominik Kilian
0e4efdb2a6 tests: ipc_service: Test restarting session in different scenarios
This commit adds a test that checks if disconnecting
and restarting the IPC session works correctly. The
test is also focused on the "unbound" callback.

Signed-off-by: Dominik Kilian <Dominik.Kilian@nordicsemi.no>
Co-authored-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
2025-02-14 13:34:49 +01:00
Mubin Sayyed
16d5d5e480 west_commands: runners: Fix parameters passed to xsdb
Existing logic is passing elf file as parameter only when fsbl
or bit file parameter is present. This is incorrect, elf file should
be always passed irrespective of other parameters.

Signed-off-by: Mubin Sayyed <mubin.sayyed@amd.com>
2025-02-14 08:44:54 +01:00
Sylvain Chouleur
4454734d12 scripts: code_relocate: support section filter
One might want to select the symbols to be relocated inside a file or
a library. To do this, one can use the FILTER argument of
zephyr_code_relocate which must contain a regular expression of the
section names to be selected for relocation.

The test_function_in_sram2 test case in
`tests/application_development/code_relocation` has been updated to
verify that only one function `function_in_sram()` is relocated to ram
and that the function `function_not_relocated()` is not being relocated
when using relocation filter.

Signed-off-by: Sylvain Chouleur <sylvain.chouleur@gmail.com>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2025-02-14 03:02:56 +01:00
Torsten Rasmussen
cb8f99ab7a cmake: code relocation setting.
With code relocation directives passed to the gen_relocate_app.py script
using generated file, then each directive can be place on individual
line in the file and thus free up the `|` character as separator.

Furthermore, a multi-line file with each directive on separate line is
also more user-readable, making debugging easier.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2025-02-14 03:02:56 +01:00
Grzegorz Chwierut
145b1b9e64 ci: twister: Group CMake and Build failures in Twister analysis
After adding more detailed information to the reason field in
Twister report, update twister_report_analyzer.py to group
CMake and Build failures.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2025-02-13 16:42:23 +01:00
Grzegorz Chwierut
33b202e295 twister: blackbox: fix test_report_summary after extending reason
Updated test_report_summary to match new string with detailed
reason of build failure.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2025-02-13 16:42:23 +01:00
Grzegorz Chwierut
cac967db9f twister: extend reason field in Twister reports
Extended the reason field in Twister report to include
more detailed information for 'Build failure' and
'CMake build failure'

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2025-02-13 16:42:23 +01:00
Findlay Feng
5ce031754a west: runners: Fix openocd's rtt shell display
To use openocd rtt shell in a non-Windows environment,
you need to turn off ICANON and ECHO.
Refer to pyocd to enable a temporary terminal and configure
it correctly.

Signed-off-by: Findlay Feng <i@fengch.me>
2025-02-12 09:39:48 +01:00