Commit graph

308 commits

Author SHA1 Message Date
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
Torsten Rasmussen
536d34fa7a cmake: scripts: support board extension
Fixes: #69548

Support extending an existing board with new board variants.

This commit introduces the following changes to allow a board to be
extended out-of-tree.

The board yaml schema is extended to support an extend field which
will be used to identify the board to be extended.

A board 'plank' can be extended like this:
> board:
>   extend: plank
>   variants:
>     - name: ext
>       qualifier: soc1

For the rest of the build system this means that there is no longer a
single board directory.
The existing CMake variable BOARD_DIR is kept and reference the
directory which defines the board.
A new CMake variable BOARD_DIRECTORIES provides a list of all
directories which defines board targets for the board.
This means the directory which defines the board as well as all
directories that extends the board.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2024-10-26 17:14:06 +02:00
Declan Snyder
4773975a6b scripts: Add dt_compat_any_has_prop value param
Add optional value parameter to dt_compat_any_has_prop
kconfig preprocessor function, which puts an additional constraint on
the truth of the function in that the property value must match the
parameter value.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2024-10-25 18:53:27 +01:00
Flavio Ceolin
e00746f9b3 scripts: hardenconfig: Improve deprecated and experimental detection
Gets experimental and deprecated symbols directly from Kconfig instead
of rely on hardened.csv.

This way we keep the tool consistent with Zephyr's code.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-08-14 09:41:00 +02:00
Pieter De Gendt
2f234c627c scripts: kconfig: Add min/max functions
Similar to arithmetic functions, min/max can be useful to use in kconfig.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-08-02 13:41:07 +02:00
TOKITA Hiroshi
f99f862a79 scripts: kconfig: Add integer arithmetic functions
Added functions for integer arithmetic operations
(add, sub, mul, div, mod, inc, dec)

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-07-31 12:56:25 +02:00
Lingao Meng
302422ad9d everywhere: replace double words
import os
import re

common_words = set([
    'about', 'after', 'all', 'also', 'an', 'and',
     'any', 'are', 'as', 'at',
    'be', 'because', 'but', 'by', 'can', 'come',
    'could', 'day', 'do', 'even',
    'first', 'for', 'get', 'give', 'go', 'has',
    'have', 'he', 'her',
    'him', 'his', 'how', 'I', 'in', 'into', 'it',
    'its', 'just',
    'know', 'like', 'look', 'make', 'man', 'many',
    'me', 'more', 'my', 'new',
    'no', 'not', 'now', 'of', 'one', 'only', 'or',
    'other', 'our', 'out',
    'over', 'people', 'say', 'see', 'she', 'so',
    'some', 'take', 'tell', 'than',
    'their', 'them', 'then', 'there', 'these',
    'they', 'think',
    'this', 'time', 'two', 'up', 'use', 'very',
    'want', 'was', 'way',
    'we', 'well', 'what', 'when', 'which', 'who',
    'will', 'with', 'would',
    'year', 'you', 'your'
])

valid_extensions = set([
    'c', 'h', 'yaml', 'cmake', 'conf', 'txt', 'overlay',
    'rst', 'dtsi',
    'Kconfig', 'dts', 'defconfig', 'yml', 'ld', 'sh', 'py',
    'soc', 'cfg'
])

def filter_repeated_words(text):
    # Split the text into lines
    lines = text.split('\n')

    # Combine lines into a single string with unique separator
    combined_text = '/*sep*/'.join(lines)

    # Replace repeated words within a line
    def replace_within_line(match):
        return match.group(1)

    # Regex for matching repeated words within a line
    within_line_pattern =
	re.compile(r'\b(' +
		'|'.join(map(re.escape, common_words)) +
		r')\b\s+\b\1\b')
    combined_text = within_line_pattern.
		sub(replace_within_line, combined_text)

    # Replace repeated words across line boundaries
    def replace_across_lines(match):
        return match.group(1) + match.group(2)

    # Regex for matching repeated words across line boundaries
    across_lines_pattern = re.
		compile(r'\b(' + '|'.join(
			map(re.escape, common_words)) +
			r')\b(\s*[*\/\n\s]*)\b\1\b')
    combined_text = across_lines_pattern.
		sub(replace_across_lines, combined_text)

    # Split the text back into lines
    filtered_text = combined_text.split('/*sep*/')

    return '\n'.join(filtered_text)

def process_file(file_path):
    with open(file_path, 'r', encoding='utf-8') as file:
        text = file.read()

    new_text = filter_repeated_words(text)

    with open(file_path, 'w', encoding='utf-8') as file:
        file.write(new_text)

def process_directory(directory_path):
    for root, dirs, files in os.walk(directory_path):
        dirs[:] = [d for d in dirs if not d.startswith('.')]
        for file in files:
            # Filter out hidden files
            if file.startswith('.'):
                continue
            file_extension = file.split('.')[-1]
            if
	file_extension in valid_extensions:  # 只处理指定后缀的文件
                file_path = os.path.join(root, file)
                print(f"Processed file: {file_path}")
                process_file(file_path)

directory_to_process = "/home/mi/works/github/zephyrproject/zephyr"
process_directory(directory_to_process)

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2024-06-25 06:05:35 -04:00
Declan Snyder
ca6adbba61 scripts: kconfig: Add dt_compat_any_has_prop
Add a kconfig preprocessor function to check if
any node of a certain compatible has a specific property in DT.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2024-06-06 20:08:27 -04:00
Ioannis Damigos
9c8fd3745c kconfigfunctions.py: Fix used-before-assignment error with pylint 3.2
CI reports error:
kconfigfunctions.py:143:11: E0601: Using variable 'edtlib' before
assignment (used-before-assignment)

Initialize edtlib to none when there is no edt.

Signed-off-by: Ioannis Damigos <ioannis.damigos.uj@renesas.com>
2024-06-05 13:49:09 -05:00
Ioannis Damigos
285969c98c scripts/kconfig: Introduce dt_node_ph_prop_path function
Introduce dt_node_ph_prop_path function.
It  takes a node 'path' and a phandle property name
and returns the path to the pointed-to node.

Signed-off-by: Ioannis Damigos <ioannis.damigos.uj@renesas.com>
2024-06-05 13:49:09 -05:00
Bjarki Arge Andreasen
79640aea09 drivers: console: remove uart_mux and gsm_mux
Remove the deprecated uart_mux and gsm_mux modules and all of
their configurations/dependencies across zephyr.

Optimally uart_mux and gsm_mux would be removed in their own
respective PRs, but the two modules are directly coupled, so
to preserve bisectability, they must be removed together.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-29 10:49:08 -07:00
Yong Cong Sin
0dac6c132b build: namespace autoconf.h with zephyr/
Namespace the generated `autoconf.h` file with `zephyr/`.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-28 22:03:55 +02:00
Théo Battrel
b2e235d530 Bluetooth: Remove legacy debug symbols
The `BT_DEBUG_*` Kconfig symbols have been deprecated for more than 2
versions, remove them.

Update code that was still using them.

Remove the Bluetooth specific `Kconfig.template.log_config_bt` and use
`Kconfig.template.log_config_inherit` from the logging subsystem
instead, now that the legacy symbols can be removed.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-05-07 09:49:27 +02:00
Jamie McCrae
a43029418c scripts: kconfig: Add substring function
Adds a substring function

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-03-21 20:10:46 +01:00
Torsten Rasmussen
732c504e4c terminology: adopt CMake, python, and Kconfig code to use qualifiers
Followup: #69905

Adopting new board terminology for CMake, python, and Kconfig code to
use qualifiers instead of identifiers.

Also adjusted to board target where applicable.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2024-03-21 15:32:17 +01:00
Lyle Zhu
40cf23daff Bluetooth: Rename BT_BREDR to BT_CLASSIC
Rename BT_BREDR to BT_CLASSIC
Rename CONFIG_BT_BREDR to CONFIG_BT_CLASSIC

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-03-07 11:26:45 +02:00