Yocto:向镜像添加内核模块配方,但在启动时未加载

8

为了测试目的,我使用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/modules目录中看到测试的“hello.ko”,但是当我检查dmesg时,我没有看到表明内核模块已加载的输出。
当我手动运行insmod hello.ko时,我可以看到输出。当我运行rmmod时,我也能够看到输出。
我做错了什么?我需要这个模块在启动时自动加载。
编辑:
输出如下,验证模块未在引导时加载,但它是一个有效的模块。
/ # dmesg | grep "Hello"
/ # insmod hello.ko 
[   68.503689] Hello World!
/ # rmmod hello.ko 
[   72.702035] Goodbye Cruel World!

我不理解 "Now, I added this module to my image recipe." 这句话的意思!是哪个文件? - dipankar pal
在您的镜像配方中添加IMAGE_INSTAL += your-recipe - Paul Knopf
1个回答

9

您需要在配方中将模块名称添加到KERNEL_MODULE_AUTOLOAD,通常像这样:

KERNEL_MODULE_AUTOLOAD += "hello"

这将会把你的模块名称放入镜像的/etc/modules-load.d/modname.conf文件中。


只在.conf文件中,如local.conf或meta .conf中对我有效,但在镜像配方中没有任何效果。 - fault-tolerant
镜像配方在许多方面都有些特殊。您可以在conf文件和实际内核或模块配方(或bbappend到内核或模块配方)中使用KERNEL_MODULE_AUTOLOAD。 - Jussi Kukkonen

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接