I.MX8 Yocto 构建SDK编译内核模块.ko方法
最近在I.MX8 的环境下想编译一个.ko内核模块做测试,就按照传统的方法去编译内核,产生了以下的问题。
环境
mechine : imx8mqevk
kernel : fsl-release-yocto
cross-compile : aarch64-poky-linux-
make -C /opt/fsl-imx-xwayland/5.4-zeus/sysroots/aarch64-poky-linux/usr/src/kernel M=/home/ysfedorov/my_c modules
make[1]: Entering directory ‘/opt/fsl-imx-xwayland/5.4-zeus/sysroots/aarch64-poky-linux/lib/modules/5.4.47-2.2.0+g5ec03d06f54e/build’
CC [M] /home/ysfedorov/my_c/my_module.o
In file included from ./include/linux/types.h:6,
from ./include/linux/list.h:5,
from ./include/linux/module.h:9,
from /home/ysfedorov/my_c/my_module.c:1:
./include/uapi/linux/types.h:5:10: fatal error: asm/types.h: No such file or directory
5 | #include <asm/types.h>
| ^~~~~~~~~~~~~
compilation terminated.
make[2]: *** [scripts/Makefile.build:266: /home/ysfedorov/my_c/my_module.o] Error 1
make[1]: *** [Makefile:1703: /home/ysfedorov/my_c] Error 2
make[1]: Leaving directory ‘/opt/fsl-imx-xwayland/5.4-zeus/sysroots/aarch64-poky-linux/lib/modules/5.4.47-2.2.0+g5ec03d06f54e/build’
make: *** [Makefile:6: all] Error 2
#include <linux/module.h>
static int __init hello_init(void)
{
pr_info("hello from init\n");
return 0;
}
static void __exit hello_exit(void)
{
pr_info(

本文档详细介绍了如何在IMX8MQEVK开发板上,基于Yocto项目和Freescale发布的SDK构建内核模块KO的过程。首先遇到的问题是在传统编译方法中头文件缺失,尝试软链接解决未果。然后按照NXP官方文档,通过添加TOOLCHAIN_TARGET_TASK_append设置,使用Yocto编译内核源码并构建SDK。完成SDK安装后,找到正确的kernel路径,并在Makefile中指定,最终成功编译出KO模块并能在匹配内核版本的开发板上正常加载运行。注意,内核版本与开发板上的Ubuntu镜像版本需一致,否则模块无法插入。
最低0.47元/天 解锁文章
1623

被折叠的 条评论
为什么被折叠?



