4 Kconfig is a tool used in coreboot, Linux, and many other projects as the main
5 configuration mechanism. In coreboot, it allows a developer both to select
6 which platform to build and to modify various features within the platform. The
7 Kconfig language was developed as a way to configure the Linux kernel, and is
8 still maintained as a part of the Linux kernel tree. Starting in Linux 2.5.45,
9 the ncurses based menuconfig was added, which is still used as the main
10 configuration front end in coreboot today.
12 The official Kconfig source and documentation is kept at kernel.org:
14 - [Kconfig source](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/scripts/kconfig)
15 - [Kconfig Language Documentation](https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt)
17 The advantage to using Kconfig is that it allows users to easily select the
18 high level features of the project to be enabled or disabled at build time.
19 Ultimately the Kconfig tool generates a list of values which are used by the
20 source code and Makefiles of the project. This allows the source files to
21 select features, and allows the build to determine which files should be
22 compiled and linked to the rom.
25 ## Kconfig targets in Make
26 The Kconfig program in coreboot is built from source in util/kconfig. There are
27 various targets in the makefile to build Kconfig in different ways. These give
28 the user control over how to build the platform
31 ### Front end configuration targets
32 These are the make targets that would be used to update the configuration of
34 - config - Text mode configuration tool, asks each configuration option in turn.
35 This does actually run in coreboot, but it is recommended that this not be
36 used as there is no way to save a partial config.
37 - gconfig - Graphical configuration tool based on GTK+ 2.0.
38 - menuconfig - Text mode, menu driven configuration tool.
39 - nconfig - Text mode, menu driven configuration tool.
40 - xconfig - Graphical front end based on QT.
43 ### Targets that update config files
44 These options are used to update the coreboot config files, typically .config.
45 The target file can be changed with variables in the environment or on the make
48 - defconfig - This generates a config based on another config file. Use the
49 environment variable KBUILD_DEFCONFIG to specify the base config file.
50 - oldconfig - Displays the answers to all configuration questions as it
51 generates the config.h file. If an interactive question is found that does
52 not have an answer yet, it stops and queries the user for the desired value.
53 - olddefconfig - Generates a config, using the default value for any symbols not
54 listed in the .config file.
55 - savedefconfig - Creates a ‘defconfig’ file, stripping out all of the symbols
56 that were left as default values. This is very useful for debugging, and is
57 how config files should be saved.
60 ### Targets not typically used in coreboot
61 - localmodconfig, localnoconfig, randconfig, allyesconfig, allnoconfig - These
62 are all used to generate various Kconfig files for testing.
65 ### Environment Variables that affect Kconfig
66 These variables are typically set in the makefiles or on the make command line.
68 #### Variables added to the coreboot Kconfig source
69 These variables were added to Kconfig specifically for coreboot and are not
70 included in the Linux version.
72 - KCONFIG_NEGATIVES=value. Define to show negative values in the autoconf.h file
73 (build/config.h). This is enabled in coreboot, and should not be changed.
76 #### Variables used to control the input and output config files
77 - KBUILD_DEFCONFIG=inputname of the defconfig file. This defaults to
78 ‘configs/defconfig’ and is used by the ‘defconfig’ target.
80 - DEFCONFIG=output name of the defconfig file. This defaults to ‘defconfig’
81 and is used by ‘savedefconfig’ target as the output filename.
83 - DOTCONFIG=name of the .config file. This defaults to '.config' and is used
84 by most config type targets.
87 #### Variables used by the makefiles for controlling Kconfig
88 - Kconfig=root Kconfig file. This is set to 'src/Kconfig' in the coreboot
91 - KCONFIG_CONFIG=input config file. coreboot sets this to $(DOTCONFIG).
93 - KCONFIG_AUTOHEADER=path and filename of autoconf.h file. coreboot sets this
96 - KCONFIG_DEPENDENCIES=”kbuild dependency file". This defaults to
97 auto.conf.cmd and outputs the name of all of the Kconfig files used.
99 - KCONFIG_SPLITCONFIG=”directory name for individual SYMBOL.h files”.
100 coreboot sets this to $(obj)/config.
102 - KCONFIG_WERROR=value. Define to enable warnings as errors. This is enabled
103 in coreboot, and should not be changed.
105 #### Used only for ‘make menuconfig’
106 - MENUCONFIG_MODE=single_menu. Set to "single_menu" to enable. All other
107 values disable the option. This makes submenus appear below the menu option
108 instead of opening a new screen.
110 - MENUCONFIG_COLOR=<theme>. This sets the color theme for the menu from
113 - mono => selects colors suitable for monochrome displays.
114 - blackbg => selects a color scheme with black background.
115 - classic => theme with blue background. The classic look.
116 - bluetitle => an LCD friendly version of classic. (default).
119 #### Used only for ‘make nconfig’
121 - NCONFIG_MODE=single_menu
123 Submenus appear below the menu option instead of opening a new screen.
126 #### Unused in coreboot
128 Although these variables are not used by coreboot, their values should be left
129 at the default values. Other values may have unexpected effects on the
132 - KCONFIG_SEED=randconfig seed value.
133 - KCONFIG_PROBABILITY=randconfig percent to set to y.
134 - KCONFIG_NOSILENTUPDATE=value. Define to prevent silent updates to .config
136 - KCONFIG_OVERWRITECONFIG=value. Define to prevent breaking a .config symlink.
137 - KCONFIG_TRISTATE=filename of tristate.conf file.
138 - SRCTREE=path to src directory.
139 - KCONFIG_AUTOCONFIG=path and filename of the auto.conf file.
141 coreboot sets this to $(obj)/auto.conf. Although this value is actually
142 set by coreboot, the resulting file is not used.
144 - CONFIG_=prefix for Kconfig output symbols.
146 coreboot expects this to *NOT* be set.
152 The Kconfig language has about 30 keywords, some overloaded, and some with the
153 same meaning. Whitespace may have specific meaning, for example in the 'help'
154 keyword. There are 8 logical operators for use in expressions, which allow
155 values to be set based on other values.
160 - Symbols - There are two types of symbols, "constant" and “non-constant”.
161 - Constant symbols are alphanumeric values used in expressions for
162 comparison. The Kconfig language specification says that these must be
163 surrounded by single or double quotes.
164 - Non-constant symbols are the 'config' values that are output into the
165 saved .config, auto.conf and config.h files. Non-constant symbols are
166 typically defined with the 'config' keyword, although they can also be
167 defined with the 'choice' keyword. These symbols may be used in a file's
168 expressions before they are defined. Valid characters for non-constant
169 symbols are any combination of alphanumeric characters, underscore.
170 Although “1234” is accepted as a symbol name, as is “o_o”, convention is
171 to use all uppercase words that are descriptive of the symbol's use so
172 they make sense when turned into CONFIG_NAME #defines.
174 - Expressions - An expression is a logical evaluation. It can be as simple as
175 a static 'y' or 'n', or can be a symbol. Alternatively, expressions can be
176 complex evaluations of multiple symbols using the various logical operators.
177 The Kconfig language allows these logical evaluations in several places. The
178 most common use for complex expressions is following 'if' or ‘depends on’
179 keywords, but they can also be used to set the value for a prompt or default
182 - Types - Each Kconfig symbol is one of the following types: bool, hex, int,
183 string, or tristate. The tristate type is not used for coreboot, leaving just
184 four types. As noted in the keyword summaries, a symbol must have a consistent
185 type anywhere it is defined. Also, Kconfig will simply not display a symbol
186 that has no type defined. A warning will be displayed in the terminal where
187 menuconfig was run if this happens:
188 _src/Kconfig:25:warning: config symbol defined without type_.
190 - Prompts - Input prompts are the text associated with the symbols which shown
191 to the user. The Kconfig language definition does not require surrounding the
192 prompt’s text with quotes, however it is recommended that quotes be used for
193 maximum compatibility.
195 - Menu Entries - These keyword blocks create the symbols and questions that are
196 visible in the front end.
203 The 'bool' keyword assigns a boolean type to a symbol. The allowable values for
204 a boolean type are 'n' or 'y'. The keyword can be followed by an optional prompt
205 string which makes the symbol editable in one of the configuration front ends.
209 bool \[prompt\] \[if <expr>\]
214 bool "Allow building with any toolchain"
216 depends on COMPILER_GCC
220 - Putting the prompt after the 'bool' keyword is the same as using a 'prompt'
221 keyword later. See the 'prompt' keyword for more notes.
222 - Only the first type definition for each symbol is valid. Further matching
223 definitions are fine, although unnecessary. Conflicting type definitions will
224 be ignored, and a warning will be presented on the console where the
225 configuration front end was run:
226 _warning: ignoring type redefinition of 'SYMBOL' from 'hex' to 'integer'_.
227 - Boolean symbols do not need a default and will default to ‘n’.
232 - This keyword must be within a symbol definition block, started by the
235 --------------------------------------------------------------------------------
239 This creates a selection list of one or more boolean symbols. For bools, only
240 one of the symbols can be selected, and one will be be forced to be selected,
241 either by a ‘default’ statement, or by selecting the first config option if
242 there is no default value listed.
253 default TESTCHOICE2 if TESTCHOICE_DEFAULT_2
263 bool "Choice 4" if TESTCHOICE_SHOW_4
266 config TESTCHOICE_DEFAULT_2
269 config TESTCHOICE_SHOW_4
274 default “String #1” if TESTCHOICE1
275 default “String #2” if TESTCHOICE2
276 default “String #4” if TESTCHOICE3
277 default “String #4” if TESTCHOICE4
282 - If no symbol is associated with a choice, then you can not have multiple
283 definitions of that choice. If a symbol is associated to the choice, then
284 you may define the same choice (ie. with the same entries) in another place.
285 Any selection in either location will update both choice menu selections. In
286 coreboot, the value of the symbol is always 1.
287 - As shown in the example above, the choice between bools can be used to set
288 the default for a non-bool type. This works best when the non-bool type
289 does not have an input prompt.
293 - Symbols used for 'choice' entries must have input prompts defined using the
295 - Symbols used in 'choice' entries may not be enabled with a 'select'
296 statement, they can be defaulted using a second Kconfig symbol however.
298 --------------------------------------------------------------------------------
302 This keyword defines a line of text that is displayed to the user in the
303 configuration frontend and is additionally written to the output files.
307 comment <prompt>
314 comment "I/O mapped, 8250-compatible"
315 depends on DRIVERS_UART_8250IO
320 - Comments are only valid outside of config blocks, but can be within menu and
323 --------------------------------------------------------------------------------
327 This is the keyword that starts a block defining a Kconfig symbol. The symbol
328 modifiers follow the 'config' statement.
331 config <symbol>
333 - \[bool | def_bool | int | hex | string\]
342 config SEABIOS_PS2_TIMEOUT
343 prompt "PS/2 keyboard timeout" if PAYLOAD_SEABIOS
345 depends on PAYLOAD_SEABIOS
348 Some PS/2 keyboard controllers don't respond to commands
349 immediately after powering on. This specifies how long
350 SeaBIOS will wait for the keyboard controller to become
351 ready before giving up.
355 - Non-coreboot projects also use the 'tristate' and 'def_tristate' types.
356 - Ends at the next Kconfig keyword that is not valid inside the config block:
358 menu | endmenu | if | endif | choice | config | source | comment
360 --------------------------------------------------------------------------------
364 The ‘default’ keyword assigns a value to a symbol in the case where no preset
365 value exists, i.e. the symbol is not present and assigned in .config. If there
366 is no preset value, and no ‘default’ keyword, the user will be asked to enter a
367 valid value when building coreboot.
371 default <expr> \[if <expr>\]
375 config GENERATE_MP_TABLE
376 prompt "Generate an MP table" if HAVE_MP_TABLE || DRIVERS_GENERIC_IOAPIC
378 default HAVE_MP_TABLE || DRIVERS_GENERIC_IOAPIC
380 Generate an MP table (conforming to the Intel
381 MultiProcessor specification 1.4) for this board.
385 - Kconfig defaults for symbols without a prompt *NEVER* affect existing legal
386 symbol definitions in a .config file. The default only affects the symbol if
387 there is no valid definition in a config file. This is a frequent source of
388 confusion. It’s covered again in the Tips section below.
389 - The first valid 'default' entry for a symbol is always used. Any further
390 'default' statements for a symbol are ignored. This means that the order of
391 Kconfig files is very important as the earlier files get to set the defaults
392 first. They should be sourced in the order from most specific (mainboard
393 Kconfig files) to the most generic (architecture-specific Kconfig files).
394 - If there is no 'default' entry for a symbol, it gets set to 'n', 0, 0x0, or
395 “” depending on the type, however the 'bool' type is the only type that
396 should be left without a default value.
397 - If possible, the declaration should happen before all default entries to make
398 it visible in Kconfig tools like menuconfig.
400 --------------------------------------------------------------------------------
404 ‘def_bool’ is similar to the 'bool' keyword in that it sets a symbol’s type to
405 boolean. It lets you set the type and default value at the same time, instead
406 of setting the type and the prompt at the same time. It's typically used for
407 symbols that don't have prompts.
411 def_bool <expr> \[if <expr>\]
415 config EC_GOOGLE_CHROMEEC_LPC
416 depends on EC_GOOGLE_CHROMEEC && ARCH_X86
418 select SERIRQ_CONTINUOUS_MODE
420 Google Chrome EC via LPC bus.
424 - Only the first type definition for each symbol is valid. Further matching
425 definitions are fine, although unnecessary. Conflicting type definitions will
426 be ignored, and a warning will be presented on the console where the
427 configuration front end was run:
428 _warning: ignoring type redefinition of 'SYMBOL' from 'hex' to 'integer'_.
431 - This keyword must be within a symbol definition block, started by the
434 --------------------------------------------------------------------------------
438 This defines a dependency for a menu entry, including symbols and comments. It
439 behaves the same as surrounding the menu entry with an if/endif block. If the
440 ‘depends on’ expression evaluates to false, the 'prompt' value will not be
441 printed, and defaults will not be set based on this block.
445 depends on <expr>
449 config COMMON_CBFS_SPI_WRAPPER
455 Use common wrapper to interface CBFS to SPI bootrom.
459 - Symbols that have multiple ‘depends on’ sections as above are equivalent to a
460 single ‘depends on’ statement with sections joined by &&. So the above is
461 the same as “depends on SPI_FLASH && ! ARCH_X86”.
463 --------------------------------------------------------------------------------
467 This ends a choice block. See the 'choice' keyword for more information and an
470 --------------------------------------------------------------------------------
474 This ends a block started by the 'if' keyword. See the 'if' keyword for more
475 information and an example.
477 --------------------------------------------------------------------------------
481 This ends a menu block. See the 'menu' keyword for more information and an
484 --------------------------------------------------------------------------------
488 The 'help' keyword defines the subsequent block of text as help for a config or
489 choice block. The help block is started by the 'help' keyword on a line by
490 itself, and the indentation level of the next line controls the end of the help
491 block. The help ends on the next non-blank line that has an indentation level
492 less than the indentation level of the first line following the 'help' keyword.
495 help <help text>
502 Use the GNU Compiler Collection (GCC) to build coreboot. For details
503 see http://gcc.gnu.org.
507 - Identical to the '---help---' keyword which isn’t used in coreboot.
508 - Other keywords are allowed inside the help block, and are not recognized as
509 keywords so long as the indentation rules are followed, even if they start a
514 - Only used for 'config' and 'choice' keywords.
516 --------------------------------------------------------------------------------
520 This is another symbol type specifier, specifying an unsigned integer value
521 formatted as hexadecimal.
524 hex <expr> \[if <expr>\]
528 config INTEL_PCH_UART_CONSOLE_NUMBER
529 hex "Serial IO UART number to use for console"
531 depends on INTEL_PCH_UART_CONSOLE
535 - Kconfig doesn’t complain if you don’t start the default value for a hex
536 symbol with ‘0x’, but not doing so will lead to issues. It will update 10
537 to 0x10 without warning the user.
538 - Putting the prompt text after the 'hex' keyword is the same as using a
539 'prompt' keyword later. See the 'prompt' keyword for more notes.
540 - Only the first type definition for each symbol is valid. Further matching
541 definitions are fine, although unnecessary. Conflicting type definitions will
542 be ignored, and a warning will be presented on the console where the
543 configuration front end was run:
544 _warning: ignoring type redefinition of 'SYMBOL' from 'hex' to 'integer'_.
548 - This keyword must be within a symbol definition block, started by the
550 - 'hex' type symbols must have a 'default' entry set.
552 --------------------------------------------------------------------------------
556 The 'if' keyword is overloaded, used in two different ways. The first definition
557 enables and disables various other keywords, and follows the other keyword
558 definition. This usage is shown in each of the other keywords' usage listings.
560 The second usage of the 'if' keyword is part of an if/endif block. Most items
561 within an if/endif block are not evaluated, while others, such as the 'source'
562 keyword, ignore the existence of the if/endif block completely. Symbols defined
563 within an if/endif block are still created, although their default values are
564 ignored - all values are set to 'n'.
583 default y if MAX_CPUS != 1
586 This option is used to enable certain functions to make
587 coreboot work correctly on symmetric multi processor (SMP) systems.
591 - Corresponding ‘if’ and ‘endif’ statements must exist in the same file.
593 --------------------------------------------------------------------------------
597 A type setting keyword, defines a symbol as an integer, accepting only signed
598 numeric values. The values can be further restricted with the ‘range’ keyword.
602 int <expr> \[if <expr>\]
606 config PRE_GRAPHICS_DELAY_MS
607 int "Graphics initialization delay in ms"
610 On some systems, coreboot boots so fast that connected
611 monitors (mostly TVs) won't be able to wake up fast enough
612 to talk to the VBIOS. On those systems we need to wait for a
613 bit before executing the VBIOS.
617 - Only the first type definition for each symbol is valid. Further matching
618 definitions are fine, although unnecessary. Conflicting type definitions will
619 be ignored, and a warning will be presented on the console where the
620 configuration front end was run:
621 _warning: ignoring type redefinition of 'SYMBOL' from 'hex' to 'integer'_.
625 - This keyword must be within a symbol definition block, started by the 'config'
627 - 'int' type symbols must have a default value set.
629 --------------------------------------------------------------------------------
633 The 'mainmenu' keyword sets the title or title bar of the configuration front
634 end, depending on how the configuration program decides to use it. It can only
635 be specified once and at the very beginning of the top level Kconfig file,
636 before any other statements.
640 mainmenu <prompt>
643 mainmenu "coreboot configuration"
646 - Must be the first statement in the top level Kconfig.
647 - Must only be used once in the entire Kconfig tree.
649 --------------------------------------------------------------------------------
653 The 'menu' and 'endmenu' keywords tell the configuration front end that the
654 enclosed statements are part of a group of related pieces.
669 menu "On-Chip Device Power Down Control"
670 config TEMP_POWERDOWN
671 bool "Temperature sensor power-down"
673 config SATA_POWERDOWN
674 bool "SATA power-down"
677 bool "ADC power-down"
679 config PCIE0_POWERDOWN
680 bool "PCIE0 power-down"
683 bool "MAC power-down"
685 config USB1_POWERDOWN
686 bool "USB2.0 Host Controller 1 power-down"
689 bool "IDE power-down"
694 - Must be closed by a corresponding ‘endmenu’ keyword in the same file.
696 --------------------------------------------------------------------------------
700 The 'prompt' keyword sets the text displayed for a config symbol or choice in
701 configuration front end.
705 prompt <prompt> \[if <expr>\]
709 config REALMODE_DEBUG
710 prompt "Enable debug messages for option ROM execution"
713 depends on PCI_OPTION_ROM_RUN_REALMODE
714 depends on DEFAULT_CONSOLE_LOGLEVEL_7 || DEFAULT_CONSOLE_LOGLEVEL_8
716 This option enables additional x86emu related debug
717 messages. Note: This option will increase the time to emulate a ROM.
723 - The same rules apply for menu entries defined by the 'prompt' keyword and
724 other prompt types such as those defined by the 'int' or 'string' keywords.
725 - Redefining the prompt text in multiple instances of config symbols is allowed.
726 Only the current prompt statement for a particular entry will be displayed by
727 the front end in any given location. This means that multiple mainboards can
728 set different prompt values for a symbol, and it would appear differently in
729 each mainboard’s menu. The symbol can even have multiple entries in the same
730 menu with different prompts if desired. For example, both of these would get
731 printed, and changing either entry would change the other.
734 string "Prompt value 1"
737 prompt "Prompt value 2"
739 - Although not required, it's recommended that you use quotes around prompt
741 * If the prompt is redefined inside the SAME config entry, you will get a
743 _warning: prompt redefined_.
744 For example, this is not allowed:
747 string "Prompt value 1"
748 prompt "Prompt value 2"
749 --------------------------------------------------------------------------------
753 This sets the allowable minimum and maximum entries for hex or int type config
758 range <symbol> <symbol> \[if <expr>\]
768 - Only the first definition of a range is used for any symbol. Further
769 definitions will be ignored without warning.
771 --------------------------------------------------------------------------------
775 The ‘select’ keyword is used within a bool type config block. In coreboot (and
776 other projects that don't use modules), the 'select' keyword can force an
777 unassociated bool type symbol to 'y'. When the symbol for the config block is
778 ‘y’, the ‘select’ action is taken. Otherwise the bool is unaffected.
782 select <symbol> \[if <expr>\]
789 select MEMORY_MAPPED_TPM if ARCH_X86
790 select I2C_TPM if ARCH_ARM
791 select I2C_TPM if ARCH_ARM64
793 Enable this option to enable TPM support in coreboot.
797 - Using the 'select' keyword can create logical contradictions in Kconfig, which
798 will create warnings and fail to save the .config. Following is an example of
799 an obviously invalid configuration, where selecting BOOLTEST violates the
800 ‘depends on’ of BOOLTEST2:
811 - The ‘select’ keyword only works on bool type symbols.
812 - Symbols created inside of choice blocks cannot be selected, and should be
813 enabled by using default values instead.
815 --------------------------------------------------------------------------------
819 The 'source' keyword functions much the same as an 'include' statement in c.
820 This pulls one or more files into Kconfig at the location of the 'source'
821 command. This statement is always parsed - there is no way to conditionally
822 source a file. coreboot has modified the source statement slightly to handle
823 directory globbing. The '*' character will match with any directory.
827 source <prompt>
833 prompt "Mainboard vendor"
834 default VENDOR_EMULATION
836 source "src/mainboard/*/Kconfig.name"
840 source "src/mainboard/*/Kconfig"
844 - As with all prompt values, the 'source' prompt may be enclosed in single or
845 double quotes, or left without any quotes. Using quotes is highly recommended
847 - The 'source' keyword loads files relative to the working directory where the
848 Kconfig command was run. For coreboot, this is the root coreboot directory, so
849 all source commands in the src directory need to start with ‘src/’.
850 - In coreboot's Kconfig, if a sourced file does not exist, the statement is
851 simply ignored. This is different than other versions of Kconfig.
852 - 'source' pulls a file into the Kconfig tree at the location of the keyword.
853 This allows for files containing small bits of the Kconfig tree to be pulled
854 into a larger construct. A restriction on this is that the starting/ending
855 keyword pairs must be within the same file - ‘endif’ cannot appear in a
856 different file than the ‘if’ statement that it ends. The same is true of
857 menu/endmenu and choice/endchoice pairs.
859 The coreboot Kconfig structure uses this along with globbing to build up the
860 mainboard directory. Each mainboard’s Kconfig.name file contains just two
861 statements that generate a list of all the platform names:
863 config BOARD_AMD_NORWICH
868 - 'source' keywords always load in the specified file or files. There is no way
869 to optionally pull in a file. Putting an if/endif block around a source
870 command does not affect the source command, although it does affect the
871 content. To avoid confusion, use if/endif blocks inside sourced files to
872 remove their content if necessary.
874 --------------------------------------------------------------------------------
878 The last of the symbol type assignment keywords. 'string' allows a text value to
883 string <expr> \[if <expr>\]
887 config BOOTBLOCK_SOUTHBRIDGE_INIT
889 default "southbridge/amd/pi/hudson/bootblock.c"
891 config HUDSON_GEC_FWM_FILE
892 string "GEC firmware path and filename"
893 depends on HUDSON_GEC_FWM
897 - Putting the prompt after the 'string' keyword is the same as using a 'prompt'
898 keyword later. See the prompt keyword for more notes.
899 - Only the first type definition for each symbol is valid. Further matching
900 definitions are fine, although unnecessary. Conflicting type definitions will
901 be ignored, and a warning will be presented on the console where the
902 configuration front end was run:
903 _warning: ignoring type redefinition of 'SYMBOL' from 'hex' to 'string'_.
904 - Some characters may not get interpreted correctly when inside a string entry
905 depending on how they are used - inside a C file, inside a Makefile, passed
906 through a Makefile to a C file, or something else. It may be necessary to
907 escape the characters at times. Because this is very dependent upon how the
908 symbol is actually used, a definitive guide cannot be given here.
909 - 'string' type variables do NOT need a default, and will default to the
914 - This keyword must be within a symbol definition block, started by the 'config'
917 --------------------------------------------------------------------------------
922 ### Keywords not used in coreboot at the time of writing:
937 ## Build files generated by Kconfig
941 The config.h file is a very basic header file made up of a list of #define
944 #define SYMBOL NAME XXX
948 - bool, int, and hex types - Every symbol of one of these types created in the
949 Kconfig tree is defined. It doesn’t matter whether they’re in an if/endif
950 block, or have a ‘depends on’ statement - they ALL end up being defined in
952 - String - Only string types that actually have a value associated with them
955 The config.h file uses 0 and 1 to represent Kconfig's 'n' and 'y' values
956 respectively. String values are placed inside double quotes.
958 The name of the file is controlled by the $KCONFIG_AUTOHEADER environment
959 variable, which is set to $(obj)/config.h by the coreboot makefiles.
961 The prefix used for the symbols is controlled by the $CONFIG_ environment
962 variable. This is not set in coreboot, which uses the default CONFIG_ prefix
963 for all of its symbols.
965 The coreboot makefile forces the config.h file to be included into all coreboot
966 C files. This is done in Makefile.mk on the compiler command line using the
967 “-include $(obj)/config.h” command line option.
969 Example of various symbol types in the config.h file:
971 #define CONFIG_BOOTBLOCK_SOURCE "bootblock_simple.c" # String
972 #define CONFIG_CBFS_SIZE 0x00300000 # Hex
973 #define CONFIG_TTYS0_BAUD 115200 # Int
974 #define CONFIG_HAVE_ACPI_TABLES 1 # Bool enabled
975 #define CONFIG_EXPERT 0 # Bool disabled
976 #define CONFIG_NORTHBRIDGE_INTEL_I440LX 0 # Bool excluded
981 The .config file in the root directory is used as the input file, but also by
982 the makefiles to set variable values. The main difference is that it does not
983 contain all of the symbols. It excludes symbols defined in an if/endif block
984 whose expression evaluated as false. Note that the symbol
985 CONFIG_NORTHBRIDGE_INTEL_I440LX shown in the config.h example above is not
986 present in the .config file.
988 In addition, the .config file below contains the 'comment' prompt text from the
989 Kconfig, separating the blocks.
992 CONFIG_BOOTBLOCK_SOURCE="bootblock_simple.c" # String
993 CONFIG_CBFS_SIZE=0x00300000 # Hex
994 CONFIG_TTYS0_BAUD=115200 # Int
995 CONFIG_HAVE_ACPI_TABLES=y # Bool enabled
996 # CONFIG_EXPERT is not set # Bool disabled
998 This file is included directly by the makefile, and sets the CONFIG symbols so
999 that they are available during the build process.
1004 Although the controlling variable for the auto.conf filename,
1005 KCONFIG_AUTOCONFIG, is set in the coreboot makefiles, the auto.conf file itself
1006 is not used by coreboot. This file has the same syntax and structure as the
1007 .config file, but contains all symbols in the Kconfig tree, including those that
1008 are not enabled, or are excluded by if/endif blocks, or the 'depends on'
1009 keyword. The kconfig tool could be updated to not generate this file, but since
1010 it's not hurting anything, it's still being generated.
1014 ## Defconfig or Miniconfig files
1016 Miniconfig files are the standard .config files with all of the symbols which
1017 are set to their default values stripped out. These files are very useful for
1018 debugging your config, as well as being the best way to store your .config file.
1019 If you store your config as a full config file, it will be much harder to
1020 maintain. Any Kconfig symbols with updated default values will retain their old
1021 values, and any symbols which have been removed will still remain in the file.
1022 Storing full config files just generally leads to a lot more maintenance than
1023 storing miniconfig files.
1025 The easiest way to generate the miniconfig file is by running
1027 make savedefconfig DOTCONFIG=.config DEFCONFIG=[output file]
1029 DEFCONFIG defaults to ‘defconfig’, DOTCONFIG defaults to ‘.config’.
1032 To turn the miniconfig back into a full config file, use one of the two targets:
1034 make olddefconfig DOTCONFIG=[input/output file]
1038 make defconfig KBUILD_DEFCONFIG=[input file] DOTCONFIG=[output file]
1040 In both of these cases, DOTCONFIG defaults to .config.
1044 ## Editing and updating saved .config files
1047 ### Don’t save full config files
1049 Save miniconfig files, as mentioned in the previous section.
1052 ### Disable values with ‘# CONFIG_SYMBOL is not set’
1054 A common mistake when trying to disable a value is to edit the .config file and
1055 change it from ‘CONFIG_SYMBOL=y’ to ‘CONFIG_SYMBOL=n’, but this doesn’t
1056 correctly disable the symbol. If the default value for the symbol is ‘n’ to
1057 begin with, this isn’t an issue - the symbol just gets ignored, and the default
1058 value is used. The problem is where the default for the symbol is ‘y’. When
1059 the bad entry in the .config file gets ignored, the value is set back to ‘y’,
1060 leading to much frustration.
1062 Always disable the Kconfig symbols in the .config file with the syntax:
1064 # CONFIG_SYMBOL is not set
1066 ### Only the LAST instance of a symbol is used
1068 When reading a saved .config file, Kconfig uses the LAST instance of a symbol
1069 that it comes across, and ignores any previous instances. This can be used to
1070 override symbols in a saved .config file by appending the new value to a config
1075 A .config file that contains these two lines:
1077 # CONFIG_BOOLTEST is not set
1080 After running ‘make olddefconfig’, ends up with the value:
1084 A case where this can be used is by a making a script to create two versions of
1085 a coreboot rom for a single platform. The first ROM could be built with serial
1086 console disabled, and the second ROM, built as a debug version, could have
1087 serial console enabled by overriding the "CONFIG_CONSOLE_SERIAL" symbol, and
1088 setting it to enabled.
1090 ## General Kconfig Tips and Notes
1092 ### Default values for config options
1094 The FIRST valid default that the Kconfig parser comes across will be used for
1095 each symbol. This means that the organization of the tree is very important.
1096 The structure should go from most specific at the top of the Kconfig tree to the
1097 most general later in the tree. In coreboot, the mainboard directories get
1098 loaded first, as they are sourced very early in the src/Kconfig file. Chipset
1099 Kconfig files get sourced later, and the architecture specific Kconfig files get
1100 sourced even later. This allows the mainboards to set their defaults early,
1101 overriding the default values set in chipset or architecture.
1103 Due to this mechanism, a default defined early cannot be changed by a default
1104 set in a later Kconfig file. There are ways around this, involving 'depends on'
1105 statements, but they add additional variables which are generally just used
1106 internal to Kconfig.
1109 ### Select statement usage
1111 The 'select' keyword forces the value of a symbol with a bool type to 'y'. It
1112 overrides any dependencies of the symbol, so using it carelessly can lead to
1113 unpredictable results.
1117 ### All bool, int, and hex Kconfig symbols are ALWAYS defined in the C code
1119 All bool, int, and hex Kconfig symbols are ALWAYS defined in the C code if they
1120 are in a sourced Kconfig - do NOT use #ifdef CONFIG_SYMBOL
1122 String symbols are the exception. All others (int, hex, etc.) are always
1123 defined in config.h. Never use an #ifdef statement for a Kconfig symbol other
1124 than strings in C to determine whether the symbol is enabled or disabled. So
1125 long as the symbol is in ANY sourced Kconfig file, it will be defined. Even if
1126 the symbol is only inside of an if/endif block where the if expression evaluates
1127 as false, the symbol STILL gets defined in the config.h file (though not in the
1130 Use \#if CONFIG(SYMBOL) to be sure (it returns false for undefined symbols
1131 and defined-to-0 symbols alike).
1135 ### Symbols with prompts use defaults *ONLY* when initially created or enabled.
1137 Symbols with a prompt which may be user-modified are NOT updated to default
1138 values when changing between platforms or modifying other symbols. There are
1139 only two times the default values are used:
1140 1. When a config is initially created.
1141 2. When a dependency which had previously kept the symbol from being active
1142 changes to allowing it to be active.
1144 Because of this, starting with a saved .config for one platform and updating it
1145 for another platform can lead to very different results than creating a platform
1150 ### Symbols with no prompt will be the default value (unless 'select' is used).
1152 Symbols that do not have a prompt will always use the first valid default value
1153 specified in Kconfig. They cannot be updated, even if they are modified in a
1154 saved .config file. As always, a 'select' statement overrides any specified
1155 'default' or 'depends on' statement.
1158 ## Differences between coreboot's Kconfig and other Kconfig implementations.
1160 - coreboot has added the glob operator '*' for the 'source' keyword.
1161 - coreboot’s Kconfig always defines variables except for strings. In other
1162 Kconfig implementations, bools set to false/0/no are not defined.
1165 ## Kconfig Editor Highlighting
1169 vim has syntax highlighting for Kconfig built in (or at least as a part of
1170 vim-common), but most editors do not.
1175 https://github.com/martinlroth/wordfiles/blob/master/kconfig.uew
1181 https://github.com/martinlroth/language-kconfig
1186 The Kconfig utility does some basic syntax checking on the Kconfig tree.
1187 Running "make oldconfig" will show any errors that the Kconfig utility
1190 ### util/kconfig_lint
1192 Because the Kconfig utility is relatively forgiving, and ignores issues that a
1193 developer might be interested in, kconfig_lint, another Kconfig checker has been
1196 The file kconfig_lint and its associated readme can be found in the coreboot
1197 utils/lint directory. It is useful for parsing the Kconfig tree, and for
1198 showing warnings, errors, and notes about coreboot’s Kconfig files.
1201 kconfig_lint <options>
1202 -o|--output=file Set output filename
1203 -p|--print Print full output
1204 -e|--errors_off Don't print warnings or errors
1205 -w|--warnings_off Don't print warnings
1206 -n|--notes Show minor notes
1207 --path=dir Path to top level kconfig
1208 -c|--config=file Filename of config file to load
1209 -G|--no_git_grep Use standard grep tools instead of git grep
1212 The -p option is very useful for debugging Kconfig issues, because it reads all
1213 of the Kconfig files in the order that the Kconfig tools would read them, and
1214 prints it out, along with where each line came from and which menu it appears
1218 This work is licensed under the Creative Commons Attribution 4.0 International
1219 License. To view a copy of this license, visit
1220 https://creativecommons.org/licenses/by/4.0/ or send a letter to Creative
1221 Commons, PO Box 1866, Mountain View, CA 94042, USA.
1223 Code examples snippets are licensed under GPLv2, and are used here under fair