本文纯属转贴,原文如下
http://dev.firnow.com/course/6_system/linux/Linuxjs/200865/122399.html
记录几个命令。
1.源码树建立
//OS版本取得
shana@shana:~$ uname -r
//查询源码
shana@shana:/usr/src$ apt-cache search linux-source
//取得源码
shana@shana:/usr/src$ sudo apt-get install linux-source-2.6.22
//解冻源码
root@shana:/usr/src#tar jxvf linux-source-2.6.20.tar.bz2
//配置源码
root@shana:/usr/src/linux-source-2.6.22# make oldconfig
//编译源码
shana@shana:/usr/src/linux-source-2.6.22$ make
shana@shana:/usr/src/linux-source-2.6.22$ make bzImage
root@shana:/usr/src/linux-source-2.6.22#make modules
root@shana:/usr/src/linux-source-2.6.22#make modules_install
//确认源码树
cd /lib/modules/2.6.22-14-generic/
2.驱动程序例子
hello.c
//hello.c
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello, world\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT"Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
Makefile
obj-m := hello.o
KERNELDIR := /lib/modules/2.6.20/build
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
3.编译,加载,卸载
//加载驱动
root@shana:/home/shana/driver# insmod ./hello.ko
//查看驱动
root@shana:/home/shana/driver# lsmod
//卸载驱动
root@shana:/home/shana/driver# rmmod hello
//查看日志
shana@shana:~/driver$ cat /var/log/syslog |grep world
分享到:
相关推荐
Ubuntu下驱动开发HelloWorld
Ubuntu下驱动开发HelloWorld.pdf
不管 有没有人下载,这个我成功了,zip里面有源码与makefile 查看输出的数据请输入dmesg
Ubuntu10.04下驱动开发环境的建立(Linux驱动开发源码树的建立),包括 Linux内核:代码的下载,编译,新内核替换老内核...helloworld驱动:源码,编译,安装模块和卸载模块 我在建立开发源码树时遇到的问题及解决方法
到这里helloworld 程序便完成了。 Qt Creator 编译的程序,在其工程文件夹下会有一个debug 文件夹,其中有程序的.exe 可执行文件。但Qt Creator 默认是用动态链接的, 就是可执行程序在运行时需要相应的.dll 文件。...
dsp 个人测试代码,类似于hello world ,ccs编程第一步。
FS4412内核hello world模块实验代码、ubuntu18.04_helloworld实验代码、FS412 LED 字符设备驱动程序 传统模型、FS4412 LED字符设备、FS4412 LED字符设备驱动程序 平台总线(platformbus)模型、FS4412 串口模块实验...
本人毕业设计的所有资源全部奉上,写的还是很粗糙的,但是足以达到hello world演示程序的要求,对刚开始研究linux设备驱动模型的应该还是有所帮助的.。。测试方法可以参看里面的how to文档. 在 ubuntu 8.04 和9.10下...
4、Linux shell编程:输出Hello World、获取系统信息、获取网卡信息、监控CPU负载 5、Linux内核编译与运行:Busybox准备、环境配置、编译最小文件系统、编译内核、运行QEMU 6、Linux内核模块编程:内核模块编程、...
用rmmod卸载模块的时候会弹出错误,如下 – rmmod: can't change directory to '/lib/modules': No such file or directory
请参阅下面的示例hello world脚本var exports = module.exports;exports.build = function (docker, args){ var time = new Date(); docker.from("ubuntu"); docker.maintainer("Matt Hayward <matt>"); docker.run...
4.如何编写ROS的第一个程序hello_world 5.编写简单的消息发布器和订阅器 6.编写简单的service和client 7.理解tf的原理 8.理解roslaunch在大型项目中的作用 9.熟练使用rviz 10.在实际机器人上运行ROS高级功能...
安装驱动程序和软件仿真应在Ubuntu平台上运行Ubuntu 18或更高版本是首选。安装Docker sudo apt install curlcurl https://get.docker.com | sh \&& sudo systemctl start docker \&& sudo systemctl enable docker...
java实现学生管理系统源码卡拉维拉 状态 2016 年 10 月 3 日 克服上游资源波动所必需的新方法。 重新考虑 Chef 方法的开销。...Ubuntu ...下作为 ...Ubuntu ...为您提供了一个基本的测试驱动的“Hello World”Java 示例
理解如何使用的最好方法是查看位于的helloworld测试配方 资源 tomcat_install tomcat_install直接从Apache的镜像站点安装tomcat二进制文件的实例。 由于不使用发行版软件包,因此我们可以轻松地按实例部署部署,并
• Linux (tested on Linux Ubuntu Dapper Drake) Supported Supported Supported Supported Development Development Development Development Environments Environments Environments Environments Eclipse IDE o...
1、Ubuntu 7.0.4发行版 2、u-boot-1.3.1 3、FS2410平台 4、交叉编译器 arm-softfloat-linux-gnu-gcc-3.4.5 【实验步骤】 一、建立自己的平台类型 (1)解压文件 #tar jxvf u-boot-1.3.1.tar.bz2 (2)进入 U...
驱动开发的方法论........................................................................................................................12 Linux内核问题门................................................
Linux内核修炼之道 任桥伟 blog.csdn.net/fudan_abc ...模块机制与“HELLO WORLD!” ........................................................................................... 35 设备模型(上) .........