Source code
MODULE_LICENSE("GPL");
static int __init hello_world_init(void)
{
printk(KERN_DEBUG "hello world!!!\n");
return 0;
}
static void __exit hello_world_exit(void)
{
printk(KERN_DEBUG "goodbye world!!!\n");
}
module_init(hello_world_init);
module_exit(hello_world_exit);
Makefile Local 直接在树莓派上编译
ifneq ($(KERNELRELEASE),)
obj-m := hello.o
else
KDIR := /lib/modules/$(shell uname -r)/build
all:
make -C $(KDIR) M=$(PWD) modules
clean:
rm -f *.ko *.o *.mod.o *.mod.c *.symvers modul*
endif
Makefile Crosscompile 在Ubuntu PC上编译
ifneq ($(KERNELRELEASE),)
obj-m := hello.o
else
KDIR := [source code of linux]
all:
make -C $(KDIR) M=$(PWD) modules ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
clean:
rm -f *.ko *.o *.mod.o *.mod.c *.symvers modul*
endif
网友评论