Linux驱动--为Ubuntu系统编写驱动程序入门

本文介绍了在Ubuntu系统中为3.13.0内核版本编写驱动程序的步骤,包括查看内核版本、安装源码包、解压、配置内核、编译及安装模块。通过编写简单的hello.c驱动程序,并使用make命令编译,最后通过insmod和rmmod命令加载和卸载驱动,观察syslog日志验证驱动工作效果。
摘要由CSDN通过智能技术生成

先查看自己系统使用的内核版本:

wang@wang:~$ uname -r
3.13.0-96-generic

查看需要下载的源码包:

wang@wang:/usr/src$ apt-cache search linux-source
linux-source - Linux kernel source with Ubuntu patches
linux-source-3.13.0 - Linux kernel source for version 3.13.0 with Ubuntu patches

sudo apt-get install linux-source-3.13.0

下载完成之后,会在/usr/src目录下有一个linux-source-3.13.0.tar.bz2压缩包,进行解压。

root@wang:/usr/src#tar jxvf  linux-source-3.13.0.tar.bz2

开始配置内核选择最快的原版的配置(默认)方式:

root@wang:/usr/src/linux-source-3.13.0#make oldconfig

然后开始make,大约需要一个小时:

root@wang:/usr/src/linux-source-3.13.0#make

root@wang:/usr/src/linux-source-3.13.0#make bzImage

root@wang:/usr/src/linux-source-3.13.0#make modules

root@wang:/usr/src/linux-source-3.13.0#make mudules_install

make bzImage会在当前目录下生成vmlinux文件,重启系统࿰

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值