Yocto: Base Build and Flash Steps
In this section, you are going to learn
How to build a base image for yocto ?
How to generate full base yocto image for RPI-4B ?
How to flash full base yocto image for RPI-4B ?
How to run minicom and work remotely with RPI-4B ?
How to do pre-build and post-build checks ?
Topics in this section,
In this section, we will see how to clone and add configurations for yocto build directory
Install all the pre-required packages to avoid package related error or dependencies
$ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \ build-essential chrpath socat cpio python3 python3-pip python3-pexpect \ xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \ pylint3 xterm
Create a build directory to clone all the yocto required meta-directories
$ cd $HOME $ mkdir yocto_build $ cd yocto_build $ mkdir sources $ cd sources
Clone the poky directory inside the sources directory
$ git clone -b dunfell git://git.yoctoproject.org/poky.git
Clone the meta-raspberrypi directory inside the sources directory
$ git clone -b dunfell git://git.yoctoproject.org/meta-raspberrypi
Clone the meta-openembedded directory inside the sources directory
$ git clone -b dunfell git://git.openembedded.org/meta-openembedded
In this secion, we will see how to intialize,add build configurations and set locale settings
Create build dir by running the following command.
$ pwd $HOME/yocto_build/sources/ $ cd .. $ . sources/poky/oe-init-build-env
Now the build directory will be created.
Add machine as raspberrypi4 in local.conf
$ vi conf/local.confMACHINE ??= "raspberrypi4" LICENSE_FLAGS_ACCEPTED = "synaptics-killswitch"
Add the neccessary meta-layers which needs to be built in bblayers.conf
$ vi conf/bblayers.confBBLAYERS ?= " \ /home/test/yocto/sources/poky/meta \ /home/test/yocto/sources/poky/meta-poky \ /home/test/yocto/sources/poky/meta-yocto-bsp \ /home/test/yocto/sources/meta-openembedded/meta-oe \ /home/test/yocto/sources/meta-openembedded/meta-python \ /home/test/yocto/sources/meta-raspberrypi \ "
Set Locale settings as “en_US.UTF-8”
export LC_ALL="en_US.UTF-8" export LC_CTYPE="en_US.UTF-8" sudo dpkg-reconfigure locales
In this section you will learn how to do Pre-build checks
Check whether the machine is set as “raspberrypi4” or not in the local.conf file.
MACHINE ??= "raspberrypi4"
Check whether the meta-layers are added or not in bblayers.conf
BBLAYERS ?= " \ /home/test/yocto/sources/poky/meta \ /home/test/yocto/sources/poky/meta-poky \ /home/test/yocto/sources/poky/meta-yocto-bsp \ /home/test/yocto/sources/meta-openembedded/meta-oe \ /home/test/yocto/sources/meta-openembedded/meta-python \ /home/test/yocto/sources/meta-raspberrypi \ "
$ pwd $HOME/yocto_build/build $ cd tmp/hosttoolsSee the output below
$ ls -l lrwxrwxrwx 1 test test 10 Jan 4 12:59 '[' lrwxrwxrwx 1 test test 11 Jan 4 12:59 ar lrwxrwxrwx 1 test test 11 Jan 4 12:59 as lrwxrwxrwx 1 test test 12 Jan 4 12:59 awk lrwxrwxrwx 1 test test 17 Jan 4 12:59 basename lrwxrwxrwx 1 test test 13 Jan 4 12:59 bash lrwxrwxrwx 1 test test 14 Jan 4 12:59 bzip2 lrwxrwxrwx 1 test test 12 Jan 4 13:00 bzr lrwxrwxrwx 1 test test 12 Jan 4 12:59 cat lrwxrwxrwx 1 test test 14 Jan 4 12:59 chgrp lrwxrwxrwx 1 test test 14 Jan 4 12:59 chmod lrwxrwxrwx 1 test test 14 Jan 4 12:59 chown lrwxrwxrwx 1 test test 16 Jan 4 12:59 chrpath lrwxrwxrwx 1 test test 12 Jan 4 12:59 cmp lrwxrwxrwx 1 test test 13 Jan 4 12:59 comm lrwxrwxrwx 1 test test 11 Jan 4 12:59 cp lrwxrwxrwx 1 test test 13 Jan 4 12:59 cpio lrwxrwxrwx 1 test test 12 Jan 4 12:59 cpp lrwxrwxrwx 1 test test 12 Jan 4 12:59 cut lrwxrwxrwx 1 test test 13 Jan 4 12:59 date lrwxrwxrwx 1 test test 11 Jan 4 12:59 dd lrwxrwxrwx 1 test test 13 Jan 4 12:59 diff lrwxrwxrwx 1 test test 17 Jan 4 12:59 diffstat lrwxrwxrwx 1 test test 16 Jan 4 12:59 dirname lrwxrwxrwx 1 test test 11 Jan 4 12:59 du lrwxrwxrwx 1 test test 13 Jan 4 12:59 echo lrwxrwxrwx 1 test test 14 Jan 4 12:59 egrep lrwxrwxrwx 1 test test 12 Jan 4 12:59 env lrwxrwxrwx 1 test test 15 Jan 4 12:59 expand lrwxrwxrwx 1 test test 13 Jan 4 12:59 expr lrwxrwxrwx 1 test test 14 Jan 4 12:59 false lrwxrwxrwx 1 test test 14 Jan 4 12:59 fgrep lrwxrwxrwx 1 test test 13 Jan 4 12:59 file lrwxrwxrwx 1 test test 13 Jan 4 12:59 find lrwxrwxrwx 1 test test 14 Jan 4 12:59 flock lrwxrwxrwx 1 test test 12 Jan 4 12:59 g++ lrwxrwxrwx 1 test test 13 Jan 4 12:59 gawk lrwxrwxrwx 1 test test 12 Jan 4 12:59 gcc lrwxrwxrwx 1 test test 15 Jan 4 13:00 gcc-ar lrwxrwxrwx 1 test test 16 Jan 4 12:59 getconf lrwxrwxrwx 1 test test 15 Jan 4 12:59 getopt lrwxrwxrwx 1 test test 12 Jan 4 12:59 git lrwxrwxrwx 1 test test 12 Jan 4 13:00 gpg lrwxrwxrwx 1 test test 18 Jan 4 13:00 gpg-agent lrwxrwxrwx 1 test test 13 Jan 4 12:59 grep lrwxrwxrwx 1 test test 15 Jan 4 12:59 gunzip lrwxrwxrwx 1 test test 13 Jan 4 12:59 gzip lrwxrwxrwx 1 test test 13 Jan 4 12:59 head lrwxrwxrwx 1 test test 17 Jan 4 12:59 hostname lrwxrwxrwx 1 test test 14 Jan 4 12:59 iconv lrwxrwxrwx 1 test test 11 Jan 4 12:59 id lrwxrwxrwx 1 test test 16 Jan 4 12:59 install lrwxrwxrwx 1 test test 13 Jan 4 13:00 join lrwxrwxrwx 1 test test 11 Jan 4 12:59 ld lrwxrwxrwx 1 test test 15 Jan 4 13:00 ld.bfd lrwxrwxrwx 1 test test 12 Jan 4 12:59 ldd lrwxrwxrwx 1 test test 16 Jan 4 13:00 ld.gold lrwxrwxrwx 1 test test 11 Jan 4 12:59 ln lrwxrwxrwx 1 test test 11 Jan 4 12:59 ls lrwxrwxrwx 1 test test 13 Jan 4 13:00 lz4c lrwxrwxrwx 1 test test 13 Jan 4 12:59 make lrwxrwxrwx 1 test test 15 Jan 4 12:59 md5sum lrwxrwxrwx 1 test test 14 Jan 4 12:59 mkdir lrwxrwxrwx 1 test test 15 Jan 4 12:59 mkfifo lrwxrwxrwx 1 test test 14 Jan 4 12:59 mknod lrwxrwxrwx 1 test test 15 Jan 4 12:59 mktemp lrwxrwxrwx 1 test test 11 Jan 4 12:59 mv lrwxrwxrwx 1 test test 11 Jan 4 13:00 nc lrwxrwxrwx 1 test test 11 Jan 4 13:00 nl lrwxrwxrwx 1 test test 11 Jan 4 12:59 nm lrwxrwxrwx 1 test test 16 Jan 4 12:59 objcopy lrwxrwxrwx 1 test test 16 Jan 4 12:59 objdump lrwxrwxrwx 1 test test 11 Jan 4 12:59 od lrwxrwxrwx 1 test test 14 Jan 4 12:59 patch lrwxrwxrwx 1 test test 13 Jan 4 12:59 perl lrwxrwxrwx 1 test test 11 Jan 4 12:59 pr lrwxrwxrwx 1 test test 15 Jan 4 12:59 printf lrwxrwxrwx 1 test test 12 Jan 4 12:59 pwd lrwxrwxrwx 1 test test 16 Jan 4 12:59 python3 lrwxrwxrwx 1 test test 14 Jan 4 12:59 pzstd lrwxrwxrwx 1 test test 15 Jan 4 12:59 ranlib lrwxrwxrwx 1 test test 16 Jan 4 12:59 readelf lrwxrwxrwx 1 test test 17 Jan 4 12:59 readlink lrwxrwxrwx 1 test test 17 Jan 4 12:59 realpath lrwxrwxrwx 1 test test 11 Jan 4 12:59 rm lrwxrwxrwx 1 test test 14 Jan 4 12:59 rmdir lrwxrwxrwx 1 test test 15 Jan 4 12:59 rpcgen lrwxrwxrwx 1 test test 12 Jan 4 13:00 scp lrwxrwxrwx 1 test test 12 Jan 4 12:59 sed lrwxrwxrwx 1 test test 12 Jan 4 12:59 seq lrwxrwxrwx 1 test test 13 Jan 4 13:00 sftp lrwxrwxrwx 1 test test 11 Jan 4 12:59 sh lrwxrwxrwx 1 test test 16 Jan 4 12:59 sha1sum lrwxrwxrwx 1 test test 18 Jan 4 12:59 sha224sum lrwxrwxrwx 1 test test 18 Jan 4 12:59 sha256sum lrwxrwxrwx 1 test test 18 Jan 4 12:59 sha384sum lrwxrwxrwx 1 test test 18 Jan 4 12:59 sha512sum lrwxrwxrwx 1 test test 13 Jan 4 13:00 size lrwxrwxrwx 1 test test 14 Jan 4 12:59 sleep lrwxrwxrwx 1 test test 14 Jan 4 13:00 socat lrwxrwxrwx 1 test test 13 Jan 4 12:59 sort lrwxrwxrwx 1 test test 14 Jan 4 12:59 split lrwxrwxrwx 1 test test 12 Jan 4 13:00 ssh lrwxrwxrwx 1 test test 13 Jan 4 12:59 stat lrwxrwxrwx 1 test test 16 Jan 4 12:59 strings lrwxrwxrwx 1 test test 14 Jan 4 12:59 strip lrwxrwxrwx 1 test test 13 Jan 4 13:00 sudo lrwxrwxrwx 1 test test 13 Jan 4 12:59 tail lrwxrwxrwx 1 test test 12 Jan 4 12:59 tar lrwxrwxrwx 1 test test 12 Jan 4 12:59 tee lrwxrwxrwx 1 test test 13 Jan 4 12:59 test lrwxrwxrwx 1 test test 14 Jan 4 12:59 touch lrwxrwxrwx 1 test test 11 Jan 4 12:59 tr lrwxrwxrwx 1 test test 13 Jan 4 12:59 true lrwxrwxrwx 1 test test 14 Jan 4 12:59 uname lrwxrwxrwx 1 test test 13 Jan 4 12:59 uniq lrwxrwxrwx 1 test test 11 Jan 4 12:59 wc lrwxrwxrwx 1 test test 13 Jan 4 12:59 wget lrwxrwxrwx 1 test test 14 Jan 4 12:59 which lrwxrwxrwx 1 test test 14 Jan 4 12:59 xargs lrwxrwxrwx 1 test test 12 Jan 4 13:00 yes lrwxrwxrwx 1 test test 13 Jan 4 13:00 zcat lrwxrwxrwx 1 test test 13 Jan 4 12:59 zstd
Once all the configurations is added run bitbake from build directory to build the base yocto image.
$ cd $HOME/yocto_build/build
$ bitbake core-image-base
In this section you will learn how to do Post-build checks
In this section we will see how to do static image verification checks
$ pwd $HOME/yocto $ cd build/tmp/deploy/images/raspberrypi4/See that binary called helloworld is present inside directory ?
See Answer
$ cd build/tmp/deploy/images/raspberrypi4/ $ ls -l -rw-r--r-- 1 test test 16136058 Jan 11 16:52 core-image-base-raspberrypi4.wic.bz2
In this section, we will how to do runtime image verification checks
Extract the final image “.wic” using the bzip2 command.
$ pwd $HOME/yocto/build/tmp/deploy/images/raspberrypi4/ $ bzip2 -d core-image-base-raspberrypi4.wic.bz2
Flash the image to SD-card using the following command.
$ sudo -E bmaptool copy --nobmap rdk-generic-broadband-image-raspberrypi4-64-rdk-broadband.wic /dev/sdb
Run minicom to boot the image.
$ sudo minicom -D /dev/ttyUSBO
Confirm you are on linux prompt if the console display looks like below
root'@'RaspberryPi-Gateway:~
To find the “BUILD ID” we can cat image.manifest and grep for “BUILD ID”
root'@'RaspberryPi-Gateway:~ cat image.manifest | grep BUILD_ID BUILD_ID=2022.01.11.07.00.00
Check the os-release version using the following command.
root'@'RaspberryPi-Gateway:~ cat /etc/os-release | grep PRETTY_NAME PRETTY_NAME="Yocto Project 3.5.1 (Dunfell)"
Check the version release using the following command
root'@'RaspberryPi-Gateway:~ cat /etc/yocto-release Yocto Project Release 3.5.1 (Dunfell)
Other topics of linux yocto rpi
Current Module
Next Module
Other Modules