美文网首页
Raspberry kernel module compile

Raspberry kernel module compile

作者: star_walker | 来源:发表于2021-09-07 19:14 被阅读0次

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

相关文章

网友评论

      本文标题:Raspberry kernel module compile

      本文链接:https://www.haomeiwen.com/subject/fxppwltx.html