以前看过很多次linux相关的资料,一直没亲自动手写,今天通过半天努力,终于完成了一个自己的linux小驱动
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
readme
执行make采用的命令如下
make -C /opt/SN/SDK/sysroots/eagle8074/usr/src/kernel/ M=`pwd` modules