linux 内核配置

来源:互联网 发布:淘宝退货信用卡手续费 编辑:程序博客网 时间:2024/06/08 07:23
1.下载内核.http://www.kernel.org/pub/linux/kernel/

2.解压内核: tar xvf linux*.tar.gz

3.sudo cp -r linux-2.6.32 /usr/src

4.cd /usr/src/linux-2.6.32

5.make mrproper把原来编译产生的垃圾删除

6 cp  /usr/src/linux-headers-3.2.0-29-generic/.config ./(拷贝.config文件到当前需要编译的内核的目录下面)

.config文件是一个内核的配置文件.它记录了内核的配置选项.在.config文件中,每个配置和选项的值只能为”y”和”m”两者之一,如果不需要这个特性不再支持她,那么可以将对应的选项用”#”注释掉。实际上,如果你手头有合适的.config文件,可以运行make oldconfig 直接按.config的内容来配置$ sudo make oldconfig

对内核的配置都是围绕.config来展开的. 即便开始.config文件不存在,进行配置后会创造它.

7.sudo make menuconfig(依赖于ncurese库)(它是基于终端的一种配置方式.)此时会出现一个图形化界面供你选择.对于这里面的配置选项,用户有三种选择.它们的含义如下:

[*]:将该功能编译进内核

[]:不将该功能编译进内核

[M]:将该功能编译成可以在需要时动态插入到内核中的代码

8.make clean

9.make vmlinux modules 编译模块(注:这里的make vmlinux modules 相当于 make vmlinux和make modules.另外,make help可以查看make ***各种命令的用途)

10.make modules_install 安装模块

11.sudo make bzImage

12. sudo make install

reboot之后进入新编译的内核即可.

Mkafile编写

#makefile start
ifneq ($(KERNELRELEASE),)
    mymodule-objs:= hello.c
    obj-m += hello.o
else
PWD :=$(shell pwd)
KVER := $(shell uname -r)
KDIR :=/lib/modules/$(KVER)/build
all:
    $(MAKE) -C $(KDIR) M=$(PWD)
clean:
    rm -rf *.o *.mod.c *.ko *.symvers *order *.markers *-
endif
#makefile stop

#remove hello.ko module
#sudo rmmod hello.ko
#install hello.ko module
#sudo insmod hello.ko
#run module
#sudo dmesg -c

0 0
原创粉丝点击