Yocto: Adding kernel module recipe to image, but it doesn't load on boot

时光总嘲笑我的痴心妄想 提交于 2019-12-20 14:45:28

问题


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.

The hello.c file is very simple.

#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

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.

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.

edit:

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!

回答1:


You should add your module name to KERNEL_MODULE_AUTOLOAD in your recipe, typically like this:

KERNEL_MODULE_AUTOLOAD += "hello"

This should put your module name into /etc/modules-load.d/modname.conf on the image.



来源:https://stackoverflow.com/questions/36188472/yocto-adding-kernel-module-recipe-to-image-but-it-doesnt-load-on-boot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!