yocto-第37篇-编译可以在beaglebone开发板上运行的镜像

By: fulinux
E-mail: fulinux@sina.com
Blog: https://blog.csdn.net/fulinus
喜欢的盆友欢迎点赞和订阅!
你的喜欢就是我写作的动力!

引言

说实话,我也没有beaglebone开发板在手上,为什么要编译这个呢?
我觉得吧,这个是一个arm架构的、能在实际板子上运行的、yocto官方官方用来验证yocto的、有uboot的、有dts的一个项目。所以很具有参考意义。

也不清楚能不能用qemu。(后记:可以运行虚拟机)

有freescale的imx系列的开发板的盆友,也可以使用meta-freescale(到这里下载:http://git.yoctoproject.org/cgit/cgit.cgi/meta-freescale/),来构建自己的项目。meta-freescale做的也是相当的专业,我最早开始接触yocto时,也是freescale的imx6q项目带入门的,在国内没有任何相关博客的时候,就是看Freescale的文档一点点折腾,搞了linux后,还把android系统给跑起来了,哈哈。现在是在搞高通平台的,不过高通的yocto版本很低,做的也不够专业,很乱很多都是从android搬过来的。

meta-yocto-bsp目录做什么的

meta-yocto-bsp目录应该可以说是yocto官方针对三个硬件体系架构(x86、arm、mips)开发的模板实例项目。是可以实际在硬件上面跑的,之前我们学习的都是在qemu上面运行的。因此作为开发人员,如果想将自己的项目通过yocto方式构建起系统,可以参考对应体系架构的项目。
arm架构的项目配置文件就是:

meta-yocto-bsp/conf/machine/beaglebone-yocto.conf
  • 1

有关beaglebone可以参考:

cat poky/README.hardware 
  • 1

很多盆友使用的电脑都是i3/i5/i7(5代和6代的)的CPU,也是可以编译x86的镜像在实际电脑上面跑一跑。具体支持看文档:

Intel Xeon/Core i-Series:
  + Intel NUC5 Series - ix-52xx Series SOC (Broadwell)
  + Intel NUC6 Series - ix-62xx Series SOC (Skylake)
  + Intel Shumway Xeon Server
  • 1
  • 2
  • 3
  • 4

有条件的盆友可以在网上购买beaglebone。

创建一个新目录

大体和上一篇类同:
~]$ mkdir beaglebone
~]$ cp -rf poky/.git beaglebone/
~]$ cp -rf poky/.gitignore beaglebone/

检出代码:

~]$ cd beaglebone/
beaglebone]$ git checkout .
  • 1
  • 2

修改local.conf模板

beaglebone相关的machine都在

poky-arm]$ vim meta-poky/conf/local.conf.sample
#改这个
MACHINE ?= "beaglebone-yocto"
  • 1
  • 2
  • 3

创建build目录

poky-arm]$ source oe-init-build-env
  • 1

修改downloads路径

英文yocto版本一致,将DL_DIR设置成之前已下载好软包的poky/build/downloads目录,这个目录下面有很多通用的软件包,避免重复下载。

build]$ vim conf/local.conf
#添加或者修改:
DL_DIR ?= "${HOME}/poky/build/downloads"
  • 1
  • 2
  • 3

重新source一遍:

build]$ cd ..
poky-arm]$ source oe-init-build-env 
  • 1
  • 2

开始编译

build]$ bitbake core-image-minimal
  • 1

等待。。。

运行虚拟机

wowo~ 太让人惊喜了,这个可以运行虚拟机:

build]$ runqemu beaglebone-yocto
  • 1

在这里插入图片描述
这个太棒了,不用购买beaglebone开发板就可以实现arm嵌入式开发。太棒了!

由于是core-image-minimal,看到的是串口控制台的内容。我们尝试完整编译看看效果:

build]$ bitbake core-image-sato
  • 1

我们先看下有哪些输出文件:

build]$ ls tmp/deploy/images/
beaglebone-yocto
[peeta@peeta-OptiPlex-7050 build]$ ls tmp/deploy/images/beaglebone-yocto/
am335x-bone--5.4.49+git0+416566e1f0_ec485bd4af-r0-beaglebone-yocto-20210109112834.dtb
am335x-bone-beaglebone-yocto.dtb
am335x-boneblack--5.4.49+git0+416566e1f0_ec485bd4af-r0-beaglebone-yocto-20210109112834.dtb
am335x-boneblack-beaglebone-yocto.dtb
am335x-boneblack.dtb
am335x-bone.dtb
am335x-bonegreen--5.4.49+git0+416566e1f0_ec485bd4af-r0-beaglebone-yocto-20210109112834.dtb
am335x-bonegreen-beaglebone-yocto.dtb
am335x-bonegreen.dtb
core-image-minimal-beaglebone-yocto-20210109112834.qemuboot.conf
core-image-minimal-beaglebone-yocto-20210109112834.rootfs.jffs2
core-image-minimal-beaglebone-yocto-20210109112834.rootfs.manifest
core-image-minimal-beaglebone-yocto-20210109112834.rootfs.tar.bz2
core-image-minimal-beaglebone-yocto-20210109112834.rootfs.wic
core-image-minimal-beaglebone-yocto-20210109112834.rootfs.wic.bmap
core-image-minimal-beaglebone-yocto-20210109112834.testdata.json
core-image-minimal-beaglebone-yocto.jffs2
core-image-minimal-beaglebone-yocto.manifest
core-image-minimal-beaglebone-yocto.qemuboot.conf
core-image-minimal-beaglebone-yocto.tar.bz2
core-image-minimal-beaglebone-yocto.testdata.json
core-image-minimal-beaglebone-yocto.wic
core-image-minimal-beaglebone-yocto.wic.bmap
core-image-minimal.env
MLO
MLO-beaglebone-yocto
MLO-beaglebone-yocto-2020.01-r0
modules--5.4.49+git0+416566e1f0_ec485bd4af-r0-beaglebone-yocto-20210109112834.tgz
modules-beaglebone-yocto.tgz
u-boot-beaglebone-yocto-2020.01-r0.img
u-boot-beaglebone-yocto.img
u-boot.img
u-boot-initial-env
u-boot-initial-env-beaglebone-yocto
u-boot-initial-env-beaglebone-yocto-2020.01-r0
zImage
zImage--5.4.49+git0+416566e1f0_ec485bd4af-r0-beaglebone-yocto-20210109112834.bin
zImage-beaglebone-yocto.bin
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41

有u-boot、dtb、zImage、rootfs等文件,是不是很nice。
具体内容后续几篇再具体分析。

完整编译运行结果

经过上面的:

build]$ bitbake core-image-sato
  • 1

运行虚拟机,发现桌面环境并没有起来,看图中错误提示:

在这里插入图片描述

xinit: giving up #放弃了
xinit: unable to connect to X server: connection refused
xinit: server error
  • 1
  • 2
  • 3

可见我们的xserver服务没有运行起来,可能是qemu虚拟机运行该平台是没有LCD显示屏,或者qemu配置没有使能等原因。
但是这个不是很要紧的问题。

后记,不过有点遗憾的是引导内核启动的不是u-boot,应该是qemu虚拟机自行将其加载到指定位置运行的。