Linux 内核编译及驱动

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通用许可证可以保证你有发布自有软件的权利。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值