You are on page 1of 30

EmbeddedLinuxTraining

Building embeddedLinux systemswith Buildroot


ThomasPetazzoni FreeElectrons http://freeelectrons.com/

1
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Rightstocopy
Copyright2009,FreeElectrons feedback@freeelectrons.com Documentsources,updatesandtranslations: http://freeelectrons.com/docs/buildroot Corrections,suggestions,contributionsand translationsarewelcome!
AttributionShareAlike3.0 Youarefree tocopy,distribute,display,andperformthework tomakederivativeworks tomakecommercialuseofthework Underthefollowingconditions Attribution.Youmustgivetheoriginalauthorcredit. ShareAlike.Ifyoualter,transform,orbuilduponthiswork,you maydistributetheresultingworkonlyunderalicenseidenticalto thisone. Foranyreuseordistribution,youmustmakecleartoothersthelicense termsofthiswork. Anyoftheseconditionscanbewaivedifyougetpermissionfromthe copyrightholder. Yourfairuseandotherrightsareinnowayaffectedbytheabove. Licensetext:http://creativecommons.org/licenses/bysa/3.0/legalcode

Latestupdate:Sep15,2009

2
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Leveragingfreesoftware
Thousandsoffreesoftwarepackagesare availableandcanbeleveragedtobuild embeddedsystems Withfreesoftware
Youhavecontroloverthesource Bugscanbefixed Newfeaturescanbeadded Yoursystemcanbecustomized

Intheory,thesystemdesignersand developershavealotofflexibilitythanksto freesoftware However,leveragingtheexistingfree softwarepackagesmaynotbeveryeasy.


3
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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

5
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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!

8
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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

9
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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

FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Packageselection(1/3)
Severalhundredsofpackagescanbeselected,withof courseafocusonpackagesusefulforembeddeddevices Dependenciesbetweenpackagesarehandled,either throughdependsonrelationorselectrelation. 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
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Demotime!
BuildingasystemwithBusybox,DirectFBand exampleapplications

16
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Directoryhierarchy
Inthesources
docs/,documentation package/,theconfigurationitemsandMakefilesforbuildingthe userspacepackages project/,theconfigurationitemsandMakefilesfortheproject concept(severalprojectsinthesameBuildroottree) scripts/variousutilities target/linux/,buildingtheLinuxkernel target/<fstype>/,generatingtherootfilesystemimage target/device/,readymadeconfigurationforsupportedboards target/generic/target_skeleton/,thedefaultroot filesystemskeleton toolchain/,buildingacrosscompilingtoolchain
17
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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

18
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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

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

toolchain_build_ARCH
Wherethetoolchaincomponentsareconfiguredandbuilt
19
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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

InsertthenewConfig.infileintheconfigurationsystem byaddingtopackage/Config.in source"package/gqview/Config.in"


20
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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

FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Futurework
Cleanup
Theprojecthasbeenunmaintainedforsometime,sosome cleanupisneeded

Morepackages
Ofcourse!

Bettersupportforexternaltoolchains
Includingglibctoolchains

$YOURIDEA

25
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

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
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Alternatives
VerysimilartoBuildroot PTXdist,developedbyPengutronix http://www.pengutronix.de/software/ptxdist/index_en.html LTIB,developedmainlybyFreescale. GoodsupportforFreescaleboards http://www.bitshrine.org/ Slightlydifferentapproaches OpenEmbedded,moreflexiblebutalsofarmorecomplicated http://www.openembedded.org GentooEmbedded http://www.gentoo.org/proj/en/base/embedded/handbook/ Let'sdiscussthese,otheralternatives,theiradvantages,drawbacks, andfutureworkinaBOFsessiononWednesdayat1PM
27
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Relateddocuments

Allourtechnicalpresentations onhttp://freeelectrons.com/docs Linuxkernel Devicedrivers Architecturespecifics EmbeddedLinuxsystemdevelopment


FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Howtohelp
Youcanhelpustoimproveandmaintainthisdocument... Bysendingcorrections,suggestions,contributionsand translations Byaskingyourorganizationtoorderdevelopment,consulting andtrainingservicesperformedbytheauthorsofthese documents(seehttp://freeelectrons.com/). Bysharingthisdocumentwithyourfriends,colleagues andwiththelocalFreeSoftwarecommunity. Byaddinglinksonyourwebsitetoouronlinematerials, toincreasetheirvisibilityinsearchengineresults.

FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Linuxkernel Linuxdevicedrivers Boardsupportcode Mainstreamingkernelcode Kerneldebugging EmbeddedLinuxTraining Allmaterialsreleasedwithafreelicense! UnixandGNU/Linuxbasics Linuxkernelanddriversdevelopment RealtimeLinux,uClinux Developmentandprofilingtools Lightweighttoolsforembeddedsystems Rootfilesystemcreation Audioandmultimedia Systemoptimization

FreeElectrons
Ourservices
CustomDevelopment Systemintegration EmbeddedLinuxdemosandprototypes Systemoptimization Applicationandinterfacedevelopment Consultingandtechnicalsupport Helpindecisionmaking Systemarchitecture Systemdesignandperformancereview Developmenttoolandapplicationsupport Investigatingissuesandfixingtoolbugs

You might also like