2.2 linux内核配置及Kconfig语法简介
1.Kconfig
Kconfig提供了一种对内核配置的手段,图形化界面显示可由Kconfig的语言及选项内容 进行编辑。
[root@localhost drivers]# vim Kconfig

[root@localhost uea_drv]# vim Kconfig
#Kconfig语法简介
#menuconfig/config
#menu/endmenu
#if/endif
#bool/tristate/int/hex/string
#select/choice/depends on
#comment/help/prompt
#source
#range
comment "My uea_drv is good!" #总的注释,在menuconfig中可见
menuconfig CLASS0411 #关键字/变量名
bool "to learn linux kernel driver!"#类型/提示信息
---help--- #帮助信息
this stage start at 2016...
###########################################################
if CLASS0411 #大的选项
menu "refer to i2c interface device driver"#组织一个新菜单1
config FT5206 #1
tristate "800*480 ts control module driver"
---help---
touch screen device driver for tiny4412...
config LEDNUM #2
int
prompt "please input a number of led"#提示信息
range 1 4
---help---
led help...
config KERINFO #3
string "please input a string for output"
---help---
kernel info...
endmenu
menu "the key other words for kconfig" #组织一个新菜单2
config CHICKEN #1
bool "chicken for driver"
---help---
chicken info...
config EGG #2
bool "egg for driver"
depends on CHICKEN #依赖关系
---help---
egg info...
config BODYRED #3
bool "body sensor driver"
select BUZZER #选择关系
---help---
body info...
config BUZZER #4
bool "buzzer sensor driver"
---help---
buzzer info...
choice #自动只能选择一个/互斥
prompt "watch dog driver"
config WDT01 #1
bool "watch dog driver version1"
---help---
wdt info...
config WDT02
bool "watch dog driver version2"
---help---
wdt info...
endchoice
endmenu
endif
[root@localhost linux-3.5]# make menuconfig //可以配置了,完了就可以查看.config
[root@localhost linux-3.5]# vim .config #该文件自动生成相关配置信息

//
[root@localhost linux-3.5]# vim include/generated/autoconf.h
[root@localhost linux-3.5]# vim include/config/auto.conf
//删除工作
[root@localhost arch]# cd arm/
[root@localhost arm]# mv mach-exynos/ plat-samsung/ ../ //这两个目录留下供使用
[root@localhost arm]# rm -rf mach-*
[root@localhost arm]# rm -rf plat-*
[root@localhost arm]# mv ../mach-exynos/ .
[root@localhost arm]# mv ../plat-samsung/ .
[root@localhost linux-3.5]# make menuconfig //报错,准备除错。。。
[root@localhost arm]# vim Kconfig //修改Kconfig
source "arch/arm/plat-samsung/Kconfig"
991
992 source "arch/arm/mach-exynos/Kconfig"
993
994
995 # Definitions to make life easier
[root@localhost linux-3.5]# make menuconfig //没有错误了。。。
浙公网安备 33010602011771号