Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda...

41
Introduction to OpenEmbedded An Embedded Linux Distribution Framework Khem Raj

Transcript of Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda...

Introduction to OpenEmbedded

An Embedded Linux Distribution Framework

Khem Raj

2

Agenda

Introduction

Features

Getting OE

Layout

Bitbake

Building OE

A bit more on features

Adding new package

Rundown

FAQ & QA

3

What is OpenEmbedded ?

Framework to build Embedded Linux distributions

Meta-data describing how to build software Includes tools to help build various RFS types. Learn more at http://www.openembedded.org http://wiki.openembedded.net/index.php/Mailing

_lists IRC channel #oe on irc.freenode.net

4

OpenEmbedded In Action

Many popular distributions based on OE MontaVista Linux 6 Palm WebOS ( Palm PRE) OpenZaurus Ångström Poky ( Garmin uses poky) http://wiki.openembedded.net/index.php/Success_s

tories

5

Features

Builds complete system includes toolchains, SDK, root file system and applications.

Fine granularity in packaging (-dev, -dbg, locale)

Supports Many popular architectures ARM, PowerPC, SH, MIPS, x86, x86-64

Machine specific tuning Supports package management (rpm,

deb, ipk)

6

More Features ...

Console, OPIE, GPE, Gnome, etc. GUI tools Qt/Qte, GTK+, tk Choices of packages Varied development tools QA, Tinderbox, insane class, Sepukku, fail-fast Distributed compiling (icecc)

7

Prerequisites

Workstation with a lot of RAM :) A large free space on hard-disk (~10G)

Can be less with rm_work feature

Install required software for build machine Internet Connection

8

Getting OpenEmbedded

Uses GIT for SCM Cloning the metadata & bitbake

git clone git://git.openembedded.org/openembedded

org.openembedded.dev – Master Stable/2009 – Stable release branch User branches

git clone git://git.openembedded.net/bitbake

You can use master branch

9

Meta-data layout

Classes – common tasks and properties Conf – Machine, distribution configurations Docs – Documentation Files – Device table additions MAINTAINERS – List of people responsible Recipes – The metadata to build a package Site – cached autoconf variables Contrib: Contributed scripts and

goodies

10

${TMPDIR} layout

TMPDIR denote the working directory used by bitbakecache/

cross/ - Cross tools gcc etc.

deploy/

images/ – Final images e.g. tar, ext2, kernel, uboot

ipk/ – individual packages

staging/ – area to have installations used in build

stamps/ - Time stamps for bitbake

work/ - The build trees for recipes all objects etc.

11

Bitbake

Simple tool to execute tasks on meta-data at the heart of OE

Parse recipes Package graph Task graph .conf, .bb, .inc .bbclass files Non executable data e.g. variable

assignment Executable tasks e.g. do_compile

12

Bitbake ...

Bitbake parses classes, recipes and conf files For every task there is a shell script generated

and executed Common tasks e.g. fetch unpack etc. packaging tasks – package, package_write_ipk build tasks – configure, compile etc

13

Bitbake ...

List of tasks

bitbake -c listtasks hello

do_build

do_fetch

...

Bitbake user Manual at http://bitbake.berlios.de/manual/

More about bitbake some other day

14

Useful bitbake operations

Bitbake -c listtasks <recipe>

bitbake -c fetch_all

bitbake -c devshell <recipe>

bitbake helloworld-image

bitbake console-image

bitbake x11-image

bitbake package-index

15

Setting up Environment

http://wiki.openembedded.net/index.php/OEandYourDistro

Sanity checkers complains about missing required packages on build machine.

Wide choice of build distributions e.g. debian, ubuntu, gentoo, Fedora, SuSE and much more

16

local.conf

Use conf/local.conf.sample as starting point You can pin version numbers and preferred

providers Enable services like QA, tinderbox, devshell Parallel build Add extra packages to image

17

local.conf

MACHINE – Machine to build for e.g. qemuarm DISTRO – Selects distributions e.g. minimal TMPDIR – Temp directory for building DEPLOY_DIR – Directory to contain images IMAGE_FSTYPES – File system types e.g.

jffs2 DL_DIR – Place for tar files PARALLEL_MAKE BB_NUMBER_THREADS

18

Building OpenEmbedded

Uses bitbake build tool bitbake console-image

Wait for build to finish .. The results are in ${TMPDIR}/deploy

19

In the backgroud

Build some -native packages for build machine

autotools, coreutils etc.

Cross-compiler Essential packages e.g. linux-kernel-headers Other target packages needed for the image image

20

OE Variables

There are many variables to control the OE and bitbake functionality

Defined in .conf files most important one is conf/bitbake.conf

21

Classes

Base – common functions calls make Autotools – configure and install tasks Kernel – Tasks to compile kernel and modules Module – Tasks to compile external kernel

modules Debian – package naming based on SONAME Etc...

22

Packaging

Package utility puts together files needed to be shipped in a package

PACKAGES variable defines what to build FILES_<packages> defines what files are part

of a package Rootfs installs the complete root file system and

packages it into a flashable file system Support cramfs, jffs2, ext2fs, squashfs

ubifs, tar

23

Package support

Many packages supported (over 8200 recipes) Supports uclibc, glibc, eglibc, klibc Network applications Console utilities Window managers Development tools

24

Updating device

Package repositories can be published as feeds with opkg installed on the device

Feeds are configured in /etc/opkg on device

25

OE Tasks

Found in recipes/tasks They are virtual packages One task can inherit another task Common tasks

task-bootstrap

task-base

task-boot

26

OE images

A set of packages as a virtual package Image rules are under recipes/images Various formats for packaing e.g. tar Commonly used images

console-image

helloworld-image

x11-image

opie-image

27

Overlay

Provides layer where user can add own recipes and configs or redefine existing one

Specify using BBPATH e.g. export BBPATH=${OE_DIR}/overlay:${OE_DIR}/openembedded

Overlay directory contains Conf/ which has any redefined configurations Recipes/ - New or redefines recipes

28

Adding new recipe

Create a directory to hold the new recipe files mkdir recipes/hello

Edit the recipe for new application vi recipes/hello/hello_2.5.bb

Add DESCRIPTION, HOMEPAGE LICENSE Locate the download URL and add to SRC_URI

SRC_URI =

“${GNU_MIRROR}/hello/hello-${PV}.tar.gz”

29

Adding new recipe ...

bitbake hello This will fail because we do not have MD5/SHA

checksums yet. But... it will generate the required checksums for

you

30

Adding New Recipe ...

Add the proper checksums to bb file. Redo bitbake hello Define the real source directory

S = “${WORKDIR}/hello-2.5” Inherit autoools for packages using autotools Customize various build steps by prepending

and appending

31

Adding New Recipe

Finished Recipe

bitbake -c clean hello; bitbake hello

32

Adding a New machine

Its easy ! Use existing board close to your machine

Create a conf/machine/yourmachine.conf Size of root flash image Type of root file system Kernel Console information MACHINE_FEATURES TARGET_ARCH Tuning for sub-arch

33

Adding a new DISTRO

You can add your own distribution Add it under conf/distro/yourdistro.conf Define

DISTRO_NAME, DISTRO_VERSION

Package format e.g. INHERIT += “package_ipk”

LIBC

TARGET_OS

TARGET_FPU

PREFERRED_PROVIDERS

PREFERRED_VERSIONS

34

FAQ

Its too slow, can I improve that ? Use BBMASK to mask out packages

How can I create multiple packages from a bb Use PACKAGES and FILES_<packages>

How can I apply patch only for a given machine Use overrides

My package needs a cross tool that you don't have Add native package for it

35

Rundown

Make build area

mkdir ${HOME}/oe;cd ${HOME}/oe Install required packages on build system Checkout OE and bitbake

git clone git://git.openembedded.org/openembedded

git://git.openembedded.net/bitbake

Takes around 5-15 mins, depends upon how big hose is running into your computer.

Meta-data should be in ${HOME}/oe/openembedded

36

Rundown ...

Create build directory

mkdir ${HOME}/oe/build

Create setup.sh in ${HOME}/oe/build

37

Rundown ...

Create local.conf in ${HOME}/oe/build

38

Rundown ...

Setup Environment

$ source ${HOME}/oe/build/setup.sh Build an image

bitbake console-image Wait for build to churn

Images are in ${HOME}/oe/build/deploy

39

Rundown ...

Boot it up in QEMUqemu-system-arm -M versatilepb --snapshot -gdb tcp::1234 -m 256 -kernel /scratch/oe/qemuarm/deploy/eglibc/images/qemuarm/zImage-qemuarm.bin -hda /scratch/oe/qemuarm/deploy/eglibc/images/qemuarm/console-image-qemuarm.ext2 -usb -usbdevice wacom-tablet -nographic --no-reboot -localtime -append 'console=ttyAMA0 console=ttyS0 root=/dev/sda rw debug user_debug=-1' -net none

40

Rundown ...

41

Future

BBCLASSEXTEND Sysroot-ing the native packages Moving cross-toolchains under native sysroot Removal of obsoleted packages