Commit graph

5595 commits

Author SHA1 Message Date
Sebastian Huber
ade1c883a8 scripts: build: Make scripts executable
Make scripts with an interpreter line executable so that they can be
invoked directly.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2025-01-15 15:06:01 +01:00
Pieter De Gendt
1378669736 scripts: west_command: spdx: Exit with non-zero code on failure
If the init or the generation fails, the resulting exit code should be
non-zero.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-01-15 15:03:59 +01:00
Daniel DeGrasse
986a170a39 scripts: west_commands: runners: fix support for JLink RTT
JLink refuses new RTT telnet connections for a few moments after a socket
closes. This causes an issue when using `nc` as the telnet viewer, since
JLink would deny the connection. To resolve this, keep the "ping" socket
we use to determine if the RTT viewer is active connected, and use that
socket for RTT communication.

Signed-off-by: Daniel DeGrasse <ddegrasse@tenstorrent.com>
2025-01-14 22:54:21 +01:00
Sylvio Alves
ccfd1fa099 runner.py: update overflow list options
Adds custom memory section names used in
Espressif linker files.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-01-14 00:01:31 +01:00
Martin Jäger
0728f5d0e2 scripts: west_commands: runners: esp32: add flash encryption option
Add an argument `--esp-encrypt` to flash an ESP32 series chip with
encrypted flash.

The content of the binary is encrypted on the fly by the chip. It is
not required to know the encryption key. However, the fuses that
disable encrypted flash download must be kept enabled for this to work.

Signed-off-by: Martin Jäger <martin@libre.solar>
2025-01-13 10:09:36 +01:00
James Roy
34bc4c3e3e style: edtlib: Use a better format string
Use f-strings as recommended by PEP-8
instead of the .format() method.

Signed-off-by: James Roy <rruuaanng@outlook.com>
2025-01-10 18:57:39 +01:00
Nicolas Pitre
46aa6717ff Revert "arch: deprecate _current"
Mostly a revert of commit b1def7145f ("arch: deprecate `_current`").

This commit was part of PR #80716 whose initial purpose was about providing
an architecture specific optimization for _current. The actual deprecation
was sneaked in later on without proper discussion.

The Zephyr core always used _current before and that was fine. It is quite
prevalent as well and the alternative is proving rather verbose.
Furthermore, as a concept, the "current thread" is not something that is
necessarily architecture specific. Therefore the primary abstraction
should not carry the arch_ prefix.

Hence this revert.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2025-01-10 07:49:08 +01:00
Pieter De Gendt
0b67255b0f scripts: twister: Add CTest harness
Introduce a twister harness for CMake's CTest.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-01-10 04:12:42 +01:00
Anas Nashif
5769966d0f twister: deal with variants set on command line
not force host variant if environment is setting something different in
the case of posix arch.

Fixes #83766

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-01-09 22:12:26 -05:00
Eric Holmberg
3d42a1cfbc west: runners: add option 'v' prefix to OpenOCD version string
The Espressif branch of OpenOCD uses the version string "v0.12.0" instead
of "0.12.0" causing the version regex match to fail.

Add an optional 'v' prefix to avoid the failure.

Fixes: #83373
Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
2025-01-10 02:16:04 +01:00
Christophe Dufaza
ee5c520326 edtlib: tests: refine coverage of Binding objects initialization
Add a series of unit tests which try to cover somewhat systematically
the possible inputs and what we finally get at the exit
of the Binding constructor.

Running the assumption that any (valid) YAML binding file is
something we can make a Binding instance with:
- check which properties are defined at which level (binding,
  child-binding, grandchild-binding, etc) and their specifications
  once the binding is initialized
- check how including bindings are permitted to specialize
  the specifications of inherited properties
- check the rules applied when overwriting a binding's description
  or compatible string (at the binding, child-binding, etc, levels)

Some tests covering known issues are disabled by default:
- this permits to document these issues
- while not causing CI errors (when running the python-devicetree
  unit tests)
- enabling these tests without causing errors should allow us
  to consider the related issues are fixed

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2025-01-08 19:17:51 +01:00
Pieter De Gendt
640a8b9302 scripts: west_commands: Support out-of-tree runners
Add runners entry to the module schema and import the file specified.

Every class that inherits from ZephyrBinaryRunner will be discovered and
added to runners list.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-01-08 17:02:06 +01:00
Anas Nashif
11e656bb6a twister: support testing multiple toolchain variants
Added integration_toolchains to allow building/testing with multiple
toolchains available in the environment.

This changes the output structure and adds another level in the path
under twister_out signifying the toolchain used. The toolchain used
(variant) is also part of the json output now.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-01-08 12:58:59 +01:00
Dmitrii Golovanov
05c167e0b8 twister: ztest: Optimize logging and comment special cases
Add more comments and optimize logging on Ztest tracing.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2025-01-08 06:07:35 +01:00
James Roy
c99a61ada4 style: edtlib: Use a better type Annotations
Use built-in types for annotations instead
of types from the typing module.

Signed-off-by: James Roy <rruuaanng@outlook.com>
2025-01-08 03:26:58 +01:00
Jordan Yates
5f0c800591 runners: jlink: win32: search for valid JLink.exe
Since "JLink.exe" is also an executable distributed with JDK's, do an
explicit search on the standard SEGGER install directories for a JTAG
"JLink.exe" before falling back to whatever is first on PATH.

Fixes #51825.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-01-08 01:30:13 +01:00
Chris Friedt
3e49a19b17 scripts: checkpatch: add special consideration for DIR
DIR is a POSIX type defined via the dirent.h header.

In Zephyr, we define it as `typedef void DIR`, since it is only
ever described via a pointer (much like `FILE`).

However, in checkpatch.pl, functions that return DIR* or accept
a DIR* argument are met with an error of the form below:

```
ERROR:SPACING: need consistent spacing around '*' (ctx:WxV)
```

Examples that trigger this false positive are, for example

```cpp
int dirfd(DIR *dirp);
DIR *fdopendir(int fd);
```

Include `DIR` as a class of specific POSIX types that should be
matched as types rather than other tokens.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2025-01-08 01:29:06 +01:00
Fin Maaß
9d0627a4bc scripts: west_commands: add --ignore-venv-check option
add --ignore-venv-check option to ignore the venv check.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-01-07 20:35:53 +01:00
Pieter De Gendt
4c5e74deae scripts: west_commands: patch: Use subprocess cwd
Instead of changing directories, pass the cwd argument to the different
subprocess calls.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-01-07 14:12:57 +01:00
Pieter De Gendt
78f96a6aba scripts: west_commands: Add module filter argument to patch command
Allow to run the west patch extension for specific modules only.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-01-07 14:12:57 +01:00
Benjamin Cabé
bc42004d1b scripts: ci: check_compliance: do not use git mailmap
When looking at git author in a commit range using git log, explicitly
indicate we don't want to use the mailmap file (default git client
behavior is to use it), so that the "actual" author info from the commit
is used to perform the compliance check, and not whatever identity the
author may have mapped to in the mailmap file (ex. their "main" email
address might be different from the one they used to commit).

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-01-07 11:53:20 +01:00
David Leach
90dfeaf61c scripts: west_commands: runners: Fix broken jlink runner
The cleanup pass (336c7da) to address long lines accidentally
removed a needed comma in the jlink runner.

Fixes #83605

Signed-off-by: David Leach <david.leach@nxp.com>
2025-01-07 00:27:28 +01:00
James Roy
802eac71f0 style: edtlib: Use a better line continuation operator
Replace backslashes('\') with PEP-8 recommended
parentheses('( )') as the line continuation operator.

Signed-off-by: James Roy <rruuaanng@outlook.com>
2025-01-04 14:15:37 +01:00
Gerhard Jörges
e4b2fe4b78 scripts: west_commands: fix type of path options
Using `west patch` with the `--patch-base`, `--patch-yaml` or
`--west-workspace` option results in an unhandled AttributeError in
filter_args() because the function expects these args to be of type
path. Adding the type to the argument definition forces argparse to
create variables of type path.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2025-01-03 17:10:58 +00:00
Carles Cufi
3c420a4828 checkpatch: Adapt the braces check to Zephyr
scripts/checkpatch.pl was written originally for the Linux kernel, and
its code reflects the kernel's coding style. In particular, it has
checks for unneeded braces around single-statement if/else/for/while
conditions. In Zephyr however, braces are always required, and so the
checks needed modifying to verify the opposite condition.

In order to enable the now-compatible checks, we also remove the
--ignore BRACES statement in .checkpatch.conf.

Limitations: the current code works well if there are not conditional
statements (e.g. #if, #ifdef or #endif) next to the if/else/for/while
conditions. This is rarely the case, but triggers with the Bluetooth
controller in code like this:

```
 #if defined(CONFIG_BT_PERIPHERAL)
        if (!lll->is_hdcd)
 #endif /* CONFIG_BT_PERIPHERAL */
        {
```

```
        } else
 #endif /* CONFIG_BT_CTLR_PRIVACY */
        {

```

```
 #if defined(CONFIG_BT_CTLR_DF_ADV_CTE_TX)
        if (lll->cte_started) {
                radio_switch_complete(phy_s, 0, phy_s, 0);
        } else
 #endif /* CONFIG_BT_CTLR_DF_ADV_CTE_TX */
        {
```

```
 #ifdef DUAL_BANK
        while ((FLASH_STM32_REGS(dev)->SR1 & FLASH_SR_QW) ||
               (FLASH_STM32_REGS(dev)->SR2 & FLASH_SR_QW))
 #else
        while (FLASH_STM32_REGS(dev)->SR1 & FLASH_SR_QW)
 #endif
        {
```

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2024-12-30 21:46:47 +01:00
Guennadi Liakhovetski
6d0c23be31 soc: intel_adsp: add support for .cold* sections
Add support for .cold and .coldrodata sections, used to implement
a cold module. Assigning code and read-only data to those sections
makes them suitable for use in a cold module, stored and executed in
slow memory.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2024-12-29 05:50:25 +01:00
Jamie McCrae
0711f42e3a sysbuild: Add support for snippets
Adds support for sysbuild loading snippets, these can be included
by using e.g.: cmake ... -DSB_SNIPPET=blah for sysbuild
directly or can be used with an application and sysbuild using
-DSNIPPET. Snippets for sysbuild can use SB_EXTRA_CONF_FILE in the
snippet file to specify an extra Kconfig fragment for sysbuild

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-12-27 07:18:13 +01:00
Chris Friedt
64442ae5cd scripts: west-commands: add an entry for the patch command
Add an entry to west-commands.yml for the west patch command.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-12-24 11:15:38 +01:00
Chris Friedt
ad611395ee scripts: west_commands: add the west patch command
In smaller projects and organizations, forking Zephyr is usually
a tenable solution for development continuity, in the case that
bug-fixes or enhancements need to be applied to Zephyr to
unblock development.

In larger organizations, perhaps in the absence of healthy patch
management, technical debt management, and open-source policies,
forking and in-tree changes can quickly get out of hand.

In other organizations, it may simply be preferable to have a
zero-forking / upstream-first policy.

Regardless of the reason, this change adds a `west patch`
command that enables users to manage patches locally in their
modules, under version control, with complete transparence.

The format of the YAML file (detailed in a previous comit)
includes fields for filename, checksum, author, email, dates,
along with pr and issue links. There are fields indicating
whether the patch is upstreamble or whether it has been merged
upstream already. There is a custom field that is not validated
and can be used for any purpose.

Workflows can be created to notify maintainers when a merged
patch may be discarded after a version or a commit bump.

In Zephyr modules, the file resides conventionally under
`zephyr/patches.yml`, and patch files reside under
`zephyr/patches/`.

Sample usage applying patches (the `-v` argument for additional
detail):
```shell
west -v patch apply
reading patch file zephyr/run-tests-with-rtt-console.patch
checking patch integrity... OK
patching zephyr... OK
reading patch file zephyr/twister-rtt-support.patch
checking patch integrity... OK
patching zephyr... OK
reading patch file zephyr/multiple_icntl.patch
checking patch integrity... OK
patching zephyr... OK
reading patch file zephyr/move-bss-to-end.patch
checking patch integrity... OK
patching zephyr... OK
4 patches applied successfully \o/
```

Cleaning previously applied patches
```shell
west patch clean
```

After manually corrupting a patch file (the `-r` option will
automatically roll-back all changes if one patch fails)
```shell
west -v patch apply -r
reading patch file zephyr/run-tests-with-rtt-console.patch
checking patch integrity... OK
patching zephyr... OK
reading patch file zephyr/twister-rtt-support.patch
checking patch integrity... OK
patching zephyr... OK
reading patch file zephyr/multiple_icntl.patch
checking patch integrity... OK
patching zephyr... OK
reading patch file zephyr/move-bss-to-end.patch
checking patch integrity... FAIL
ERROR: sha256 mismatch for zephyr/move-bss-to-end.patch:
expect: 00e42e5d89f68f8b07e355821cfcf492faa2f96b506bbe87a9b35a823fd719cb
actual: b9900e0c9472a0aaae975370b478bb26945c068497fa63ff409b21d677e5b89f
Cleaning zephyr
FATAL ERROR: failed to apply patch zephyr/move-bss-to-end.patch
```

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-12-24 11:15:38 +01:00
Chris Friedt
39588e7ca2 scripts: schemas: add schema for patches.yml files
Add a pykwalify schema for patches.yml files, which are used by
the west patch command.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-12-24 11:15:38 +01:00
Ryan Grachek
47b4e4c2fb UF2: Enable support for Raspberry Pi RP2350
Add UF2 Family ID for Raspberry Pi 2350 and build
UF2 image by default for Pico 2 board

Signed-off-by: Ryan Grachek <grachek@gmail.com>
Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
2024-12-23 23:57:57 +01:00
Øyvind Rønningstad
617df3b5c1 scripts: Remove zcbor requirement from requirements-extras.txt
lwm2m_README: Add instructions to install zcbor when needed

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2024-12-23 17:09:43 +01:00
Peter Johanson
27615a7cf1 west: runners: bossac: Honor --erase flag
Instead of unconditionally erasing the whole target, add
support for using the common --erase flag.

Signed-off-by: Peter Johanson <peter@peterjohanson.com>
2024-12-22 18:20:30 +00:00
Hake Huang
15edce26e4 twister: add dt_node_prop_enabled support
using "dt_node_prop_enabled" to filter out supported platforms
1. check node existing.
2. check prop in node.
3. check the prop is True.

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2024-12-20 18:30:43 +01:00
Benjamin Cabé
eacd5527aa Revert "cmake: remove enforcement of DWARF v4"
This reverts commit 9d849d92bf that seems to
be causing dozens of basic kernel test failures across various platforms.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-12-20 16:05:23 +01:00
Benedikt Schmidt
9d849d92bf cmake: remove enforcement of DWARF v4
Remove the enforcement of DWARF v4 as pyelftools is able
to parse DWARF v5.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2024-12-20 12:36:46 +01:00
Benedikt Schmidt
895db44388 scripts: logging: dictionary: fix parsing of DWARF v5
Fix parsing of DWARF v5 in database_gen.py.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2024-12-20 12:36:46 +01:00
Pieter De Gendt
b65a97ef0c modules: nanopb: Move pip dependencies to optional module
The west packages extension can be used to install module dependencies.

Upstream nanopb has added the pip package dependencies to the
zephyr/module.yml file. Remove in-tree pip package dependencies.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-12-19 15:20:11 +01:00
Josuah Demangeon
5847e04be8 west: runner: add support for ecpprog
The ecpprog command is an utility written by Greg Davill for flashing
FPGAs such as ECP5 or CrossLink-NX series. Devkits typically have an
FTDI interface chip to access the external flash. FPGA image is
typically at flash offset 0x00000000 flash offset, and the Zephyr
image offset can be set via CONFIG_FLASH_LOAD_OFFSET.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2024-12-19 08:38:55 +01:00
James Roy
4553a21fe5 devicetree: Add DT_FOREACH_ANCESTOR macro
Add 'DT_FOREACH_ANCESTOR' macro to get a list of
ancestor node of a given node_id.

Signed-off-by: James Roy <rruuaanng@outlook.com>
2024-12-18 10:17:09 +01:00
James Roy
ab959d5a3b scripts: dts: Use better string concatenation
Replace string concatenation operator with f-string.

Signed-off-by: James Roy <rruuaanng@outlook.com>
2024-12-18 08:33:13 +01:00
Mathieu Choplain
4dc8acc6d1 scripts: west: runners: stm32cubeprogrammer: add start address argument
Add new '--start-address' argument to the STM32CubeProgrammer west runner.
This argument can be used to specify an address from which the MCU should
start executing, instead of relying on the default value in CubeProgrammer.

Also update STM32CubeProgrammer runner tests to support new argument.

Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
2024-12-17 23:15:13 +01:00
Dmitrii Golovanov
26e0aa268f twister: handlers: Pass harness reason to instance
Pass a test failure reason text from harness to the instance
to convey more details on the failure.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-12-17 11:37:40 +00:00
Dmitrii Golovanov
ea3f105f82 twister: binaryhandler: Fix None status on test fail
Set missing TestCase statuses when a test under the BinaryHandler failed
(crashed), so remaining 'STARTED' and 'NONE' are now 'BLOCK' instead.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-12-17 11:37:40 +00:00
Guennadi Liakhovetski
733241d737 west: rimage: generate TOML with all LLEXTs included
"west sign" uses the C preprocessor to generate a TOML configuration
file, needed for rimage. When creating LLEXTs rimage also uses a
configuration file where all supporting components are configured as
LLEXT. This adds such a file generation.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2024-12-17 11:35:32 +00:00
Declan Snyder
cc620a312c kconfig: Add dt_compat_any_not_has_prop function
Add preprocessor function that returns 'y' if any enabled node with
compat does NOT have a certain property. This is different from using
dt_compat_any_has_prop to check that they ALL don't have the property.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2024-12-16 13:09:14 +01:00
Benjamin Cabé
9d4c027993 twister: reports: use Path instead of PosixPath
Directly instantiating a PosixPath is not allowed on Windows, use
Path instead.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-12-16 13:08:22 +01:00
Dmitrii Golovanov
2c5195c814 twister: reports: Pretty print XML reports
Pretty print XML reports with tab identation on levels for better
readability and ease text diff there as well.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-12-16 08:35:34 +01:00
Dmitrii Golovanov
c5c4165f68 twister: reports: Long testcase.classname XML properties
The testcase.classname properties in `twister_report.xml` and
`twister_suite_report.xml` now contain the full testsuite name
(without its path prefix) instead of just two its dot-separated
leftmost components. This way `twister_report.xml` testsuite container
has no duplicate testcase elements with the same `classname` and `name`
properties executing with --no-detailed-test-id for a project with same
testcase names in its 'sibling' suites, for example`tests/kernel/sleep`.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-12-16 08:35:34 +01:00
Dmitrii Golovanov
b69a8d1deb twister: ztest: short test case names on --no-detailed-test-id
Extend `--no-detailed-test-id` command line option: in addition to its
current behavior to exclude from a test Suite name its configuration path
prefix, also don't prefix each Ztest Case name with its Scenario name.

For example: 'kernel.common.timing' Scenario name, the same Suite name,
and 'sleep.usleep' test Case (where 'sleep' is its Ztest suite name
and 'usleep' is Ztest test name.

This way both TestSuite and TestCase names follow the same principle
having no parent object name prefix.

There is no information loss in Twister reports with this naming:
TestSuite is a container object for its TestCases, whereas TestSuite
has its configuration path as a property.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-12-16 08:35:34 +01:00