OpenEmbedded & BitBake - Denx

31
OpenEmbedded & BitBake Open Source Software Carlos Ramirez Martinez-Eiroa Professor: Corby Schmitz

Transcript of OpenEmbedded & BitBake - Denx

Page 1: OpenEmbedded & BitBake - Denx

OpenEmbedded & BitBake

Open Source SoftwareCarlos Ramirez Martinez-Eiroa

Professor: Corby Schmitz

Page 2: OpenEmbedded & BitBake - Denx

Index

• Build Tools• Make• Ant• Maven• OpenZaurus• OpenEmbedded• BitBake

Page 3: OpenEmbedded & BitBake - Denx

Evolution

Make Ant Maven BuiltRoot BitBake

QuickTime™ and a decompressor

are needed to see this picture.

Page 4: OpenEmbedded & BitBake - Denx

Build Tools

• The process of building a computer program is usually managed by a build tool

• Build Tool: program that coordinates and controls other programs

• The build utility needs to compile and link the various files, in the correct order

Page 5: OpenEmbedded & BitBake - Denx

Make

• Initial release: 1977

• Already seen in classQuickTime™ and a

decompressorare needed to see this picture.

Page 6: OpenEmbedded & BitBake - Denx

Ant I

• Similar to make, but:

– Implemented using the Java language– Requires the Java platform– Is best suited to building Java projects

• Ant uses XML to describe the build process and its dependencies - Make has its Makefile format

QuickTime™ and a decompressorare needed to see this picture.

Page 7: OpenEmbedded & BitBake - Denx

Ant II

• Conceived by James Duncan Davidson while turning Apache Tomcat (from Sun) into open source

• A proprietary version of Make was used to build it on the Solaris Operating Environment

QuickTime™ and a decompressorare needed to see this picture.

Page 8: OpenEmbedded & BitBake - Denx

Ant III

• In the open source world there was no way of controlling which platform was used to build Tomcat

• Ant was created as a simple, platform-independent tool to build Tomcat from directives in an XML "build file”

QuickTime™ and a decompressorare needed to see this picture.

Page 9: OpenEmbedded & BitBake - Denx

Ant IV

• In a Makefile the actions required to create a target are specified as shell commands which are specific to the current platform (usually Unix)

• Ant provides a large amount of built-in functionality which can guarantee will behave (nearly) identically on all platforms

QuickTime™ and a decompressorare needed to see this picture.

Page 10: OpenEmbedded & BitBake - Denx

Ant V

• January 2000, Ant was moved to a separate CVS module and was promoted to a project of its own, independent of Tomcat, and became Apache Ant

QuickTime™ and a decompressorare needed to see this picture.

Page 11: OpenEmbedded & BitBake - Denx

• Maven uses a construct known as a Project Object Model (POM) to describe:

– The software project being built– Its dependencies on other external modules and

components– The build order

• A key feature of Maven is that it is network-ready - The core engine can dynamically download plug-ins from a repository

QuickTime™ and a decompressor

are needed to see this picture.

Page 12: OpenEmbedded & BitBake - Denx

Towards OpenEmbedded

Page 13: OpenEmbedded & BitBake - Denx

A Bit of History I• 2001: Sharp introducestheSL-5000 PDA running Linux

• 2002: Chris Larson finds out that the SharpROM sucks and starts hacking on a build system for a customized Linux distribution called "OpenZaurus”

• 2002-2003: The OpenZaurus build system is getting stretched (beyond belief) by adding support for many more packages and target devices

• January 2003: Brainstorming towards a new distribution and device independent build system

Page 14: OpenEmbedded & BitBake - Denx

A Bit of History II• February 2003: Holger Schurig creates the OpenEmbedded

repository and starts hacking on the first version

• May 2003: Chris Larson adds major functionality to the OpenEmbedded core and starts converting packages from the OpenZaurus build system

• December 2003: Michael Lauer releases OpenZaurus3.3.5, abandons the OpenZaurus build system, and converts100s of packages to OpenEmbedded

• December 2004: OpenEmbedded is split up into the BitBake build system and the OpenEmbedded metadata

Page 15: OpenEmbedded & BitBake - Denx

OpenZaurus

• OpenEmbedded is the successor to the great OpenZaurus project

• The OpenZaurus project was created as an alternative ROM image for the Sharp Zaurus Personal Mobile Tool

QuickTime™ and a decompressor

are needed to see this picture.

QuickTime™ and a decompressor

are needed to see this picture.

Page 16: OpenEmbedded & BitBake - Denx

(ROM image)

• (ROM image: computer file which contains a copy of the data from a read-only memory chip

• Software which is being developed for embedded computers is often written to ROM files for testing on a standard computer before it is written to a ROM chip for use in the embedded system)

Page 17: OpenEmbedded & BitBake - Denx

OpenZaurus II

• The project had pushed buildroot to its limits

• Buildroot: set of Makefiles and patches that makes it easy generate a cross-compilation toolchain and root filesystem for a target Linux system using the uClibc C library

QuickTime™ and a decompressor

are needed to see this picture.

Page 18: OpenEmbedded & BitBake - Denx

OpenZaurus III• Buildroot supported the creation of ipk packages, feeds and images and had support for more than one machine

But => impossible to use different patches, files for different architectures, machines or distributions

(ipk: lightweight package management system designed specifically for use in Linux devices with limited storage)

QuickTime™ and a decompressor

are needed to see this picture.

Page 19: OpenEmbedded & BitBake - Denx

OpenEmbedded

• OpenEmbedded was created to overcome this shortcoming

• On 7 December 2004 Chris Larson split the project into two parts: BitBake, a generic task executor and OpenEmbedded, the metadata for BitBake

QuickTime™ and a decompressorare needed to see this picture.

Page 20: OpenEmbedded & BitBake - Denx

OpenEmbedded II• Software framework to create Linux distributions for

embedded systems

• This may include bootloader, Linux, and applications

• Is a set of metadata used to cross-compile, package and install software packages

• License: GPL

QuickTime™ and a decompressorare needed to see this picture.

Page 21: OpenEmbedded & BitBake - Denx

Objectives

• Be self-contained

• Be able to use external toolchains or build them

• Easily cross-compile software, build packages or create root-filesystems

• Easily add new features, machines, architectures,…

QuickTime™ and a decompressorare needed to see this picture.

Page 22: OpenEmbedded & BitBake - Denx

BitBake I

• OpenEmbedded built tool

• Controls how to build things and the build dependencies

• Collects and manages an open set of largely independent build descriptions (package recipes) and builds them in proper order

Page 23: OpenEmbedded & BitBake - Denx

BitBake II• Used to compile different Linux kernels for a

variety of PDAs

• Easier to use (in theory) than manually using tools like patch and make

• Programming language: Python

• License: GNU General Public License (GPL), MIT/X Consortium License

Page 24: OpenEmbedded & BitBake - Denx

Process of Making Images

BitBake Recipes

Binary Packages

Task Graph

Flash Image

Page 25: OpenEmbedded & BitBake - Denx

BitBake File and Data Types• Three different file types:

– .conf: configuration data– .bbclass: (build) classes– .bb (.inc): package recipes

• BitBake parses the build classes, config files, and recipes

• For every task BitBake creates a shell script on-the-fly and executes it

Page 26: OpenEmbedded & BitBake - Denx

Main TasksTASK DESCRIPTION FUNCTION

Fetch Downloads data from upstream do_fetch()

Unpack Unpacks data do_unpack()

Patch Applies patches do_patch()

Configure Configures the source tree do_configure()

Compile Compiles the source tree do_compile()

Stage Installs to the staging area do_stage()

Install Installs into the packaging are do_install()

Package Creates packages do_package()

Page 27: OpenEmbedded & BitBake - Denx

BitBake RecipeDESCRIPTION = "Hello world program“PR = "r0“SRC_URI = "file://myhelloworld.c \ file://README.txt“

do_compile() { ${CC} ${CFLAGS} ${LDFLAGS} ${WORKDIR}/myhelloworld.c -o myhelloworld

}

do_install() { install -m 0755 -d ${D}${bindir} ${D}${docdir}/myhelloworldinstall -m 0644 ${S}/myhelloworld ${D}${bindir} install -m 0644 ${WORKDIR}/README.txt ${D}${docdir}/myhelloworld

}

Page 28: OpenEmbedded & BitBake - Denx

Summary I

• OpenEmbedded: A metadata repository containing

– Build classes– Machine configurations– Distribution policies– Recipes

To create complete embedded Linux distributions from scratch

Page 29: OpenEmbedded & BitBake - Denx

Summary II

• BitBake: A simple tool to execute tasks on metadata

– Parser to handle metadata– Package graph to handle package

interdependencies – Task graph to handle task interdependencies – On-the-fly shell script generator

Page 30: OpenEmbedded & BitBake - Denx

Why all this?

• SlugOS/BE is a replacement firmware image for the Linksys NSLU2

• It is produced using OpenEmbedded

Page 31: OpenEmbedded & BitBake - Denx

Questions?