首页 > 解决方案 > yocto 构建 linux 内核模块

问题描述

请帮忙,我在组装内核模块时遇到问题,创建了一个新层

$ ll ~/work/yocto/sources/meta-gobinet
total 28K
drwxr-xr-x  5 ivr ivr 4.0K Aug 18 11:27 .
drwxr-xr-x 12 ivr ivr 4.0K Aug 18 11:26 ..
drwxr-xr-x  2 ivr ivr 4.0K Aug 18 11:26 conf
-rw-r--r--  1 ivr ivr 1.1K Aug 18 11:26 COPYING.MIT
-rw-r--r--  1 ivr ivr  801 Aug 18 11:26 README
drwxr-xr-x  3 ivr ivr 4.0K Aug 18 11:26 recipes-example
drwxr-xr-x  3 ivr ivr 4.0K Aug 18 11:28 recipes-gobinet

我正在创建食谱

$ cat ~/work/yocto/sources/meta-gobinet/recipes-gobinet/gobinet/gobinet_1.bb 
SUMMARY = "gobinet module"
LICENSE = "CLOSED"
inherit module
SRC_URI = "file://gobinet.tar.xz;md5sum=13b5f20214a3925eb4be3b831b62612f"
#SRC_URI += " file://0001_gobinet_makefile.patch;md5sum=1261df573e1b91177954f6190a12c7b1"

我把 gobinet.tar.xz 放进去

$ ll ~/work/yocto/sources/meta-gobinet/recipes-gobinet/gobinet/gobinet/
total 44K
drwxr-xr-x 2 ivr ivr 4.0K Aug 18 15:28 .
drwxr-xr-x 3 ivr ivr 4.0K Aug 18 15:31 ..
-rw-r--r-- 1 ivr ivr  30K Aug 18 15:31 gobinet.tar.xz

gobinet.tar.xz 的内容是

tar -xf gobinet.tar.xz 
ivr@home-machine:~/work/yocto/sources/meta-gobinet/recipes-gobinet/gobinet/gobinet
$ ll gobinet
total 244K
drwxr-xr-x 2 ivr ivr 4.0K Aug 17 21:32 .
drwxr-xr-x 3 ivr ivr 4.0K Aug 18 15:39 ..
-rw-r--r-- 1 ivr ivr 3.1K Aug 17 21:32 GobiNetworkManager.h
-rw-r--r-- 1 ivr ivr  36K Aug 17 21:32 GobiUSBNet.c
-rw-r--r-- 1 ivr ivr  131 Aug 17 21:32 Kconfig
-rw-r--r-- 1 ivr ivr  324 Aug 17 21:32 kernel-deploy-guide
-rw-r--r-- 1 ivr ivr  326 Aug 17 21:32 Makefile
-rwxr-xr-x 1 ivr ivr  127 Aug 17 21:32 Makefile.kernel
-rw-r--r-- 1 ivr ivr  36K Aug 17 21:32 QMI.c
-rw-r--r-- 1 ivr ivr  97K Aug 17 21:32 QMIDevice.c
-rw-r--r-- 1 ivr ivr 9.8K Aug 17 21:32 QMIDevice.h
-rw-r--r-- 1 ivr ivr 8.7K Aug 17 21:32 QMI.h
-rw-r--r-- 1 ivr ivr 2.9K Aug 17 21:32 Readme.txt
-rw-r--r-- 1 ivr ivr  13K Aug 17 21:32 Structs.h

但我有错误

ERROR: gobinet-1-r0 do_compile: oe_runmake failed
ERROR: gobinet-1-r0 do_compile: Execution of '/home/ivr/work/yocto/build/tmp/work/phyboard_segin_imx6ul_6-phytec-linux-gnueabi/gobinet/1-r0/temp/run.do_compile.1734076' failed with exit code 1:
make: *** No targets specified and no makefile found.  Stop.
WARNING: exit code 1 from a shell command.

ERROR: Logfile of failure stored in: /home/ivr/work/yocto/build/tmp/work/phyboard_segin_imx6ul_6-phytec-linux-gnueabi/gobinet/1-r0/temp/log.do_compile.1734076

写道没有 Makefile 但 Makefile 存在。告诉我有什么问题?我已经很累了,但我想不通这个复杂的装配系统缺少什么

标签: linuxyocto

解决方案


您的 *.bb 文件中没有任何编译和安装操作(do_compile()do_install())。请分析并尝试这个例子。


创建一个简单的“Hello, World!” 示例食谱

1. 在元层创建一个目录来存储你的应用程序:

cd sources/meta-<custom_layer>
mkdir -p recipes-<custom_recipe_dir>/hello-world/hello-world

将 <custom_recipe_dir> 替换为您的首选名称。

2. 为应用程序创建配方(.bb 文件):

cd sources/meta-<custom_layer>/recipes-<custom_recipe_dir>/hello-world/
touch hello-world_1.0.0.bb

然后,将以下说明添加到配方中:

~/var-fslc-yocto/sources/meta-<custom_layer>/recipes-<custom_recipe_dir>/hello-world/hello-world_1.0.0.bb

SUMMARY = "A simple Hello World application"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://hello_world.c"

TARGET_CC_ARCH += "${LDFLAGS}"

S = "${WORKDIR}"

do_compile() {
  ${CC} -Wall hello-world.c -o hello-world
}

do_install() {
  install -d ${D}${bindir}
  install -m 0755 ${S}/hello-world ${D}${bindir}
}

3. 创建一个打印“Hello, World!”的简单 C 编程语言源文件:

cd $SDIR/meta-<custom_layer>/recipes-<custom_recipe_dir>/hello-world/hello-world/
touch hello_world.c

然后,将以下源代码添加到文件中:

~/var-flsc-yocto/sources/meta-<custom_layer>/recipes-<custom_recipe>/hello-world/src/hello_world.c

#include <stdio.h>
#include <stdlib.h>
int main(void)
{
  printf("Hello, World!\n");
  return EXIT_SUCCESS;
}

4.打开local.conf文件:

~/var-fslc-yocto/build/conf/local.conf

然后,在文件末尾添加以下行,以将包包含在您接下来将构建的任何映像中:

IMAGE_INSTALL_append = " hello-world"

5. 构建你的镜像(例如 core-image-base):

cd ~/your-yocto-fslc/build/
bitbake core-image-base

“你好,世界!” 应用程序将安装到 /usr/bin/hello-world,如上面配方的 do_install() 函数中所定义。

基于 Variscite 博客的示例:创建自定义 Yocto BSP 层


推荐阅读