Buildroot Vs. OpenEmbedded/Yocto Project: A Four Hands Discussion

Transcription

Embedded Linux Conference 2016Buildroot vs. OpenEmbedded/Yocto Project: A Four HandsDiscussionAlexandre Belloni, Thomas PetazzoniFree s.petazzoni@free-electrons.comFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com1/32

Alexandre BelloniIThe Yocto Project guy for this talkIEmbedded Linux engineer/trainer at Free Electrons since 2013IYocto Project/OE expertIMaintainer of several Freescale boards in meta-fsl, strong contributor tometa-atmelIOpenEmbedded setup for numerous customersITrainer for Free Electrons Yocto Project / OpenEmbedded courseIAnd also a kernel contributor: co-maintainer of the RTC subsystem and the AtmelARM processor supportFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com2/32

Thomas PetazzoniIThe Buildroot guy for this talkICTO and Embedded Linux engineer/trainer at Free Electrons since 2008IStrong Buildroot contributorIInterim Buildroot maintainerITrainer for Free Electrons Buildroot courseIAnd also a kernel contributor: support for Marvell processorsFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com3/32

Common aspectsIEmbedded Linux build systemsIIGoal is to build a complete, customized, embedded Linux systemRoot filesystem, toolchain, kernel, bootloadersIBuild from scratch from sourceIUsing cross-compilationIVery actively maintained and developed projectsIWidely used in the industryIWell documented, training coursesIFree softwareFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com4/32

Buildroot: general philosophyIStrong focus on simplicityISimple to use, but also simple to understand/extendISpecial use cases handled via extension scripts, rather than in Buildroot itselfRe-use of existing technologies/languages: kconfig, make.IILearning effort worth the investmentIMinimalist: small by defaultIPurpose-agnosticIOpen community, no vendor or bureaucratic/corporate managementFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com5/32

Yocto Project: general philosophyISupport for the major architecturesIIOpenEmbedded: only qemuYocto Project: adds support for a few machinesIOnly provides core recipes, use layers to get support for more packages and moremachinesICustom modifications should stay in a separate layerIVersatile build system: tries to be as flexible as possible and to handle most usecases.IOpen community but the project is still governed by the Yocto Project AdvisoryBoard made up of its corporate sponsors.IOpenEmbedded is an independent community driven project.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com6/32

Buildroot: outputIBuildroot main product is a root filesystem imageIIIBut also: toolchain, kernel image, bootloaders, etc.Many formats supported: ext2/3/4, ubifs, iso9660, etc.No binary packages, no package management systemIIIISome people call it a firmware generatorUpdates are not possible via packagesUpdates require a full system update, like AndroidBelief that partial updates are harmfulFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com7/32

Yocto Project: outputIBuilds distributions, the main output is a package feedIIthe package management system is optional on the targetit is possible to install or update only part of the systemIAlso generates root filesystem images by installing those packages. Supportsthe usual ext2/3/4, ubifs, iso9660, etc. but also VM images: vmdk, vdi, qcow2IFinally, images classes or a tool, wic, can be used to create disk imagesIAlso able to generate an SDK alongside the image to allow application developersto compile and test their applications without having to integrate it in the build.But, the SDK has to be kept in sync with the image.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com8/32

Buildroot: configurationIRe-uses kconfig from the Linux kernelISimple {menu,x,n,g}config interfaceIEntire configuration stored in a single .config/defconfigIDefines all aspects of the system: architecture, kernel version/config, bootloaders,user-space packages, etc.Imake menuconfig, make, profit!Building the same system for different machines: to be handled separatelyIIIIA tool can generate defconfig from fragmentsDoable, but not super easyComplete separate build for each machineFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com9/32

Yocto Project: configurationIThe configuration is separated in multiple parts:IIIIDistribution configuration (general package configuration, toolchain and libcselection,.)Machine configuration (defines the architecture, machine features, BSP.)Image recipe (what packages should be installed on the target.)Local configuration (distribution and default machine selection, how many threads touse when compiling, whether to remove build artifacts,.)IIt is also necessary to gather the various layers that will be used and declare them.IAllows to build the same image for different machines or using differentdistributions or different images for one machine.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com10/32

Buildroot: layersIIInitially: no concept of layersAll packages are maintained in the official repositoryIIAllows for very high quality, thanks to review by expertsAddition of BR2 EXTERNALIIIIAllows to store package definitions, configurations and other artefactsOne BR2 EXTERNAL onlyGenerally used for proprietary/custom packages and configurationsCan only add packages, not override the ones in BuildrootFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com11/32

Yocto Project: layersILayer mechanism allows to modify or add new package or image recipes.IClear separation between the core build system, the BSP and custommodifications.IScales properly, third parties provide their layers with BSPs or a set of recipeshandling their dedicated applicationsILayers have to be compatible and use the same OE branch base.IBeware of layer quality, reviews are not systematic.IOpenEmbedded Metadata Index lists available layers, recipes, /IAlso, there is a powerful overrides mechanism allowing to adjust recipe variablesbased on the machine or distribution.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com12/32

Buildroot/Yocto Project: toolchainSimilar capabilitiesIIBuilding their own toolchains, based on gcc, a choice of C libraries (glibc, uClibc,musl)Using pre-built external toolchainsIISomewhat easier in Buildroot, since it’s built-inOnly really properly supported with additional vendor layers in the Yocto ProjectFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com13/32

Buildroot: new packagepackage/tmux/Config.inconfig BR2 PACKAGE TMUXbool "tmux"depends on BR2 USE MMU # fork()select BR2 PACKAGE LIBEVENTselect BR2 PACKAGE NCURSEShelptmux is a terminal multiplexer, it enables a number of terminals(or windows) to be accessed and controlled from a single mkTMUX VERSION 2.1TMUX SITE https://github.com/tmux/tmux/releases/download/ (TMUX VERSION)TMUX LICENSE ISCTMUX LICENSE FILES READMETMUX DEPENDENCIES libevent ncurses host-pkgconf (eval (autotools-package))package/tmux/tmux.hash# Locally computed:sha256 31564e7bf4bcef2de.f6176tmux-2.1.tar.gzFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com14/32

Yocto Project: new packagemeta-oe/recipes-extended/tmux/tmux 2.1.bbSUMMARY "Terminal multiplexer"HOMEPAGE "http://tmux.sourceforge.net"SECTION "console/utils"LICENSE "ISC"LIC FILES CHKSUM "file://tmux.c;beginline 3;endline 17;md5 8685b4455.DEPENDS "ncurses libevent"SRC URI "git://github.com/tmux/tmux.git;branch master"SRCREV ? "310f0a960ca64fa3809545badc629c0c166c6cd2"S " {WORKDIR}/git"B " {WORKDIR}/build"inherit autotools pkgconfigPACKAGECONFIG ? ""PACKAGECONFIG[utempter] \"ac cv header utempter h yes,ac cv header utempter h no,libutempter,"Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com15/32

Buildroot: complexityIDesigned to be simpleIEvery proposed feature for the core is analyzed in terms ofusefulness/complexity ratioCore logic written entirely in make, less than 1000 lines of code including 230 linesof commentsIIIReally easy to understand what is going on, why and how a package is builtAlmost as simple as a shell script downloading, extracting, building and installingyour software components one after the otherIDetailed documentation, lots of resources/talksIOne hour talk sufficient to describe all the internals (ELCE 2014)ITypical feedback on IRC: coming over from Yocto and very pleasantly surprisedhow much easier it is. This is the first thing that’s stumped meFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com16/32

Yocto Project: complexityISomewhat steeper learning curve.IThe core is bitbake, a separate project written in python (60kloc).IA set of classes define the common tasks.IRecipes are written in a mix of bitbake specific language, python and shell script.ILogging and debugging allows to understand what is done for each task.IDetailed documentation but many different configuration variables.IIt is not always easy to understand the best practices (e.g. Poky should not beused for production, distro/image modifications should not be done in local.conf,removing tmp/)IPeople are still confused by the terminology (Yocto Project, Poky,OpenEmbedded, bitbake)Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com17/32

Buildroot: number/variety of packagesI1800 packagesIGraphics: X.org, Wayland, Qt4/Qt5,Gtk2/Gtk3, EFLIMultimedia: Gstreamer 0.10/1.x, ffmpeg, Kodi,OpenGL support for numerous platformsILanguages: Python 2/3, PHP, Lua, Perl,Erlang, Mono, Ruby, Node.jsINetworking: Apache, Samba, Dovecot, Exim,CUPS, lots of servers/toolsIInit systems: Busybox (default), initsysv,systemdINo support for a toolchain on the targetFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com18/32

Yocto Project: number/variety of packagesISeveral thousand recipes: around 2200 for oe-core, meta-openembedded,meta-qt5. More than 8400 known by the Metadata Index (includes duplicates).IMostly the same packages as BuildrootIHas layers for more languages: Java, Go, Rust, smalltalkIStill has an active layer for Qt3Imeta-virtualization (Docker, KVM, LXC, Xen) and meta-openstack layersFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com19/32

Buildroot: approach of dependenciesIMinimalistic approachIIIIif a feature can be disabled, it should be disabled by defaultLots of automatic dependenciesi.e., if you enable OpenSSL, you will automatically get SSL support in all otherpackages you have enabled that can provide SSL supportLeads to small root filesystems by default, with no effortFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com20/32

Yocto Project: approach of dependenciesIPackage configuration is done at the distribution levelIIIEnabling OpenSSL will enable it for all the packagesbut it is still possible to disable it for a few packagesinversely, it is possible to enable a feature only for selected packages.ICan be amended at the machine level but this should be avoided.IEach recipe can define its own set of default features to lead to a sane defaultconfiguration.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com21/32

Buildroot: updates/securityIReleases published every three months: two months of development, one monthstabilization.IEvery release includes updates of package versions: both security updates andmajor updates.IAnd also potentially changes in the core infrastructure.INo LTS versions with only security updates so far, users are handling this on theirown, only for the packages they care aboutIScript to assess the unfixed CVEs in a given Buildroot configuration is beingcontributed.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com22/32

Yocto Project: updates/securityIReleases published every six months: one release in April, one in October.IPlanning and roadmap is available on the wiki:https://wiki.yoctoproject.org/wiki/Yocto Project v2.1 StatusIFour milestones with 3 months between M1 and the final releaseIAt least the previous and the current releases have appointed maintainers, theyget security and important fixes but no recipe upgrade.IOlder releases are maintained by the community, on a best effort basis.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com23/32

Buildroot: detection of configuration changesIBuildroot does not try to be smartIWhen doing a change in the configuration, it does not try to detect what needs tobe rebuiltIOnce a package has been built, Buildroot will not rebuild it unless you force itMajor configuration changes require a full rebuildIIIMinor configuration changes can often be handled without a full rebuildIIStarts to be annoying for large systemsRequires understanding a bit what you’re doingNo way to share build artefacts between different configurations: oneconfiguration, one build.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com24/32

Yocto Project: detection of configuration changesIbitbake maintains a shared State Cache (sstate-cache) to allow incrementalbuilds.IIt detects changes in the inputs of task by creating a checksum of those inputsIThis cache is shared between all the builds. Building for similar machines is fast.IIt is possible to share that cache across hosts (for example a nightly build serverand a developer machine), allowing to greatly speed up a full build.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com25/32

Buildroot: architecture supportIWide range of architecture supportIBig ones: ARM(64), MIPS, PowerPC(64), x86/x86-64But also numerous more specific architecturesIIIIXtensa, Blackfin, ARC, m68k, SPARC, Microblaze, NIOSIIARM noMMU, especially ARMv7-MContributions from architecture vendorsIIIIMIPS by Imagination TechnologiesPowerPC64 by IBMARC by SynopsysBlackfin by Analog DevicesFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com26/32

Yocto Project: architecture supportIIIn the core: ARM, MIPS, PowerPC, x86 and their 64-bit variantsIn separate layers:IIUsually silicon vendors maintain their own BSP layers:IIIIIMicroblaze, NIOSIImeta-intelmeta-altera (both ARM and NIOSII)meta-atmel, meta-fsl, meta-ti, .meta-xilinx (both ARM and Microblaze)But also community effort:Imeta-rockchip, meta-sunxi, .Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com27/32

Buildroot: minimal buildMinimal build (qemu arm versatile defconfig) takes 15 minutes and 25 seconds,image size is gmphost-m4Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com28/32

Yocto Project: minimal buildMinimal build (core-image-minimal for qemuarm) takes 50 minutes and 47 seconds,image size is 4.9MB. With an existing sstate-cache, it takes 1 minute 21 abi-g me-nativeFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com29/32

License complianceIBoth are able to create a list of used licensesIBoth are able to detect a license changeIYocto Project can be configured to exclude GPLv3Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com30/32

Buildroot/Yocto Project: choosingFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com31/32

Questions?Alexandre BelloniThomas s.petazzoni@free-electrons.comSlides under CC-BY-SA elc/belloni-petazzoni-buildroot-oe/Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com32/32

Alexandre Belloni I The Yocto Project guy for this talk I Embedded Linux engineer/trainer at Free Electrons since 2013 I Yocto Project/OE expert I Maintainer of several Freescale boards in meta-fsl, strong contributor to meta-atmel I OpenEmbedded setup for numerous customers I Trainer for Free Electrons Yocto Project / OpenEmbedded course I And also a kernel contributor: co-maintainer of the .