Commit graph

786 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
Pieter De Gendt
4d1d8a77a7 scripts: west_commands: runners: openocd: Fix debugging with TUI
Prevent server output when running gdb with --tui to prevent garbled
console output.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-12-12 19:59:35 +01:00
Andy Ross
82c5f548d9 scripts/west/sign: Auto-detect rimage ELF files
This code had a growing "enumerate all the platforms" wart.  In point
of fact only intel_adsp is special here.  Other rimage platforms don't
have a bootloader and use zephyr.elf directly.

Don't hard code platform names (especially since they aren't the same
as board/soc names!).  Just autodetect which scheme we have at
runtime.

Signed-off-by: Andy Ross <andyross@google.com>
2024-12-05 22:08:55 +01:00
Pieter De Gendt
9e4f8616e1 scripts: west_commands: runners: teensy: Replace printf with f-string
Fix linter warning UP037 for teensy runner.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-12-03 23:30:00 +00:00
Tomasz Chyrowicz
866e690dda scripts: nrf_common: Move MPI to sysbuild Kconfig
Use sysbuild to build and configure SUIT Manifest Provisioning
Information.

Signed-off-by: Tomasz Chyrowicz <tomasz.chyrowicz@nordicsemi.no>
2024-12-02 22:05:27 +00:00
de19a13c34 runners: add minichlink
This commit adds a runner wrapper for the 'minichlink' program which
offers a free, open mechanism to use the CH-LinkE programming dongle for
the CH32V003.

https://github.com/cnlohr/ch32v003fun/tree/master/minichlink

Signed-off-by: Michael Hope <michaelh@juju.nz>
Signed-off-by: Dhiru Kholia <dhiru.kholia@gmail.com>
2024-11-26 14:41:46 +00:00
Pieter De Gendt
43b112a309 scripts: west_commands: runners: Fix jlink unbound cmd
Commit e2a32d8b0ca596afeae48739c43817f693720a88 introduced an unbound
cmd issue for jlink flashing.

Fixed by moving cmd assignment outside of condition.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-26 08:45:06 +01:00
Jean-Christophe Pince
dd5874b924 jlink: custom flashing support
Allows to use a custom flashing script with jlink runners.

Signed-off-by: Jean-Christophe Pince <jean.christophe.pince@qorvo.com>
2024-11-25 21:53:43 +01:00
Pieter De Gendt
2ad915284b scripts: west_commands: Add packages command
Add a new west command as helper for package management of Zephyr
and modules.

The first package manager to get supported is pip, where west projects
can list individual packages or requirements files in their module file.

A convenience --install argument is added to install the packages instead.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-25 12:16:43 +01:00
Pieter De Gendt
bf2db7afc0 python: Format and sort imports
ruff check --select I001 --fix applied to all python files that had
this as only issue.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-25 10:07:13 +01:00
Pieter De Gendt
86a8dacaa1 scripts: west_commands: Fix MissingProgram import
MissingProgram should be exported in __all__.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-23 15:28:33 +01:00
Pieter De Gendt
336c7dadac scripts: west_commands: runners: Fix line-too-long (E501)
Wrap long lines to max 100 characters.

See https://docs.astral.sh/ruff/rules/line-too-long/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
775db0e63a scripts: west_commands: runners: Fix f-string (UP032)
Replace .format() calls with f-strings.

See https://docs.astral.sh/ruff/rules/f-string/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
bf7f41d880 scripts: west_commands: runners: Sort and format imports (I001)
Apply sorting and formatting rules on imports.

See
https://docs.astral.sh/ruff/rules/unsorted-imports/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
93457b42f9 scripts: west_commands: runners: Fix unused/deprecated imports (F401/UP035)
Remove some imports that are no longer needed.

See
https://docs.astral.sh/ruff/rules/unused-import/
https://docs.astral.sh/ruff/rules/deprecated-import/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
acb2eaacbd scripts: west_commands: runners: Fix non-pep604-annotation (UP007)
Replace Optional types with the | operator.

https://docs.astral.sh/ruff/rules/non-pep604-annotation/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
907a0db599 scripts: west_commands: runners: Fix non-pep585-annotation (UP006)
Use standard library variants for list, dict, tuple, set

See https://docs.astral.sh/ruff/rules/non-pep585-annotation/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
523015b6ef scripts: west_commands: runners: raise-without-from-inside-except (B904)
Pass exceptions up the chain.

See https://docs.astral.sh/ruff/rules/raise-without-from-inside-except/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
f7902bc817 scripts: west_commands: runners: Fix bare except (E722 & B904)
Catch explicit exceptions and pass them them to the ValueError

See
https://docs.astral.sh/ruff/rules/bare-except/
https://docs.astral.sh/ruff/rules/raise-without-from-inside-except/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
1e1c7f7c16 scripts: west_commands: runners: Fix mutable-argument-default (B006)
Do not use mutable default arguments.

See https://docs.astral.sh/ruff/rules/mutable-argument-default/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
8055145ad3 scripts: west_commands: runners: Fix super-call-with-parameters (UP008)
Simplify super() calls.

See https://docs.astral.sh/ruff/rules/super-call-with-parameters/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
07342d9b81 scripts: west_commands: runners: Fix if-with-same-arms (SIM114)
Simplify if statements with same arms.

See https://docs.astral.sh/ruff/rules/if-with-same-arms/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
cd02de5df9 scripts: west_commands: runners: Fix reimplemented-builtin (SIM110)
Convert for loop to use any().

See https://docs.astral.sh/ruff/rules/reimplemented-builtin/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
0f54805faa scripts: west_commands: runners: Fix suppressible-exception (SIM105)
Use contextlib to suppress an error.

See https://docs.astral.sh/ruff/rules/suppressible-exception/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
df794b5493 scripts: west_commands: runners: Conditional import
Convert except: pass statement so the conditional import results in a
NoneType.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
7f72dd3a0f scripts: west_commands: runners: Fix f-string-missing-placeholders (F541)
Constant strings should not be f-strings.

See https://docs.astral.sh/ruff/rules/f-string-missing-placeholders/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
c0d08e5212 scripts: west_commands: runners: Fix not-is-test (E714)
Make the "not is" more readable.

See https://docs.astral.sh/ruff/rules/not-is-test/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
02fac6e1c0 scripts: west_commands: runners: Fix multiple statements on one line (E701)
Place if and conditional statements on separate lines.

https://docs.astral.sh/ruff/rules/multiple-statements-on-one-line-colon/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
3a55e8a52f scripts: west_commands: runners: Fix set-attr-with-constant (B010)
Do not use setattr for constants.

See https://docs.astral.sh/ruff/rules/set-attr-with-constant/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
e42d30ef6c scripts: west_commands: runners: Fix printf-string-formatting (UP031)
Replace printf-style string format.

See https://docs.astral.sh/ruff/rules/printf-string-formatting/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
d562731096 scripts: west_commands: runners: Fix redundant-open-modes (UP015)
Don't pass default open mode.

See https://docs.astral.sh/ruff/rules/redundant-open-modes/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
fc5286fe25 scripts: west_commands: runners: Fix useless-object-inheritance (UP004)
Remove object inheritance.

See https://docs.astral.sh/ruff/rules/useless-object-inheritance/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
dbaf01ef28 scripts: west_commands: runners: Ignore open file without ctx (SIM115)
Add noqa to a complex statement with multiple open/close statements.

See https://docs.astral.sh/ruff/rules/open-file-with-context-handler/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
2e39674344 scripts: west_commands: runners: Fix needless-bool (SIM103)
Return the result instead of the if statements.

See https://docs.astral.sh/ruff/rules/needless-bool/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
d397b01338 scripts: west_commands: runners: Fix collapsible-if (SIM102)
Combine multiple nested if statements.

See https://docs.astral.sh/ruff/rules/collapsible-if/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
133665e55a scripts: west_commands: runners: Fix unused-import (F401)
Removed unused import.

See https://docs.astral.sh/ruff/rules/unused-import/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
ddbba0ef4c scripts: west_commands: runners: Fix mixed-spaces-and-tabs (E101)
Use spaces for indentation.

See https://docs.astral.sh/ruff/rules/mixed-spaces-and-tabs/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
a48e37608f scripts: west_commands: runners: Ignore missing abstract decorator (B027)
The empty function is intentional.

https://docs.astral.sh/ruff/rules/empty-method-without-abstract-decorator/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
e8294b4590 scripts: west_commands: runners: Fix assert-false (B011)
Prefer AssertionError instead of assert False.

See https://docs.astral.sh/ruff/rules/assert-false/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
25be1501ab scripts: west_commands: runners: Fix pylint unbound issues
Variables are possibly unbound, initialize to None.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
aae018be87 scripts: west_commands: runners: Remove obsolete pylint ignores
These ignores were added with an older version of pylint and are
either removed or ignored by default.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
f05deb1aa4 python: Format trivial files where only newlines were missing
Apply formatting on files that only needed adding newlines.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-21 20:10:51 +01:00