-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modelling modules in Kconfig #15429
Comments
Tagging people who I think, might be interested on this: @fjmolinas @aabadie @cgundogan @jia200x @miri64 @maribu |
Can you please elaborate on this?
|
With this I mean symbols that have dependencies that are known, and somehow fixed (will not change), so it's safe to move them 'one level up'. The main example for this are the peripheral drivers modules, which always depend on their respective feature: RIOT/drivers/periph_common/Kconfig.spi Lines 8 to 11 in 3234b91
We can safely assume that when the SPI feature is there it is OK to select the SPI peripheral, so we check that feature from the driver symbol. For example: Lines 8 to 12 in 3234b91
|
I agree with your proposal. In order to alleviate the pain of all modules, could we think of providing some default or "starter" configuration files? Examples and |
Yes, definitely. Together with the migration the configurations for the applications are needed of course: RIOT/tests/driver_at/app.config.test Lines 3 to 20 in f23c616
We could as well place other configurations in some folder and add documentation to them if needed (maybe some sort of "cookbook"?). I can imagine some configuration guide may be needed for complex systems like the network stack. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
I guess we can close this now? |
Introduction
There is currently an ongoing effort to model all RIOT modules' dependencies in Kconfig, in order to use this system for module configuration and selection. This would replace our current Make-based dependency resolution system.
Currently the dependency resolution is done in a sort of top-down fashion (with some caveats), where a module is enabled by adding it to the
USEMODULE
list, and that module is responsible for pulling all the modules it needs, and indicating the features it needs. This happens iteratively until no new modules are added to the list.Many RIOT developers are used to 'just enable module FOO', which would in many cases (although not all) bring the needed modules to use it. There are some cases where intermediate modules need to be explicitly added, but the logic is not always defined.
The Kconfig options
The Kconfig approach is based on modelling RIOT modules as Kconfig symbols, leveraging Kconfig's dependency system. Kconfig allows to express dependencies among symbols in the following ways:
depends on
Expresses a normal dependency, reducing the upper limit of a symbol. In the following example if
MODULE_BAR
is not set toy
,MODULE_FOO
can't be enabled by the user (either viamenuconfig
or a configuration file).Example of `depends on`
select
This expresses a reverse dependency. From the Linux Kconfig language definition:
The caveat with this attribute is that it does not take into account the direct dependencies of the
select
ed symbol. That's why this note is also present:Currently we are using
select
in our Kconfig files to indicate features, CPUs and to select other non visible symbols, and with peripheral drivers. This is because the drivers map 1 to 1 to the features, so the user of the peripheral driver can depend on the feature to avoid selecting the module when the feature is not present.Example of `select`
A good explanation with examples and alternatives can be found in Zephyr's Kconfig tips.
imply
This attribute expresses a weak reverse dependency between two symbols:
The
imply
ed symbol is enabled only when its dependencies are met, but being disabled is also a valid configuration for the symbol that implies it. This is usually used to enable "nice to have" modules.How should we model?
The current make approach has much more in common to dependencies modelled using
select
(top-down) than withdepends on
(bottom-up). There are some cases where this does not work. For instance, when there can be multiple modules that provide a certain feature, or that implement a certain API, or when there are complex conditions for a module to be enabled.When modelling dependencies using
depends on
more steps may be needed to enable the module we want to use, but there is no risk of illegal conditions (provided that the dependencies are modelled correctly :). Having long chains ofselect
does not scale well, and tends to get out of sync when updating dependencies. Withdepends on
there is always more control on which is being included on the binary. In both cases interfaces likemenuconfig
can be used to check dependencies and whichsymbols select each other.
To try to mitigate the need for extra steps certain modules that are commonly needed can be
default
ed toy
. This would cause that users that do not need the module will have to explicitly disable it. In the end this is a trade-off between what is enabled usually and what not.Proposal
To me the safest way is to limit the usage of
select
to:The rest should be modelled with
depends on
. Of course common sense always applies.Example of dependencies of AT driver modules
Note that:
MODULE_AT_URC_ISR
depends onMODULE_EVENT_THREAD
that is why I assumed it wassafe to select
MODULE_EVENT_THREAD_%
modules from the choices.MODULE_FMT
does not present dependencies, so it's selected.The text was updated successfully, but these errors were encountered: