基于poky项目创建自己的层并且在层中增加自己的配方文件

1.本地获取poky

git clone git://git.yoctoproject.org/poky

建议使用kirkstone分支

git checkout -b remotes/origin/kirkstone

2.新增层

初始化poky环境

source oe-init-build-env

创建新层,meta-test

~/test/poky/build$ bitbake-layers create-layer ../meta-test

把层配置到poky环境中

~/test/poky/build$ bitbake-layers add-layer ../meta-test

检查层是否配置成功

~/test/poky/build$ bitbake-layers show-layers
NOTE: Starting bitbake server...
layer                 path                                                 priority
===================================================================================
core                  /xxx/xxx/poky/meta                                   5
yocto                 /xxx/xxx/poky/meta-poky                              5
yoctobsp              /xxx/xxx/poky/meta-yocto-bsp                         5
meta-test             /xxx/xxx/poky/meta-test                              6

检查层中文件

~/test/poky/meta-test$ tree
.
├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
└── recipes-example└── example└── example_0.1.bb3 directories, 4 files

在层中新增文件夹,并且为了便于后序,模仿example在该文件夹下新增hello包

~/test/poky/meta-test$ tree
.
├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
├── recipes-example
│   └── example
│       └── example_0.1.bb
└── recipes-test└── hello5 directories, 4 files

3.在层中添加测试配方文件

3.1 配方文件目标源为本地压缩包

  • 1.创建简单工程

    • hello.h

      #pragma once#include<stdio.h>void hello(void);
      
    • hello.c
      #include"hello.h"void hello(void)
      {printf("hello world!!");
      }
      
    • main.c
      #include "hello.h"int main()
      {hello();return 0;
      }
      
  • 2.将这三个文件打包
    tar cvfz hello-1.0.tgz .
    

    将包放在recipes-test/hello/hello-1.0中

  • 3.新建配方文件hello-1.0.bb,并将配方文件放在hello工程文件夹中
    SUMMARY = "Hello World"
    DESCRIPTION = "A simple test to learn how to crate a recipe"SECTION = "examples"
    PRIORITY = "optional"LICENSE = "MIT"
    LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"SRC_URI = "file://hello-1.0.tgz"S = "${WORKDIR}"do_compile(){${CC} -c hello.c${CC} -c main.c${CC} -o hello hello.o main.o
    }do_install() {install -d ${D}${bindir}install -m 0755 hello ${D}${bindir}
    }
    

    recipes-test的文件结构

    recipes-test└── hello├── hello-1.0│   └── hello-1.0.tgz└── hello_1.0.bb
    

3.2 配方文件目标源为在线源

源:https://ftp.gnu.org/gnu/hello/

配方文件:hello_2.12.bb

SUMMARY = "The Test hello"
DESCRIPTION = "T"
HOMEPAGE = "https://ftp.gnu.org/gnu/hello/"LICENSE = ""
LIC_FILES_CHKSUM = ""#建议不使用固定版本号便于移植
SRC_URI = "${HOMEPAGE}hello-${PV}.tar.gz"
#SRC_URI = "https://ftp.gnu.org/gnu/hello/hello-{PV}.tar.gz"
#SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.gz"
#这里三种下载方式都可以使用#打补丁
#SRC_URI = "https://ftp.gnu.org/gnu/hello/hello-{PV}.tar.gz \
#           file://patch-1.patch;striplevel=3 \  #如果补丁需要多级目录被除去
#           file://patch-2.diff;patchdir=src/common \ #补丁需要被应用进特定的、不是在补丁文件本身内提供的子目录中,那么你增加patchdir选项到SRC_URI
#           "
#把补丁和任何其他本地获取的文件放在菜谱旁边的子目录中,子目录被命名成和菜谱的基名称BPN相同,或者被命名成基名称加版本号BP,或者被命名成filesSRC_URI[sha256sum] = "cf04af86dc085268c5f4470fbae49b18afbc221b78096aab842d934a76bad0ab"
#既可以使用sha256也可以使用MD5进行校验S = "${WORKDIR}/{BP}"do_install() {install -d {B}/bin/hello ${D}/${bindir}install -d {B}/bin/hello.lib ${D}/${libdir}
}

:配方文件中源所指定的包名字为hello-${PV}.tar.gz${PV}为配方文件名的版本号2.12。一定要确保源上存在hello-2.12.tar.gz的包,不然会fetch失败

4.调试

4.1 整体编译

bitbake hello

:因为配方文件使用了gcc编译,而gcc是默认继承autotool类,所以在第一次整体编译时bitbake会从网上下载工具所依赖的各种库,速度较慢。

4.2 分task进行编译

在自己编写配方文件时分task进行执行编译在编译过程中debug

  • fetch
bitbake -c fetch hello

注:fetch task和配方文件中的SRC_URI息息相关,并且可以有多种来源,在使用时一定要确保源地址正确并且和任务文件夹名正确(配方的file变量,本例中为hello/hello-1.0)

常见错误

fetch路径有误

WARNING: hello-1.o-r0 do_fetch: Failed to fetch URL file://hello-1.0.tgz, attempting MIRRORS if available
ERROR: hello-1.o-r0 do_fetch: Fetcher failure: Unable to find file file://hello-1.0.tgz anywhere. The paths that were searched were:
检查包存放路径是否正确
确保路径名字是否正确
确保配方文件名是否和存放压缩包的上层名字对应

fetch下载源错误

ERROR: hello-2.12-r0 do_fetch: Bitbake Fetcher Error: FetchError('Unable to fetch URL from any source.', 'https://ftp.gnu.org/gnu/hello/hello-{PV}.tar.gz')
hello-2.12-r0 do_fetch: Failed to fetch URL https://ftp.gnu.org/gnu/hello/hello-{PV}.tar.gz, attempting MIRRORS if available
ERROR: hello-2.12-r0 do_fetch: Fetcher failure: Fetch command export PSEUDO_DISABLED=1; export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"; export SSH_AGENT_PID="1683"; export SSH_AUTH_SOCK="/run/user/1000/keyring/ssh"; export PATH="/xxx/poky/poky/build/tmp/sysroots-uninative/x86_64-linux/usr/bin:/xxx/poky/scripts:/xxx/poky/poky/build/tmp/work/core2-64-poky-linux/hello/2.12-r0/recipe-sysroot-native/usr/bin/x86_64-poky-linux:/xxx/poky/poky/build/tmp/work/core2-64-poky-linux/hello/2.12-r0/recipe-sysroot/usr/bin/crossscripts:/xxx/poky/build/tmp/work/core2-64-poky-linux/hello/2.12-r0/recipe-sysroot-native/usr/sbin:/xxx/poky/build/tmp/work/core2-64-poky-linux/hello/2.12-r0/recipe-sysroot-native/usr/bin:/xxx/poky/poky/build/tmp/work/core2-64-poky-linux/hello/2.12-r0/recipe-sysroot-native/sbin:/xxx/poky/poky/build/tmp/work/core2-64-poky-linux/hello/2.12-r0/recipe-sysroot-native/bin:/xxx/poky/poky/bitbake/bin:/xxx/poky//poky/build/tmp/hosttools"; export HOME="xxx"; /usr/bin/env wget -t 2 -T 30 --passive-ftp -P /xxx/poky/poky/build/downloads 'https://ftp.gnu.org/gnu/hello/hello-{PV}.tar.gz' --progress=dot -v failed with exit code 8, no output
ERROR: hello-2.12-r0 do_fetch: Bitbake Fetcher Error: FetchError('Unable to fetch URL from any source.', 'https://ftp.gnu.org/gnu/hello/hello-{PV}.tar.gz')
ERROR: Logfile of failure stored in: /xxx/poky/poky/build/tmp/work/core2-64-poky-linux/hello/2.12-r0/temp/log.do_fetch.17456
ERROR: Task (/xxx/poky/poky/meta-test/recipes-test/hello/hello_2.12.bb:do_fetch) failed with exit code '1'
配方文件所指定的源的包名为hello-{PV}.tar.gz,那么在下载时就需要确保提供的源镜像网站是正确的并且存在该包hello-{PV}.tar.gz,也就是需要确保配方文件的版本号和源镜像网站的包进行对应
确保包名无误,确保源网站包存在

源下载校验错误

ERROR: hello-2.12-r0 do_fetch: Checksum failure fetching https://ftp.gnu.org/gnu/hello/hello-2.12.tar.gz
ERROR: hello-2.12-r0 do_fetch: Bitbake Fetcher Error: ChecksumError('Checksum mismatch!\nFile: \'/xxx/poky/build/downloads/hello-2.12.tar.gz\' has md5 checksum \'048d95d41f9c0bd3424bf0917f53782d\' when \'67607d2616a0faaf5bc94c59dca7c3cb\' was expected\nIf this change is expected (e.g. you have upgraded to a new version without updating the checksums) then you can use these lines within the recipe:\nSRC_URI[sha256sum] = "cf04af86dc085268c5f4470fbae49b18afbc221b78096aab842d934a76bad0ab"\nOtherwise you should retry the download and/or check with upstream to determine if the file has become corrupted or otherwise unexpectedly modified.', 'https://ftp.gnu.org/gnu/hello/hello-2.12.tar.gz')
SRC_URI[sha256sum]检验值和源包的sha256值不对应
用log提示的正确值替换错误的

compile使用gcc错误

ERROR: hello-1.0-r0 do_compile: ExecutionError('/xxx/poky/build/tmp/work/core2-64-poky-linux/hello/1.0-r0/temp/run.do_compile.830233', 1, None, None)
ERROR: Logfile of failure stored in: /xxx/poky/build/tmp/work/core2-64-poky-linux/hello/1.0-r0/temp/log.do_compile.830233
Log data follows:
| DEBUG: Executing shell function do_compile
| x86_64-poky-linux-gcc: warning: hello: linker input file unused because linking not done
| x86_64-poky-linux-gcc: error: hello: linker input file not found: No such file or directory
| WARNING: exit code 1 from a shell command.
错误 代码编译错误
检查gcc参数是否使用正确

[yocto]基于poky项目创建自己的层并且在层中增加自己的配方文件相关推荐

  1. 基于javaweb项目ssm食品管理系统设计与实现(论文+程序设计源码+数据库文件)

    摘要:随着食品产业的发展.食品销量的增加.新食品种类的快速增加.新的食品技术的发展,已经得到各个国家的关注,因为食品安全状况是和广大人民群众的身体健康息息相关的.本系统主要采用springboot开发 ...

  2. scp创建远程目录_在Linux系统中使用Vim读写远程文件

    大家好,我是良许. 今天我们讨论一个 Vim 使用技巧--用 Vim 读写远程文件.要实现这个目的,我们需要使用到一个叫 netrw.vim 的插件.从 Vim 7.x 开始,netrw.vim 就被 ...

  3. Abp VNext 项目创建简介

    文章目录 简介 项目创建 关于 module 项目的简单说明 简单优化项目 1.移动端项目删除 2.*.sln.DotSettings 3.*.HttpApi.Host 的调整 4.*.HttpApi ...

  4. git的项目创建和常用命令

    如果是第一次使用git,需要配置提交者的信息 git config user.name 你的目标用户名 git config user.email 你的目标邮箱名# 使用--global参数,配置全局 ...

  5. 01-创建项目 创建数据表-类别管理--添加类别--持久层

    文章目录 1. 关于此项目 2. 关于项目的开发流程 3. 创建数据库与数据表 4. 关于Project与Module 5. 创建Project 6. 商品管理模块项目 7. 关于编写代码 8. 类别 ...

  6. git项目创建、克隆(基于git bash)

    git项目创建.克隆(基于git bash) 1.本地搭建仓库 1)先在远程仓库(gitee)创建项目 2)在本地打开git bash用下面的代码初始化 3) 给本地仓库添加远程仓库 4) 配置.gi ...

  7. 基于ABP vNext 4.X(.Net 5)的Blazor项目创建及配置

    0 环境 Visual Studio 2019 (v16.8.3) dotnet C:\Users\liudy> dotnet --version 5.0.101 Redis 5.0.3 CLI ...

  8. 基于HTML5 Boilerplate创建自己的项目

    web 开发团队的一个常见实践是创建一组标准文件,团队成员基于它们开始 web 开发流程,包括一个公共文件结构.基本命名惯例和标准库. 这样做能够更容易启动并运行一个项目.它还能将开发人员引向内部编码 ...

  9. Ecplise基于Maven创建springboot项目基础-项目创建报错分析

    1.工具:Ecplise 2.jdk 3.下载maven 下载地址:https://maven.apache.org/ 将下载文件解压在任意一个空文件夹内,项目文件结构如图(小编是下载maven3.3 ...

最新文章

  1. jQuery判断checkbox是否选中
  2. 99%的产品经理不知道的秘密:如何招程序猿喜欢?
  3. USACO 3.1 Score Inflation(完全背包 模版)
  4. 容器和云服务器集群,什么是docker集群与镜像
  5. Microsoft .NET 框架资源基础 ---摘自:msdn
  6. Qt实现QTextEdit背景透明
  7. linux的nice命令用法,nice命令详解
  8. 【kafka】Number of alive brokers 0 does not meet the required replication factor 3
  9. java表格怎么添加按钮_1.6.2 在表格中添加按钮
  10. std::set, std::list, std::vector在erase的区别
  11. 昔日网瘾少年,现在用AI教你打守望先锋
  12. Pikachu实验重现2(Sql的注入)
  13. Project configuration is not up-to-date with pom.xml. Run Maven-Update Project or use Quick Fix
  14. linux 编译cgal,CGAL Bindings python Linux(Ubuntu) 安装配置 使用 CGAL-5.0.2库
  15. SpringCLoud+redis+es高并发项目《九》(Spring Security Oauth2 JWT)
  16. 珍大户《认知世界的经济学》学习笔记 -- 第17课 影响消费者的因素,更新时间2021年03月18日21:53:57
  17. 微信小程序【获取用户昵称头像和昵称(附源码)】
  18. 出入库管理系统php,php销售供应链管理系统
  19. 教程 | 在Unity中使用 Isometric Tilemap(等距、正交)
  20. UPC 2020年夏混合个人训练第七十五场

热门文章

  1. oracle数据库日常管理,讲解Oracle数据库管理员每月的职责以及日常管理工作
  2. Evernote 竞品 Notesnook 正式开源
  3. JIT 即时编译及优化技术
  4. VGA、QVGA、HVGA、WVGA、
  5. 我是如何用IDEA调试BUG的?
  6. django连接mysql出现MySQLdb._exceptions.OperationalError
  7. c语言中两个文件一起编译,keil中怎么把两个c程序怎么同时同时编译生成一个hex文件...
  8. wex5 java服务器_wex5教程 宝塔面板+lnmp+wex5项目部署
  9. 跨境电商与时俱进,流星汇聚紧跟新规则做优质服务
  10. 【数据库课设】图书馆借阅系统