Yocto

From ArchWiki
Revision as of 12:07, 5 August 2015 by Soderstrom (talk | contribs) (Updated the summary)
Jump to navigation Jump to search

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements. See Help:Style for reference.Tango-edit-clear.png

Reason: Several Help:Style issues. (Discuss in Talk:Yocto#)

The Yocto Project (YP) is a popular open-source collaboration project focused on embedded Linux developers. In early versions of YP it could be problematic to get it running on Arch Linux. In later versions this is no longer the case, and hopefully in the future it will be even easier. For information about how to get it running on older version, there is a good guide here.

For this guide the focus will be on YP Core 1.8 (Fido) and newer. Note that Arch Linux is still not validated to work with Yocto/Poky.

Installation

Multilib

Enable Multilib repository by uncommenting both of these lines in /etc/pacman.conf

[multilib]
Include = /etc/pacman.d/mirrorlist

Then update the package list and upgrade with pacman -Syu.

Install dependencies

pacman -S git diffstat unzip texinfo python2 chrpath \
          gcc-multilib wget xterm sdl socat cpio

You may recieve the following conflicts

:: gcc-multilib and gcc are in conflict. Remove gcc? [y/N] y
:: gcc-libs-multilib and gcc-libs are in conflict. Remove gcc-libs? [y/N] y

Resolve these by choosing 'y' (we actually want the multilib versions)


Test your installation

In order to test that yocto is properly working, we will build core-image-minimal

Clone the git repository

Before we begin we need to clone the official git repository. Here we will use the fido branch.

$ git clone --branch fido git://git.yoctoproject.org/poky.git poky

python2

Yocto currently requires the use of python2, but the default in Arch Linux is python3. In the Python page there is an explanation about how to trick the environment.

We will do almost the same, but also add a simple script file so that it can be easily sourced later.

$ mkdir -p ~/bin/python2
$ ln -s /usr/bin/python2 ~/bin/python2/python
$ ln -s /usr/bin/python2-config ~/bin/python2/python-config

Now create the file ~/bin/python2-env and insert the following text within it

export PATH=~/bin/python2:$PATH

Setup and build the minimal image

First you need to source the python2-env file we just created and then initialize the yocto environment. In the example below we create a folder named build-qemux86, the source command will also place you in this folder. From here we can now build the core-image-minimal.

$ cd poky
$ source ~/bin/python2-env && source oe-init-build-env build-qemux86
$ bitbake core-image-minimal
WARNING: Host distribution "Arch-Linux" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Parsing recipes: 100%
|########################################################################################################################################################################################################################################################################################| Time: 00:02:42
Parsing of 884 .bb files complete (0 cached, 884 parsed). 1285 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   = "Arch-Linux"
TARGET_SYS        = "i586-poky-linux"
MACHINE           = "qemux86"
DISTRO            = "poky"
DISTRO_VERSION    = "1.8"
TUNE_FEATURES     = "m32 i586"
TARGET_FPU        = ""
meta              
meta-yocto        
meta-yocto-bsp    = "fido:08d32590411568e7bf11612ac695a6e9c6df6286"

NOTE: Preparing RunQueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
WARNING: Failed to fetch URL http://downloads.sourceforge.net/project/libpng/libpng16/1.6.16/libpng-1.6.16.tar.xz, attempting MIRRORS if available
NOTE: Tasks Summary: Attempted 1989 tasks of which 9 didn't need to be rerun and all succeeded.

Summary: There were 2 WARNING messages shown.

This will take some time to complete. For more details about yocto there is a Quick Start Guide

The first warning about Arch Linux not been validated is expected. The second warning can happen when failing to download a resource, the build system will then attempt to get that resource from the next mirror.

Run the image in QEMU

To run this image in QEMU, start it with the runqemu command as follows


$ runqemu qemux86

Continuing with the following parameters:
KERNEL: [/home/user/poky/build-qemux86/tmp/deploy/images/qemux86/bzImage-qemux86.bin]
ROOTFS: [/home/user/poky/build-qemux86/tmp/deploy/images/qemux86/core-image-minimal-qemux86-20150804095542.rootfs.ext4]
FSTYPE: [ext4]
Setting up tap interface under sudo
[sudo] password for user: 
Acquiring lockfile for tap0...
Running qemu-system-i386...
/home/user/poky/build-qemux86/tmp/sysroots/x86_64-linux/usr/bin/qemu-system-i386 -kernel /home/user/poky/build-qemux86/tmp/deploy/images/qemux86/bzImage-qemux86.bin -net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=no,downscript=no -cpu qemu32 -hda /home/user/poky/build-qemux86/tmp/deploy/images/qemux86/core-image-minimal-qemux86-20150804095542.rootfs.ext4 -show-cursor -usb -usbdevice wacom-tablet -vga vmware -no-reboot -m 256 --append "vga=0 uvesafb.mode_option=640x480-32 root=/dev/hda rw mem=256M ip=192.168.7.2::192.168.7.1:255.255.255.0 oprofile.timer=1 rootfstype=ext4 "
Set 'tap0' nonpersistent
Releasing lockfile of preconfigured tap device 'tap0'

If you have updated the host kernel (ie pacman -Syyu) but not rebooted your system, then you will most likely get into problems with tunctl. The solution is simple, reboot.