Linux所有的内核下载
https://mirrors.edge.kernel.org/pub/linux/kernel/v2.6/
内核的升级不对破坏现有的内核,也不会破坏文件上的文件等资源。
#!/bin/bash
# this file set in the linux-kernel directory
cd /
mkdir linux-2.6.29.4
cp linux-2.6.29.4.tar.bz2 /linux-2.6.29.4/
cd linux-2-6.29.4
tar xjvf linux-2.6.29.4.tar.bz2
cd linux-2.6.29.4
make menconfig
make
make modules
make moudles_install
make install
reboot
内核配置报错
love@ubuntu:~/Downloads/linux-2.6.29.4$ make menuconfig
*** Unable to find the ncurses libraries or the
*** required header files.
*** 'make menuconfig' requires the ncurses libraries.
***
*** Install ncurses (ncurses-devel) and try again.
***
/home/love/Downloads/linux-2.6.29.4/scripts/kconfig/Makefile:154: recipe for target 'scripts/kconfig/dochecklxdialog' failed
make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
Makefile:454: recipe for target 'menuconfig' failed
make: *** [menuconfig] Error 2
安装ncurses库
love@ubuntu:~/Downloads/linux-2.6.29.4$ sudo apt-get install libncurses5-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libtinfo-dev
Suggested packages:
ncurses-doc
The following NEW packages will be installed:
libncurses5-dev libtinfo-dev
0 upgraded, 2 newly installed, 0 to remove and 70 not upgraded.
Need to get 256 kB of archives.
After this operation, 1,422 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
内核配置界面
模块支持
驱动内核的裁剪
Linux驱动程序
驱动模块组成结构:
头文件
#include <linux/module.h>
#include <linux/init.h>
//module.h 文件包含了加载模块时需要使用的大量符号和函数定义
//init.h 文件包含了模块加载函数和模块释放函数的宏定义
模块参数
模块参数是驱动模块加载时,需要传递给驱动模块的参数。类似于函数传参。
模块加载函数
模块加载时必选要执行的函数
module_init(Function);
模块卸载函数
模块卸载时必须要执行的函数
module_exit(Function);
模块许可声明
MODULE_LICENSE("GPL");
MODULE_LICENSE("Dual BSD/GPL");
MODULE_LICENSE("Dual MPL/GPL");
GPL(general public license),表示通用许可证。GNU通用许可证可以保证你有发布自有软件的权利。