README.kconfig 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. Here are some worth-mentioning configuration targets.
  13. - silentoldconfig
  14. This target updates .config, include/generated/autoconf.h and
  15. include/configs/* as in Linux. In U-Boot, it also does the following
  16. for the compatibility with the old configuration system:
  17. * create a symbolic link "arch/${ARCH}/include/asm/arch" pointing to
  18. the SoC/CPU specific header directory
  19. * create include/config.h
  20. * create include/autoconf.mk
  21. * create spl/include/autoconf.mk (SPL and TPL only)
  22. * create tpl/include/autoconf.mk (TPL only)
  23. If we could completely switch to Kconfig in a long run
  24. (i.e. remove all the include/configs/*.h), those additional processings
  25. above would be removed.
  26. - defconfig
  27. In U-Boot, "make defconfig" is a shorthand of "make sandbox_defconfig"
  28. - <board>_defconfig
  29. Now it works as in Linux.
  30. The prefixes such as "+S:" in *_defconfig are deprecated.
  31. You can simply remove the prefixes. Do not add them for new boards.
  32. - <board>_config
  33. This does not exist in Linux's Kconfig.
  34. "make <board>_config" works the same as "make <board>_defconfig".
  35. Prior to Kconfig, in U-Boot, "make <board>_config" was used for the
  36. configuration. It is still supported for backward compatibility, so
  37. we do not need to update the distro recipes.
  38. The other configuration targets work as in Linux Kernel.
  39. Migration steps to Kconfig
  40. --------------------------
  41. Prior to Kconfig, the C preprocessor based board configuration had been used
  42. in U-Boot.
  43. Although Kconfig was introduced and some configs have been moved to Kconfig,
  44. many of configs are still defined in C header files. It will take a very
  45. long term to move all of them to Kconfig. In the interim, the two different
  46. configuration infrastructures should coexist.
  47. The configuration files are generated by both Kconfig and the old preprocessor
  48. based configuration as follows:
  49. Configuration files for use in C sources
  50. - include/generated/autoconf.h (generated by Kconfig for Normal)
  51. - include/configs/<board>.h (exists for all boards)
  52. Configuration file for use in makefiles
  53. - include/config/auto.conf (generated by Kconfig)
  54. - include/autoconf.mk (generated by the old config for Normal)
  55. - spl/include/autoconfig.mk (generated by the old config for SPL)
  56. - tpl/include/autoconfig.mk (generated by the old config for TPL)
  57. When adding a new CONFIG macro, it is highly recommended to add it to Kconfig
  58. rather than to a header file.
  59. Conversion from boards.cfg to Kconfig
  60. -------------------------------------
  61. Prior to Kconfig, boards.cfg was a primary database that contained Arch, CPU,
  62. SoC, etc. of all the supported boards. It was deleted when switching to
  63. Kconfig. Each field of boards.cfg was converted as follows:
  64. Status -> "S:" entry of MAINTAINERS
  65. Arch -> CONFIG_SYS_ARCH defined by Kconfig
  66. CPU -> CONFIG_SYS_CPU defined by Kconfig
  67. SoC -> CONFIG_SYS_SOC defined by Kconfig
  68. Vendor -> CONFIG_SYS_VENDOR defined by Kconfig
  69. Board -> CONFIG_SYS_BOARD defined by Kconfig
  70. Target -> File name of defconfig (configs/<target>_defconfig)
  71. Options -> CONFIG_SYS_EXTRA_OPTIONS defined by Kconfig
  72. Maintainers -> "M:" entry of MAINTAINERS
  73. Tips to add/remove boards
  74. -------------------------
  75. When adding a new board, the following steps are generally needed:
  76. [1] Add a header file include/configs/<target>.h
  77. [2] Make sure to define necessary CONFIG_SYS_* in Kconfig:
  78. Define CONFIG_SYS_CPU="cpu" to compile arch/<arch>/cpu/<cpu>
  79. Define CONFIG_SYS_SOC="soc" to compile arch/<arch>/cpu/<cpu>/<soc>
  80. Define CONFIG_SYS_VENDOR="vendor" to compile board/<vendor>/common/*
  81. and board/<vendor>/<board>/*
  82. Define CONFIG_SYS_BOARD="board" to compile board/<board>/*
  83. (or board/<vendor>/<board>/* if CONFIG_SYS_VENDOR is defined)
  84. Define CONFIG_SYS_CONFIG_NAME="target" to include
  85. include/configs/<target>.h
  86. [3] Add a new entry to the board select menu in Kconfig.
  87. The board select menu is located in arch/<arch>/Kconfig or
  88. arch/<arch>/*/Kconfig.
  89. [4] Add a MAINTAINERS file
  90. It is generally placed at board/<board>/MAINTAINERS or
  91. board/<vendor>/<board>/MAINTAINERS
  92. [5] Add configs/<target>_defconfig
  93. When removing an obsolete board, the following steps are generally needed:
  94. [1] Remove configs/<target>_defconfig
  95. [2] Remove include/configs/<target>.h if it is not used by any other boards
  96. [3] Remove board/<vendor>/<board>/* or board/<board>/* if it is not used
  97. by any other boards
  98. [4] Update MAINTAINERS if necessary
  99. [5] Remove the unused entry from the board select menu in Kconfig
  100. [6] Add an entry to doc/README.scrapyard
  101. TODO
  102. ----
  103. - The option field of boards.cfg, which was used for the pre-Kconfig
  104. configuration, moved to CONFIG_SYS_EXTRA_OPTIONS verbatim now.
  105. Board maintainers are expected to implement proper Kconfig options
  106. and switch over to them. Eventually CONFIG_SYS_EXTRA_OPTIONS will go away.
  107. CONFIG_SYS_EXTRA_OPTIONS should not be used for new boards.
  108. - In the pre-Kconfig, a single board had multiple entries in the boards.cfg
  109. file with differences in the option fields. The corresponding defconfig
  110. files were auto-generated when switching to Kconfig. Now we have too many
  111. defconfig files compared with the number of the supported boards. It is
  112. recommended to have only one defconfig per board and allow users to select
  113. the config options.
  114. - Move the config macros in header files to Kconfig. When we move at least
  115. macros used in makefiles, we can drop include/autoconfig.mk, which makes
  116. the build scripts much simpler.