linux驱动开发第一例
来源:互联网 发布:手机淘宝宝贝排名查询 编辑:程序博客网 时间:2024/04/27 06:28
1. Code
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("GPL");
static int times=1;
module_param(times,int,S_IRUGO);
static int hello_init(void)
{
int i=0;
for(;i <times;i++)
printk(KERN_ALERT "hello,word/n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye,word/n");
}
module_init(hello_init);
module_exit(hello_exit);
2. Makefile
ifneq ($(KERNELRELEASE),)
obj-m :=hello.o
else
PWD :=$(shell pwd)
KEVER ?=$(shell uname -r)
#KDIR :=/usr/src/linux-2.6.23
KDIR :=/usr/src/kernels/2.6.23.1-42.fc8-i686
all:
$(MAKE) -C $(KDIR) M=$(PWD)
clean:
rm -rf .*.cmd *.o *.mod.c *.ko .tmp_versions *.order *symvers
endif
3. 遇到的问题:
insmod: error inserting 'hello.ko': -1 Invalid module format
解决方法: 如下的版本号必须匹配,修改Makefile中的KDIR为系统匹配的linux内核树路径
/usr/src/linux-2.6.23/include/linux/utsrelease.h
[root@localhost ~]# modinfo hello.ko
filename: hello.ko
license: GPL
depends:
vermagic: 2.6.23 SMP mod_unload 686 4KSTACKS
parm: times:int
[root@localhost ~]# uname -r
2.6.23.1-42.fc8
- linux驱动开发第一例
- linux 模块驱动开发第一弹 helloworld
- UBuntu8.10 开发第一个基本Linux 驱动内核模块
- Linux驱动开发学习 第一个驱动程序 hello world
- 第一个Linux驱动
- 第一个linux 驱动
- Linux驱动开发系列之二:第一个linux驱动hello word程序
- 基于tiny6410开发板的LED驱动 编写与使用(第一个linux驱动)
- ZYNQ Linux驱动开发——第一个字符设备驱动
- 【嵌入式linux】(第五步):使用eclipse集成开发环境开发第一个嵌入式Linux驱动
- 【嵌入式linux】(第五步):使用eclipse集成开发环境开发第一个嵌入式Linux驱动
- 【Linux驱动】第一个驱动程序
- Linux第一个驱动--点灯
- Linux驱动第一课--helloworld
- linux驱动第一个程序
- 使用eclipse集成开发环境开发第一个嵌入式Linux驱动
- ubuntu 使用eclipse集成开发环境开发第一个嵌入式Linux驱动
- Exynos 4412 Cortex-A9嵌入式Linux驱动开发学习笔记-第一期
- 玩转Google开源C++单元测试框架Google Test(gtest)
- 不带框上传
- 更新 DataGridView 中修改过的Cell值到数据库中
- jdbc链接数据库(oracle10g)
- 探索dojo/json
- linux驱动开发第一例
- 基本术语:源程序,目标程序,翻译程序
- android 手机翻译
- linux下安装五笔输入法
- 英语练习112 The secret of longevity
- php处理大的日志文件
- SQL 修改表名及列名
- HttpURLConnection类发送GET请求却变成了POST请求
- 挂起正在运行的线程