Commit graph

5778 commits

Author SHA1 Message Date
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
Jamie McCrae
9b8b418a2c scripts: ci: check_compliance: Add Kconfig to allow list
Adds a Kconfig used for configuring MCUboot to the allow list

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-02-10 19:05:25 +01:00
Torsten Rasmussen
4061311da3 scripts: support list of images in build info
Add 'images' as valid list in build info schema.
This allow sysbuild and regular Zephyr images to populate build_info.yml
with images included in the build.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2025-02-10 15:56:52 +00:00
Anas Nashif
d80e3f7687 twister: harness: introduce shell harness
Introduce a new harness based on pytest that does basic shell command
handling. The harness is enabeld using:

harness: shell

and expects a file with parameters in the form:

test_shell_harness:
- command: "kernel version"
  expected: "Zephyr version .*"
- ...

Multiple commands and their expected output can be tested.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-02-08 08:13:46 +01:00
Irfan Ahmad
f3d513da09 scripts: build: Add support for generating string literals in file2hex.py
Currently, file2hex.py supports conversion of binary data into hexadecimal
character list format only. The generated list can then be used to embed
the binary data by using the list to initialize an array. However, this
approach is highly inefficient for large binary files.

A close but considerably more efficient alternative is to use string
literals composed of hex characters (in escaped form) to initialize the
array, instead of an initializer list. Benchmarking (with GCC and clang)
indicates that compile time and host memory usage by the compiler can be
more than an order of magnitude less with string literal approach compared
to the initializer list form.

The only caveat is that string literals contain the null character as
terminator so where accurate length is required, the correct length must
be specified explicitly while defining the array.

Signed-off-by: Irfan Ahmad <irfan.ahmad@siemens.com>
2025-02-08 08:13:08 +01:00
Jeremy Bettis
e88499cf8e twister: Check lcov exit codes
Don't ignore lcov exit codes, but instead log and return if one of the
lcov commands fails.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2025-02-08 00:31:54 +01:00
Jeremy Bettis
1385f02979 twister: Collect test names in lcov
When using --coverage-per-instance, collect the test names in lcov, and
add --show-details to the html report to display those test names.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2025-02-08 00:31:54 +01:00
Jeremy Bettis
b544e0a2b3 twister: Implement coverage file merging for lcov
Instead of capturing the coverage data twice with
--coverage-per-instance, just merge the lcov files in the aggregation
report.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2025-02-08 00:31:54 +01:00
Jeremy Bettis
6c7d518300 twister: Fix --disable-coverage-aggregation help text
There is no flag named --coverage-split, switch help to
--coverage-per-instance

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2025-02-08 00:31:54 +01:00
Grzegorz Chwierut
728d846cb0 scripts: ci: added twister_report_analyzer.py
Added script to parse and analyse Twister reports.
Failed tests are grouped together by reason of failure,
Cmake and build errors are grouped using predefined patterns.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2025-02-07 17:47:43 +01:00
Luca Burelli
5d3fe7e85a llext-edk: import data from build_info.yml and .config
Currently, the llext-edk.cmake script requires a number of variables to
be passed in from the main CMakeLists.txt file as arguments to be able
to customize the generated files.

To improve this rigid approach, the script is modified to read in the
following files in the build directory:

 * 'zephyr/.config', for the final set of Kconfig options used;
 * 'build_info.yml', for the cmake-related variables.

This is more flexible and also easier to maintain, as it doesn't require
manual changes to the main CMakelists.txt file when new variables need
to be referenced.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-02-07 17:45:45 +01:00
Adrian Warecki
2c5e18b971 sign: rimage: Include uuid-registry.h header in toml preprocessing
Add a function generate_uuid_registry that calls the gen-uuid-reg.py script
to generate the uuid-registry.h file. If signing an image without sof,
trigger the generation of the uuid-registry.h file.

Instruct the toml file preprocessor to also use the definitions from the
uuid-registry.h file. This will allow the values ​​placed in the
uuid-registry to be used in toml files.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
2025-02-07 14:31:48 +01:00
Carles Cufi
16f212d6f2 scripts: runners: nrf54H/92: Use RESET_HARD instead of RESET_SYSTEM
The nRF54H and the nRF92 series do not support the RESET_SYSTEM reset
kind. Instead one must use RESET_HARD, which this patch now implements.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-02-07 07:38:36 +01:00
Carles Cufi
7254a61530 scripts: runners: nrf: Fix flashing of FLPR/PPR on nRF54H20
After commit aaefaad, flashing of the FLPR and PPR cores in the nRF54H20
was broken due to those cores missing from the _get_core() function that
retrieves the core to program, triggering an exception. Fix it by
referencing those cores and mapping them to the application core.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-02-06 14:47:25 +01:00
Hake Huang
c268f15ae3 twister: testinstance: compare hwmap platform name with alias
in hwmap we may use short name, so need compare alias

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2025-02-06 07:44:55 +01:00
Benjamin Cabé
ead3a016cf scripts: footprint: Update hifive1 board name
Rev B of hifive1 is 'hifive1@B' since HWMv2 switch

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-02-05 21:03:08 +01:00
Carles Cufi
2effae5594 scripts: runners: nrfutil: Add a new external memory config param
This acts in a similar way to nrfjprog's --qspiini parameter introduced
in 7eb364b, but works slightly differently in nrfutil: it requires a
config file in JSON format instead of .ini, and it is passed along to
the `execute-batch` command instead of providing it together with the
`program` command.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-02-05 21:01:57 +01:00
Carles Cufi
f20168fe89 scripts: runners: nrf: Honor the --erase flag for external memory
Both backends supported as runners for nRF ICs, nrfjprog and nrfutil,
support erasing external memory as part of the programming operation.
Before this patch, and when the firmware was detected to be partially or
fully placed in external flash by inspecting the .hex address range, the
runner would instruct the backend tool to fully erase the external
flash (but the nrfjprog runner would ignore that, always erasing only
the sectors required). Instead, correctly default to erasing only the
sectors that are required to program the new firmware image in both tools,
and erase it completely only when the --erase flag is provided by the user.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-02-05 21:01:57 +01:00
Jamie McCrae
f8a5ebfd20 scripts: ci: check_compliance: Add check for disallowed Kconfigs
Adds a check for Kconfig settings that are disallowed from being
used in defconfig files (because it is the complete wrong place
for them), with the default entry being PINCTRL

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Co-authored-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-02-05 17:49:27 +01:00
Dmitrii Golovanov
e9cb2ef86b twister: runner: Log trace on general exception
Log trace on general exception at ProjectBuilder to provide
more details on its cause.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2025-02-05 14:59:00 +01:00
Carles Cufi
17a671ca00 scripts: runners: nrf: Default to soft reset for the nRF52 series
The Nordic nRF52 series have a peculiarity that is not shared with any
other Nordic families of SoCs: the reset pin can be reconfigured as a
regular GPIO. This has an unintended consequence: if the user has
reconfigured the pin in Devicetree to be a GPIO, `west flash` will
override that and configure the IC to use it as a reset pin, and the
firmware at boot won't be able to switch it back to GPIO, because that
requires a UICR erase. This behavior is very confusing to users, because
the GPIO does not work at all, since it is now just a reset line.

With this patch, `west flash` defaults to using soft reset instead of
pin reset for the nRF52 family of devices, to avoid overwriting the
reset pin configuration that the user includes in the image.

In order to be able to continue to use pin reset for users that so
desire it, a new option `--pinreset` is added that forces the use of pin
reset. The existing `--softreset` option is left exactly as it was, but
it is now applicable only to families other than the nRF52.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-02-05 01:13:42 +01:00
Carles Cufi
706689b376 scripts: runners: nrf: Fix missing kind in erase operations
Commit dc7d8bb introduced the requirement to provide the erase kind when
executing the corresponding op, but it was forgotten in this particular
spot.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-02-04 15:01:36 +01:00
Erwan Gouriou
b859423051 scripts: twister: Board id not needed for stm32cubeprog in BOOT-SERIAL
Flashing in BOOT-SERIAL mode with stm32cubeprogrammer doesn't support
using serial number.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2025-02-03 19:56:49 +01:00
Erwan Gouriou
a37a9c323a scripts: stm32cubeprogrammer: Add 2 new options for start and download
Implement possibility to specify options for --start and --download
arguments.
These options are implemented as lists to better fit STM32CubeProgrammer
programming model.

This options are required to enable the programming of STM32N6 in USB-DFU
mode, which requires "-d my.bin 0x1 -s noack" arguments list.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2025-02-03 19:56:49 +01:00
Chris Friedt
7bd0e84d20 west: commands: blobs: fail on checksum error
If a blob checksum does not match what is recorded in the
associated module.yml file, `west blobs fetch` should
(eventually) fail.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2025-02-03 19:52:58 +01:00
Carles Cufi
dc7d8bbe16 scripts: runners: nrf: Implement the erase command
The `erase` command was being used but there was no "backend"
implementation for it in nrfutil nor nrfjprog. Simplify the syntax and
implement it for both tools.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-02-03 16:59:40 +01:00
Carles Cufi
4e8ec169fb scripts: runners: nrfjprog: Remove erasepage handling
This is no longer used at all.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-02-03 16:59:40 +01:00
Carles Cufi
fa66984c2b scripts: runners: nrf: Add UICR ranges for nRF54L
These are used to detect if the firmware image contains any values
inside the UICR for additional handling.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-02-03 16:59:40 +01:00
Carles Cufi
aaefaad898 scripts: runners: nrf: Remove the nRF5340 special handling
This is no longer necessary, because thanks to sysbuild we no longer
invoke a runner with a .hex file that is the result of merging builds
for more than one core.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-02-03 16:59:40 +01:00