linux 2.6下编译最简单的hello.ko驱动 2008-05-27 10:08:10
分类: LINUX
linux 2.6下编译最简单的hello.ko驱动
1.下载kernel源码 http://www.kernel.org/
2.配置内核
luther@gliethttp:~/work/kernel/linux-2.6.22.14$ make oldconfig
luther@gliethttp:~/work/kernel/linux-2.6.22.14$ make prepare
luther@gliethttp:~/work/kernel/linux-2.6.22.14$ make scripts 否则提示:MODPOST 1 modules /bin/sh: scripts/mod/modpost: not found
3.写测试程序hello.c
//luther@gliethttp:~/work/kernel/module_drivers/hello$ vim hello.c
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
static int init_hello_4(void)
{
printk(KERN_ALERT "Hello, world 4 ");
return 0;
}
static void cleanup_hello_4(void)
{
printk(KERN_ALERT "Goodbye, world 4 ");
}
module_init(init_hello_4);
module_exit(cleanup_hello_4);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Playmud");
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余3页未读,立即下载