Yocto:将内核模块配方添加到映像,但是在启动时不会加载 [英] Yocto: Adding kernel module recipe to image, but it doesn't load on boot
问题描述
出于测试目的,我使用yocto提供的示例配方来演示如何构建内核模块.
For testing purposes, I am using the example recipe provided by yocto to demonstrate how to build kernel modules.
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");
现在,我将此模块添加到了我的图像配方中.
Now, I added this module to my image recipe.
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/modules目录中看到测试"hello.ko",但是当我检查dmesg
时,看不到指示内核模块已加载的输出.
When I boot the image, I see the test "hello.ko" in the /lib/modules directory, but when I check dmesg
, I don't see the output indicating the kernel module loaded.
当我在hello.ko
上手动运行insmod
时,得到了输出.另外,当我运行rmmod
时,我得到了输出.
When I manually run insmod
on hello.ko
, I get the output. Also, when I run rmmod
, I get the output.
我做错了什么?我需要这个模块在启动时自动加载.
What am I doing wrong? I need this module to auto load on boot.
修改:
在此处显示输出,验证该模块在引导时未加载,但它是有效的模块.
Here the output, verifying that the module isn't loaded on boot, but it is a valid module.
/ # dmesg | grep "Hello"
/ # insmod hello.ko
[ 68.503689] Hello World!
/ # rmmod hello.ko
[ 72.702035] Goodbye Cruel World!
推荐答案
You should add your module name to KERNEL_MODULE_AUTOLOAD in your recipe, typically like this:
KERNEL_MODULE_AUTOLOAD += "hello"
这应该将您的模块名称放入映像上的/etc/modules-load.d/modname.conf中.
This should put your module name into /etc/modules-load.d/modname.conf on the image.
这篇关于Yocto:将内核模块配方添加到映像,但是在启动时不会加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!