Top Banner
Introduction to OpenEmbedded An Embedded Linux Distribution Framework Khem Raj
41

Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

May 22, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

Introduction to OpenEmbedded

An Embedded Linux Distribution Framework

Khem Raj

Page 2: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

2

Agenda

Introduction

Features

Getting OE

Layout

Bitbake

Building OE

A bit more on features

Adding new package

Rundown

FAQ & QA

Page 3: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 4: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 5: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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)

Page 6: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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)

Page 7: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 8: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 9: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 10: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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.

Page 11: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 12: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 13: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 14: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 15: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 16: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 17: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 18: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

18

Building OpenEmbedded

Uses bitbake build tool bitbake console-image

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

Page 19: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 20: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 21: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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...

Page 22: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 23: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

23

Package support

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

Page 24: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

24

Updating device

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

Feeds are configured in /etc/opkg on device

Page 25: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 26: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 27: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 28: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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”

Page 29: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 30: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 31: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

31

Adding New Recipe

Finished Recipe

bitbake -c clean hello; bitbake hello

Page 32: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 33: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 34: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 35: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 36: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

36

Rundown ...

Create build directory

mkdir ${HOME}/oe/build

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

Page 37: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

37

Rundown ...

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

Page 38: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 39: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

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

Page 40: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

40

Rundown ...

Page 41: Introduction to OpenEmbedded - Meetupfiles.meetup.com/1590495/openembedded.pdf · 2 Agenda Introduction Features Getting OE Layout Bitbake Building OE A bit more on features Adding

41

Future

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