Bootstrap

配置内核Kconfig语法 和 make menuconfig

加载流程分析
kconfig --> make menuconfig --> .config --> auto.conf autoconf.h

图形界面的make menuconfig加载的是kconfig,通常我们会编写kconfig语法来添加menuconfig图形界面的选择项,然后会生成.config,一般在arch/arm/make_xxxdeconfig会有默认,这个其实是默认加载项,如果想用自己的为默认加载,把生成的.config拷贝到此目录下即可,内核中所有文件都会引用include/config/auto.conf,并且内核中所有代码都会包含include/generated/autoconf.h此文件。

config语法
  • config
    config symbol
    config options

config是关键字,表示一个配置选项的开始;紧跟着的是配置选项的名称,省略了前缀"CONFIG_"。

config TMPFS_POSIX_ACL
bool “Tmpfs POSIX Access Control Lists”
​ depends on TMPFS
​ select GENERIC_ACL
​ help
POSIX Access Control Lists (ACLs) support permissions for users and
groups beyond the owner/group/world scheme.
To learn more about Access Control Lists, visit the POSIX ACLs for
Linux website http://acl.bestbits.at/.
解析:config是关键字,表示一个配置选项的开始;紧跟着的TMPFS_POSIX_ACL是配置选项的名称,省略了前缀"CONFIG_"
bool表示变量类型,即"CONFIG_ TMPFS_POSIX_ACL "的类型,有5种类型:bool、 tristate、string、hex和int,其中tristate和string是基本的类型
​ bool变量的值: y和n
tristate变量的值: y、n和m (在make menuconfig图形界面中分别是 * , 空格, m)
​ string变量的值: 字符串
​ bool之后的字符串“Tmpfs POSIX Access Control Lists”是提示信息,在配置界面中上下移动光标选中它时,就可以通过按空格或回车键来设置CONFIG_ TMPFS_POSIX_ACL的值。
depends on:表示依赖于XXX,“depends on TMPFS”表示只有当TMPFS配置选项被选中时,当前配置选项的提示信息才会出现,才能设置当前配

  • menuconfig
    menuconfig symbol
    config options
    此关键字和前面的关键字很相似,但它在前面的基础上要求所有的子选项作为独立的行显示。

例如,在uplooking下创建了kconfig 文件修要在上一级目录的kconfig文件

cd /opt/UEA_10_08/s5p6818sdk_lzy1/Linux/src/linux-3.4/drivers/uplooking
vim ../Kconfig
# 在 source "drivers/base/Kconfig" 下面添加
source "drivers/uplooking/Kconfig
实例

menuconfig讲解

menuconfig UPLOOKING_MENU
  bool "uplooking menu"
  default y
  help
  If select uplooking menu display uplooking ops

在这里插入图片描述
在这里插入图片描述menu -> tristate、string、int(depend on)、

if UPLOOKING_MENU
  menu "uplooking"
    config UPLOOKING_TRISTATE
      tristate "this is uplooking tristate"
      default m
      help
      If .......

    config UPLOOKING_STRING
      string "this is uplooking string"
      default "this is string"
      help
      If .......

    config UPLOOKING_INT
      int "uplooing int"
      default 100
      depends on UPLOOKING_TRISTATE
      help
      If .......

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
bool讲解

    config UPLOOKING_BOOL
      bool "uplooing bool"
      default y
      select UPLOOKING_TRISTATE
      help
      If .......

  endmenu # "uplooking"

在这里插入图片描述
在这里插入图片描述

choice讲解


  choice
      prompt "uplooking state"
      default UPLOOING_OFF

      config UPLOOING_OFF
        bool "uplooking off"
        help
        if .......

      config UPLOOKING_ON
        bool "uplooking on"
        help
        if .......
  endchoice

在这里插入图片描述
在这里插入图片描述

menuconfig UPLOOKING_MENU
  bool "uplooking menu"
  default y
  help
  If select uplooking menu display uplooking ops
if UPLOOKING_MENU
  menu "uplooking"
    config UPLOOKING_TRISTATE
      tristate "this is uplooking tristate"
      default m
      help
      If .......

    config UPLOOKING_STRING
      string "this is uplooking string"
      default "this is string"
      help
      If .......

    config UPLOOKING_INT
      int "uplooing int"
      default 100
      depends on UPLOOKING_TRISTATE
      help
      If .......

    config UPLOOKING_BOOL
      bool "uplooing bool"
      default y
      select UPLOOKING_TRISTATE
      help
      If .......

  endmenu # "uplooking"

  choice
      prompt "uplooking state"
      default UPLOOING_OFF

      config UPLOOING_OFF
        bool "uplooking off"
        help
        if .......

      config UPLOOKING_ON
        bool "uplooking on"
        help
        if .......
  endchoice
;