ARM Linux 下 Hello 驱动程序
来源:互联网 发布:网上商城源码下载 编辑:程序博客网 时间:2024/05/17 04:50
今天终于在我的TQ2440 ARM板子上运行了一个简单的驱动程序,惭愧!!!
简单的 Hello 驱动 .
下面是步骤:
因为是字符char 的驱动程序 . 所以我们应该在内核源码目录下的 drivers/char/
编写程序驱动程序:
新建一个名为 yikai_hello.c .
内容如下:
/*************************************NAME:yikai_hello.cCOPYRIGHT:www.embedsky.net*************************************/#include <linux/module.h>#include <linux/kernel.h>MODULE_LICENSE("GPL"); static int __init EmbedSky_hello_init(void){ printk("<1>\n Hello,EmbedSky!\n"); printk("<1>\nThis is first driver program.\n\n"); return 0;}static void __exit EmbedSky_hello_exit(void){ printk("<1>\n Exit!\n"); printk("<1>\nGoodbye EmbedSky!\n\n");} module_init(EmbedSky_hello_init);module_exit(EmbedSky_hello_exit);MODULE_LICENSE("GPL");
修改当前目录下Kconfig 文件:
在 drivers/char/ Kconfig 文件 ,加入如下:
config yikai_HELLOtristate "yikai Board Hello module test"depends on ARCH_S3C2440default m if ARCH_S3C2440helpSKY2440/TQ2440 Board First module test.
修改当前目录下Makefile 文件
在 drivers/char/ Makefile 文件 ,加入如下:
obj-$(CONFIG_yikai_HELLO)+= yikai_hello.o
配置内核:
make menuconfig :
配置如下,编译成模块:
Device Drivers --->
Character devices --->
<M> yikai Board Hello module test
编译内核模块:
最后在内核源码顶层目录下输入命令:make SUBDIR=drivers/char/ modules
在drivers/char/ 就生成 yikai_hello.ko 文件.
用 SecurceCRT 传送ko文件到开发板 .
通过共享目录,拷贝出来,
首先配置 SecurceCRT,
再设置目录
在 SecurceCRT 输入 rz 回车,
选择对应文件add 再 OK.
[root@EmbedSky /]# rzrz ready. Type "sz file ..." to your modem programStarting zmodem transfer. Press Ctrl+C to cancel.Transferring yikai_hello.ko... 100% 2 KB 2 KB/s 00:00:01 0 Errors妑z 3.48 01-27-98 finished.[root@EmbedSky /]# ls_new. linuxrc sbin varbin lost+found sddisk webdev mnt sys myetc opt tmp yikai_hello.kohome proc udisklib root usr[root@EmbedSky /]#
执行驱动程序:
insmod yikai_hello.ko
[root@EmbedSky /]# insmod yikai_hello.ko Hello,yikai!This is first driver program.[root@EmbedSky /]#
执行:rmmod yikai_hello.ko
[root@EmbedSky /]# rmmod yikai_hello.ko Exit!Goodbye yikai![root@EmbedSky /]#
这个简单的 Hello 显示驱动程序到此就完毕,
主要学习的是一个驱动 编写,修改配置文件 ,配置内核,编译,上传,执行的过程.
- ARM Linux 下 Hello 驱动程序
- linux下的第一个驱动程序 hello (for 2.4)
- ARM-Linux下ZLG7290 I2C驱动程序的编写
- arm-linux驱动:hello
- linux 驱动程序的hello world
- Hello world 之Linux驱动程序
- linux 设备驱动程序 hello+param
- Linux 驱动程序入门(hello world)
- hello.ko---linux设备驱动程序
- Linux驱动程序入门—Hello World
- Linux驱动程序入门—Hello World
- Linux驱动程序入门—Hello World
- hello world" linux驱动程序的编译与
- Linux驱动程序入门—Hello World
- Linux设备驱动程序0-hello world
- 第一个linux 设备驱动程序 hello.ko
- Linux内核---51.驱动程序的hello world
- linux驱动入门-hello设备驱动程序编写
- ubuntu下C编程,编译基础
- android 颜色代码 汇总
- MATLAB报错Missing variable or function
- QGraphic view实例:利用QGraphicsItem与定时器实现动画效果:蝴蝶飞舞
- [全程建模]用例的子流和分析类的关系
- ARM Linux 下 Hello 驱动程序
- java 控件失去或者获取焦点的响应
- 给年轻工程师的十大忠告
- 空手套白狼。生意之道?
- Ubuntu中vi显示中文乱码的问题
- MSVC和MinGW的DLL工具
- 使用typedef语句定义数组类型
- linux线程互斥锁
- zoj 1037 Gridland