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