Embedded linux using yocto

Yocto Project

The Yocto Project, or more commonly just called Yocto, is a build system used to create custom Linux distributions for embedded systems.

It is important to note that it is not a Linux distribution itself, but a collection of tools to generate a custom Linux distribution for your specific embedded hardware.

Quick Start

This is a Yocto “Quick Start”, aimed to get you familiar with the basics of the Yocto and building a embedded Linux image in no time! This quick start has been tested with Ubuntu 16.04 64-bit, running in VMWare on a Windows host (the free VirtualBox VM should also work fine).

Give your VM a ton of hard drive space, memory and processors. You will be building Linux from source code, and this is very resource intensive! I gave the VM 120GB hard drive space (grows as needed), 8GB memory and 8 processors.**

Yocto has it’s own quick start guide at http://www.yoctoproject.org/docs/2.2.1/yocto-project-qs/yocto-project-qs.html. However, I have has problems with this, including errors such as:

E: Unable to locate package pip3 E: Unable to locate package pexpect 

Install Prerequisites

$ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python python3 python-pip libsdl1.2-dev xterm 

Clone Yocto’s poky Repository

poky is a Yocto project release. As of April 2017, this is the most recent release. Run the following command, which should clone poky into ~/poky/ .

$ git clone git://git.yoctoproject.org/poky 

Checkout The Correct Branch Of poky

Initialise Build Environment

Before you can start a Linux build, you need to initialise the Yocto build environment. This can be done with the following command:

Читайте также:  Поменять владельца файла линукс

After running this command, you should of automatically been moved into the poky/build/ directory. This command needs to be re-run everytime your environment variables get reset (e.g. everytime you login).

Build Linux

We’re almost at Linux building time! We won’t touch any of the config files for now, and just build Linux using Yocto’s default settings. Run the following command (from the poky/build/ directory):

Now go grab a coffee. Or better yet, take your family out to a restaurant for a nice meal. This is going to TAKE A WHILE.

An embedded Linux build in progress (using Yocto), note the CPU usage!

Make sure your computer is not set to go to sleep/shutdown after 1-2 hours of activity, otherwise you might find the build won’t complete! Yocto will calculate all dependencies, download them, and compile! (make sure you have an o.k. internet connection). You can safely ignore (usually) most of the orange “Failed to fetch URL…” warnings that pop-up as the build progresses, as Yocto can attempt to download them from other sources. After the build was complete, Yocto had used about 35GB of hard drive memory. The output build images should be in poky/build/tmp/deploy/images/ . You can now test out the Linux image you just built by running it in QEMU:

Running the finished Yocto build in QEMU (an emulator).

The Project Configuration File

Moving The Entire Yocto Project Directory Somewhere Else

Moving the entire Yocto project directory isn’t as straightforward as you might think (e.g. moving or renaming the poky folder). Because Yocto stores a small but non-zero amount of information in the project using absolute paths (gasp!), moving/renaming this folder will break a build (assuming a build has already been completed at least once, if not, you’re o.k.!). You will probably receive an error message along the lines of: Oh no! I have to rebuild? But that took hours! Luckily, you can fix this without having to do a complete rebuild. Upon receiving this error, open up the poky/build/tmp/saved_tmpdir file in a text editor, and update the path to the new location (the path should be the only thing in this file). You should now be able to run bitbake … without any errors, and without having to restart the build from scratch.

Читайте также:  Chat server in linux

Disabling sanity Checks

Although not recommended, sometimes it is necessary to disable the sanity checks. This can be done by commenting out the out the INHERIT += «sanity» line from the file meta/conf/sanity.conf , so it looks like the following:

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 
# Sanity checks for common user misconfigurations # # See sanity.bbclass # # Expert users can confirm their sanity with "touch conf/sanity.conf" BB_MIN_VERSION = "1.31.2"  SANITY_ABIFILE = "$TMPDIR>/abi_version"  SANITY_VERSION ?= "1" LOCALCONF_VERSION ?= "1" LAYER_CONF_VERSION ?= "7" SITE_CONF_VERSION ?= "1"  #INHERIT += "sanity" 
  • Do not use Bitbake as root
  • Error, TMPDIR has changed location
  • The TMPDIR: can’t be located on nfs .

Источник

Embedded Linux Development using Yocto Projects — Second Edition

Embedded Linux Development using Yocto Projects - Second Edition

Read it now on the O’Reilly learning platform with a 10-day free trial.

O’Reilly members get unlimited access to books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.

Book description

Optimize and boost your Linux-based system with Yocto Project and increase its reliability and robustness efficiently and cost-effectively.

  • Optimize your Yocto Project tools to develop efficient Linux-based projects
  • Practical approach to learning Linux development using Yocto Project
  • Demonstrates concepts in a practical and easy-to-understand way

If you are an embedded Linux developer with a basic knowledge of Yocto Project and want to broaden your knowledge with examples of embedded development, then this book is for you. This book is also for professionals who want to find new insights into working methodologies for Linux development.

  • Understand the basic concepts involved in Poky workflows along with configuring and preparing the Poky build environment.
  • Configure a build server and customize images using Toaster.
  • Generate images and fit packages into created images using BitBake.
  • Support the development process by setting up and using Package feeds.
  • Debug Yocto Project by configuring Poky.
  • Build an image for the BeagleBone Black, RaspberryPi 3, and Wandboard, and boot it from an SD card.

Yocto Project is turning out to be the best integration framework for creating reliable embedded Linux projects. It has the edge over other frameworks because of its features such as less development time and improved reliability and robustness.

Embedded Linux Development using Yocto Project starts with an in-depth explanation of all Yocto Project tools, to help you perform different Linux-based tasks. The book then moves on to in-depth explanations of Poky and BitBake. It also includes some practical use cases for building a Linux subsystem project using Yocto Project tools available for embedded Linux. The book also covers topics such as SDK, recipetool, and others.

By the end of the book, you will have learned how to generate and run an image for real hardware boards and will have gained hands-on experience at building efficient Linux systems using Yocto Project.

A clear, concise, and straightforward book that will enable you to use and implement the latest features of Yocto Project.

Источник

Оцените статью
Adblock
detector