"Das U-Boot" Source Tree
at master 157 lines 5.9 kB view raw
1.. SPDX-License-Identifier: GPL-2.0-or-later 2 3Kconfig in U-Boot 4================= 5 6This document describes the configuration infrastructure of U-Boot. 7 8The conventional configuration was replaced by Kconfig at v2014.10-rc1 release. 9 10Language Specification 11---------------------- 12 13The Kconfig configuration language originates in Linux kernel. 14See the Linux document 15`Kconfig Language <https://www.kernel.org/doc/html/latest/kbuild/kconfig-language.html>`_ 16for a description of Kconfig. 17 18Difference from Linux's Kconfig 19------------------------------- 20 21Here are some worth-mentioning configuration targets. 22 23silentoldconfig 24 This target updates .config, include/generated/autoconf.h and 25 include/configs/* as in Linux. In U-Boot, it also does the following 26 for the compatibility with the old configuration system: 27 28 * create a symbolic link "arch/${ARCH}/include/asm/arch" pointing to 29 the SoC/CPU specific header directory 30 * create include/config.h 31 * create include/autoconf.mk 32 * create spl/include/autoconf.mk (SPL and TPL only) 33 * create tpl/include/autoconf.mk (TPL only) 34 35 If we could completely switch to Kconfig in a long run 36 (i.e. remove all the include/configs/\*.h), those additional processings 37 above would be removed. 38 39defconfig 40 In U-Boot, "make defconfig" is a shorthand of "make sandbox_defconfig" 41 42<board>_defconfig 43 Now it works as in Linux. 44 The prefixes such as "+S:" in \*_defconfig are deprecated. 45 You can simply remove the prefixes. Do not add them for new boards. 46 47<board>_config 48 This does not exist in Linux's Kconfig. 49 "make <board>_config" works the same as "make <board>_defconfig". 50 Prior to Kconfig, in U-Boot, "make <board>_config" was used for the 51 configuration. It is still supported for backward compatibility, so 52 we do not need to update the distro recipes. 53 54The other configuration targets work as in Linux Kernel. 55 56Migration steps to Kconfig 57-------------------------- 58 59Prior to Kconfig, the C preprocessor based board configuration had been used 60in U-Boot. 61 62Although Kconfig was introduced and some configs have been moved to Kconfig, 63many of configs are still defined in C header files. It will take a very 64long term to move all of them to Kconfig. In the interim, the two different 65configuration infrastructures should coexist. 66The configuration files are generated by both Kconfig and the old preprocessor 67based configuration as follows: 68 69Configuration files for use in C sources 70 - include/generated/autoconf.h (generated by Kconfig for Normal) 71 - include/configs/<board>.h (exists for all boards) 72 73Configuration file for use in makefiles 74 - include/config/auto.conf (generated by Kconfig) 75 - include/autoconf.mk (generated by the old config for Normal) 76 - spl/include/autoconfig.mk (generated by the old config for SPL) 77 - tpl/include/autoconfig.mk (generated by the old config for TPL) 78 79When adding a new CONFIG macro, it is highly recommended to add it to Kconfig 80rather than to a header file. 81 82Conversion from boards.cfg to Kconfig 83------------------------------------- 84 85Prior to Kconfig, boards.cfg was a primary database that contained Arch, CPU, 86SoC, etc. of all the supported boards. It was deleted when switching to 87Kconfig. Each field of boards.cfg was converted as follows: 88 89=========== ==================================================== 90From To 91=========== ==================================================== 92Arch CONFIG_SYS_ARCH defined by Kconfig 93Board CONFIG_SYS_BOARD defined by Kconfig 94CPU CONFIG_SYS_CPU defined by Kconfig 95Maintainers "M:" entry of MAINTAINERS 96SoC CONFIG_SYS_SOC defined by Kconfig 97Status "S:" entry of MAINTAINERS 98Target File name of defconfig (configs/<target>\_defconfig) 99Vendor CONFIG_SYS_VENDOR defined by Kconfig 100=========== ==================================================== 101 102Tips to add/remove boards 103------------------------- 104 105When adding a new board, the following steps are generally needed: 106 1071. Add a header file include/configs/<target>.h 108 1092. Make sure to define necessary CONFIG_SYS_* in Kconfig: 110 111 * Define CONFIG_SYS_CPU="cpu" to compile arch/<arch>/cpu/<cpu> 112 * Define CONFIG_SYS_SOC="soc" to compile arch/<arch>/cpu/<cpu>/<soc> 113 * Define CONFIG_SYS_VENDOR="vendor" to compile board/<vendor>/common/\* 114 and board/<vendor>/<board>/\* 115 * Define CONFIG_SYS_BOARD="board" to compile board/<board>/\* 116 (or board/<vendor>/<board>/* if CONFIG_SYS_VENDOR is defined) 117 Define CONFIG_SYS_CONFIG_NAME="target" to include 118 include/configs/<target>.h 119 1203. Add a new entry to the board select menu in Kconfig. 121 The board select menu is located in arch/<arch>/Kconfig or 122 arch/<arch>/\*/Kconfig. 123 1244. Add a MAINTAINERS file 125 It is generally placed at board/<board>/MAINTAINERS or 126 board/<vendor>/<board>/MAINTAINERS 127 1285. Add configs/<target>_defconfig 129 130When removing an obsolete board, the following steps are generally needed: 131 1321. Remove configs/<target>_defconfig 133 1342. Remove include/configs/<target>.h if it is not used by any other boards 135 1363. Remove board/<vendor>/<board>/\* or board/<board>/\* if it is not used 137 by any other boards 138 1394. Update MAINTAINERS if necessary 140 1415. Remove the unused entry from the board select menu in Kconfig 142 1436. Add an entry to doc/README.scrapyard 144 145TODO 146---- 147 148* In the pre-Kconfig, a single board had multiple entries in the boards.cfg 149 file with differences in the option fields. The corresponding defconfig 150 files were auto-generated when switching to Kconfig. Now we have too many 151 defconfig files compared with the number of the supported boards. It is 152 recommended to have only one defconfig per board and allow users to select 153 the config options. 154 155* Move the config macros in header files to Kconfig. When we move at least 156 macros used in makefiles, we can drop include/autoconfig.mk, which makes 157 the build scripts much simpler.