Commit graph

5,887 commits

Author SHA1 Message Date
Abderrahmane JARMOUNI
3cc9a843e8 scripts: west runners: ST-LINK GDB Server: add external-init cmd
When debugging boards with external Flash, to make it accessible for
read and write by the debugger, we need the --external-init option
together with --extload <file_path> option.
It allows the ST-LINK GDB server to make external memory accessible
after reset without any need for the app to set it up.
The external memory must be memory mapped and directly accessed because
normal memory read/write is used by gdb.

Signed-off-by: Abderrahmane JARMOUNI <git@jarmouni.me>
2025-10-25 10:46:38 +03:00
Henrik Brix Andersen
58a334f2f9 scripts: pylib: twister: hardwaremap: add Tigard support
Add support for the Tigard multi-protocol hardware hacking tool from
SecuringHardware.com.

More information available at https://github.com/tigard-tools/tigard

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2025-10-24 20:17:04 -04:00
BUDKE Gerson Fernando
6334838cdb scripts: build: mergehex: Add --output-bin parameter
The optional --output-bin parameter instructs the IntelHex class to
save the content as a binary file instead of the Intel Hex format.

Signed-off-by: BUDKE Gerson Fernando <gerson.budke@leica-geosystems.com>
2025-10-24 13:27:24 -04:00
Thorsten Klein
5ee522efc0 scripts: west_commands: added tests for config build.dir-fmt
Tests are added for different build.dir-fmt format string arguments.

Signed-off-by: Thorsten Klein <thorsten.klein@bshg.com>
2025-10-24 13:26:37 -04:00
Thorsten Klein
122edfef5b scripts: west_commands: extend build.dir-fmt format args
build.dir-fmt format string arguments are extended. New format args are
'west_topdir' (absolute path to the west workspace directory) and
'source_dir_workspace' (relative path of the source directory to
west_topdir).

Signed-off-by: Thorsten Klein <thorsten.klein@bshg.com>
2025-10-24 13:26:37 -04:00
Jordan Yates
dbb45ddd18 scripts: checkpatch.pl: relax Missing a blank line
Relax the `Missing a blank line after declarations` checkpatch error by
loosening the requirements for a macro to be treated as one that
declared a variable.

Currently the regex matches the pattern `DECLARE` or `DEFINE`, as long
as there are between 1 and 6 trailing `_FOO` components to the macro
name (e.g. `DECLARE_MY_TYPE()`). Zephyr however contains many macros
that don't have the trailing components but still resolve to variables
(e.g. `ATOMIC_DEFINE`, `K_MUTEX_DEFINE, etc`).

By changing `{1,6}` to `{0,6}`, we remove the requirement for the
trailing `_FOO` component(s) while still allowing them. This stops
checkpatch from erroring on patterns like this:
```
struct driver_data {
	uint16_t some_value;
	ATOMIC_DEFINE(some_atomic, 16);
};
```

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-10-24 13:26:04 -04:00
WenBin Zhang
47855127a0 script: west: completion: add missing west completion for zsh
this path only provides autocompletion for the `west` command
itself, not for its subcommands. (i.e. `west [tab]` rather than
`west packages [tab]`). However, it remains highly userful,
significantly reducing typing time and errors when using longer
commands like `west packages`.

Signed-off-by: WenBin Zhang <freey7955@gmail.com>
2025-10-24 13:18:52 -04:00
WenBin Zhang
84a53e5ecc script: west: completion: add missing west completion for fish
this path only provides autocompletion for the `west` command
itself, not for its subcommands. (i.e. `west [tab]` rather than
`west packages [tab]`). However, it remains highly userful,
significantly reducing typing time and errors when using longer
commands like `west packages`.

Signed-off-by: WenBin Zhang <freey7955@gmail.com>
2025-10-24 13:18:52 -04:00
WenBin Zhang
fe3a02d234 script: west: completion: add missing west completion for bash
this path only provides autocompletion for the `west` command
itself, not for its subcommands. (i.e. `west [tab]` rather than
`west packages [tab]`). However, it remains highly userful,
significantly reducing typing time and errors when using longer
commands like `west packages`.

Signed-off-by: WenBin Zhang <freey7955@gmail.com>
2025-10-24 13:18:52 -04:00
Anas Nashif
6ea5f0abd7 twister: prefer 'fork' on POSIX to maintain pre-3.14 behavior
multiprocessing no longer defaults to fork, so force it to maintain pre
3.14 behavior. We will need to revisit the implementation and at some
point move to forkserver

Fixes #95058

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-24 08:59:30 -07:00
Carles Cufi
0679c05712 scripts: runners: nrfutil: Add a new --dry-run parameter
In order to allow for users to invoke "west flash" without actual
hardware connected but still running the logic and pregeneration of
commands, specifically the json file.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-10-24 08:59:13 -07:00
Carles Cufi
146fd2c88e scripts: runners: nrf: Generalize the use of --erase-mode for all ICs
Until now, for historical reasons (see
f42cef9c81 and
58e0e31c7e), the use of the --erase-mode
command-line switch was reserved for the nRF54L family. But in fact this
can be used (instead of --erase) for any of the Nordic ICs. This patch
extends the usage of this switch regardless of family.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-10-24 08:59:13 -07:00
Luca Burelli
338a8b1e48 west: bindesc: add extract subcommand
Add a new 'west bindesc extract' subcommand that dumps all binary
descriptors into a separate binary file. It will also report the range
(offset and length) of the dumped data within the original image.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-10-24 09:43:40 +03:00
Kyle Micallef Bonnici
1dc7eb995d CI: devicetree: linting to check_compliance.py
Use dts-linter to check each touched file in PR

Signed-off-by: Kyle Micallef Bonnici <kylebonnici@hotmail.com>
2025-10-23 16:04:38 -04:00
Nilesh Vyas
9ca3cad57d script: footprint: Improve C++ static variable reporting
Enhance the `size_report` script to correctly categorize static C++
variables in the memory report.

Static C++ variables are currently listed under the "No paths"
category in the size report. This occurs because the script's
address-based mapping logic is designed for functions, which
occupy an address range, but fails to handle variables that
have only a single memory address.

This commit improves the `do_address_range_matching` function
to handle single-address mappings. The updated logic now correctly
identifies and assigns static C++ variables to their corresponding
source file paths in the report tree, providing a more accurate and
comprehensive memory footprint analysis for C++ applications.

This enhancement ensures that all symbols, regardless of their
linkage or type, are correctly placed in the report, providing a
more accurate overview of memory usage.

Signed-off-by: Nilesh Vyas <nileshvyas1112@gmail.com>
2025-10-23 16:02:23 -04:00
Keith Short
028cf7f3d9 twister: fix environment:os tag
Set the environment:os tag to the return value of platform.system(),
which is more useful than os.name() which always returns "posix".

Signed-off-by: Keith Short <keithshort@google.com>
2025-10-23 15:59:41 -04:00
Andreas Kurz
0b5b6b827e native_simulator: Get latest from upstream
Align with native_simulator's upstream main
95f560a2140aacb03a74b8c933f3b27a59c56d50

Which includes:
95f560a: nct: fix possible redefinition of GNU_SOURCE

Signed-off-by: Andreas Kurz <info@akurz.net>
2025-10-23 18:08:14 +02:00
Luca Burelli
e4fa6a8f61 traceconfig: add target to export value origin traces to Markdown
The new 'traceconfig' target generates a Markdown file listing all
configuration symbols, their values, and where those values originated
(user assignment, default, selection, implication, or unset).

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-10-22 18:34:49 +03:00
Luca Burelli
bce4b9af4f kconfig: collect and save trace data
Collect and save trace data for all symbols in the merged configuration.
This includes information about where each symbol was defined or
assigned, which can be useful for debugging complex Kconfig setups.

The trace data includes the following information for each symbol:
- Name
- Visibility
- Type
- Value
- Kind and location of value origin (as defined in kconfiglib)

The trace data is saved for later use in two formats: a binary pickle
file and a human-readable JSON file.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-10-22 18:34:49 +03:00
Luca Burelli
5d2c97d3c1 kconfiglib: track origin for symbol values
Track information about what caused a value to be set in the 'origin'
property of Symbol. 'imply' and 'select' dependencies do not have a
location associated with them, so in those cases the location is
a string representation of the dependency expression. For defaults and
user values, the location in the Kconfig file is stored.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-10-22 18:34:49 +03:00
Luca Burelli
125d0daaa1 kconfiglib: add 'loc' to reverse dependencies
Store the location (filename and line number) where a 'select', 'imply',
'range' or 'default' was added to a Symbol or Choice.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-10-22 18:34:49 +03:00
Luca Burelli
45bea950a2 kconfiglib: add 'user_loc' to Symbol and Choice classes
The 'user_loc' stores the location (filename and line number) where a
symbol or choice was last set via a direct user selection.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-10-22 18:34:49 +03:00
Luca Burelli
9d842ab955 kconfiglib: refactor Kconfig._warn() to use 'loc'
Replace filename and linenr parameters to _warn() with a single loc
element, which is a constant (filename, linenr) tuple that can be more
efficiently passed and stored.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-10-22 18:34:49 +03:00
Luca Burelli
1337f839cd kconfiglib: node: add 'loc' attribute
Replace 'filename' and 'linenr' usages with a single 'loc' attribute,
which is a (filename, linenr) tuple. This simplifies code dealing with
locations, and makes it explicitly constant. The original attributes are
now provided via properties for compatibility.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-10-22 18:34:49 +03:00
Pieter De Gendt
ef7c370187 scripts: west_commands: runners: Replace ToggleAction
Replaces the custom ToggleAction with the argparse.BooleanOptionalAction.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-10-22 18:33:01 +03:00
Pieter De Gendt
e2b3d2a893 scripts: west_commands: sign: Replace ToggleAction
Replaces the custom ToggleAction with the argparse.BooleanOptionalAction.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-10-22 18:33:01 +03:00
Pieter De Gendt
5709b55875 scripts: west_commands: Convert sysbuild argument to BooleanOptionalAction
Instead of using a mutually exclusive group for sysbuild/no-sysbuild
argparse arguments, use the argparse.BooleanOptionalAction to allow passing
multiple arguments, where the last one is applied.

This is consistent with for example gcc compiler flags.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-10-22 15:55:21 +03:00
Sebastian Bøe
8e59980f01 scripts: ci: check_compliance: Add missing gen_uicr UNDEF's
Add missing gen_uicr UNDEF's.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2025-10-22 15:54:59 +03:00
Jukka Rissanen
867128011e scripts: compliance: Add ZVFS_OPEN_ADD_SIZE_ to undef whitelist
The ZVFS_OPEN_ADD_SIZE_ is used as a prefix for matching specific
Kconfig option names, i.e. it's not a real option in itself.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-21 17:22:03 +03:00
Tomas Pajurek
145637c04b Debugging: Fix GDB packet parsing for ARM Cortex M
When analyzing Zephyr coredumps from ARM Cortex M, sometimes the GDB
server fails with the error 'binascii.Error: Odd-length string'.
This happens because the GDB packet parsing logic does not correctly
handle the '=' separator in register write packets containing register
identifiers with more than one letter/digit. Fix it by properly
locating the '=' character and slicing the packet string accordingly.

Signed-off-by: Tomas Pajurek <tomas.pajurek@spotflow.io>
2025-10-21 17:21:28 +03:00
Gerard Marull-Paretas
4f484cd662 scripts: kconfig: kconfigfunctions: add dt_node_reg_addr_by_name_hex
So we can obtain a register address (as hex) given its name.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2025-10-20 14:23:43 -04:00
Paul Oberosler
1889a879a2 scripts: west_commands: fix ZEPHYR_BASE env check
detect_version() used os.environ["ZEPHYR_BASE"],
which raises a KeyError when the variable is
absent, preventing the fallback path from running.
Switch to os.environ.get("ZEPHYR_BASE") and use
Path(__file__).resolve() for the fallback so the
path is absolute/canonical.

Signed-off-by: Paul Oberosler <paul.oberosler@raspberrypi.com>
2025-10-20 11:35:06 -04:00
Pieter De Gendt
aca4027726 scripts: ci: check_compliance: Run Python linter not only on changed files
The linter is super fast, no need to limit to only changed files.

For example if the linter configuration changes, all Python files need to
be validated.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-10-20 11:27:46 -04:00
Morten Kristensen
f33dff5102 scripts: ci: use vermin 1.7.0
Update workflow to use the new version of Vermin to enrich the Python
minimum version checks in the CI pipelines.

Signed-off-by: Morten Kristensen <me@mortens.dev>
2025-10-20 11:25:55 -04:00
Declan Snyder
de6b5dba60 scripts: flash: Add west config for flash skip rebuild
Add a west config option to skip rebuilds by default or not when doing
west flash. Also add corresponding symmetrical CLI options.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-10-20 11:22:52 -04:00
Artur Wilczak
de183df157 tests: pm: Fix collecting data after fail
Fix for collecting and presenting measured data.
During verify measured values, the test skipped all results
after the first incorrect one. Furthermore, it duplicated
already collected data on the output list. So in this case the
result list include wrong data.

Signed-off-by: Artur Wilczak <arturx.wilczak@intel.com>
2025-10-16 22:38:01 -04:00
Pieter De Gendt
aad2408b30 scripts: Don't use isort known-first-party
Partially revert 1bcc0652241af70d0b28aee155f260cd9ca0fc74

This change impacts all other scripts that import those modules, while
those weren't updated.

It will be hard to maintain this list, whilst keeping the entire tree
compliant.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-10-16 17:09:14 +03:00
Sebastian Bøe
35b89abd61 soc: nordic: uicr: Add safety flag for permanent device transition
Add --permit-permanently-transitioning-device-to-deployed safety flag
to gen_uicr.py, required when enabling both UICR.LOCK and
UICR.ERASEPROTECT together. This prevents accidental permanent locking
of devices since this combination makes the configuration irreversible.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2025-10-15 17:37:02 -04:00
Sebastian Bøe
1438f8ae69 soc: nordic: uicr: Add support for UICR.APPROTECT
Add support for UICR.APPROTECT configuration, which controls debugger
and access-port permissions through the TAMPC peripheral.

This introduces three Kconfig options that allow independent control
over access port protection for different processor domains:

- GEN_UICR_APPROTECT_APPLICATION_PROTECTED: Controls debug access to
  the application domain processor
- GEN_UICR_APPROTECT_RADIOCORE_PROTECTED: Controls debug access to
  the radio core processor
- GEN_UICR_APPROTECT_CORESIGHT_PROTECTED: Controls access to the
  CoreSight debug infrastructure

When enabled, each option sets the corresponding UICR.APPROTECT
register to PROTECTED (0xFFFFFFFF), which disables debug access for
that domain. When disabled, the registers remain at their erased value
(UNPROTECTED), allowing full debug access.

This feature is critical for production devices where debug access must
be restricted to prevent unauthorized access to sensitive code and data.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2025-10-15 17:37:02 -04:00
Sebastian Bøe
e20352d80a soc: nordic: uicr: Add support for UICR.ERASEPROTECT
Add support for UICR.ERASEPROTECT configuration, which blocks ERASEALL
operations to prevent bulk erasure of protected memory.

This introduces a Kconfig option GEN_UICR_ERASEPROTECT that enables
blocking of ERASEALL operations on NVR0, preserving UICR settings even
if an attacker attempts a full-chip erase.

This is a critical security feature for production devices. When enabled
together with UICR.LOCK, it becomes impossible to modify the UICR in
any way, establishing a permanent device protection scheme. Due to this
irreversibility, it should only be enabled during the final stages of
production.

When enabled, the gen_uicr.py script sets UICR.ERASEPROTECT to
0xFFFFFFFF, which prevents the ERASEALL command from affecting the
NVR0 page.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2025-10-15 17:37:02 -04:00
Sebastian Bøe
1ffdf09c25 soc: nordic: uicr: Add support for UICR.LOCK
Add support for UICR.LOCK configuration, which locks the entire UICR
configuration in NVR0 to prevent unauthorized modifications.

This introduces a Kconfig option GEN_UICR_LOCK that enables locking
of the UICR. Once locked, the UICR can only be modified by performing
an ERASEALL operation.

This is a critical security feature for production devices, typically
enabled alongside UICR.APPROTECT, UICR.PROTECTEDMEM, and
UICR.ERASEPROTECT to establish a complete device protection scheme.

When enabled, the gen_uicr.py script sets UICR.LOCK to 0xFFFFFFFF,
which configures the NVR0 page as read-only and enforces integrity
checks on the UICR content.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2025-10-15 17:37:02 -04:00
Sebastian Bøe
c3f6b8cb34 soc: nordic: uicr: Add support for UICR.SECONDARY.PROTECTEDMEM
Add support for UICR.SECONDARY.PROTECTEDMEM configuration, which enables
configuration of the protected memory region for secondary firmware.

This introduces Kconfig options for configuring:
- GEN_UICR_SECONDARY_PROTECTEDMEM - Enable/disable protected memory
  for secondary firmware
- GEN_UICR_SECONDARY_PROTECTEDMEM_SIZE_BYTES - Size of the protected
  memory region in bytes

The implementation validates that the configured size is divisible by
4096 bytes (4 KiB) as required by the hardware, and converts it to
4 KiB units when writing to UICR.SECONDARY.PROTECTEDMEM.SIZE4KB.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2025-10-15 17:37:02 -04:00
Sebastian Bøe
9dc2b614d6 soc: nordic: uicr: Add support for UICR.SECONDARY.TRIGGER
Add support for UICR.SECONDARY.TRIGGER configuration, which enables
automatic booting of secondary firmware based on specific reset reasons.

This introduces Kconfig options for configuring:
- UICR.SECONDARY.TRIGGER.ENABLE - Enable/disable automatic triggers
- UICR.SECONDARY.TRIGGER.RESETREAS - Bitmask of reset reasons that
  trigger secondary firmware boot

Individual Kconfig options are provided for each reset reason:
- APPLICATIONWDT0/1 - Application core watchdog timeouts
- APPLICATIONLOCKUP - Application core CPU lockup
- RADIOCOREWDT0/1 - Radio core watchdog timeouts
- RADIOCORELOCKUP - Radio core CPU lockup

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2025-10-15 17:37:02 -04:00
Sebastian Bøe
af32ebd198 soc: nordic: uicr: Add support for UICR.WDTSTART
Add support for UICR.WDTSTART.

UICR.WDTSTART configures the automatic start of a local watchdog timer
before the application core is booted. This provides early system
protection ensuring that the system can recover from early boot
failures.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2025-10-15 17:37:02 -04:00
Łukasz Fundakowski
2d60533558 twister: Refactor twister tests
- Removed redundant `sys.path.insert`
- Fixed imports order to follow PEP8 style

Signed-off-by: Łukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
2025-10-15 17:36:11 -04:00
Graham Roff
d5f8b8d03d size_report: Add a report showing total memory use.
The current size_report generates "ram" and "rom" reports, but not one
showing the total of all run-time memory used (the "ram" report does not
include memory required to load the code for non-XIP boards).
Summing the existing reports does not work as it double-counts
statically initialized data.
The new "all" report shows the correct accounting of all run-time memory
used.
To support this functionality the "targets" argument has been extended
to allow multiple arguments, for example to generate all three reports:
$ size_report -k ... -z ... --output=. ram rom all

In the JSON output, the location ("ram" or "rom") is included in the
"loc" property for each symbol.

Signed-off-by: Graham Roff <grahamr@qti.qualcomm.com>
2025-10-15 15:38:22 +03:00
Lukasz Fundakowski
9c5325df29 twister: Add unit tests for Pytest harness
Added unit tests for parsing JUnitXml report by Pytest harness.

Signed-off-by: Lukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
2025-10-14 17:41:32 -04:00
Łukasz Fundakowski
8201d20b24 twister: remove not needed try..except
Removed redundant try..except around the code
and fixed a test for that code which was false positive.

Signed-off-by: Łukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
2025-10-13 18:13:11 -04:00
Mathieu Choplain
7bbecd8c37 scripts: kconfig: fix dt_nodelabel_int_prop crash if prop doesn't exist
dt_nodelabel_int_prop did not check if the property existed on the node
before accessing it, which would result in a build-time crash (and thus
build error) if used on a node which lacked the requested property.

Fix by using the common _node_int_prop() helper which handles all edge
cases properly.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-10-10 20:51:13 -04:00
Benjamin Cabé
c07d182466 scripts: ci: do_not_merge.py: labels starting with 'block:' mean DNM
When checking for "do not merge" labels on a pull request, also consider
any label that starts with "block:" as a DNM label (e.g "block: HW
Test").

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-10-10 12:53:14 -04:00