Embedded Linux Projects Using Yocto Project Cookbook
Total Page:16
File Type:pdf, Size:1020Kb
www.it-ebooks.info Embedded Linux Projects Using Yocto Project Cookbook Over 70 hands-on recipes for professional embedded Linux developers to optimize and boost their Yocto know-how Alex González BIRMINGHAM - MUMBAI www.it-ebooks.info Embedded Linux Projects Using Yocto Project Cookbook Copyright © 2015 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: March 2015 Production reference: 1240315 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78439-518-6 www.packtpub.com Cover image by Alex González ([email protected]) www.it-ebooks.info Credits Author Project Coordinator Alex González Rashi Khivansara Reviewers Proofreaders Burt Janz Simran Bhogal Dave (Jing) Tian Clyde Jenkins Javier Viguera Indexer Commissioning Editor Tejal Soni Nadeem N. Bagban Production Coordinator Acquisition Editor Alwin Roy Owen Roberts Cover Work Content Development Editor Alwin Roy Natasha DSouza Technical Editor Prajakta Mhatre Copy Editors Puja Lalwani Aditya Nair Vikrant Phadke www.it-ebooks.info Foreword If we look back at the last 15 years of the field of embedded systems, we will see that everything has changed radically. Embedded systems have become more and more powerful and have gained new functionalities. Today, you can find "embedded" quad-core systems with 1 GB of RAM and several GBs of storage, comparable to a few-years-old desktop computer. Nowadays, it is not unusual that the requirements of an embedded system are low consumption, graphic acceleration, multimedia capabilities, sufficient storage, and so on. On the software side, if we look back again at those 15 years, we will notice that most of the Linux-running embedded systems at that time were in-house developments built from the ground up. Their main functionality was to boot the device and run the specific application (usually not graphical) the device was designed for. A typical system from those days contained a minimal Linux kernel, a small C library (uclibc), BusyBox as the base user space, and then the specific application or set of applications. As the hardware became more powerful and gained more functionalities, the requirements of the software also increased. With embedded systems becoming powerful enough to run distributions that were considered mostly for desktops (such as Debian or Ubuntu), it's no longer as easy as building a minimal set of software packages (uclibc, BusyBox, and a command-line application) anymore. You now have to choose between different windowing systems (X11, Wayland, and so on) and different graphic libraries (Qt, GTK, and so on). Maybe your hardware has dedicated units for video processing (VPU) or graphics processing (GPU) and is running its own firmware, and so on. All of this extra difficulty is what makes an embedded software engineer look for new tools that ease their work and speed up the development. This is the context where different Linux build systems began to appear. The first build system to show up was Buildroot. It has its roots in the uClibc project. The initial goal of Buildroot was to build a root filesystem based on the uclibc library for testing purposes. Buildroot is based on a Makefile's structure, kconfig as the configuration tool, and patches that apply to the different software packages before being built. These days, Buildroot supports multiple architectures, and apart from root filesystem images, it also can build kernel and bootloader images. www.it-ebooks.info A bit later, OpenEmbedded was born. Its goal is a bit different because it is defined as a Linux distribution builder. OpenEmbedded is based on recipes interpreted by the BitBake build engine. BitBake in turn is a tool derived from portage (Gentoo's distribution package manager). An interesting feature about OpenEmbedded is that the recipes can specify dependencies between packages, and later on, BitBake parses all the recipes and creates a queue of tasks in the correct order to fulfill the dependencies. Two examples of distributions created with OpenEmbedded are Angstrom and OpenMoko. Another OpenEmbedded-based distribution was Poky Linux. This has special importance because it's the way that leads to Yocto. The Yocto Project is an open source project whose goal is to provide the tools that help build Linux-based embedded systems. Under the umbrella of the Yocto Project, there are multiple software projects, such as Poky, the BitBake build engine, and even OpenEmbedded-Core. These are probably the main projects, but by no means, the only projects. In this new phase, Poky (the former Linux distribution) became the reference system of the Yocto Project, being the build system of the Yocto Project these days and using the BitBake build engine and OpenEmbedded-Core metadata (recipes, classes, and configuration files) underneath. This is the reason people tend to confuse the Yocto Project with the Poky build system. Poky is a nearly complete solution for embedded software engineering teams. It allows you to create a distribution for your hardware. It also allows you to create a software development kit (SDK) tailored for your distribution. This SDK may be used by other engineers in a team to compile the user-space applications that will later run on your Linux system. The price to pay for the functionality Poky provides is a steep learning curve compared to other build systems. Alex González's contribution with Embedded Linux Projects Using Yocto Project Cookbook is of great help to overcome that steep learning curve. The practical focus of this book and its structure in the form of short recipes help you resolve specific problems that you may find along the way when building an embedded product. So please enjoy and learn from this book. In return for the invested time, you will get deeper knowledge of embedded system development with the help of the Yocto Project. Javier Viguera Embedded Software Engineer at Digi International www.it-ebooks.info About the Author Alex González is software engineering supervisor at Digi International and one of the maintainers of the Digi Embedded Yocto distribution. He started working professionally with embedded systems in 1999 and the Linux kernel in 2004, designing products for voice and video over IP networks, and followed his interests into machine-to-machine (M2M) technologies and the Internet of Things. Born and raised in Bilbao, Spain, Alex has his second home in the UK, where he lived for over 10 years and received his MSc in communication systems from the University of Portsmouth. He currently lives in La Rioja, where he enjoys photography and a good Riojan wine. I would like to thank the Yocto and OpenEmbedded communities, whose dedication keeps the Yocto project running, and the people involved with the Freescale BSP community layer, whose work is the basis for this book. I would also like to thank my family, for the time, space, and support that made this possible, and especially my mum for showing me how to be brave—gracias Ama por enseñarme a ser valiente. www.it-ebooks.info About the Reviewers Burt Janz has been involved with computing systems since he assembled his first microcomputer in the US Navy in 1975. Starting with the development of device drivers and low-level interfaces on *NIX systems in the early 1980s, he has been creating complex software products for over 30 years. His expertise includes the design and implementation of low-level operating system internals and device drivers, complex applications for embedded and handheld devices, and government- and enterprise-level systems. A graduate of Franklin Pierce College in 1988 (BSCS with high honors), Burt was an adjunct professor at Daniel Webster College for 11 years in their evening-based continuing education program, while developing embedded and enterprise-level software during the day. His curricula of instruction included courses ranging from a basic introduction to computers and programming languages (C, C++, and Java), networking theory and network programming, database theory, and schema design to artificial intelligence systems. Along the way, Burt has written magazine articles and other technical commentaries. He was also involved in one of the first over-the-counter Linux distributions, Yggdrasil, in 1994. Burt has designed complete embedded and enterprise-level software systems as a lead architect and has led teams from the requirements and design phases of new products to the phases of completion and delivery to customers. He has experience with x86, 68xxx, PPC, ARM, and SPARC processors. He continues to write kernel threads and kmods, open firmware device trees, drivers for new and proprietary hardware, FPGA I/P core interfaces, applications, libraries, and boot manager code. He can be contacted directly by e-mail at [email protected] or burt.janz@gmail. com or via LinkedIn. www.it-ebooks.info Dave (Jing) Tian is a graduate research fellow and PhD student in the Computer and Information Science and Engineering (CISE) Department at the University of Florida.