Home >Operation and Maintenance >Linux Operation and Maintenance >Kernel configuration knowledge that a Linux driver engineer must know
There are many Linux kernel source codes, thousands of configuration options, and the configuration is quite large complex.
In order to better choose the functional configuration you want, the Linux kernel source code organizes a configuration system;
The configuration system consists of three parts:
Makefile
: Responsible for the overall configuration compilationKconfig
: The source of configuration optionsThis configuration system is the graphical interface displayed by executing make menuconfig
:
Source of kernel configuration options The file is Kconfig
file;
The configuration source file of the main option is: arch/$(ARCH)/Kconfig
file;
mainKconfig
file calls the Kconfig
files in other directories, and the Kconfig
files in other directories call the Kconfig
in subdirectories at all levels. file to form a tree-like configuration option;
For example: in drivers/net/usb/Kconfig, DM9601 menu:
config USB_NET_DM9601
is the menu item; below the menu item is the attribute of the menu;
Menus all start with config
, with spaces in the middle, and the menu items are in capital letters.
tristate
: Indicates prompt information, a string displayed in the configuration menu : Indicates the dependent option (this option can only be selected when the dependent option is selected)
: Indicates that after this menu is selected, it will automatically Selected menu
: Help text;
Kconfig syntax detailed reference: Documentation/ kbuild/kconfig-languages.txt
kernel source code Generate .config file
in the top directory;
.config file, we can see the following content:
"Davicom DM96xx based USB 10/100 ethernet device" option is selected in the configuration, and "
CONFIG_USB_NET_DM9601=" will be generated in the .config
file. y" configuration information; if it is not selected, it will be commented out with "#";
is the same as Kconfig
, there is a # at the top level and in each subdirectory. ##MakefileFile. Its functions are as follows:
is responsible for configuring and compiling the entire linux kernel;
Read the
.config file and compile the kernel according to the configuration options of the
.config file;
Recursive Traverse all subdirectories in the kernel source code and compile all target files;
files in each subdirectory, these
MakefileThe file will use the information in the
.config file to compile the corresponding file;
Example in Makefile:
obj-$(CONFIG_USB_NET_DM9601) = dm9601.o
Equivalent to:
obj-y = dm9601.o
obj-y
means to compile the dm9601.o
target file into the kernel, dm9601 The .o
target file should be compiled from the dm9601.c
or dm9601.S
file; means compiling the target file into a module
defconfig file. When loading the configuration, you only need to execute
make xxx_defconfig, and then a
.config file will be generated. That means the configuration is loaded.
In the daily development process, for modified .config
, the .config
copy is usually overwritten with the original xxx_defconfig
, and then the code is uploaded.
The above is the detailed content of Kernel configuration knowledge that a Linux driver engineer must know. For more information, please follow other related articles on the PHP Chinese website!