Friday, June 12, 2015

RaspberryPI and Yocto

NEW HOWTO FOR RaspberryPI3 available!

http://mytechpg.blogspot.com/2016/04/raspberrypi3-and-yocto.html


Updated to new Yocto Fido and Raspberry PI layers

The Yocto project (https://www.yoctoproject.org/) can be used to create a personal Linux distribution for the RaspberryPI device through few simple steps.

The aim of this post is to configure Yocto to build a minimal firmware for a RaspberryPI.

Configuring the host

I used Ubuntu 15.04 to generate the image and first I have installed the required packages on Ubuntu to build the Yocto image. As mentioned in the Yocto Project Quick Start the command to install the essential Ubuntu packages is:

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

Preparing the environment

I used this README file: http://git.yoctoproject.org/cgit/cgit.cgi/meta-raspberrypi/tree/README
First, you have to download Yocto with this command:

git clone -b fido git://git.yoctoproject.org/poky

Then you have to move into poky directory and download the required layers: meta-raspberrypi and meta-openembedded, with these commands:

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

git clone -b fido git://git.openembedded.org/meta-openembedded

Configuring Yocto

Then  you have to create your build directory and configure the system to build a Yocto image for a RaspberryPI board with the command:

source oe-init-build-env raspberrypi

The development system will be created into the raspberrypi directory. If you want, you can chose another name for this directory. You have to repeat this command every time you use a new shell (e.g. after a reboot), to reconfigure the build environment.

At the end of the execution, oe-init-build-env leaves you inside the raspberrypi directory.

In the conf directory there are the two configuration files: local.conf and bblayers.conf.
The main parameter that you can customize in the local.conf are:
  • MACHINE ?= "raspberrypi" 
  • DL_DIR ?= "/home/mytechpg/dl"
  • IMAGE_FEATURES += "package-management"
  • PACKAGE_CLASSES ?= "package_ipk"
MACHINE is used to specify the target type.
DL_DIR can be used to specify the directory where source tarballs are downloaded during the build process. I suggest to specify a path outside Yocto directory because it could be shared between multiple builds on the same host.
IMAGE_FEATURES is used to install rpm tool, to add to the image new packages

In the bblayers.conf file you have to add the path for the new layers to BBLAYER variable:

BBLAYERS ?= " \
  /home/mytechpg/yocto/poki/meta \
  /home/mytechpg/yocto/poki/meta-yocto \
  /home/mytechpg/yocto/poki/meta-yocto-bsp \
  /home/mytechpg/yocto/poki/meta-raspberrypi \
  /home/mytechpg/yocto/poki/meta-openembedded/meta-multimedia \
"
In this case, I have added the latest two lines, with meta-raspberrypi and meta-openembedded layers.

You can download my config files from GitHub.

Build and install the system

To build the system you have to use the command bitbake from the /home/mytechpg/yocto/poki/raspberrypi/ directory.
You can use:

bitbake rpi-hwup-image

to build a minimal system, without the graphical environment 


You can find the images in poky/raspberrypi/tmp/deploy/images/raspberrypi and copy:

rpi-hwup-image-raspberrypi.rpi-sdimg


on a SD with the dd command.

The syntax of dd command is:

sudo dd if=<image file> of=/dev/<SD name>

You can discover the correct dev with the dmesg command.

To build a more complete environment you can use this command:
bitbake core-image-full-cmdline

10 comments:

  1. Hi there,

    Great tutorial by the way, looks really good.

    I'm trying to replicate what you've done, and I'm running into these errors:


    ....
    | ERROR: Function failed: Fetcher failure for URL: 'http://download.savannah.gnu.org/releases/quilt/qu ilt-0.63.tar.gz'. Unable to fetch URL from any source.
    ...
    and subsequent errors afterwards.

    which is odd, as I can ping download.savannah.gnu.org...

    Do you have any idea what might be going on?

    Any help would be much appreciated.


    Cheers

    Stu

    ReplyDelete
    Replies
    1. Thank you

      There is a space in the URL, but I think it is due to a copy & paste problem.

      Then, when you face these problems, you can download the file "by hand", with a browser or with wget and save it in the download directory.
      If you didn't set the DL_DIR directory, you have to save the file in:

      ~/poky/raspberrypi/download

      and run again bitbake.

      Sorry for my late reply

      Delete
  2. I am stuck here. No further improvements.........any idea,why? i have left system for overnight but no change.....I have followed exactly as u said, but............please help as quickly as possible

    NOTE: Preparing RunQueue
    NOTE: Executing SetScene Tasks
    NOTE: Executing RunQueue Tasks
    WARNING: Failed to fetch URL ftp://ftp.debian.org/debian/pool/main/b/base-passwd/base-passwd_3.5.29.tar.gz, attempting MIRRORS if available
    WARNING: Failed to fetch URL ftp://ftp.debian.org/debian/pool/main/d/dpkg/dpkg_1.17.4.tar.xz, attempting MIRRORS if available
    WARNING: Failed to fetch URL ftp://ftp.uni-erlangen.de/pub/Linux/LOCAL/dosfstools/dosfstools-2.11.src.tar.gz, attempting MIRRORS if available
    WARNING: Failed to fetch URL http://ftp.de.debian.org/debian/pool/main/m/mklibs/mklibs_0.1.39.tar.xz, attempting MIRRORS if available
    Currently 2 running tasks (2119 of 2145):
    Currently 3 running tasks (2119 of 2145):
    Currently 2 running tasks (2119 of 2145):
    Currently 1 running tasks (2130 of 2145):
    0: bcm2835-bootfiles-20140817-r3 do_fetch (pid 28507)

    ReplyDelete
  3. Hi

    yes, these files are not available at the specified paths.

    You have two options:
    - change the recipes, moving to a different release
    - look for these files in Internet, download them and save in DL_DIR directory

    Please, let me know if you need any other help

    ReplyDelete
  4. Please answer to these questions:
    1) What basic packages needed fo raspberrypi ?
    2) What if I want to add any package after my image is build ?
    3) Do i need to repeat the complete process again?
    4) How can i add any driver (ex: TFT driver) to the build kernel image?
    5) How to add any desired applications to packages?

    ReplyDelete
    Replies
    1. Here my answers
      1) with bitbake rpi-hwup-image you build a "minimal" image, with mandatory packages. I think you can remove some packages but at the end you can consider these packages as "the basic ones"

      2) No problem, you can add how many packages you want. if you enable rpm management, as I suggested, you can add packages also later

      3) If you don't delete any file/chache, bitbake builds only required packages.

      4) e 5) Please refers to yocto documentations to add packages or to create new packages. I will post a howto on this topic in a couple of week

      Delete
  5. I have successfully created rpi-basic-image with ssh server. Now I want to access raspberrypi via ethernet cable using ssh server on my laptop.I have tried to use the standard ways as mentioned for raspbian. But nmap is not able to find raspberrypi’s address. Could u please specify steps how to connect raspberrypi with ubuntu using ssh? Please help

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. I am getting these errors during building of image .Please help..
    WARNING: Failed to fetch URL http://www.sqlite.org/2014/sqlite-autoconf-3080704.tar.gz, attempting MIRRORS if available
    WARNING: Failed to fetch URL http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz, attempting MIRRORS if available
    WARNING: Failed to fetch URL ftp://ftp.gnu.org/gnu/gcc/gcc-4.9.1/gcc-4.9.1.tar.bz2, attempting MIRRORS if available
    ERROR: Fetcher failure: Fetch command failed with exit code 4, no output
    ERROR: Function failed: Fetcher failure for URL: 'http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz'. Unable to fetch URL from any source.
    ERROR: Logfile of failure stored in: /home/mahi/poky/raspberrypi/tmp/work/i686-linux/pkgconfig-native/0.28-r0/temp/log.do_fetch.2690
    ERROR: Task 716 (virtual:native:/home/mahi/poky/meta/recipes-devtools/pkgconfig/pkgconfig_0.28.bb, do_fetch) failed with exit code '1'
    WARNING: Failed to fetch URL ftp://ftp.gnu.org/gnu/bison/bison-2.7.1.tar.xz, attempting MIRRORS if available
    WARNING: Failed to fetch URL http://downloads.sourceforge.net/flex/flex-2.5.39.tar.bz2, attempting MIRRORS if available
    ERROR: Fetcher failure: Fetch command failed with exit code 4, no output
    ERROR: Function failed: Fetcher failure for URL: 'http://downloads.sourceforge.net/flex/flex-2.5.39.tar.bz2'. Unable to fetch URL from any source.
    ERROR: Logfile of failure stored in: /home/mahi/poky/raspberrypi/tmp/work/i686-linux/flex-native/2.5.39-r0/temp/log.do_fetch.25862
    ERROR: Task 1280 (virtual:native:/home/mahi/poky/meta/recipes-devtools/flex/flex_2.5.39.bb, do_fetch) failed with exit code '1'

    ReplyDelete
  8. Hello,
    Thanks for the tutorial. Do you know the simplest way to edit the kernel version ? I am using poky 1.6.2 and the default kernel version is 3.12.

    I edited the rpi-default-versions.inc and put PREFERRED_VERSION_linux-raspberrypi ?= "3.6.%" to have the 3.6.11

    I can build the image, but on the boot I only got the raspberry pi image and I can't login after boot. I think I miss some parameters, do you have an idea ?

    Thank you

    ReplyDelete