-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Description
Is your feature request related to a problem? Please describe.
Some Kconfig options often come with set of default values depending on other options. Providing proper default configuration requires knowledge of all possible users of the Kconfig option. This becomes cumbersome with even growing number of modules using Kconfig options. Some of the modules are outside of Zephyr (customer applications/downstream forks) which makes it impossible to know all users of the Kconfig options.
Consider following use cases:
- A resource provides kind of "channels". The number of channels is configurable. We want to have as small number of "channels" as possible (memory footprint/runtime overhead) but satisfying all users.
config RESOURCE_CHANNELS_COUNT
int "Number of channels provided by the resource"
default 3 if KNOWN_OPTION_1 && KNOWN_OPTION_2
default 2 if KNOWN_OPTION_1
default 1 if KNOWN_OPTION_2
default 0
Users expect that there will be enough "channels" of the resource they can use, independent of other users. During the build it is ensured that given capacity is provided, like in following simple example:
static resource_channel_t channels[CONFIG_RESOURCE_CHANNELS_COUNT];
- A resource is kind of memory which is required to be at least given value, like stack sizes.
config SOME_THERAD_STACK_SIZE
int "Stack size for some thread performing some important processing"
default 8192 if KNOWN_OPTION_1
default 4096 if KNOWN_OPTION_2
default 1024
Describe the solution you'd like
I would like the Kconfig language to be extended to allow dependency inversion so that users unaware of each other can "request" or "alloc" given Kconfig option an the Kconfig option itself serving some purpose does not need to know all it's users to provide reasonable default value. The build process would calculate final value of the Kconfig option. If calculated value is outside specified range the build fails. Following some hypothetical example:
"Resource" and "some_thread" are not aware of modules 1 and 2 being possibly part of external repositories.
config RESOURCE_CHANNELS_COUNT
int "Number of channels provided by the resource"
default 0
config SOME_THERAD_STACK_SIZE
int "Stack size for some thread performing some important processing"
default 1024
Module 1 is unaware of module 2, but it's KNOWN_OPTION_1 requires that "resource" reserves 2 channels and "some_thread" stack size is at least 8192 (can be greater).
config KNOWN_OPTION_1
bool "Some feature 1"
select RESOURCE_CHANNELS_COUNT alloc 2
select SOME_THERAD_STACK_SIZE at_least 8192
Module 2 is unaware of module 1, but it's KNOWN_OPTION_2 requires that "resource" reserves 1 channel and "some_thread" stack size is at least 4096 (can be greater).
config KNOWN_OPTION_2
bool "Some feature 2"
select RESOURCE_CHANNELS_COUNT alloc 1
select SOME_THERAD_STACK_SIZE at_least 4096
Build system would gather all requirements on value of (in example above) RESOURCE_CHANNELS_COUNT and SOME_THERAD_STACK_SIZE and would calculate final value of these options satisfying all needs. Given serving Kconfig like RESOURCE_CHANNELS_COUNT and SOME_THERAD_STACK_SIZE would not need to know all users but the system would provide correct default value for these Kconfig.
The syntax (select alloc
at_least
keywords ) is to be discussed as long as the goal ca be achieved.