1.make安装
执行命令:sudo apt install make
执行命令:sudo apt-get install build-essential
#include <linux/init.h>
#include <linux/module.h>
static int hello_init(void)
{
printk("hello, world!\r\n");
return 0;
}
static void hello_exit(void)
{
printk("see you agin\r\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL"); //MODULE_LICENSE
MODULE_AUTHOR("DriverDesigner"); //声明作者信息
KERNELDIR := /usr/src/linux-headers-$(shell uname -r)
CURRENT_PATH := $(shell pwd)
obj-m := hello.o
build: kernel_modeles
kernel_modeles:
$(MAKE) -C $(KERNELDIR) M=$(CURRENT_PATH) modules
clean:
$(MAKE) -C $(KERNELDIR) M=$(CURRENT_PATH) clean