Prática 03 - Preparando ambiente Yocto Project
Note
Diretório de trabalho: ~/treinamento/yp
Baixando Poky
Basicamente para começar a trabalhar com Yocto Project, precisamos clonar o repositório do projeto Poky que contém todas as ferramentas.
mkdir -p ~/treinamento/yp
cd ~/treinamento/yp
git clone -b scarthgap git://git.yoctoproject.org/poky.git
ATENÇÃO
Em caso de erro utilizar:
git clone -b scarthgap https://git.yoctoproject.org/poky
Acessando o diretório poky e listando o conteúdo:
Saída esperada:
drwxrwxr-x 6 b2open b2open 300 May 01 12:26 bitbake
drwxrwxr-x 4 b2open b2open 80 May 01 12:26 contrib
drwxrwxr-x 21 b2open b2open 740 May 01 12:26 documentation
-rw-rw-r-- 1 b2open b2open 834 May 01 12:26 LICENSE
-rw-rw-r-- 1 b2open b2open 15394 May 01 12:26 LICENSE.GPL-2.0-only
-rw-rw-r-- 1 b2open b2open 1286 May 01 12:26 LICENSE.MIT
-rw-rw-r-- 1 b2open b2open 2186 May 01 12:26 MAINTAINERS.md
-rw-rw-r-- 1 b2open b2open 244 May 01 12:26 MEMORIAM
drwxrwxr-x 21 b2open b2open 460 May 01 12:26 meta
drwxrwxr-x 5 b2open b2open 120 May 01 12:26 meta-poky
drwxrwxr-x 10 b2open b2open 220 May 01 12:26 meta-selftest
drwxrwxr-x 7 b2open b2open 160 May 01 12:26 meta-skeleton
drwxrwxr-x 8 b2open b2open 180 May 01 12:26 meta-yocto-bsp
-rwxrwxr-x 1 b2open b2open 1488 May 01 12:26 oe-init-build-env
lrwxrwxrwx 1 b2open b2open 33 May 01 12:26 README.hardware.md -> meta-yocto-bsp/README.hardware.md
lrwxrwxrwx 1 b2open b2open 14 May 01 12:26 README.md -> README.poky.md
-rw-rw-r-- 1 b2open b2open 998 May 01 12:26 README.OE-Core.md
lrwxrwxrwx 1 b2open b2open 24 May 01 12:26 README.poky.md -> meta-poky/README.poky.md
-rw-rw-r-- 1 b2open b2open 529 May 01 12:26 README.qemu.md
drwxrwxr-x 11 b2open b2open 1860 May 01 12:26 scripts
-rw-rw-r-- 1 b2open b2open 1064 May 01 12:26 SECURITY.md
Criando o primeiro projeto
Saída esperada:
You had no conf/local.conf file. This configuration file has therefore been
created for you from /tmp/poky/meta-poky/conf/templates/default/local.conf.sample
You may wish to edit it to, for example, select a different MACHINE (target
hardware).
You had no conf/bblayers.conf file. This configuration file has therefore been
created for you from /tmp/poky/meta-poky/conf/templates/default/bblayers.conf.sample
To add additional metadata layers into your configuration please add entries
to conf/bblayers.conf.
The Yocto Project has extensive documentation about OE including a reference
manual which can be found at:
https://docs.yoctoproject.org
For more information about OpenEmbedded see the website:
https://www.openembedded.org/
This is the default build configuration for the Poky reference distribution.
### Shell environment set up for builds. ###
You can now run 'bitbake <target>'
Common targets are:
core-image-minimal
core-image-full-cmdline
core-image-sato
core-image-weston
meta-toolchain
meta-ide-support
You can also run generated qemu images with a command like 'runqemu qemux86-64'.
Other commonly useful commands are:
- 'devtool' and 'recipetool' handle common recipe tasks
- 'bitbake-layers' handles common layer tasks
- 'oe-pkgdata-util' handles common target package tasks
You had no /tmp/poky/.vscode configuration.
These configuration files have therefore been created for you.
Configurando o projeto pela primera vez
Utilize o editor de sua preferência, e edite o arquivo conf/local.conf procure a variável MACHINE ??= "qemux86-64" comente e descomente a opção MACHINE ?= "qemuarm":
Antes de executar o comando bitbake é uma boa prática configurar limites no hardware de build para não ocorrer travamentos, Configurando Limites para Build com Bitbake
Executando o primeiro build
Utilizando bitbake execute o comando abaixo para iniciar a construção de um Sistema Linux Embarcado, configurado acima para o hardware qemuarm:
Acessando os arquivos gerados
O resultado da construção é a geração dos arquivos Bootloaderk, Kernel, RootFS, Device-Tree entre outros arquivos como de Instalação e Firmwares. Acesse o diretorio tmp/deploy/images/qemuarm:
Listando o conteudo do diretorio:
Resultado:
-rw-r--r-- 2 b2open b2open 14110720 May 6 08:56 core-image-minimal-qemuarm.rootfs-20260506115431.ext4
-rw-r--r-- 2 b2open b2open 1116 May 6 08:56 core-image-minimal-qemuarm.rootfs-20260506115431.manifest
-rw-r--r-- 2 b2open b2open 1893 May 6 08:56 core-image-minimal-qemuarm.rootfs-20260506115431.qemuboot.conf
-rw-r--r-- 2 b2open b2open 126369 May 6 08:56 core-image-minimal-qemuarm.rootfs-20260506115431.spdx.tar.zst
-rw-r--r-- 2 b2open b2open 4340958 May 6 08:56 core-image-minimal-qemuarm.rootfs-20260506115431.tar.bz2
-rw-r--r-- 2 b2open b2open 264442 May 6 08:56 core-image-minimal-qemuarm.rootfs-20260506115431.testdata.json
lrwxrwxrwx 2 b2open b2open 53 May 6 08:56 core-image-minimal-qemuarm.rootfs.ext4 -> core-image-minimal-qemuarm.rootfs-20260506115431.ext4
lrwxrwxrwx 2 b2open b2open 57 May 6 08:56 core-image-minimal-qemuarm.rootfs.manifest -> core-image-minimal-qemuarm.rootfs-20260506115431.manifest
lrwxrwxrwx 2 b2open b2open 62 May 6 08:56 core-image-minimal-qemuarm.rootfs.qemuboot.conf -> core-image-minimal-qemuarm.rootfs-20260506115431.qemuboot.conf
lrwxrwxrwx 2 b2open b2open 61 May 6 08:56 core-image-minimal-qemuarm.rootfs.spdx.tar.zst -> core-image-minimal-qemuarm.rootfs-20260506115431.spdx.tar.zst
lrwxrwxrwx 2 b2open b2open 56 May 6 08:56 core-image-minimal-qemuarm.rootfs.tar.bz2 -> core-image-minimal-qemuarm.rootfs-20260506115431.tar.bz2
lrwxrwxrwx 2 b2open b2open 62 May 6 08:56 core-image-minimal-qemuarm.rootfs.testdata.json -> core-image-minimal-qemuarm.rootfs-20260506115431.testdata.json
-rw-r--r-- 2 b2open b2open 51811068 May 6 07:28 modules--6.6.144+git0+a77e1b9654_3adc19c1e1-r0-qemuarm-20260506012920.tgz
lrwxrwxrwx 2 b2open b2open 73 May 6 07:28 modules-qemuarm.tgz -> modules--6.6.144+git0+a77e1b9654_3adc19c1e1-r0-qemuarm-20260506012920.tgz
lrwxrwxrwx 2 b2open b2open 72 May 6 07:28 zImage -> zImage--6.6.144+git0+a77e1b9654_3adc19c1e1-r0-qemuarm-20260506012920.bin
-rw-r--r-- 2 b2open b2open 7378928 May 6 07:28 zImage--6.6.144+git0+a77e1b9654_3adc19c1e1-r0-qemuarm-20260506012920.bin
lrwxrwxrwx 2 b2open b2open 72 May 6 07:28 zImage-qemuarm.bin -> zImage--6.6.144+git0+a77e1b9654_3adc19c1e1-r0-qemuarm-20260506012920.bin
Executando a imagem gerada com runqemu
A ferramenta runqemu é um script que permite executar a imagem gerada no Yocto Project com bitbake utilizando QEMU, as possíveis configurações para MACHINE e utilizar QEMU são:
MACHINE ?= "qemuarm"
#MACHINE ?= "qemuarm64"
#MACHINE ?= "qemumips"
#MACHINE ?= "qemumips64"
#MACHINE ?= "qemuppc"
#MACHINE ?= "qemux86"
#MACHINE ?= "qemux86-64"
Executando o comando runqemu com o mesmo MACHINE configurado:
Para retornar ao terminal do Linux com Yocto Project, digite poweroff dentro do QEMU em execução!