为了辅助理解yocto编译的架构和编译过程,写一遍helloworld会好很多。

首先下载编译poky

$ git clone git://git.yoctoproject.org/poky
$ cd poky
$ source oe-init-build-env
$ bitbake core-image-sato

创建自己的layer:meta-mylayer

$ bitbake-layers create-layer meta-mylayer
NOTE: Starting bitbake server...
Add your new layer with 'bitbake-layers add-layer meta-mylayer'

在poky目录下通过bitbake-layers增加meta-layer,提示找不到bblayers.conf,原来是要在build目录下添加才对:

hui@hui:~/disk4t/codes/poky
$ bitbake-layers add-layer meta-mylayer
NOTE: Starting bitbake server...
Unable to find bblayers.conf

在build目录下add-layer, 没有指定meta-mylayer路径报错

hui@hui:~/disk4t/codes/poky/build
$ bitbake-layers add-layer meta-mylayer
NOTE: Starting bitbake server...
Specified layer directory /home/hui/disk4t/codes/poky/build/meta-mylayer doesn't exist

指定路径后可以了:

$ bitbake-layers add-layer ../meta-mylayer
NOTE: Starting bitbake server...

cat bblayer.conf可以看到meta-mylayer加到了最后一行

$ cat conf/bblayers.conf
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"BBPATH = "${TOPDIR}"
BBFILES ?= ""BBLAYERS ?= " \/home/hui/disk4t/codes/poky/meta \/home/hui/disk4t/codes/poky/meta-poky \/home/hui/disk4t/codes/poky/meta-yocto-bsp \/home/hui/disk4t/codes/poky/meta-mylayer \"

查看meta-mylayer目录

$ tree .
.
├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
└── recipes-example└── example└── example_0.1.bb

新建files目录,在files目录下添加hello.c文件

$ tree meta-mylayer/
meta-mylayer/
├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
└── recipes-example└── example├── example_0.1.bb└── files└── hello.c

修改example_0.1.bb,定义编译规则

SUMMARY = "bitbake-layers recipe"
LICENSE = "MIT"python do_display_banner() {bb.plain("***********************************************");bb.plain("*                                             *");bb.plain("*  Example recipe created by bitbake-layers   *");bb.plain("*                                             *");bb.plain("***********************************************");
}DESCRIPTION = "Simple helloworld application"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"SRC_URI = "file://hello.c"S = "${WORKDIR}"do_compile() {${CC} hello.c ${LDFLAGS} -o helloworld
}do_install() {install -d ${D}${bindir}install -m 0755 helloworld ${D}${bindir}
}

编译

$ bitbake example
Loading cache: 100% |########################################################################################################################################################################| Time: 0:00:00
Loaded 1470 entries from dependency cache.
NOTE: Resolving any missing task queue dependenciesBuild Configuration:
BB_VERSION           = "1.51.1"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "x86_64-poky-linux"
MACHINE              = "qemux86-64"
DISTRO               = "poky"
DISTRO_VERSION       = "3.3+snapshot-bf47addb34debc049b59e5e466228f00045c2061"
TUNE_FEATURES        = "m64 core2"
TARGET_FPU           = ""
meta
meta-poky
meta-yocto-bsp
meta-mylayer         = "master:bf47addb34debc049b59e5e466228f00045c2061"Initialising tasks: 100% |###################################################################################################################################################################| Time: 0:00:00
Sstate summary: Wanted 0 Local 0 Network 0 Missed 0 Current 153 (0% match, 100% complete)
NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 623 tasks of which 623 didn't need to be rerun and all succeeded.

然后在tmp目录下find生成的Helloworld

$ find . -name "helloworld"
./work-shared/gcc-11.2.0-r0/gcc-11.2.0/libgo/misc/cgo/fortran/helloworld
./work/core2-64-poky-linux/gstreamer1.0/1.18.4-r0/gstreamer-1.18.4/tests/examples/helloworld
./work/core2-64-poky-linux/example/0.1-r0/packages-split/example/usr/bin/helloworld
./work/core2-64-poky-linux/example/0.1-r0/packages-split/example-dbg/usr/bin/.debug/helloworld
./work/core2-64-poky-linux/example/0.1-r0/package/usr/bin/.debug/helloworld
./work/core2-64-poky-linux/example/0.1-r0/package/usr/bin/helloworld
./work/core2-64-poky-linux/example/0.1-r0/image/usr/bin/helloworld
./work/core2-64-poky-linux/example/0.1-r0/helloworld

在conf/local.conf文件中增加IMAGE_INSTALL

IMAGE_INSTALL = "example"

IMAGE_INSTALL_append = "example",用IMAGE_INSTALL_append如下会报错,没有研究应该怎么用

$ bitbake core-image-sato
ERROR: Variable IMAGE_INSTALL_append contains an operation using the old override syntax. Please convert this layer/metadata before attempting to use with a newer bitbake.

然后build core-image-sato

$ bitbake core-image-sato

编译完成后再次运行,这次可能因为加了helloworld的缘故,没有进入到图形界面,但是在QEMU的shell环境中就可以运行helloworld程序,输出’Hello World!’。

$ runqemu tmp/deploy/images/qemux86-64/bzImage-qemux86-64.bin tmp/deploy/images/qemux86-64/core-image-sato-qemux86-64.ext4

参考:

  • Yocto项目介绍及入门 – 嵌入师工程师必备利器
  • DART-6UL - Hello, World!

yocto的hello world相关推荐

  1. yocto linux dns,yocto-sumo源码解析(一): o

    oe-init-build-env是yocto构建环境运行的第一个脚本,通过运行下面的命令: . oe-init-build-env build-arm64 即可对yocto项目进行构建,顾名思义,该 ...

  2. yocto中文环境搭建

    2019独角兽企业重金招聘Python工程师标准>>> 我所使用的yocto版本是1.5.1,系统默认的locale是en_US,并不包含中文环境.但是在实际编译的过程中不仅仅是中文 ...

  3. imx6 板卡移植官方yocto版本(2_定制系统)

    上一节中已经讲述了如何去构建编译环境,这一节讲一下如何定制专属于自己板卡的系统.1.配置linux内核官方repo下来的yocto项目里配置了多个内核可选,我们可以在yocto目录下/source/m ...

  4. imx6 板卡移植官方yocto版本(1_安装环境)

    玩imx6板卡也有两年了,之前由于各种原因(主要是懒),一直用的是官方的LTIB版本,这里必须要吐槽一下这个LTIB,各种错误百出,而且严重挑系统,硬是将我从CentOS阵营搞到Ubuntu社区.最近 ...

  5. Yocto的使用实例

    Yocto的使用实例 本文以往rootfs中添加一个软件包为例,阐述使用Yocto定制发行版的大致流程.  有关Yocto的功能和结构介绍,详见Yocto详解 1.开发环境构建 一般有两种情况:一种是 ...

  6. Yocto基本概念及介绍

    Yocto详解 参考:http://www.yoctoproject.org/docs/2.1/mega-manual/mega-manual.html#creating-a-general-laye ...

  7. linux在mak时候出现错误,在使用yocto构建linux映像时出现“memfd戋create的静态声明跟随非静态声明”错误...

    我正在使用 Yocto 建立系统 Ubuntu 18.04 主机.我正在遵循提供的步骤 here . 我正在为 Colibri iMX6ULL 模块上的计算机.但是,我的生成失败,它显示以下错误 de ...

  8. 根文件系统构建(Yocto方式)

    本章有独立的教程,请参考<[正点原子]I.MX6U Yocto 构建根文件系统V1.0.pdf>!

  9. Yocto Project - basic - 01 - Quick Start

    Yocto 是一个被广泛使用的操作系统,本节开始介绍: 文章的内容来自于Yocto的官方介绍文档. 1 简介 The Yocto Project is an open-source collabora ...

  10. YOCTO项目介绍:通过提供模版、工具和方法帮助开发者创建基于linux内核的定制系统

    目录 YOCTO项目介绍 配置内核 build配套 Yocto ,是一个开源社区.它通过提供模版.工具和方法帮助开发者创建基于linux内核的定制系统,支持ARM, PPC, MIPS, x86 (3 ...

最新文章

  1. 使用iText库创建PDF文件
  2. [链接]开方检验原理
  3. group by分组、having() 筛选组的用法
  4. MySQL表结构管理
  5. 安装rpm报错:requires Ruby version >= 2.*.*
  6. Centos 6.4部署DNS服务器
  7. RocketMQ源码解析-事务消息的二阶段提交
  8. matlab转自张朋飞
  9. 数据分析对企业的重要性
  10. shell基础之综合练习
  11. OrCAD PSpice添加Spice模型——Cadence 17.4
  12. python编程课件_Python面向对象程序设计ppt课件.ppt
  13. Elasticsearch开启安全认证详细步骤
  14. 【黑金原创教程】【Modelsim】【第五章】仿真就是人生
  15. ubuntu 改屏幕分辨率命令_ubuntu下修改分辨率
  16. mysql密码认证插件_关于mysql:无法加载身份验证插件’caching_sha2_password’
  17. win10-2016企业版长期服务版激活
  18. 左眼跳灾,右眼跳财?
  19. 帖子浏览定位展开、收起标签js部分思路及代码
  20. Python学习笔记——selenium无头模式

热门文章

  1. LaTex 带边框逻辑清晰的伪代码
  2. 突然发现一款优化神器
  3. python实用案例教程第四章-python 入门到实践第四章案例
  4. 六级(2020/12-2) Section B
  5. 计算机如何更改键盘设置在哪里设置,原神pc按键怎么改
  6. python词频统计三国演义_python实例:三国演义TXT文本词频分析
  7. 【服务器】服务器安全防护、防止服务器攻击和保护措施
  8. 计算机中怎样算2的21次方,脑筋急转弯:2的31次方与3的21次方哪个大?天才知道!...
  9. linux tab键失灵了,Linux grep \t Tab 键失效
  10. Barrett And Montgomery of Polynomials