Commit graph zephyr/scripts/kconfig
Author SHA1 Message Date
Johan Hedberg
81eb5db08f Bluetooth: Host: Remove deprecated CONFIG_BT_FIXED_PASSKEY
CONFIG_BT_FIXED_PASSKEY, bt_passkey_set() and BT_PASSKEY_INVALID were
deprecated in commit 82cfb5a056 ("Bluetooth: Host: Deprecate
BT_FIXED_PASSKEY"), released in Zephyr 4.3, in favour of the app_passkey
callback gated on CONFIG_BT_APP_PASSKEY. Two releases have passed, so
remove them.

The replacement covers what the option did: an application that returns a
constant from bt_conn_auth_cb.app_passkey gets a fixed passkey, and one
that returns BT_PASSKEY_RAND gets a Host generated one, which is what
BT_PASSKEY_INVALID was used to fall back to.

DISPLAY_FIXED() could only ever be true with a fixed passkey configured,
so the four conditions using it reduce to the JUST_WORKS test they were
already OR'd with. Likewise the two branches in get_io_capa() that
upgraded the reported capability when a fixed passkey was set collapse to
the values they already returned otherwise; the CONFIG_BT_APP_PASSKEY
block above them covers that case for the replacement API. Behaviour is
therefore unchanged for anyone not enabling the removed option.

Drop the accompanying build warning and the hardened.csv entry, both of
which existed only to steer users away from the option.

Fixes: #36005

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Assisted-by: Claude:claude-opus-5
2026-08-26 15:48:41 +01:00
Pieter De Gendt
97c8c661aa scripts: kconfig: test the length-check exemptions
Cover the quoted-string exemption (single and double quotes) and that
comments and 'help' body text stay subject to the limit, with a macro
in help text still exempt. Keep the '$(...)' case on an unquoted line
so it exercises the macro branch independently of the quote branch.

Assisted-by: Claude Code:claude-opus-4.8
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-08-24 18:44:47 +02:00
Pieter De Gendt
ad12f820a8 scripts: kconfig: exempt unsplittable lines from the length check
A long quoted value (e.g. a path) or '$(...)' macro cannot be brought
under the 100-column limit: kconfiglib joins backslash continuations by
raw concatenation, so splitting the value injects the continuation's
leading whitespace into it. Exempt lines containing a quoted string
(single or double) too, not just macros. Comments and 'help' text are
re-wrappable prose and stay subject to the limit (a macro cited in help
text stays exempt, as it still cannot be split).

Assisted-by: Claude Code:claude-opus-4.8
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-08-24 18:44:47 +02:00
Etienne Carriere
8bf05cca7b scripts: kconfig: Warn when dt_*_has_prop() is used on a boolean prop
dt_*_has_prop() functions from kconfigfunctions.py always the same
value ("y", aside dt_compat_any_not_has_prop() that always return "n")
when used with a boolean property defined the node DT bindings
since such property is always found whatever it is set to True or False.

Using such functions on boolean properties is not accurate and could
corrupt the target configuration.

When testing a DT boolean property, one should:
- use dt_node_bool_prop() instead of  dt_node_has_prop(),
- use dt_nodelabel_bool_prop() instead of dt_nodelabel_has_prop(),
- use dt_compat_all_has_prop() with valid value parameter,
- use dt_compat_any_has_prop() with valid value parameter,
- not use dt_compat_any_not_has_prop().

This change makes configuration build stage to emit a warning message
upon such a wrong usage of these helper functions.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-08-24 18:43:41 +02:00
Pieter De Gendt
5911d9006b scripts: style: Add test cases for CMake/Kconfig style checkers
Add pytest unit tests for the CMake and Kconfig style checkers: one
flagged and one clean snippet per rule, asserting the exact set of rules
raised. Snippets are passed as strings, so no fixture files are committed
(which the compliance checks would otherwise scan). Both suites run in
the Scripts tests workflow.

Assisted-by: Claude Code:claude-opus-4.8
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-08-07 07:02:48 -04:00
Pieter De Gendt
eb4ef86614 scripts: kconfig: make blank-line rules continuation-aware
The if-blank and decl-blank checks assumed single-line statements, so a
backslash-continued 'if' condition produced false positives: the blank
required after 'if' was checked at the keyword line (a continuation
line), and the block-opener exemption for declarations tested that
continuation line instead of the opener keyword.

Follow continuations to the statement's start and end in both checks.
Also require the continuation backslash to be the final character, since
a backslash before trailing whitespace escapes it rather than continuing
the line.

Assisted-by: Claude Code:claude-opus-4.8
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-08-07 07:02:48 -04:00
Juergen Werner
2dfdec7f37 scripts: import sys was removed from guiconfig.py but is still in use
This is a recent regression from commit e95e5b8.

Signed-off-by: Juergen Werner <j.werner@aduart.de>
2026-07-27 14:42:58 +02:00
Graham Roff
18fc4eca4e scripts/kconfig: kconfiglib: support running on Windows
Currently the testsuite does not execute succesfully on Windows due to
various issues including path separator mismatch, shell command
incompatibility, and lack of proper symlink support. Fix these issues to
allow running the testsuite on Windows. Note that the compatibility
and symlink tests are skipped due to basic incompatibility.

Signed-off-by: Graham Roff <grahamr@qti.qualcomm.com>
(cherry picked from kconfiglib commit b8535af53f0650a69e52db4bf8585c09d55852e7)
2026-07-14 09:52:40 -04:00
Graham Roff
19c29291c5 scripts/kconfig: support conditional deps using "depends on A if B"
Extend the "depends on" syntax to support conditional dependencies
using "depends on A if B". While functionally equivalent to "depends
on !B || A", "depends on A if B" is much more readable.

This change is implemented by converting the "A if B" syntax into the
"!B || A" syntax during "depends on" token processing.

Signed-off-by: Graham Roff <grahamr@qti.qualcomm.com>
(cherry picked from kconfiglib commit d13e125024ec1c8e573aacd463765d028515503e)
2026-07-14 09:52:40 -04:00
Benjamin Cabé
e95e5b8349 scripts/kconfig: drop support for Python 2.x as it is very much EOL
A follow-up to b96a5ad562deffa697d966c29546650aae645f48 where we stopped
having CI run tests on Python 2.x. This actually drops the few remaining
Python 2.x compatibility bits as Python 2.x has EOL'd a long time ago.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
(cherry picked from kconfiglib commit 24aef157aead07f813f874f43ee471b057e622cb)
Signed-off-by: Graham Roff <grahamr@qti.qualcomm.com>
2026-07-14 09:52:40 -04:00
Tomasz Chyrowicz
3c9a08aadf kconfig: Allow to get partition MTD path
The partition MTD path is required to correctly check if two partitions
overlap with each other.

Signed-off-by: Tomasz Chyrowicz <tomasz.chyrowicz@nordicsemi.no>
2026-07-10 08:51:55 -05:00
Pieter De Gendt
a9992bfb8b scripts: kconfig: Don't require a blank line between comment and if
A comment directly above a top-level 'if' documents the conditional
block, so anchor the required blank line before the comment rather than
between the comment and the 'if'.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Assisted-by: Claude Code:claude-opus-4.8
2026-06-29 14:05:29 -05:00
Pieter De Gendt
a3b078938c scripts: kconfig: Add style checker helper script
Add scripts/kconfig/kconfig_style.py, a dependency-free checker for the
Kconfig formatting rules from the style guidelines (line length,
indentation, blank lines, comment spacing and final newline).

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Assisted-by: Claude Code:claude-opus-4.8
2026-06-25 15:25:02 +02:00
Anas Nashif
e836695cc8 scripts: fix various typos
Fix various typos under scripts/

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-23 09:12:58 -04:00
Mathieu Choplain
aea7120dab scripts: kconfig: add function to obtain highest IRQn on a controller
Add a custom Kconfig preprocessor option to obtain the highest IRQn on a
controller. This can be useful to compute CONFIG_NUM_IRQS automatically at
build time.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-03-20 12:34:28 -05:00
Thomas Stranger
81c2b3ed0f scripts: kconfig: hardend: remove TEST_SHELL from file
The TEST_SHELL config was removed in commit be0dff6844
("test: remove TEST_SHELL") a while ago.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2026-02-25 13:20:19 +01:00
Thomas Stranger
6044651979 scripts: kconfig: hardened: rename ATMEL_SAME70
The config options have been renamed in commit 8dc3f85622
("hwmv2: Introduce Hardware model version 2 and convert devices"),
therefore update them in the hardend file.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2026-02-25 13:20:19 +01:00
Yves Wang
181e421611 scripts: traceconfig: Improve file path display
For Windows, if the build dir is under same drive with zephyr base, the
generated link shall be relative url like posix style.
If they are in different drive, url is meaningless. So just use raw link
format so that some editors can directly jump to.

Signed-off-by: Yves Wang <zhengjia.wang@nxp.com>
2026-01-29 16:08:38 -06:00
Yves Wang
745e0b28bd scripts: guiconfig: Add dark mode
TK under Windows/Linux did not have a native support for dark mode.

Signed-off-by: Yves Wang <zhengjia.wang@nxp.com>
2026-01-29 17:17:31 +01:00
Fin Maaß
0247086963 Kconfig: dt: add dt_node_array_prop_has_val
add dt_node_array_prop_has_val function and
extend dt_nodelabel_array_prop_has_val to be
used with string-arrays.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-01-29 13:38:01 +01:00
Jamie McCrae
27a91104c6 scripts: kconfig: Fix dt_chosen_partition_addr function
Fixes this function so that it returns the unit address of the
node, without having to rely on odd tricks to locate various parent
nodes and check that they have reg addresses and perform additions

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-01-28 10:18:57 +01:00
Fin Maaß
c42538600f scripts: Refactor dt_compat_any_has_prop
Refactor dt_compat_any_has_prop
to reduce its Cognitive Complexity.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-01-26 14:15:18 +01:00
Fin Maaß
3bffe47e3d scripts: Add dt_compat_all_has_prop
Add the dt_compat_all_has_prop
kconfig preprocessor function, simillar to
dt_compat_any_has_prop.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-01-26 14:15:18 +01:00
Fin Maaß
8f23fdc743 scripts: Add list array support for dt_compat_any_has_prop
Add support for arrays and string-arrays to
dt_compat_any_has_prop
kconfig preprocessor function.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-01-26 14:15:18 +01:00
Yasushi SHOJI
6d6508ae12 scripts: kconfig: gnuconfig: Ignore loc
The commit 125d0daaa1 added 'loc' to the sym.ranges tuples and fixed
kconfiglib.py but guiconfig.py is left untouched. This make menuconfig to
die with:

  Exception in Tkinter callback
  Traceback (most recent call last):
    File "/usr/lib/python3.13/tkinter/__init__.py", line 2077, in __call__
      return self.func(*args)
             ~~~~~~~~~^^^^^^^
    File ".../scripts/kconfig/guiconfig.py", line 917, in _tree_double_click
      return _tree_enter(event)
    File ".../scripts/kconfig/guiconfig.py", line 942, in _tree_enter
      _change_node(node, tree.winfo_toplevel())
      ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File ".../scripts/kconfig/guiconfig.py", line 1125, in _change_node
      s = _set_val_dialog(node, parent)
    File ".../scripts/kconfig/guiconfig.py", line 1219, in _set_val_dialog
      range_info = _range_info(sym)
    File ".../scripts/kconfig/guiconfig.py", line 1339, in _range_info
      for low, high, cond in sym.ranges:
          ^^^^^^^^^^^^^^^
  ValueError: too many values to unpack (expected 3)

This commit ignores the last element in the tuples.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2025-11-11 12:46:17 -05:00
Yasushi SHOJI
090d294ae0 scripts: kconfig: menuconfig: Ignore loc
The commit 125d0daaa1 added 'loc' to the sym.ranges tuples and fixed
kconfiglib.py but menuconfig.py is left untouched. This make menuconfig to
die with:

  Traceback (most recent call last):
    File ".../scripts/kconfig/menuconfig.py", line 3284, in <module>
      _main()
      ~~~~~^^
    File ".../scripts/kconfig/menuconfig.py", line 663, in _main
      menuconfig(standard_kconfig(__doc__))
      ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File ".../scripts/kconfig/menuconfig.py", line 732, in menuconfig
      print(curses.wrapper(_menuconfig))
            ~~~~~~~~~~~~~~^^^^^^^^^^^^^
    File "/usr/lib/python3.13/curses/__init__.py", line 94, in wrapper
      return func(stdscr, *args, **kwds)
    File ".../scripts/kconfig/menuconfig.py", line 872, in _menuconfig
      _change_node(sel_node)
      ~~~~~~~~~~~~^^^^^^^^^^
    File ".../scripts/kconfig/menuconfig.py", line 1586, in _change_node
      s, _range_info(sc))
         ~~~~~~~~~~~^^^^
    File ".../scripts/kconfig/menuconfig.py", line 3119, in _range_info
      for low, high, cond in sym.ranges:
          ^^^^^^^^^^^^^^^
  ValueError: too many values to unpack (expected 3)

This commit ignores the last element in the tuples.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2025-11-11 12:46:17 -05: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
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
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
Cherniaev Andrei
fceca3b268 doc: Kconfiglib development has moved
Details https://github.com/ulfalizer/Kconfiglib/issues/139

Signed-off-by: Cherniaev Andrei <dungeonlords789@naver.com>
2025-09-18 13:49:22 -04:00
Benjamin Cabé
198147a49b scripts: kconfig: use tabulate for printing hardenconfig results
Make use of `tabulate` to pretty print the results of the hardening tool
instead of custom formatting.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-09-04 21:03:57 +02:00
Benjamin Cabé
5e032d7f84 scripts: kconfig: apply ruff fixes to hardenconfig.py
Wrap long lines so that there is no need to exclude this file from ruff
anymore.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-09-04 21:03:57 +02:00
Guðni Már Gilbert
b7efede67e scripts: kconfig: optimize write_kconfig_filenames
Filter duplicate entries in `kconf.kconfig_filenames` before calling
`os.path.realpath`.

Before (current code), all entries in `kconf.kconfig_filenames` go
through `os.path.realpath`. Including all duplicate entries.

With the proposed change, the duplicate entries are removed before
calling `os.path.realpath`.

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2025-08-13 18:31:41 +02:00
Declan Snyder
72f451ee9b scripts: kconfiglib: Fix file leaks
Fixing a couple cases of a programming error where a file is not closed
in case of an exception, which was causing resource leak warnings in
some cases when encountering a kconfig error.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-07-19 13:25:56 -04:00
Flavio Ceolin
1de500e89f kconfig: hardenconfig: Add support for insecure option
Treat insecure options in Kconfig options.

Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
2025-07-10 16:00:26 -05:00
Flavio Ceolin
674fd094aa build: kconfig: Add support for warning insecure features
Add a new promptless Kconfig symbol (INSECURE). This symbols must
be selected by any setting which is used to enable an insecure
feature.

Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
2025-07-10 16:00:26 -05:00
Henrik Brix Andersen
08175f816a scripts: kconfig: functions: add dt_compat_enabled_num function
Add dt_compat_enabled_num Kconfig helper function for counting the number
of compatible nodes with status okay.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2025-06-27 10:07:01 -05:00
Anas Nashif
bd8597c9d7 x86: rename DEBUG_INFO to X86_DEBUG_INFO
This is an X86 specific option and should not appear as generic debug
option.

Fixes zephyrproject-rtos/zephyr#52929

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-06-20 14:43:42 -05:00
Grzegorz Swiderski
64bb8b6796 scripts: kconfig: Add hex variants of arithmetic functions
Functions like `add` and `sub` can only return base 10 integers, which
means they can't really be used to define Kconfig symbols of type `hex`.

For the same reason, there already exist pairs of devicetree functions
named e.g., `dt_node_reg_addr_(int|hex)` after different return types.

Introduce `add_hex`, `sub_hex`, and friends.

To avoid confusion, it should be possible for those new functions to
accept arguments in base 16 as well. It's actually easier to let all
arithmetic functions take their inputs in "any" base, by leveraging
Python's built-in: `int(..., base=0)`.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2025-06-17 16:09:41 +02:00
Jamie McCrae
a9d0a36332 scripts: kconfig: Add dt_nodelabel_int_prop function
Adds a function which can be used to get the integer value of a
devicetree property in Kconfig from a nodelabel

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-05-23 14:04:32 +02: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
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
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
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