1*4882a593SmuzhiyunKconfig in U-Boot 2*4882a593Smuzhiyun================= 3*4882a593Smuzhiyun 4*4882a593SmuzhiyunThis document describes the configuration infrastructure of U-Boot. 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunThe conventional configuration was replaced by Kconfig at v2014.10-rc1 release. 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun 9*4882a593SmuzhiyunLanguage Specification 10*4882a593Smuzhiyun---------------------- 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunKconfig originates in Linux Kernel. 13*4882a593SmuzhiyunSee the file "Documentation/kbuild/kconfig*.txt" in your Linux Kernel 14*4882a593Smuzhiyunsource directory for a basic specification of Kconfig. 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun 17*4882a593SmuzhiyunDifference from Linux's Kconfig 18*4882a593Smuzhiyun------------------------------- 19*4882a593Smuzhiyun 20*4882a593SmuzhiyunHere are some worth-mentioning configuration targets. 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun- silentoldconfig 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun This target updates .config, include/generated/autoconf.h and 25*4882a593Smuzhiyun include/configs/* as in Linux. In U-Boot, it also does the following 26*4882a593Smuzhiyun for the compatibility with the old configuration system: 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun * create a symbolic link "arch/${ARCH}/include/asm/arch" pointing to 29*4882a593Smuzhiyun the SoC/CPU specific header directory 30*4882a593Smuzhiyun * create include/config.h 31*4882a593Smuzhiyun * create include/autoconf.mk 32*4882a593Smuzhiyun * create spl/include/autoconf.mk (SPL and TPL only) 33*4882a593Smuzhiyun * create tpl/include/autoconf.mk (TPL only) 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun If we could completely switch to Kconfig in a long run 36*4882a593Smuzhiyun (i.e. remove all the include/configs/*.h), those additional processings 37*4882a593Smuzhiyun above would be removed. 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun- defconfig 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun In U-Boot, "make defconfig" is a shorthand of "make sandbox_defconfig" 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun- <board>_defconfig 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun Now it works as in Linux. 46*4882a593Smuzhiyun The prefixes such as "+S:" in *_defconfig are deprecated. 47*4882a593Smuzhiyun You can simply remove the prefixes. Do not add them for new boards. 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun- <board>_config 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun This does not exist in Linux's Kconfig. 52*4882a593Smuzhiyun "make <board>_config" works the same as "make <board>_defconfig". 53*4882a593Smuzhiyun Prior to Kconfig, in U-Boot, "make <board>_config" was used for the 54*4882a593Smuzhiyun configuration. It is still supported for backward compatibility, so 55*4882a593Smuzhiyun we do not need to update the distro recipes. 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun 58*4882a593SmuzhiyunThe other configuration targets work as in Linux Kernel. 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun 61*4882a593SmuzhiyunMigration steps to Kconfig 62*4882a593Smuzhiyun-------------------------- 63*4882a593Smuzhiyun 64*4882a593SmuzhiyunPrior to Kconfig, the C preprocessor based board configuration had been used 65*4882a593Smuzhiyunin U-Boot. 66*4882a593Smuzhiyun 67*4882a593SmuzhiyunAlthough Kconfig was introduced and some configs have been moved to Kconfig, 68*4882a593Smuzhiyunmany of configs are still defined in C header files. It will take a very 69*4882a593Smuzhiyunlong term to move all of them to Kconfig. In the interim, the two different 70*4882a593Smuzhiyunconfiguration infrastructures should coexist. 71*4882a593SmuzhiyunThe configuration files are generated by both Kconfig and the old preprocessor 72*4882a593Smuzhiyunbased configuration as follows: 73*4882a593Smuzhiyun 74*4882a593SmuzhiyunConfiguration files for use in C sources 75*4882a593Smuzhiyun - include/generated/autoconf.h (generated by Kconfig for Normal) 76*4882a593Smuzhiyun - include/configs/<board>.h (exists for all boards) 77*4882a593Smuzhiyun 78*4882a593SmuzhiyunConfiguration file for use in makefiles 79*4882a593Smuzhiyun - include/config/auto.conf (generated by Kconfig) 80*4882a593Smuzhiyun - include/autoconf.mk (generated by the old config for Normal) 81*4882a593Smuzhiyun - spl/include/autoconfig.mk (generated by the old config for SPL) 82*4882a593Smuzhiyun - tpl/include/autoconfig.mk (generated by the old config for TPL) 83*4882a593Smuzhiyun 84*4882a593SmuzhiyunWhen adding a new CONFIG macro, it is highly recommended to add it to Kconfig 85*4882a593Smuzhiyunrather than to a header file. 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun 88*4882a593SmuzhiyunConversion from boards.cfg to Kconfig 89*4882a593Smuzhiyun------------------------------------- 90*4882a593Smuzhiyun 91*4882a593SmuzhiyunPrior to Kconfig, boards.cfg was a primary database that contained Arch, CPU, 92*4882a593SmuzhiyunSoC, etc. of all the supported boards. It was deleted when switching to 93*4882a593SmuzhiyunKconfig. Each field of boards.cfg was converted as follows: 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun Status -> "S:" entry of MAINTAINERS 96*4882a593Smuzhiyun Arch -> CONFIG_SYS_ARCH defined by Kconfig 97*4882a593Smuzhiyun CPU -> CONFIG_SYS_CPU defined by Kconfig 98*4882a593Smuzhiyun SoC -> CONFIG_SYS_SOC defined by Kconfig 99*4882a593Smuzhiyun Vendor -> CONFIG_SYS_VENDOR defined by Kconfig 100*4882a593Smuzhiyun Board -> CONFIG_SYS_BOARD defined by Kconfig 101*4882a593Smuzhiyun Target -> File name of defconfig (configs/<target>_defconfig) 102*4882a593Smuzhiyun Options -> CONFIG_SYS_EXTRA_OPTIONS defined by Kconfig 103*4882a593Smuzhiyun Maintainers -> "M:" entry of MAINTAINERS 104*4882a593Smuzhiyun 105*4882a593Smuzhiyun 106*4882a593SmuzhiyunTips to add/remove boards 107*4882a593Smuzhiyun------------------------- 108*4882a593Smuzhiyun 109*4882a593SmuzhiyunWhen adding a new board, the following steps are generally needed: 110*4882a593Smuzhiyun 111*4882a593Smuzhiyun [1] Add a header file include/configs/<target>.h 112*4882a593Smuzhiyun [2] Make sure to define necessary CONFIG_SYS_* in Kconfig: 113*4882a593Smuzhiyun Define CONFIG_SYS_CPU="cpu" to compile arch/<arch>/cpu/<cpu> 114*4882a593Smuzhiyun Define CONFIG_SYS_SOC="soc" to compile arch/<arch>/cpu/<cpu>/<soc> 115*4882a593Smuzhiyun Define CONFIG_SYS_VENDOR="vendor" to compile board/<vendor>/common/* 116*4882a593Smuzhiyun and board/<vendor>/<board>/* 117*4882a593Smuzhiyun Define CONFIG_SYS_BOARD="board" to compile board/<board>/* 118*4882a593Smuzhiyun (or board/<vendor>/<board>/* if CONFIG_SYS_VENDOR is defined) 119*4882a593Smuzhiyun Define CONFIG_SYS_CONFIG_NAME="target" to include 120*4882a593Smuzhiyun include/configs/<target>.h 121*4882a593Smuzhiyun [3] Add a new entry to the board select menu in Kconfig. 122*4882a593Smuzhiyun The board select menu is located in arch/<arch>/Kconfig or 123*4882a593Smuzhiyun arch/<arch>/*/Kconfig. 124*4882a593Smuzhiyun [4] Add a MAINTAINERS file 125*4882a593Smuzhiyun It is generally placed at board/<board>/MAINTAINERS or 126*4882a593Smuzhiyun board/<vendor>/<board>/MAINTAINERS 127*4882a593Smuzhiyun [5] Add configs/<target>_defconfig 128*4882a593Smuzhiyun 129*4882a593SmuzhiyunWhen removing an obsolete board, the following steps are generally needed: 130*4882a593Smuzhiyun 131*4882a593Smuzhiyun [1] Remove configs/<target>_defconfig 132*4882a593Smuzhiyun [2] Remove include/configs/<target>.h if it is not used by any other boards 133*4882a593Smuzhiyun [3] Remove board/<vendor>/<board>/* or board/<board>/* if it is not used 134*4882a593Smuzhiyun by any other boards 135*4882a593Smuzhiyun [4] Update MAINTAINERS if necessary 136*4882a593Smuzhiyun [5] Remove the unused entry from the board select menu in Kconfig 137*4882a593Smuzhiyun [6] Add an entry to doc/README.scrapyard 138*4882a593Smuzhiyun 139*4882a593Smuzhiyun 140*4882a593SmuzhiyunTODO 141*4882a593Smuzhiyun---- 142*4882a593Smuzhiyun 143*4882a593Smuzhiyun- The option field of boards.cfg, which was used for the pre-Kconfig 144*4882a593Smuzhiyun configuration, moved to CONFIG_SYS_EXTRA_OPTIONS verbatim now. 145*4882a593Smuzhiyun Board maintainers are expected to implement proper Kconfig options 146*4882a593Smuzhiyun and switch over to them. Eventually CONFIG_SYS_EXTRA_OPTIONS will go away. 147*4882a593Smuzhiyun CONFIG_SYS_EXTRA_OPTIONS should not be used for new boards. 148*4882a593Smuzhiyun 149*4882a593Smuzhiyun- In the pre-Kconfig, a single board had multiple entries in the boards.cfg 150*4882a593Smuzhiyun file with differences in the option fields. The corresponding defconfig 151*4882a593Smuzhiyun files were auto-generated when switching to Kconfig. Now we have too many 152*4882a593Smuzhiyun defconfig files compared with the number of the supported boards. It is 153*4882a593Smuzhiyun recommended to have only one defconfig per board and allow users to select 154*4882a593Smuzhiyun the config options. 155*4882a593Smuzhiyun 156*4882a593Smuzhiyun- Move the config macros in header files to Kconfig. When we move at least 157*4882a593Smuzhiyun macros used in makefiles, we can drop include/autoconfig.mk, which makes 158*4882a593Smuzhiyun the build scripts much simpler. 159