码迷,mamicode.com
首页 > 系统相关 > 详细

Linux内核配置

时间:2016-05-12 16:45:00      阅读:709      评论:0      收藏:0      [点我收藏+]

标签:

1 开发环境

    宿主机:Ubuntu16.04

    开发板:Mini2440

    内核版本:2.6.34.7

2 下载与解压

    下载linux-2.6.34.7.tar.bz2并解压:

tar -axvf linux-2.6.34.7.tar.bz2
3 默认配置

    进入内核源码顶级目录执行:

make defconfig
    输出如下:

liyihai@ubuntu:~/Mini2440/Kernels/linux-2.6.34.7$ make defconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/docproc
  HOSTCC  scripts/basic/hash
  HOSTCC  scripts/kconfig/conf.o
scripts/kconfig/conf.c: In function ‘conf_sym’:
scripts/kconfig/conf.c:159:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]
  int type;
      ^
scripts/kconfig/conf.c: In function ‘conf_choice’:
scripts/kconfig/conf.c:231:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]
  int type;
      ^
scripts/kconfig/conf.c:307:9: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
    fgets(line, 128, stdin);
         ^
scripts/kconfig/conf.c: In function ‘conf_askvalue’:
scripts/kconfig/conf.c:105:8: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
   fgets(line, 128, stdin);
        ^
  HOSTCC  scripts/kconfig/kxgettext.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/lex.zconf.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
*** Default configuration is based on 'i386_defconfig'
#
# configuration written to .config
#

    根据上述输出信息倒数第倒数4行可知,默认情况下内核的配置是针对x86架构的,并且根据i386_defconfig生成了.config(源码中本没有此文件,是配置时才创建的)。通过find命令查找i386_deconfig

技术分享

    使用vim打开分别打开.configi386_defconfig,发现它们的内容基本一样,通过diff命令对它们进行比较:

技术分享

    由上图可见,.configi386_defconfig是不完全同的,make defconfig并非简单的将arch/x86/configs/i386_defconfig复制到.config

3.1 默认架构

    上述默认配置是针对x86构架的,那么怎么启动ARM构架的默认配置呢?答案是指定顶级MakefileARCH变量值,同时指定交叉编译工具链前缀

ARCH        ?= arm
CROSS_COMPILE   ?= arm-linux-
    这时候再执行make defconfig时,针对的就是ARM架构了:

liyihai@ubuntu:~/Mini2440/Kernels/linux-2.6.34.7$ make defconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/docproc
  HOSTCC  scripts/basic/hash
  HOSTCC  scripts/kconfig/conf.o
scripts/kconfig/conf.c: In function ‘conf_sym’:
scripts/kconfig/conf.c:159:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]
  int type;
      ^
scripts/kconfig/conf.c: In function ‘conf_choice’:
scripts/kconfig/conf.c:231:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]
  int type;
      ^
scripts/kconfig/conf.c:307:9: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
    fgets(line, 128, stdin);
         ^
scripts/kconfig/conf.c: In function ‘conf_askvalue’:
scripts/kconfig/conf.c:105:8: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
   fgets(line, 128, stdin);
        ^
  HOSTCC  scripts/kconfig/kxgettext.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/lex.zconf.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
*** Default configuration is based on 'versatile_defconfig'
#
# configuration written to .config
#

    由上述信息可知,此时根据versatile_defconfig进行默认配置生成.config,使用find查找versatile_defconfig

技术分享

    使用diff比较versatile_defconfig.config

技术分享

    由上图可见,versatile_defconfig.config还是不完全同的。

3.2 配置文件.config

    由上可见,配置信息主要保存于内核源码顶级目录的.config文件中,ARM构架.config最开始部分的内容如下所示:

#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.34.7
# Tue May 10 11:30:25 2016
#
CONFIG_ARM=y
CONFIG_SYS_SUPPORTS_APM_EMULATION=y
CONFIG_GENERIC_TIME=y
CONFIG_GENERIC_CLOCKEVENTS=y
CONFIG_HAVE_PROC_CPU=y
CONFIG_GENERIC_HARDIRQS=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_HAVE_LATENCYTOP_SUPPORT=y
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_TRACE_IRQFLAGS_SUPPORT=y
CONFIG_HARDIRQS_SW_RESEND=y
CONFIG_GENERIC_IRQ_PROBE=y
CONFIG_RWSEM_GENERIC_SPINLOCK=y
CONFIG_GENERIC_HWEIGHT=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_NEED_DMA_MAP_STATE=y
CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
CONFIG_VECTORS_BASE=0xffff0000
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
CONFIG_CONSTRUCTORS=y

    根据上述信息第2行的说明可知,.config文件的内容是由make config自动生成的(其实i386_defconfig也是的第2行也是这么写),不要手动修改。

    第6行指定了使用ARM架构,此外,其余所有的配置项都以CONFIG_为前缀。

3.3 其它默认配置文件

    根据参考资料[1]的提示,在内核源码arch目录中有alphax86arm等子目录,分别对应相应的架构:

技术分享

    其中arm目录包含bootcommonconfigsinclude以及内核已支持的ARM芯片子目录:

技术分享

    上图configs目录包含了各个ARM芯片的默认配置文件(包括3.1小节的versatile_defconfig):

技术分享

   根据参考资料[1] 的提示,若要使用这些平台的配置文件,只能将其复制到顶级目录并且重命名为.config

cd linux-2.6.34.7
cp arch/arm/configs/mini2440_defconfig .config

4 交互配置

    进入内核源码顶级目录执行:

make config
    输出如下:

liyihai@ubuntu:~/Mini2440/Kernels/linux-2.6.34.7$ make config
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/docproc
  HOSTCC  scripts/basic/hash
  HOSTCC  scripts/kconfig/conf.o
scripts/kconfig/conf.c: In function ‘conf_sym’:
scripts/kconfig/conf.c:159:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]
  int type;
      ^
scripts/kconfig/conf.c: In function ‘conf_choice’:
scripts/kconfig/conf.c:231:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]
  int type;
      ^
scripts/kconfig/conf.c:307:9: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
    fgets(line, 128, stdin);
         ^
scripts/kconfig/conf.c: In function ‘conf_askvalue’:
scripts/kconfig/conf.c:105:8: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
   fgets(line, 128, stdin);
        ^
  HOSTCC  scripts/kconfig/kxgettext.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/lex.zconf.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf arch/x86/Kconfig
#
# using defaults found in /boot/config-3.16.0-30-generic
#
/boot/config-3.16.0-30-generic:1264:warning: symbol value 'm' invalid for NET_DSA
/boot/config-3.16.0-30-generic:1680:warning: symbol value 'm' invalid for MTD_CMDLINE_PARTS
/boot/config-3.16.0-30-generic:2418:warning: symbol value 'm' invalid for NET_DSA_MV88E6XXX
/boot/config-3.16.0-30-generic:2419:warning: symbol value 'm' invalid for NET_DSA_MV88E6060
/boot/config-3.16.0-30-generic:2421:warning: symbol value 'm' invalid for NET_DSA_MV88E6131
/boot/config-3.16.0-30-generic:2422:warning: symbol value 'm' invalid for NET_DSA_MV88E6123_61_65
/boot/config-3.16.0-30-generic:2861:warning: symbol value 'm' invalid for IWL4965
/boot/config-3.16.0-30-generic:3783:warning: symbol value 'm' invalid for GPIO_UCB1400
/boot/config-3.16.0-30-generic:4259:warning: symbol value 'm' invalid for REGULATOR_88PM8607
/boot/config-3.16.0-30-generic:4318:warning: symbol value 'm' invalid for REGULATOR_TWL4030
/boot/config-3.16.0-30-generic:5396:warning: symbol value 'm' invalid for SND_HDA_CODEC_REALTEK
/boot/config-3.16.0-30-generic:5397:warning: symbol value 'm' invalid for SND_HDA_CODEC_ANALOG
/boot/config-3.16.0-30-generic:5398:warning: symbol value 'm' invalid for SND_HDA_CODEC_SIGMATEL
/boot/config-3.16.0-30-generic:5399:warning: symbol value 'm' invalid for SND_HDA_CODEC_VIA
/boot/config-3.16.0-30-generic:5402:warning: symbol value 'm' invalid for SND_HDA_CODEC_CIRRUS
/boot/config-3.16.0-30-generic:5403:warning: symbol value 'm' invalid for SND_HDA_CODEC_CONEXANT
/boot/config-3.16.0-30-generic:5404:warning: symbol value 'm' invalid for SND_HDA_CODEC_CA0110
/boot/config-3.16.0-30-generic:5407:warning: symbol value 'm' invalid for SND_HDA_CODEC_CMEDIA
/boot/config-3.16.0-30-generic:5408:warning: symbol value 'm' invalid for SND_HDA_CODEC_SI3054
/boot/config-3.16.0-30-generic:5409:warning: symbol value 'm' invalid for SND_HDA_GENERIC
/boot/config-3.16.0-30-generic:7288:warning: symbol value 'm' invalid for NFS_V3
/boot/config-3.16.0-30-generic:7290:warning: symbol value 'm' invalid for NFS_V4
*
* Linux Kernel Configuration
*
*
* General setup
*
Prompt for development and/or incomplete code/drivers (EXPERIMENTAL) [N/y/?] (NEW)
    由上述最后1行可知,需要用户确认是否Prompt for development and/or incomplete code/drivers (EXPERIMENTAL),因此可知这是交互式的配置,需要用户对内核非常了解,操作比较繁琐。

5 菜单配置

make menuconfig
技术分享

6 清空配置

    若要删除上述的配置值,执行:

make mrproper

技术分享

    注:make distcean不能替代上述命令!

参考资料

[1]交叉编译 Linux 内核 for ARM

Linux内核配置

标签:

原文地址:http://blog.csdn.net/q1302182594/article/details/51360938

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!