Home > Operation and Maintenance > Linux Operation and Maintenance > Kernel configuration knowledge that a Linux driver engineer must know

Kernel configuration knowledge that a Linux driver engineer must know

Release: 2023-07-31 15:51:41
forward
1555 people have browsed it

Composition of the Linux kernel configuration system

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 compilation
  • Kconfig: The source of configuration options
  • Configuration Menu

This configuration system is the graphical interface displayed by executing make menuconfig:

Kernel configuration knowledge that a Linux driver engineer must know

Kernel Kconfig file

Kconfig hierarchy

Source of kernel configuration options The file is Kconfig file;

The configuration source file of the main option is: arch/$(ARCH)/Kconfigfile;

The

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;

Kconfig syntax introduction

For example: in drivers/net/usb/Kconfig, DM9601 menu:

Kernel configuration knowledge that a Linux driver engineer must know

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
  • ## depends: Indicates the dependent option (this option can only be selected when the dependent option is selected)
  • select: Indicates that after this menu is selected, it will automatically Selected menu
  • Help : Help text;
Kconfig syntax detailed reference: Documentation/ kbuild/kconfig-languages.txt

.config file

After the kernel configuration is completed, it will be in the

kernel source code Generate .config file in the top directory;

Open the

.config file, we can see the following content:

Kernel configuration knowledge that a Linux driver engineer must know
Here the

"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 "#";

Kernel Makefile file

is the same as Kconfig, there is a # at the top level and in each subdirectory. ##MakefileFile. Its functions are as follows:

  • Top-level
    Makefile is responsible for configuring and compiling the entire linux kernel;
  • Top-level
    MakefileRead the .config file and compile the kernel according to the configuration options of the .config file;
  • Top-level
    makfile Recursive Traverse all subdirectories in the kernel source code and compile all target files;
  • There are
    Mekefile files in each subdirectory, these MakefileThe file will use the information in the .config file to compile the corresponding file;

Example in Makefile:

Kernel configuration knowledge that a Linux driver engineer must know

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;
  • ##obj-m means compiling the target file into a module

How to load the kernel configuration

Usually each manufacturer has its own

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!

Related labels:
source:嵌入式Linux充电站
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template