6- Kernel configuration option writing

There are two ways of kernel clipping:

    The first: make menuconfig to enter the configuration of the graphical interface.

    The second: is to open the source code for corresponding tailoring.

Here we first introduce the cutting method of the first method: make menuconfig

  First of all, let's introduce the make menuconfig This command actually runs like this: ./scripts/kconfig/mconf arch/arm/Kconfig

  mconf: This is a parser for parsing Kconfig files

  Kconfig: It is used to generate all the options we see in make menuconfig. Of course, Kconfig is also called layer by layer, similar to makefile. Let's write a simple Kconfig file.

  First, create a Kconfig file under driver/mydriver in the directory of our previous lesson: and write the code

  1 config MY_DRIVER
   2          bool  " select mydriver " //This is an option, and it is not associated with our mydirver.c 
  3          default n //It is not selected by default, that is, if [ ] is empty in make menuconfig, if you want to choose, default y
   4 help //corresponds to help 5          in select exit help below in our make menuconfig
            IF yuo select this ,you will be happy!!! //this is the explanation description in help 

  Then save and exit the ./scripts/kconfig/mconf driver/mydriver/Kconfig file:

    You can see that our options look like this;

  We said above that Kconfig is called layer by layer, so let's open the upper Kconfig, and write the Kconfig we wrote to the upper Kconfig, so that we can directly see what our Kconfig has in the overall options when making menuconfig. generated options;

  vim ../Kconfig: The third line is the source command for the code we added. source our Kconfig      

  1 menu "Device Drivers"
  2 
  3 source "drivers/mydriver/Kconfig"
  4 
  5 source "drivers/base/Kconfig"
  6 
  7 source "drivers/connector/Kconfig"
  8 
  9 source "drivers/mtd/Kconfig"

  Finally, make menuconfig can see our options, this time we use the space button to select it, exit to save.

[liuye@LiuYe linux- 3.5 ]$> make menuconfig
scripts/kconfig/mconf Kconfig
#
# configuration written to .config
#


*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

  You can see that the configuration is written to the .config file:

  Let's open this file and search :/MY_DRIVER

1096 #
1097 # Device Drivers
1098 #
1099 CONFIG_MY_DRIVER=y
1100 
1101 #
1102 # Generic Driver Options
1103 #

  You can see: CONFIG_MY_DRIVER=y. This is the option we have written; if it is not selected, it will be as follows #CONFIG_MY_DRIVER is not set

1096 #
1097 # Device Drivers
1098 #
1099 # CONFIG_MY_DRIVER is not set
1100 
1101 #
1102 # Generic Driver Options
1103 #

  Adding a simple make menuconfig option here is done, and we will explain how to write other types of options later.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324850593&siteId=291194637