首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Yocto:将内核模块配方添加到映像中,但它在引导时不加载

Yocto:将内核模块配方添加到映像中,但它在引导时不加载
EN

Stack Overflow用户
提问于 2016-03-23 20:53:06
回答 1查看 22.2K关注 0票数 8

出于测试目的,我正在使用yocto提供的示例菜谱来演示如何构建内核模块。

代码语言:javascript
运行
复制
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文件非常简单。

代码语言:javascript
运行
复制
#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");

现在,我将这个模块添加到我的图像食谱中。

代码语言:javascript
运行
复制
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时,我得到了输出。

我做错了什么?我需要这个模块在引导时自动加载。

编辑

这里是输出,验证模块没有在引导时加载,但它是一个有效的模块。

代码语言:javascript
运行
复制
/ # dmesg | grep "Hello"
/ # insmod hello.ko 
[   68.503689] Hello World!
/ # rmmod hello.ko 
[   72.702035] Goodbye Cruel World!
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-24 07:55:31

您应该将模块名添加到菜谱中的自拍中,通常如下所示:

代码语言:javascript
运行
复制
KERNEL_MODULE_AUTOLOAD += "hello"

这应该将您的模块名放到映像上的/etc/ your load.d/modname.conf中。

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36188472

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档