README.kconfig 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. Kconfig in U-Boot
  2. =================
  3. This document describes the configuration infrastructure of U-Boot.
  4. The conventional configuration was replaced by Kconfig at v2014.10-rc1 release.
  5. Language Specification
  6. ----------------------
  7. Kconfig originates in Linux Kernel.
  8. See the file "Documentation/kbuild/kconfig*.txt" in your Linux Kernel
  9. source directory for a basic specification of Kconfig.
  10. Difference from Linux's Kconfig
  11. -------------------------------
  12. The biggest difference between Linux Kernel and U-Boot in terms of the
  13. configuration is that U-Boot has to configure multiple boot images per board:
  14. Normal, SPL, TPL.
  15. Kconfig functions need to be expanded for U-Boot to handle multiple images.
  16. The files scripts/kconfig/* were imported from Linux Kernel and adjusted
  17. for that purpose.
  18. See below for how each configuration target works in U-Boot:
  19. - config, nconfig, menuconfig, xconfig, gconfig
  20. These targets are used to configure Normal and create (or modify) the
  21. .config file. For SPL configuration, the configutation targets are prefixed
  22. with "spl/", for example "make spl/config", "make spl/menuconfig", etc.
  23. Those targets create or modify the spl/.config file. Likewise, run
  24. "make tpl/config", "make tpl/menuconfig", etc. for TPL.
  25. - silentoldconfig
  26. This target updates .config, include/generated/autoconf.h and
  27. include/configs/*. In U-Boot, the same thing is done for SPL, TPL,
  28. if supported by the target board. Depending on whether CONFIG_SPL and
  29. CONFIG_TPL are defined, "make silentoldconfig" iterates three times at most
  30. changing the work directory.
  31. To sum up, "make silentoldconfig" possibly updates:
  32. - .config, include/generated/autoconf.h, include/config/*
  33. - spl/.config, spl/include/generated/autoconf.h, spl/include/config/*
  34. (in case CONFIG_SPL=y)
  35. - tpl/.config, tpl/include/generated/autoconf.h, tpl/include/config/*
  36. (in case CONFIG_TPL=y)
  37. - defconfig, <board>_defconfig
  38. The target "<board>_defconfig" is used to create the .config based on the
  39. file configs/<board>_defconfig. The "defconfig" target is the same
  40. except it checks for a file specified with KBUILD_DEFCONFIG environment.
  41. Note:
  42. The defconfig files are placed under the "configs" directory,
  43. not "arch/$(ARCH)/configs". This is because "ARCH" is not necessarily
  44. given from the command line for the U-Boot configuration and build.
  45. The defconfig file format in U-Boot has the special syntax; each line has
  46. "<condition>:" prefix to show which image(s) the line is valid for.
  47. For example,
  48. CONFIG_FOO=100
  49. S:CONFIG_FOO=200
  50. T:CONFIG_FOO=300
  51. ST:CONFIG_BAR=y
  52. +S:CONFIG_BAZ=y
  53. +T:CONFIG_QUX=y
  54. +ST:CONFIG_QUUX=y
  55. Here, the "<condition>:" prefix is one of:
  56. None - the line is valid only for Normal image
  57. S: - the line is valid only for SPL image
  58. T: - the line is valid only for TPL image
  59. ST: - the line is valid for SPL and TPL images
  60. +S: - the line is valid for Normal and SPL images
  61. +T: - the line is valid for Normal and TPL images
  62. +ST: - the line is valid for Normal, SPL and TPL images
  63. So, if neither CONFIG_SPL nor CONFIG_TPL is defined, the defconfig file
  64. has no "<condition>:" part and therefore has the same form as in Linux.
  65. From the example defconfig shown above, three separete configuration sets
  66. are generated and used for creating .config, spl/.config and tpl/.config.
  67. - Input for the default configuration of Normal
  68. CONFIG_FOO=100
  69. CONFIG_BAZ=y
  70. CONFIG_QUX=y
  71. CONFIG_QUUX=y
  72. - Input for the default configuration of SPL
  73. CONFIG_FOO=200
  74. CONFIG_BAR=y
  75. CONFIG_BAZ=y
  76. CONFIG_QUUX=y
  77. - Input for the default configuration of TPL
  78. CONFIG_FOO=300
  79. CONFIG_BAR=y
  80. CONFIG_QUX=y
  81. CONFIG_QUUX=y
  82. - savedefconfig
  83. This is the reverse operation of "make defconfig". If neither CONFIG_SPL
  84. nor CONFIG_TPL is defined in the .config file, it works like "savedefconfig"
  85. in Linux Kernel: creates the minimal set of config based on the .config
  86. and saves it into the "defconfig" file. If CONFIG_SPL (and CONFIG_TPL) is
  87. defined, the common lines among .config, spl/.config (and tpl/.config) are
  88. coalesced together with "<condition:>" prefix for each line as shown above.
  89. This file can be used as an input of "defconfig" target.
  90. - <board>_config
  91. This does not exist in Linux's Kconfig.
  92. Prior to Kconfig, in U-Boot, "make <board>_config" was used for the
  93. configuration. It is still supported for backward compatibility and
  94. its behavior is the same as "make <board>_defconfig".
  95. Migration steps to Kconfig
  96. --------------------------
  97. Prior to Kconfig, the C preprocessor based board configuration had been used
  98. in U-Boot.
  99. Although Kconfig was introduced and some configs have been moved to Kconfig,
  100. many of configs are still defined in C header files. It will take a very
  101. long term to move all of them to Kconfig. In the interim, the two different
  102. configuration infrastructures should coexist.
  103. The configuration files are generated by both Kconfig and the old preprocessor
  104. based configuration as follows:
  105. Configuration files for use in C sources
  106. - include/generated/autoconf.h (generated by Kconfig for Normal)
  107. - spl/include/generated/autoconf.h (generated by Kconfig for SPL)
  108. - tpl/include/generated/autoconf.h (generated by Kconfig for TPL)
  109. - include/configs/<board>.h (exists for all boards)
  110. Configuration file for use in makefiles
  111. - include/config/auto.conf (generated by Kconfig for Normal)
  112. - spl/include/config/auto.conf (generated by Kconfig for SPL)
  113. - tpl/include/config/auto.conf (generated by Kconfig for TPL)
  114. - include/autoconf.mk (generated by the old config for Normal)
  115. - spl/include/autoconfig.mk (generated by the old config for SPL)
  116. - tpl/include/autoconfig.mk (generated by the old config for TPL)
  117. When adding a new CONFIG macro, it is highly recommended to add it to Kconfig
  118. rather than to a header file.
  119. Conversion from boards.cfg to Kconfig
  120. -------------------------------------
  121. Prior to Kconfig, boards.cfg was a primary database that contained Arch, CPU,
  122. SoC, etc. of all the supported boards. It was deleted when switching to
  123. Kconfig. Each field of boards.cfg was converted as follows:
  124. Status -> "S:" entry of MAINTAINERS
  125. Arch -> CONFIG_SYS_ARCH defined by Kconfig
  126. CPU -> CONFIG_SYS_CPU defined by Kconfig
  127. SoC -> CONFIG_SYS_SOC defined by Kconfig
  128. Vendor -> CONFIG_SYS_VENDOR defined by Kconfig
  129. Board -> CONFIG_SYS_BOARD defined by Kconfig
  130. Target -> File name of defconfig (configs/<target>_defconfig)
  131. Options -> CONFIG_SYS_EXTRA_OPTIONS defined by Kconfig
  132. Maintainers -> "M:" entry of MAINTAINERS
  133. Tips to add/remove boards
  134. -------------------------
  135. When adding a new board, the following steps are generally needed:
  136. [1] Add a header file include/configs/<target>.h
  137. [2] Make sure to define necessary CONFIG_SYS_* in Kconfig:
  138. Define CONFIG_SYS_CPU="cpu" to compile arch/<arch>/cpu/<cpu>
  139. Define CONFIG_SYS_SOC="soc" to compile arch/<arch>/cpu/<cpu>/<soc>
  140. Define CONFIG_SYS_VENDOR="vendor" to compile board/<vendor>/common/*
  141. and board/<vendor>/<board>/*
  142. Define CONFIG_SYS_BOARD="board" to compile board/<board>/*
  143. (or board/<vendor>/<board>/* if CONFIG_SYS_VENDOR is defined)
  144. Define CONFIG_SYS_CONFIG_NAME="target" to include
  145. include/configs/<target>.h
  146. [3] Add a new entry to the board select menu in Kconfig.
  147. The board select menu is located in arch/<arch>/Kconfig or
  148. arch/<arch>/*/Kconfig.
  149. [4] Add a MAINTAINERS file
  150. It is generally placed at board/<board>/MAINTAINERS or
  151. board/<vendor>/<board>/MAINTAINERS
  152. [5] Add configs/<target>_defconfig
  153. When removing an obsolete board, the following steps are generally needed:
  154. [1] Remove configs/<target>_defconfig
  155. [2] Remove include/configs/<target>.h if it is not used by any other boards
  156. [3] Remove board/<vendor>/<board>/* or board/<board>/* if it is not used
  157. by any other boards
  158. [4] Update MAINTAINERS if necessary
  159. [5] Remove the unused entry from the board select menu in Kconfig
  160. [6] Add an entry to doc/README.scrapyard
  161. TODO
  162. ----
  163. - The option field of boards.cfg, which was used for the pre-Kconfig
  164. configuration, moved to CONFIG_SYS_EXTRA_OPTIONS verbatim now.
  165. Board maintainers are expected to implement proper Kconfig options
  166. and switch over to them. Eventually CONFIG_SYS_EXTRA_OPTIONS will go away.
  167. CONFIG_SYS_EXTRA_OPTIONS should not be used for new boards.
  168. - In the pre-Kconfig, a single board had multiple entries in the boards.cfg
  169. file with differences in the option fields. The correspoing defconfig files
  170. were auto-generated when switching to Kconfig. Now we have too many
  171. defconfig files compared with the number of the supported boards. It is
  172. recommended to have only one defconfig per board and allow users to select
  173. the config options.
  174. - Move the config macros in header files to Kconfig. When we move at least
  175. macros used in makefiles, we can drop include/autoconfig.mk, which makes
  176. the build scripts much simpler.