Yocto environment preparation

Yocto environment preparation

ASSUMPTIONS:

Following tutorial assume that User knew the Linux Ubuntu system, git activity, console activity, etc.

OS:

Basically should be Ubuntu 16.04 or 18.04 for the newer version. Other distribution can also be but Yocto issue warning about it.

UBUNTU TIPS AND TRICK:

To invoke console use left “ALT” + left “CTRL” + “T”

PACKAGES:

Yocto needs some packages for normal work. Below is a list of necessary application to be installed:

  • gawk
  • wget
  • git-core
  • diffstat
  • unzip
  • texinfo
  • gcc-multilib
  • build-essential
  • chrpath
  • socat
  • cpio
  • python
  • python3
  • python3-pip
  • python3-pexpect
  • xz-utils
  • debianutils
  • iputils-ping
  • libsdl1.2-dev
  • xterm

All of those packages can be installed on Ubuntu using

sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping libsdl1.2-dev xterm

More details can be found on Yocto web page in Yocto Project Quick Start

https://www.yoctoproject.org/docs/2.4.2/yocto-project-qs/yocto-project-qs.html

SHELL:

Reconfigure shell from dash to bash by issue following instruction:

sudo dpkg-reconfigure dash

choose NO to dash when prompted

RECOMMENDED YOCTO FILE STRUCTURE:

The base main folder should be named “yocto”. In “yocto” should appears “poky”, many of “_build” directories and “downloads”, “sstate-cache”, “tmp”. In “poky” should be all “meta-layers” like “meta-poky”, “meta”, “meta-openembedded”, and users “meta-s” like “meta-beaglebone” or “meta-rpi”.

Significant is to modify a few files

bblayers.conf and local.conf. Files should have the following content

  • 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}/yocto/poky/meta \
${HOME}/yocto/poky/meta-poky \
${HOME}/yocto/poky/meta-openembedded/meta-oe \
${HOME}/yocto/poky/meta-openembedded/meta-networking \
${HOME}/yocto/poky/meta-openembedded/meta-python \
${HOME}/yocto/poky/meta-qt5 \
${HOME}/yocto/poky/meta-sunxi \
${HOME}/yocto/poky/meta-bbb \
"
  • local.conf
MACHINE ??= "beaglebone"

DL_DIR ?= "${HOME}/yocto/downloads"

SSTATE_DIR ?= "${HOME}/yocto/sstate-cache"

TMPDIR = "${HOME}/yocto/tmp"

PACKAGE_CLASSES ?= "package_ipk"

SDKMACHINE ?= "x86_64"

RM_OLD_IMAGE = "1"

INHERIT += "rm_work"

By default, Yocto propose to use “root” account for the test. In the final production image following line in local.conf should be commented and user account should be created

  • local.conf

Comment line

#EXTRA_IMAGE_FEATURES = "debug-tweaks"

Add lines

INHERIT += "extrausers"
EXTRA_USERS_PARAMS = "usermod -P password root;"

Of course, the password should be set to final and root should have a final name or can be kept.

GOOD PRACTISE IN YOCTO:

In Yocto one of good practice is to modify/tune existing *.bb files by *.bbappend. File *.bbappend must have the same name as original *.bb file. For instance ti-linux.bb – > ti-linux.bbappend.

Example:

Adding patch for existing Kernel (ti-linux.bb)

The ti-linux.bbappend should have a content

FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

SRC_URI += "\
file://001_name_of_patch.patch\
"

Of course in the same directory where ti-linux.bbappend is located a directory called “ti-linux” need also exist and should contain mentioned *.patch file. The patch file can be located along with *.bbappned but content needs to be modified accordingly.

Lucjan Bryndza

Embedded software engineer