Pau*_*opf 4 kernel-module yocto
出于测试目的,我使用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.
Run Code Online (Sandbox Code Playgroud)
该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");
Run Code Online (Sandbox Code Playgroud)
现在,我将此模块添加到我的图像配方中.
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
Run Code Online (Sandbox Code Playgroud)
当我启动映像时,我在/ 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!
Run Code Online (Sandbox Code Playgroud)
您应该将模块名称添加到配方中的KERNEL_MODULE_AUTOLOAD,通常如下所示:
KERNEL_MODULE_AUTOLOAD += "hello"
Run Code Online (Sandbox Code Playgroud)
这应该将您的模块名称放在图像上的/etc/modules-load.d/modname.conf中.
| 归档时间: |
|
| 查看次数: |
14616 次 |
| 最近记录: |