[英]How to build external kernel module in yocto without the help of bitbake
我用 yocto branch dunfell 编译了一个 linux 图像并在 x86-64 板上运行。 我将直接在 x86-64 映像中编译我的模块。
我想用这个图像编译我的模块并在 x86-64 板上运行。 出于某种原因,我不想编写模块配方并通过 bitbake 编译模块。
我在 yocto local.conf 中添加 IMAGE_INSTALL_append += kernel-devsrc
我想直接通过 make 命令编译这个模块。 但是我失败了。
root@genericx86-64:~/mount_file/test_module# make
make -C /lib/modules/5.4.213-rt44-yocto-preempt-rt/build M=/home/root/mount_file/test_module modules
make[1]: Entering directory '/lib/modules/5.4.213-rt44-yocto-preempt-rt/build'
make[2]: *** No rule to make target '/home/root/mount_file/test_module/hello.o', needed by '__build'. Stop.
make[1]: *** [Makefile:1737: /home/root/mount_file/test_module] Error 2
make[1]: Leaving directory '/lib/modules/5.4.213-rt44-yocto-preempt-rt/build'
make: *** [Makefile:9: all] Error 2
这些是我的源代码和 makefile:
你好.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
kernel_src = /lib/modules/$(shell uname -r)/build
all:
make -C ${kernel_src} M=$(PWD) modules
clean:
make -C ${kernel_src} M=$(PWD) clean
这是我的 /lib/module/5.4.213-rt44-yocto-preempt-rt/build
root@genericx86-64:~/mount_file/test_module# tree -aL 1 /lib/modules/5.4.213-rt44-yocto-preempt-rt/build/
/lib/modules/5.4.213-rt44-yocto-preempt-rt/build/
|-- .config
|-- Documentation
|-- Kconfig
|-- Makefile
|-- Module.symvers
|-- System.map-5.4.213-rt44-yocto-preempt-rt
|-- arch
|-- block
|-- certs
|-- crypto
|-- drivers
|-- fs
|-- include
|-- init
|-- ipc
|-- kernel
|-- lib
|-- localversion-rt
|-- mm
|-- net
|-- samples
|-- scripts
|-- security
|-- sound
|-- tools
|-- usr
`-- virt
21 directories, 6 files
有没有人有在没有 bitbake 帮助的情况下在 yocto 中编译外部 kernel 模块的经验。 即在Makefile中设置kernel源码路径编译模块,直接make。 多谢!!!
一切看起来都很好。 假设您将模块构建到同一个源代码目录中,您可能会缺少准备构建区域。
尝试在modules
一之前调用scripts modules_prepare
目标。 这将设置您的构建目录。 用于外部模块编译。
make scripts modules_prepare
make
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.