Customizing u-boot build configuration
u-boot uses the Kconfig build system like Linux. One issue I faced with Kconfig in u-boot is how to alter the configuration of a build via a script. The typical u-boot flow is to seed the build configuration by using a defconfig
for a specific board.
The .config
file is then populated with reasonable default values. The next step is to interactively edit the configuration via a ncurses application.
This approach is not feasible in a script because make menuconfig
is interactive. Fortunately u-boot ships with a utility script ./scripts/kconfig/merge_config.sh
which allows merging of two different config files.
This script allows merging two sets of config files together. For example to add on zstd compression to the pine64_plus_defconfig
configuration just do the following:
After running the above the CONFIG_ZSTD
option will be merge into the .config
file and set.
The same approach can be taken to disable certain configuration values as well. For example to disable any networking related functionality, it’s possible to flip the value of the CONFIG_NET
option.
After the script runs, any networking related options will be disabled.
There are some limitations to this approach, with depends on
such as the following:
The pine64_plus_defconfig
does not set CMD_USB_MASS_STORAGE
but it also doesn’t set USB_GADGET_DOWNLOAD
. Trying to enable CMD_USB_MASS_STORAGE
without the dependencies results in the following.
In order to actually enable this feature, all of the dependencies need to be enabled as well in the final configuration.
Despite its limitations the merge_config.sh
script is a powerful way to alter the build configuration of u-boot via a script.