I have a situation where our software needs to work with several different Linux kernel distributions / kernel trees. (including Android forks)
In trying to automate our build process, I am finding that some of the defconfig
files for particular builds we need to support do not include the kernel modules we depend on.
For example, let's imagine I need an option called XXX
in my .config
. For some dependencies, I can do something like this:
sed -i 's/# CONFIG_XXX is not set/CONFIG_XXX=m/' .config
For others, it's not so easy since the dependency may span multiple lines of .config
statements.
Is there a more supported way to do this non-interactively, or am I stuck writing a more complex search-and-replace script?
The Linux kernel configuration is usually found in the kernel source in the file: /usr/src/linux/. config . It is not recommended to edit this file directly but to use one of these configuration options: make config - starts a character based questions and answer session.
To configure the kernel, change to /usr/src/linux and enter the command make config. Choose the features you want supported by the kernel. Usually, There are two or three options: y, n, or m. m means that this device will not be compiled directly into the kernel, but loaded as a module.
How are Android's kernel configs stored? The kernel configs are stored in the kernel/configs repo. Kernel configuration settings that must be present for Android to function are located in the base config fragment, android-base. config .
To do a series of simple flipping of a single config while updating any and all config dependencies:
./scripts/config --set-val CONFIG_OPTION y
./scripts/config --enable CONFIG_BRIDGE
./scripts/config --enable CONFIG_MODULES
./scripts/config --disable CONFIG_X25
./scripts/config --module CONFIG_NFT
make oldconfig
(updates dependencies; may prompt with new dependencies, but old deps silently goes away)
If you have several small snippets of .config-*
files that you want to selectively merge into the main .config
file, execute:
# Merge IP fragment CONFIG_ settings into the main .config file
./scripts/kconfig/merge_config.sh .config .config-fragment
# Merge Notebook HW-specific CONFIG_ settings into main .config file
./scripts/kconfig/merge_config.sh .config .config-notebook-toshiba
# Auto-add/auto-remove CONFIG_ dependencies
make oldconfig
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With