Skip to content

Instantly share code, notes, and snippets.

@ljaraque
Last active July 16, 2018 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ljaraque/1681e30173676c51ef4f5bf55548a596 to your computer and use it in GitHub Desktop.
Save ljaraque/1681e30173676c51ef4f5bf55548a596 to your computer and use it in GitHub Desktop.
Creating Embedded Linux Distributions with YOCTO Project

Creating Embedded Linux Distributions with YOCTO Project

ljaraque@yahoo.com

1. Introduction

This guide is developed and tested using Ubuntu 16.04 as a host computer.

2. Installing Dependencies

sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm

3. Creating a First Image and Test It in qemu emulator

Cloning Yocto Project Repo:

git clone http://git.yoctoproject.org/git/poky
cd poky/

Checkout fido branch, which will be used for this guide:

git checkout -b fido origin/fido

Create build environment for our first yocto image (qemu image):

source oe-init-build-env

We will run this project with the qemu emulator with the command runqemu qemux86.

Then create our first image with:

bitbake -k core-image-sato

It will take several ours to create the image. Many WARNING message might appear in the process but will not affect the result. The important thing is to not have ERRROR messages.
The output should look like:

Parsing recipes: 100% |########################################################################################################| Time: 00:02:16
Parsing of 884 .bb files complete (0 cached, 884 parsed). 1286 targets, 41 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION        = "1.26.0"
BUILD_SYS         = "x86_64-linux"
NATIVELSBSTRING   = "Ubuntu-16.04"
TARGET_SYS        = "i586-poky-linux"
MACHINE           = "qemux86"
DISTRO            = "poky"
DISTRO_VERSION    = "1.8.2"
TUNE_FEATURES     = "m32 i586"
TARGET_FPU        = ""
meta              
meta-yocto        
meta-yocto-bsp    = "fido:<hash code>"

NOTE: Preparing RunQueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
WARNING: Failed to fetch URL http://www.zlib.net/zlib-1.2.8.tar.xz, attempting MIRRORS if available
WARNING: Failed to fetch URL http://www.multiprecision.org/mpc/download/mpc-1.0.2.tar.gz, attempting MIRRORS if available
WARNING: Failed to fetch URL http://download.gna.org/cryptodev-linux/cryptodev-linux-1.6.tar.gz, attempting MIRRORS if available
WARNING: Failed to fetch URL http://zlib.net/pigz/pigz-2.3.3.tar.gz, attempting MIRRORS if available
WARNING: Failed to fetch URL http://gnome-build-stage-1.googlecode.com/files/uuid-1.6.2.tar.gz, attempting MIRRORS if available
...

Finally run the created image in the qemu emulator, with:

runqemu qemux86

4. Creating a Basic Image to Run in Real Hardware Raspberry Pi

Firstly, while staying in our poky directory, we will get the repo containing the yoctolayer to be added in order to make our image for raspberry pi.

git clone -b fido git://git.yoctoproject.org/meta-raspberrypi

We will create a parallel build directory to the one we used in section 3, and we will name it rpi-build:

source oe-init-build-env rpi-build

Then being inside rpi-build directory we will run the bitbake-layers command that will add the meta-raspberrypi layer to the default configuration file conf/bblayers.conf:

cd rpi-build
bitbake-layers add-layer ../meta-raspberrypi/

After this, the file conf/bblayers.conf will contain the line including meta-raspberrypi path.
Then we need to edit the file local.conf in order to specify for what machine or hardware this image will be composed. There are different Raspberry Pi versions supported. We will set the variable MACHINE = "raspberrypi2".

Then, staying in the same directory rpi-build, we will run the bitbake command to create our image including the default layers plus the downloaded meta-raspberrypi layer that will let us run our image in the real hardware raspberrypi2.

bitbake -k rpi-basic-image

The process will take again, like in the previous case, several hours to complete.

After the image is created, we will be able to find it in:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment