出于测试目的,我正在使用yocto提供的示例菜谱来演示如何构建内核模块。
SUMMARY = "Example of how to build an external Linux kernel module"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e"
inherit module
PR = "r0"
PV = "0.1"
SRC_URI = "file://Makefile \
file://hello.c \
file://COPYING \
"
S = "${WORKDIR}"
# The inherit of module.bbclass will automatically name module packages with
# "kernel-module-" prefix as required by the oe-core build environment.
hello.c
文件非常简单。
#include <linux/module.h>
int init_module(void)
{
printk("Hello World!\n");
return 0;
}
void cleanup_module(void)
{
printk("Goodbye Cruel World!\n");
}
MODULE_LICENSE("GPL");
现在,我将这个模块添加到我的图像食谱中。
SUMMARY = "A console-only image that fully supports the target device \
hardware."
IMAGE_FEATURES += "splash package-management"
IMAGE_INSTALL += "test-mod autoconf automake binutils make busybox"
LICENSE = "MIT"
inherit core-image
当我引导映像时,我看到/lib/hello.ko目录中的测试“dmesg
”,但是当我检查dmesg
时,我没有看到表示加载了内核模块的输出。
当我在insmod
上手动运行hello.ko
时,我得到了输出。另外,当我运行rmmod
时,我得到了输出。
我做错了什么?我需要这个模块在引导时自动加载。
编辑
这里是输出,验证模块没有在引导时加载,但它是一个有效的模块。
/ # dmesg | grep "Hello"
/ # insmod hello.ko
[ 68.503689] Hello World!
/ # rmmod hello.ko
[ 72.702035] Goodbye Cruel World!
发布于 2016-03-24 07:55:31
您应该将模块名添加到菜谱中的自拍中,通常如下所示:
KERNEL_MODULE_AUTOLOAD += "hello"
这应该将您的模块名放到映像上的/etc/ your load.d/modname.conf中。
https://stackoverflow.com/questions/36188472
复制相似问题