kernel .config优化

kernel .config优化

      • 一、概述
      • 二、明确具体CONFIG作用
      • 三、总结

一、概述

在嵌入式开发中,使用linux kernel不可避免,kernel支持的驱动非常庞大,删除不需要的驱动也是势在必行。那么那么多的配置,都有什么作用?该删除哪些呢?下面介绍一种快速明白相应配置的功能。

二、明确具体CONFIG作用

以USB模块为例
在kernel编译时使用的.config部分内容如下:

#
# USB Network Adapters
#
# CONFIG_USB_CATC is not set
# CONFIG_USB_KAWETH is not set
# CONFIG_USB_PEGASUS is not set
# CONFIG_USB_RTL8150 is not set
# CONFIG_USB_RTL8152 is not set
CONFIG_USB_USBNET=y
# CONFIG_USB_NET_AX8817X is not set
# CONFIG_USB_NET_AX88179_178A is not set
CONFIG_USB_NET_CDCETHER=y
# CONFIG_USB_NET_CDC_EEM is not set
# CONFIG_USB_NET_CDC_NCM is not set
# CONFIG_USB_NET_CDC_MBIM is not set
# CONFIG_USB_NET_DM9601 is not set
# CONFIG_USB_NET_SMSC75XX is not set
# CONFIG_USB_NET_SMSC95XX is not set
# CONFIG_USB_NET_GL620A is not set
# CONFIG_USB_NET_NET1080 is not set
# CONFIG_USB_NET_PLUSB is not set

很明显有很多驱动都用不上,要确定具体一个CONFIG的作用,在kernel根目录执行(以CONFIG_USB_CATC为例)

linux-3.10$ grep -nr "USB_CATC" --include=Kconfig
drivers/net/usb/Kconfig:10:config USB_CATC

注意: 搜索时把前面的CONFIG_去掉,搜索出的结果是config USB_CATC形式的。有时会搜索出很多,因此需要这个规则。
查看Kconfig内容,部分内容如下:

#
# USB Network devices configuration
#
comment "Networking support is needed for USB Network Adapter support"
        depends on USB && !NET

menu "USB Network Adapters"
        depends on USB && NET

config USB_CATC
        tristate "USB CATC NetMate-based Ethernet device support"
        select CRC32
        ---help---
          Say Y if you want to use one of the following 10Mbps USB Ethernet
          device based on the EL1210A chip. Supported devices are:
          Belkin F5U011
          Belkin F5U111
          CATC NetMate
          CATC NetMate II
          smartBridges smartNIC

          This driver makes the adapter appear as a normal Ethernet interface,
          typically on eth0, if it is the only ethernet device, or perhaps on
          eth1, if you have a PCI or ISA ethernet card installed.

          To compile this driver as a module, choose M here: the
          module will be called catc.

看到这里已经很明白了吧。该段中不仅描述的驱动的作用,还描述了驱动的依赖。

三、总结

一般修改kernel配置,使用make menuconfig,但是使用该命令需要配一些编译环境。自己搭建的编译环境自己做主,折腾下无所谓,当使用公司服务器编译时,不同版本kernel需要的环境不同,配置环境还需要申请,流程相当麻烦。

实际上,kernel编译最总使用的是.config文件,make menuconfig修改的也是.config文件,当.config文件不存在时,会拷贝一个默认配置文件为.config,因此我们修改默认配置文件,删除.config文件,也可以正常编译kernel且使修改生效;如果不想修改默认配置文件,按照以上描述的方法,修改.config文件也可以。

你可能感兴趣的:(通用kernel资料,Android系统优化)