The Yocto Project is a build system that allows developers to make custom Linux distributions matching their exact needs. I’ve already shown how to build a 12MB Compressed image for the Raspberry Pi with Yocto, but the Raspberry Pi 2 has recently been added to the project, so I’ve tried to build it too in a machine running Ubuntu 14.04.
I’ll use poky since it’s the default, but you could also build the system for Angstrom or without distributions (OpenEmbedded Core only). The steps to get the code is just the same as for the Raspberry Pi:
1 2 3 4 5 |
mkdir yocto cd yocto git clone git://git.yoctoproject.org/poky.git cd poky git clone git://git.yoctoproject.org/meta-raspberrypi |
1 |
. oe-init-build-env build |
Now edit conf/local.conf with vim or nano to set the machine to raspberrypi2 instead of qemux86:
1 2 |
MACHINE ??= "raspberrypi2" GPU_MEM = "16" |
There are more Raspberry Pi specific option in the README for setting the GPU memory, overclocking, adding VC-1 or/and MPEG-2 licenses, and so on.
You also need to add the path to meta-raspberrypi in conf/bblayers file, so that it looks like:
1 2 3 4 5 6 |
BBLAYERS ?= " \ /home/jaufranc/edev/rpi/yocto/poky/meta \ /home/jaufranc/edev/rpi/yocto/poky/meta-yocto \ /home/jaufranc/edev/rpi/yocto/poky/meta-yocto-bsp \ <strong> /home/jaufranc/edev/rpi/yocto/poky/meta-raspberrypi \</strong> " |
Two minimal images are available: rpi-basic-image and rpi-hwup-image. I’ve built rpi-basic-image, which adds ssh-server-dropbear (for ssh server support) and splash (for the splash screen).
1 |
bitbake rpi-basic-image |
This will take a while, possibly over one or more hours, and upon completion the log shown in the terminal windows should look similar to:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
bitbake rpi-basic-image Loading cache: 100% |###########################################| ETA: 00:00:00 Loaded 1310 entries from dependency cache. NOTE: Resolving any missing task queue dependencies Build Configuration: BB_VERSION = "1.25.0" BUILD_SYS = "x86_64-linux" NATIVELSBSTRING = "Ubuntu-14.04" TARGET_SYS = "arm-poky-linux-gnueabi" MACHINE = "raspberrypi2" DISTRO = "poky" DISTRO_VERSION = "1.7" TUNE_FEATURES = "arm armv7a vfp thumb neon callconvention-hard vfpv4 cortexa7" TARGET_FPU = "vfp-vfpv4-neon" meta meta-yocto meta-yocto-bsp = "master:6d7cf8e9dd00bdff882311fecbadfadc46e9cc03" meta-raspberrypi = "master:d8bf60ce6c4a6c6371527c6df2e3243d2771c0cc" NOTE: Preparing RunQueue NOTE: Executing SetScene Tasks NOTE: Executing RunQueue Tasks NOTE: Tasks Summary: Attempted 1984 tasks of which 1968 didn't need to be rerun and all succeeded. |
The step “0: bcm2835-bootfiles-20150206-r3 do_fetch (pid 25484)” may take a long time as it’s cloning a few gigabytes of data for the firmware stored in GitHub. Just be patient, this step took several hours on my machine.
You can now flash the image to a micro SD card with:
1 |
sudo dd if=tmp/deploy/images/raspberrypi2/rpi-basic-image-raspberrypi2.rpi-sdimg | pv | sudo dd of=/dev/sdX bs=16M |
Where you need to replace X with the letter of your SD card, which you can check with lsblk. Alternatively, you could also flash the image with Win32DiskImager in Windows. Here’s the compiled image for your reference: rpi-basic-image-raspberrypi2-20150227091441.rootfs.rpi-sdimg (104 MB). You’ll also need to use tools like gparted to expand the ext-4 partition to make use of all the space on your micro SD card.
You’d then just have to insert the micro SD card into your Raspberry Pi 2, boot, and login as root without password. I have not tried, since I don’t have a Raspberry Pi 2 yet.

Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress