0% found this document useful (0 votes)
245 views25 pages

Building Embedded Linux Systems With Buildroot: Thomas Petazzoni

- The document discusses using Buildroot to build embedded Linux systems from scratch. Buildroot automates the process of downloading, configuring, compiling and installing free software packages to generate a root filesystem and toolchain. - Buildroot provides a menuconfig-like interface to select target architecture, packages, kernel configuration, and output filesystem format. It handles dependencies between packages and cross-compiling issues. - New packages can be added to Buildroot by creating configuration files and makefiles describing build and installation steps. Buildroot supports many existing packages and makes it easier to manage embedded Linux systems.

Uploaded by

Yusuf Siddiqui
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
245 views25 pages

Building Embedded Linux Systems With Buildroot: Thomas Petazzoni

- The document discusses using Buildroot to build embedded Linux systems from scratch. Buildroot automates the process of downloading, configuring, compiling and installing free software packages to generate a root filesystem and toolchain. - Buildroot provides a menuconfig-like interface to select target architecture, packages, kernel configuration, and output filesystem format. It handles dependencies between packages and cross-compiling issues. - New packages can be added to Buildroot by creating configuration files and makefiles describing build and installation steps. Buildroot supports many existing packages and makes it easier to manage embedded Linux systems.

Uploaded by

Yusuf Siddiqui
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

EmbeddedLinuxTraining

Building
embeddedLinux
systemswith
Buildroot
ThomasPetazzoni

Leveragingfreesoftware
Thousandsoffreesoftwarepackagesare
availableandcanbeleveragedtobuild
embeddedsystems
Withfreesoftware
Youhavecontroloverthesource
Bugscanbefixed
Newfeaturescanbeadded
Yoursystemcanbecustomized

Intheory,thesystemdesignersand
developershavealotofflexibilitythanksto
freesoftware
However,leveragingtheexistingfree
softwarepackagesmaynotbeveryeasy.
3

Usingadistribution
Distributionsprovidereadytousebinarypackages
Somedistributions,suchasDebian,areavailablefor
embeddedarchitectures(ARM,MIPS,PowerPC)
Theymakeitrelativelyeasytogetaworkingsystem,but
Themaintainerofeachpackagehasmadeconfiguration
choicesthatdon'tnecessarilymatchyourchoices(softfloat
vs.hardfloat,EABIvsOABI,featureAornotfeatureA)
Youdon'thavealotofcontrolonsystemintegration
(initializationscripts,dependenciesofthecomponents)
Ifyouwanttointegratefixesornewfeatures,youneedto
rebuildthepackages.Whilethismaynotbeverydifficult,
there'susuallynoautomatedinfrastructuretorebuildthe
wholesystem.
4

Manually
Youcanconfigure,compile,installandintegrateallthefree
softwarecomponentsneededtobuildaworkingLinux
systemmanually.
Itgivesyoufullflexibility,but
Youneedtoknowthedependenciesbetweenallthe
components
Crosscompilingisusuallyatediousprocess,sometimes
requiringpackagesourcecodechanges
Youdon'thaveanautomatedproceduretorebuildyour
system,whichmightbeneededifyouwanttointegrateabug
fixoranewfeature

Buildsystems
BuildsystemsallowanembeddedLinuxdevelopertogeneratea
workingembeddedLinuxsystemfromscratch.
Theyautomatetheprocessofdownloading,configuring,
compilingandinstallingallthefreesoftwarepackages
Youhaveawellknownprocedureforrebuildingyoursystemfrom
scratch
Youcaneasilyintegratepatches,bugfixesornewupstream
versions
Yourcolleaguescaneasilytakeoveryourwork,asthere'sa
documentedprocedureforsystemgeneration

Thebuildsystemalreadyknowsaboutmostfreesoftware
packages
Dependenciesaremanaged,andcrosscompilingissuesare
alreadysolved.
6
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

EnteringBuildroot
Buildroot<http://www.buildroot.net>
isasetof
Makefilesthatautomatestheprocessofbuildingacross
compilingtoolchainandarootfilesystemforanembedded
system.
BuildroothasbeeninitiallydevelopedbyuClibcdevelopers.
Foralongtime,ithadnomaintainerandnoreleaseswere
delivered
SinceJanuary2009,Buildrootnowhasanofficial
maintainer,PeterKorsgaard
InFebruary2009,thefirststablereleasehasbeen
published,Buildroot2009.02.Anewreleasewillbe
publishedevery3months.
AnopportunitytotakeafreshlookatBuildroot!
7

Buildrootusers
TheyarealreadyusingBuildroot
ATMELfortheirAVR32developmentkit
http://www.atmel.no/buildroot/buildrootdoc.html
Gumstix
http://docwiki.gumstix.org/index.php/Buildroot
Armadeus(ARMboardswithFPGA)
http://www.armadeus.com
CalaoSystems
http://www.calaosystems.com/
Andprobablyalotmore!

Buildrootconfiguration
Buildrootuses
theKconfig
configuration
system
Offersa
menuconfiglike
interface
Savesthe
configurationina
.configfile

Mainconfiguration
Targetarchitecture
arm,armeb,avr32,cris,i386,mips,mipsel,powerpc,superh,
superh64,x86_64

Architecturevariant
ForARM,forexample:Generic,ARM7TDMI,ARM610,ARM710,
ARM720T,ARM920T,Xscale,etc.

ABIselection
ForARM,EABIorOABI

Targetoptions
Buildoptions
Hosttoolstouse,directorydefinition
Installdocumentation?Debuggingsymbols?Strip?Levelofgcc
optimization?

10

Toolchainconfiguration
Buildrootcaneitherbuildatoolchain(limitedto
uClibctoolchains)orreuseanexistingexternal
toolchain(limitedtosysrootabletoolchains)
InthecaseofatoolchainbuiltbyBuildroot,the
configurationallowstoselectthingssuchas
Kernelheadersversion
uClibcversionandconfiguration
GCCversionandoptions(Fortran?C++?
Java?ObjectiveC?)
GDBversionandoptions
(gdbserver,gdbonthetarget,crossgdbonthe
host)
Generaltoolchainoptions(largefilesupport,
RPCsupport,IPv6support,localesupport,etc.)
11

Packageselection(1/3)
Severalhundredsofpackagescanbeselected,withof
courseafocusonpackagesusefulforembeddeddevices
Dependenciesbetweenpackagesarehandled,either
throughdependson relationorselect relation.
Mainpackages:busybox,bash,bzip2,diffutils,flex,native
toolchain,grep,bootutils,cups,at,beecrypt,dash,file,
gamin,less,lsof,ltrace,memstat,moduleinittools,procps,
psmisc,screen,strace,sudo,syslogd,klogd,utillinux,
which,etc.
Corelibraries:libconfig,libconfuse,libdaemon,libelf,
libevent,libgcrypt,libiconv,libidn,liblockfile,liboil,libsysfs,
etc.
12

Packageselection(2/3)
Databases:MySQLclient,sqlite
Texteditors:ed,nano,uemacs,vim
Networking:argus,avahi,axel,boa,bind,bridgeutils,
DHCPsupport,dnsmasq,dropbear,ethtool,haserl,ifplugd,
iperf,iproute2,ipsectools,iptables,kismet,l2tp,lighttpd,
linkns,lrzsz,mDNSresponder,miidiag,mrouted,nbd,ncftp,
netcat,netkitbase,netkittelnet,netplug,netsnmp,nfsutils,
ntp,openntpd,openssh,openssl,openvpn,portmap,pppd,
pppoe,pptplinux,proftpd,quagga,isisd,samba,rsync,
stunnel,tcpdump,tftpd,thttpd,vsftpd,wirelesstools,etc.
Hardware/systemtools:dm,dmraid,e2fsprogs,fis,libfuse,
hal,hdparm,hotplug,i2ctools,inputtools,iostat,libaio,
libraw1394,libusb,lmsensors,lvm2,mdadm,mtdutils,
pciutils,setserial,udev,usbutils,etc.
13

Packageselection(3/3)
Audio/video:aumix,flac,gstreamerwithplugins,libmad,
libmpd,libogg,libtheora,libvorbis,madplay,mpg123,mplayer,
speex,vlc,festival
Graphiclibraries:ncurses,slang,dialog,DirectFB,
imagemagick,jpeg,libpng,libungif,pixman,SDL,QT
Embedded,Gtk(atk,cairo,pango,glib),fontconfig,Freetype,
Matchbox,X.orgKdriveandafewXapplications(window
managers,etc.)
Compressor/decompressors
Packagemanagers:ipkg,portage,rpm
Interpreters,languages:lua,microperl,python,ruby,tcl,php
Misc:XMLlibraries,Java,Games
14

Filesystemandkernelconfiguration
Outputformatselectionfortherootfilesystem
cramfs,cloop,ext2,jffs2,ubifs,squashfs,tar,cpio,initramfs,
romfs.
Ofcourse,therawrootfilesystemisalsoavailable

Bootloaderconfiguration
UBootsupported

Kernelconfiguration
Theversion,configuration,additionalpatchesandthekernel
binaryformat(uImage,zImage,bzImage)canbespecified

15

Demotime!
BuildingasystemwithBusybox,DirectFBand
exampleapplications

16

Directoryhierarchy
Inthesources
docs/ ,documentation
package/ ,theconfigurationitemsandMakefilesforbuildingthe
userspacepackages
project/ ,theconfigurationitemsandMakefilesfortheproject
concept(severalprojectsinthesameBuildroottree)
scripts/

variousutilities

target/linux/

,buildingtheLinuxkernel

target/<fstype>/
target/device/

,generatingtherootfilesystemimage

,readymadeconfigurationforsupportedboards

target/generic/target_skeleton/
filesystemskeleton
toolchain/

,thedefaultroot

,buildingacrosscompilingtoolchain
17

UsingBuildrootinanutshell
Downloadthelateststableversion,orgetadevelopment
versionfromtheSVN(bettertoreportissues)
makemenuconfig
make
Getyourrawrootfilesystemin
project_build_ARCH/PROJECT/root/
Getyourrootfilesystemimageandkernelimagein
binaries/PROJECT/
Locationofoutputdirectoriescanbechangedusing
O=/path/to

18

Generateddirectories
build_ARCH
Onedirectoryforeachpackage,whereithasbeenconfigured
andbuilt
staging_dir ,wherethetoolchainandpackagesare
installed,andwherenonstrippedversionsofthe
binaries/librariescanbefound

project_build_ARCH/PROJECT
autotools_stamps ,stampsforhandlingdependencies
betweenbuildsteps
,headerfilesrelatedtoBuildroot
buildrootconfig
configurationmechanism
root ,therootfilesystemforthetarget

toolchain_build_ARCH
Wherethetoolchaincomponentsareconfiguredandbuilt
19

Buildroot:addingnewpackages
Createanewdirectory,forexamplepackage/gqview/
AddaConfig.in fileinthisdirectorytodescribethe
configurationoptions
configBR2_PACKAGE_GQVIEW
bool"gqview"
selectBR2_PACKAGE_PKGCONFIG
help
GQviewisanimageviewerforUnix
operatingsystems
http://prdownloads.sourceforge.net/gqview

InsertthenewConfig.in fileintheconfigurationsystem
byaddingtopackage/Config.in
source"package/gqview/Config.in"
20

Buildroot:addingnewpackages(2)
Createthegqview.mkfiletodescribethebuildsteps.The
followingexampleusestheMakefile.autotools.in

machinery,whichmakesiteasytosupportautotoolsbased
packages
GQVIEW_VERSION=2.1.5
GQVIEW_SOURCE=gqview$(GQVIEW_VERSION).tar.gz
GQVIEW_SITE=http://prdownloads.sourceforge.net/gqview
GQVIEW_AUTORECONF=NO
GQVIEW_INSTALL_STAGING=NO
GQVIEW_INSTALL_TARGET=YES
GQVIEW_DEPENDENCIES=uclibcpkgconfiglibgtk2
$(eval$(callAUTOTARGETS,package,gqview))

Patchescanalsobeaddedinthepackagedirectory,withfilenames
likepkgnameversionfeature.patch
.Theywillbe
automaticallyappliedbeforeconfiguringthepackage.
21

Buildroot:addingnewpackages(3)
Packagesnotbasedonautotools,orneedingspecific
configuration,compilationandinstallationstepscanbe
handledmanually.
GZIP_VERSION:=1.3.12
GZIP_SOURCE:=gzip$(GZIP_VERSION).tar.gz
GZIP_SITE:=$(BR2_GNU_MIRROR)/gzip
GZIP_DIR:=$(BUILD_DIR)/gzip$(GZIP_VERSION)
GZIP_CAT:=$(ZCAT)
GZIP_BINARY:=$(GZIP_DIR)/gzip
GZIP_TARGET_BINARY:=$(TARGET_DIR)/bin/zmore
$(DL_DIR)/$(GZIP_SOURCE):
$(callDOWNLOAD,$(GZIP_SITE),$(GZIP_SOURCE))
gzipsource:$(DL_DIR)/$(GZIP_SOURCE)
$(GZIP_DIR)/.unpacked:$(DL_DIR)/$(GZIP_SOURCE)
$(GZIP_CAT)$(DL_DIR)/$(GZIP_SOURCE)|\
tarC$(BUILD_DIR)$(TAR_OPTIONS)
touch$(GZIP_DIR)/.unpacked

22

Buildroot:addingnewpackages(4)
$(GZIP_DIR)/.configured:$(GZIP_DIR)/.unpacked
(cd$(GZIP_DIR);rmrfconfig.cache;\
$(TARGET_CONFIGURE_OPTS)\
$(TARGET_CONFIGURE_ARGS)\
./configure\
target=$(GNU_TARGET_NAME)\
host=$(GNU_TARGET_NAME)\
build=$(GNU_HOST_NAME)\
prefix=/usr\
execprefix=/\
$(DISABLE_NLS)\
$(DISABLE_LARGEFILE)\
)
touch$(GZIP_DIR)/.configured
$(GZIP_BINARY):$(GZIP_DIR)/.configured
$(MAKE)CC=$(TARGET_CC)C$(GZIP_DIR)

23

Buildroot:addingnewpackages(5)
$(GZIP_TARGET_BINARY):$(GZIP_BINARY)
$(MAKE)DESTDIR=$(TARGET_DIR)CC=$(TARGET_CC)\
C$(GZIP_DIR)installstrip
ifneq($(BR2_HAVE_INFOPAGES),y)
rmrf$(TARGET_DIR)/usr/share/info
endif
ifneq($(BR2_HAVE_MANPAGES),y)
rmrf$(TARGET_DIR)/usr/share/man
endif
gzip:uclibc$(GZIP_TARGET_BINARY)
gzipclean:
$(MAKE)DESTDIR=$(TARGET_DIR)CC=$(TARGET_CC)\
C$(GZIP_DIR)uninstall
$(MAKE)C$(GZIP_DIR)clean
gzipdirclean:
rmrf$(GZIP_DIR)
ifeq($(BR2_PACKAGE_GZIP),y)
TARGETS+=gzip
endif
24

Futurework
Cleanup
Theprojecthasbeenunmaintainedforsometime,sosome
cleanupisneeded

Morepackages
Ofcourse!

Bettersupportforexternaltoolchains
Includingglibctoolchains

$YOURIDEA

25

Feedbackandcommunity
Buildrootisorganizedlikeatypicalfreesoftwarecommunity,
itisnottrustedbyanycompany,eventhoughsomeofthe
developersareobviouslyprofessionals
Mailinglist,athttp://lists.busybox.net/mailman/listinfo/buildroot
Veryhelpfulsupport!

Bugtrackerathttps://bugs.uclibc.org/
Subversionrepositoryatsvn://uclibc.org/trunk/buildroot
Documentationathttp://www.buildroot.net/buildroot.html

Feelfreetotest,reportandcontribute!

26

You might also like