This helper allows setting default Kconfig values based on devicetree
node properties without giving the full path to the node.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This helper allows setting default Kconfig values based on devicetree
node properties without giving the full path to the node.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Use the compat2enabled and label2node maps in the global edt object to
speed up some functions.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Pass EXTRA_DTC_FLAGS to kconfig so the EDT object we have in
kconfigfunctions can use that to set warn_reg_unit_address_mismatch
properly.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This can be used from Kconfig to detect if any enabled nodes of a
compatible are on a bus. This can be useful if a compatible might
appear on multiple buses, to enable them by default from application
code without having to change prj.conf settings depending on what's in
the devicetree.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
The last user of the .conf file format DTS data has been removed. We
can now remove the generation and associated support for the .conf file.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
dt_int_val, dt_hex_val, and dt_str_val have been deprecated for two
releases and thus are meant to be removed.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add kconfigfunctions that given the property name to an integer type
property will return its value as either an string int or string hex
value.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This function takes a 'label' and returns "y" if an "enabled" node with
such label can be found in the EDT and that node is compatible with the
provided 'compat', otherwise it returns "n".
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
With the introduction of ZephyrConfig.cmake all parts of CMake code
should rely on the CMake ZEPHYR_BASE variable instead of the environment
setting.
This ensures that after the first CMake invocation, then all subsequent
invocation in same build folder will use same zephyr base.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
If the #address-cells property for a register is 0 than we set the addr
value of the reg to None. Similar, if #size-cells is 0 than we set the
size value to None for the reg.
Fixup kconfigfunctions.py to handle reg.size and reg.addr being None.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add a function takes a 'label' and returns "y" if we find an
"enabled" node that has a 'nodelabel' of 'label' in the EDT
otherwise we return "n"
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Change the output during CMake configure from
Devicetree configuration written to .../devicetree.conf
Parsing /home/ulf/z/z/Kconfig
Loaded configuration '.../frdm_kw41z_defconfig'
Merged configuration '.../prj.conf'
Configuration saved to '.../.config'
to
Devicetree header saved to '.../devicetree_unfixed.h'
Parsing /home/ulf/z/z/Kconfig
Loaded configuration '.../frdm_kw41z_defconfig'
Merged configuration '.../prj.conf'
Configuration saved to '.../.config'
Kconfig header saved to '.../autoconf.h'
devicetree_unfixed.h is more useful to be aware of than devicetree.conf
(still hoping we can get rid of it at some point), and seeing the
Kconfig header clarifies things to.
"Saved" instead of "written" for consistency. Maybe it could say
"Kconfig configuration" instead of "configuration" too, though it gets a
bit spammy in other contexts where the message shows up.
Updates Kconfiglib (and menuconfig/guiconfig, just to sync) to upstream
revision 061e71f7d7, to get this commit in, which is used to print the
header path:
Return a message from Kconfig.write_autoconf()
Like for Kconfig.write_config() and Kconfig.write_min_config(),
return a string from Kconfig.write_autoconf() with a message saying
that the header got saved, or that there were no changes to it. Can
be handy in tools.
Also make the "no change" message for the various files more
specific, by mentioning what type of file it is (configuration,
header, etc.)
Return True/False from Kconfig._write_if_changed() to indicate if
the file was updated. This also allows it to be reused in
Kconfig.write_min_config().
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Add a new --check-missing-config-prefix check that looks for references
like
#if MACRO
#if(n)def MACRO
defined(MACRO)
IS_ENABLED(MACRO)
where MACRO is the name of a defined Kconfig symbol but doesn't have a
CONFIG_ prefix. Could be a typo.
Skip MACRO if it is #define'd somewhere, even if it looks like a Kconfig
symbol.
Found e.g. https://github.com/zephyrproject-rtos/zephyr/pull/22195.
Piggyback skipping binary files when grepping for Kconfig symbol
references.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Include the "warning: "/"error: " part of the string when wrapping
lines, and consistenly start messages with a capital letter.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Turn the warning for selecting a symbol with unsatisfied dependencies
into an error. The last instance has been fixed (that triggers in CI at
least).
Also remove the warning whitelisting functionality, which was only used
to whitelist that warning. It hasn't been used for anything else in over
a year, so it probably wouldn't be useful to keep. Getting rid of it
makes the script easier to read.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Use f-strings instead of .format() to make things more readable. They
were added in Python 3.6, which Zephyr requires now.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Show which dependencies are unsatisfied when symbols don't get their
assigned value.
For example, assume that FOO below is assigned with CONFIG_FOO=y. Note
that BAR, BAZ, and STR = "hmm" are 'n'.
config FOO
bool "foo"
depends on BAR && BAZ && QAZ && STR = "hmm"
config BAR
def_bool n
config BAZ
def_bool n
config QAZ
def_bool y
config STR
def_string "zmh"
This now prints this warning:
warning: FOO (defined at /home/ulf/z/z/Kconfig:10) was assigned the
value 'y' but got the value 'n'. Check these unsatisfied
dependencies: BAR (=n), BAZ (=n), STR = "hmm" (=n). See ...
Fixes: #21888
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
There are some issues with the behavior when rerunning CMake in an
already initialized build directory:
1. The check for assignments to promptless symbols in configuration
fragments isn't run when reconfiguring, because it only runs if
zephyr/.config doesn't exist
2. As outlined in
https://github.com/zephyrproject-rtos/zephyr/issues/9573, you can
get into situations where zephyr/.config is invalid (e.g. due to
being outdated), but menuconfig/guiconfig can't be run to fix it
3. If kconfig.py fails while merging fragments during reconfiguration,
it will ignore the fragments during the next reconfiguration and use
the existing zephyr/.config instead, because the fragment checksum
is calculated and saved before running kconfig.py
(Footnote: The input configuration file(s) to kconfig.py can be either a
list of configuration fragments, when merging fragments, or just
zephyr/.config, if the merged configuration is up-to-date. The output
configuration file is always zephyr/.config.)
To fix the first two issues, explicitly tell kconfig.py when it's
dealing with handwritten configuration input (fragments), via a new
--handwritten-input-configs flag. This is more robust than checking
whether zephyr/.config exists, which was the old logic.
When dealing with handwritten input, there should be no assignments to
promptless symbols. Assignments to promptless symbols is expected in
zephyr/.config however, because it doubles as configuration output.
When running menuconfig/guiconfig, the input configuration is
zephyr/.config rather than configuration fragments, so this change also
makes sure that menuconfig can always be run as long as zephyr/.config
exists and is up-to-date.
To fix the last issue, only write the checksum for the configuration
fragments if kconfig.py succeeds (which means it wrote a
zephyr/.config).
Also improve naming a bit, add help texts for the command-line
parameters to kconfig.py, and simplify write_kconfig_filenames() by
moving logic into it.
Partial fix for
https://github.com/zephyrproject-rtos/zephyr/issues/9573, without the
part in #issuecomment-469701831. Can still run into issues when e.g.
when CMake files can't make sense of settings.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Assigning to promptless symbols has no effect.
Previously, the only check was for whether the value assigned to a
symbol matched its final value. This misses cases where a promptless
symbol is assigned to and just happens to get the assigned-to value as
its final value.
Instead, detect whether configuration files are being merged (by
checking if zephyr/.config already exists), and explicitly check for
assignments to promptless symbols in that case. We can't do it when
zephyr/.config already exists (and is being loaded), because it includes
values for promptless symbols as well.
With the no-prompt check moved out, also use a more specific message for
it, and remove stuff related to prompts elsewhere. Shorten messages a
bit at the same time, and add two warn() and err() helpers.
Fixes: #20697
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
generated_dts_board.h is pretty redundant and confusing as a name. Call
it devicetree.h instead.
dts.h would be another option, but DTS stands for "devicetree source"
and is the source code format, so it's a bit confusing too.
The replacement was done by grepping for 'generated_dts_board' and
'GENERATED_DTS_BOARD'.
Two build diagram and input-output SVG files were updated as well, along
with misc. documentation.
hal_ti, mcuboot, and ci-tools updates are included too, in the west.yml
update.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Update menuconfig (and kconfiglib and guiconfig, just to sync) to
upstream revision 424d0d38e7, to get this commit in, which works around
a crash on some macOS Python installations.
menuconfig: Work around crash on resize on some macOS systems
get_wch() has started raising curses.error when resizing the
terminal on some macOS Python installations. Work around for now by
falling back on getch(), which still works.
See https://github.com/ulfalizer/Kconfiglib/issues/84. Needs more
investigation, but I don't have a Mac handy.
Based on https://github.com/ulfalizer/Kconfiglib/pull/85, but with
some more comments.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
dt_chosen_reg() and dt_node_reg() take between 1 and 3 arguments, not
between 1 and 4 arguments. The implicit name argument isn't included in
the count.
These functions implement $(dt_chosen_reg_*) and $(dt_node_reg_*).
Giving the right max argument count makes Kconfiglib generate error
messages that give the location of the call, instead of getting a
cryptic generic Python error.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
If the working directory for a command was missing (usually due to
forgetting to run 'west update'), you'd get a FileNotFoundError
exception along with a cryptic error like
'git' not found
Only catch OSError instead (which is a base class of FileNotFoundError),
and always show the exception message. It makes it clear that it's the
working directory that's missing.
Add some other misc. improvements too:
- Turn stderr output from external commands into a warning instead of
an error
- Add err() and warn() helpers
- Include the command name in messages
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Add shields_list_contains Kconfig function which return bool based on
check of shield presence in cmake SHIELD_AS_LIST.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Update Kconfiglib to upstream revision 9c0b562c94 to get this commit in:
Add Kconfig.__init__() helper flag for suppressing tracebacks
Tools that don't use standard_kconfig() currently generate spammy
tracebacks for e.g. syntax errors.
Add a suppress_traceback flag to Kconfig.__init__() for catching
"expected" exceptions and printing them to stderr and exiting with
status 1. Use it to make all tools consistently hide tracebacks.
Use the new flag to hide tracebacks for expected exceptions in
kconfig.py, lint.py, and genrest.py.
Some menuconfig robustness tweaks for wonky terminals are included as
well, and a new feature for customizing .config and autoconf.h header
comments via environment variables.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Basic tool to help checking Kconfig options against a list of
hardening preferences.
This tool is available as a kconfig target, so to run it:
make/ninja hardenconfig
[Flavio Ceolin: Simplify logic and fix python lint issues]
Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Update Kconfiglib, menuconfig, and guiconfig to upstream revision
faa1d21998, mostly to get this commit in:
Add public helpers for generating "<name> (defined at ...)" strings
Have Symbol/Choice.name_and_loc return strings like
"MY_SYM (defined at foo:1, bar:2)"
"<choice> (defined at foo:4)"
I've added a function like that in at least four different scripts
now, so that's probably a sign that it's a worthwhile helper.
Clean up the tests/Klocation tests a bit while adding tests.
Use the new helper to simplify kconfig.py a bit. Also clean it up a bit
by removing some unused stuff.
Some other minor improvements are included as well, e.g. to make
menuconfig/guiconfig give more helpful errors on invalid arguments.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Add a cleaned-up version of a script I used to find a bunch of unused
symbols and some other Kconfig issues. It's set up to be run directly,
with few environment dependencies.
West is required, because the checks need to see Kconfig files and
source code from all modules.
Checks so far:
- Symbols that can never be anything but n/empty
- Symbols that look unused
- menuconfig symbols with empty menus
- Symbols only defined in Kconfig.defconfig files
See the help strings for the command-line flags for more information.
Some of these checks could probably be checked in CI later, though the
always-n and unused-symbol checks are a bit heuristic and might need a
lot of whitelisting.
Another reason I want to get this in is to have a clean standalone
reference for how to set up the environment for parsing the Kconfig
files. It's gotten trickier over time.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Add function that will return 'y' or 'n' if a node pointed to by a
chosen property exists and is enabled.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Replace:
dt_chosen_reg_addr
dt_chosen_reg_size
dt_node_reg_addr
dt_node_reg_size
with:
dt_chosen_reg_addr_int
dt_chosen_reg_size_int
dt_chosen_reg_addr_hex
dt_chosen_reg_size_hex
dt_node_reg_addr_int
dt_node_reg_size_int
dt_node_reg_addr_hex
dt_node_reg_size_hex
So that we get the proper formatted string for the type of symbol.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Fix a bug where DTS_BINDINGS_DIRS could only have one entry. When
there were more than one entry the command for invoking menuconfig
became corrupted.
This changes the separator of DTS_BINDINGS_DIR from a space to ? so
that the shell does not interpret the space as an argument separator.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Prompted by an upstream bug report. Nothing in Zephyr triggers this at
the moment, but might as well fix it.
Update Kconfiglib to upstream revision 7d05084b7e, to get this commit
in:
Fix handling of parentheses in macro argument values
As an oversight, there was no check for nested parentheses in macro
arguments, making the preprocessor think the call ended after
'void)' in
def_bool $(success,echo 'void foo(void) { asm inline (""); }' \
| $(CC) -x c - -c -o /dev/null)
This broke the latest linux-next kernels (with a Kconfig error),
starting with commit eb111869301e1 ("compiler-types.h: add
asm_inline definition").
I remember seeing this when going through the C code, but somehow
forgot to put it in. Fix it, and clean up _expand_macro() a bit at
the same time.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
edtlib.Device is just a devicetree node augmented with binding
information and some interpretation of properties. Rename it to
edtlib.Node to make that clearer. That also avoids calling things like
flash partition nodes "devices", which is a bit confusing.
I called it edtlib.Device instead of edtlib.Node originally to avoid
confusion with dtlib.Node, but in retrospect it probably makes it more
confusing on the whole. Something like edtlib.ENode might work too, but
it's probably overkill. Clients of edtlib.py only interact with
edtlib.Node, so the only potential for confusion is within edtlib.py
itself, and it doesn't get too bad there either.
Piggyback some documentation nits, and consistently write it
"devicetree" instead of "device tree", to match the spec.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Some confluence of recent changes resulted in builds with
application-specific bindings being unable to find bindings present in
the system directory. Add quotes and splits as necessary to propagate
multiple directories through the system.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
As we work on removing the .conf file that is generated by the dt
scripts, mark dt_{int,hex,str}_val functions as deprecated.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Update Kconfiglib (and menuconfig/guiconfig, just to sync) to upstream
revision f2ce282eca, to get this commit in:
Allow preprocessor user functions to access the parsing location
Just requires making Kconfig.filename/linenr public.
'lineno' would be a more standard name, but be consistent with
MenuNode.linenr.
This can be used to give friendly errors in
scripts/kconfig/kconfigfunctions.py, e.g. for
https://github.com/zephyrproject-rtos/zephyr/pull/18752.
Some minor optimizations are included too.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
dtlib.py and guiconfig.py do some hackery to build token and image
variable names, which triggers spurious pylint warnings like
scripts/dts/dtlib.py:243:28: E0602: Undefined variable '_T_LABEL'
(undefined-variable)
Suppress the warning for those files. The generated names get used in
lots of places.
Also suppress some warnings in doc/conf.py ('tags' is from Sphinx), and
fix a legitimate issue in scripts/dts/testdtlib.py.
This pylint check is useful enough to want enabled in the upcoming CI
check.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
pylint might be afraid that there'd be less than three elements in
'args', but there never is. Fixes this warning:
scripts/kconfig/menuconfig.py:3184:8: W0632: Possible unbalanced
tuple unpacking with sequence: left side has 3 label(s), right side
has 0 value(s) (unbalanced-tuple-unpacking)
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
There is a bug where non-normalized paths can introduce multiple entries
for the same file. E.g. '/1/2/../2.file' and '/1/2/3/../../2.file' would
both be listed, and end in a ninja error because multiple targets
generate the same file.
This commit fixes this issue by normalizing the paths.
Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
Similar deal to commit cc14c40a2d ("kconfiglib: Unclutter symbol
strings, avoid redundant writes, misc.").
Hide the direct dependencies in the defaults, selects, and implies
sections. Do the same in menuconfig/guiconfig as well.
This uses a new Kconfiglib API, so update Kconfiglib to upstream
revision 164ef007a8. This also includes some minor optimizations and
cleanups.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
load_config() and write_config() now return a message to print. This
message also says whether the configuration was loaded (replace=True) or
merged (replace=False), and whether the new .config is different from
the old (for write_config()).
Print the returned messages and remove some old print()s.
Also switch to an improved warning control API (the old one is still
supported, but might as well).
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Update kconfiglib, menuconfig, and guiconfig to upstream revision
5c904f4549 to get various improvements and fixes in:
- Marc Herbert found an issue involving symlinks, absolute paths,
and rsource that could lead to files not being found. The root cause
was relpath() assuming that symlink/../bar is the same as bar/, which
isn't guaranteed.
Fix it by handling paths in a simpler, more textual way.
- Propagated dependencies from 'depends on' are now stripped from
properties when symbols are printed (e.g. in information dialogs and
generated documentation).
The printed representation now also uses shorthands.
Before:
config A
bool
prompt "foo" if C && D
default A if B && C && D
depends on C && D
After:
config A
bool "foo"
default A if B
depends on C && D
- Before writing a configuration file or header, Kconfiglib now
compares the previous contents of the file against the new contents,
and skips the write if there's no change. This avoids updating the
modification time, and can save work.
A message like "No change to '.config'" is shown when there's no
change.
- .config now has '# end of <menu>' comments to make it easier to see
where a menu ends. This was taken from a change to the C tools.
- load_config() and write_(min_)config() now return a message that can
be printed with print(kconf.load_config()). This allows messages to
be reused in e.g. the configuration interfaces (nice now that there's
also a "No change to..." string).
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
This is a graphical configuration interface written in Tkinter. Like
menuconfig.py, it supports showing all symbols (with invisible symbols
in red) and jumping directly to symbols. Symbol values can also be
changed directly from the jump-to dialog.
This interface should feel a lot smoother than menuconfig.py on Windows.
When single-menu mode is enabled, a single menu is shown at a time, like
in the terminal menuconfig. Only this mode distinguishes between symbols
defined with 'config' and symbols defined with 'menuconfig'.
Compatible with both Python 2 and Python 3. Has been tested on X11,
Windows, and macOS.
To avoid having to carry around a bunch of GIFs, the image data is
embedded in guiconfig.py. To use separate GIF files instead, change
_USE_EMBEDDED_IMAGES to False. The image files can be found in
https://github.com/ulfalizer/Kconfiglib/tree/screenshots/guiconfig.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>