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 ?

  • 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.conf
MACHINE ??= "raspberrypi4"
LICENSE_FLAGS_ACCEPTED = "synaptics-killswitch"
  • Add the neccessary meta-layers which needs to be built in bblayers.conf

$ vi conf/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 \
     "
  • 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/hosttools
  • 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 ?

  • 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)