\documentclass[aspectratio=169,obeyspaces,spaces,hyphens,dvipsnames]{beamer}
\usepackage[utf8]{inputenc}
\usepackage{minted}
\usepackage{hyperref}

\mode<presentation>
\usetheme{Bootlin}

\newcommand{\codehack}[1]{{\usebeamercolor[fg]{code} {\tt #1}}}

\title{Buildroot vs. OpenEmbedded/Yocto Project: A Four Hands Discussion}
\authors{Alexandre Belloni - Thomas Petazzoni}
\institute{Bootlin}

\setcounter{tocdepth}{2}

\setbeamerfont{block title}{size=\scriptsize}
\addtobeamertemplate{block begin}{\pgfsetfillopacity{0.5}}{\pgfsetfillopacity{1}}

\begin{document}

\begin{frame}{Embedded Linux Conference 2016}
  \begin{center}
    \Large
    Buildroot vs. OpenEmbedded/Yocto Project: A Four Hands Discussion\\
  \end{center}
  \vspace{1cm}
  \begin{columns}[c]
    \column{0.6\textwidth}
    \normalsize
    Alexandre Belloni, Thomas Petazzoni\\
    {\bf Bootlin}\\
    {\em alexandre.belloni@bootlin.com}\\
    {\em thomas.petazzoni@bootlin.com}
    \column{0.4\textwidth}
    \includegraphics[width=\textwidth]{four-hands.jpg}
  \end{columns}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{yocto-background.png}}
\begin{frame}{Alexandre Belloni}
  \begin{itemize}
  \item The {\bf Yocto Project guy} for this talk
  \item Embedded Linux engineer/trainer at Bootlin since 2013
  \item Yocto Project/OE expert
  \item Maintainer of several Freescale boards in \code{meta-fsl},
    strong contributor to \code{meta-atmel}
  \item OpenEmbedded setup for numerous customers
  \item Trainer for Bootlin Yocto Project / OpenEmbedded course
  \item And also a kernel contributor: co-maintainer of the RTC
    subsystem and the Atmel ARM processor support
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{buildroot-background.png}}
\begin{frame}{Thomas Petazzoni}
  \begin{itemize}
  \item The {\bf Buildroot guy} for this talk
  \item CTO and Embedded Linux engineer/trainer at Bootlin
    since 2008
  \item Strong Buildroot contributor
  \item Interim Buildroot maintainer
  \item Trainer for Bootlin Buildroot course
  \item And also a kernel contributor: support for Marvell processors
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{both-background.png}}
\begin{frame}{Common aspects}
  \begin{itemize}
  \item Embedded Linux build systems
    \begin{itemize}
    \item Goal is to build a complete, customized, embedded Linux system
    \item Root filesystem, toolchain, kernel, bootloaders
    \end{itemize}
  \item Build {\bf from scratch from source}
  \item Using {\bf cross-compilation}
  \item Very {\bf actively maintained} and developed projects
  \item {\bf Widely used} in the industry
  \item Well documented, training courses
  \item Free software
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{buildroot-background.png}}
\begin{frame}{Buildroot: general philosophy}
  \begin{itemize}
  \item Strong focus on {\bf simplicity}
  \item Simple to use, but also simple to understand/extend
  \item Special use cases handled via {\bf extension scripts}, rather than
    in Buildroot itself
  \item Re-use of {\bf existing technologies}/languages: kconfig, make.
    \begin{itemize}
    \item Learning effort worth the investment
    \end{itemize}
  \item {\bf Minimalist}: small by default
  \item Purpose-agnostic
  \item {\bf Open community}, no vendor or bureaucratic/corporate management
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{yocto-background.png}}
\begin{frame}{Yocto Project: general philosophy}
  \begin{itemize}
  \item Support for the major architectures
    \begin{itemize}
    \item OpenEmbedded: only qemu
    \item Yocto Project: adds support for a few machines
    \end{itemize}
  \item Only provides {\bf core} recipes, use {\bf layers} to get
    support for more packages and more machines
  \item Custom modifications should stay in a separate layer
  \item {\bf Versatile} build system: tries to be as flexible as
    possible and to handle most use cases.
  \item Open community but the project is still governed by the Yocto
    Project Advisory Board made up of its corporate sponsors.
  \item OpenEmbedded is an independent community driven project.
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{buildroot-background.png}}
\begin{frame}{Buildroot: output}
  \begin{itemize}
  \item Buildroot main product is a {\bf root filesystem image}
    \begin{itemize}
    \item But also: toolchain, kernel image, bootloaders, etc.
    \end{itemize}
  \item Many formats supported: ext2/3/4, ubifs, iso9660, etc.
  \item {\bf No binary packages}, no package management system
    \begin{itemize}
    \item Some people call it a {\em firmware generator}
    \item Updates are not possible via packages
    \item Updates require a full system update, like Android
    \item Belief that partial updates are harmful
    \end{itemize}
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{yocto-background.png}}
\begin{frame}{Yocto Project: output}
  \begin{itemize}
    \item Builds {\bf distributions}, the main output is a package feed
    \begin{itemize}
    \item the package management system is optional on the target
    \item it is possible to install or update only part of the system
    \end{itemize}
  \item Also generates {\bf root filesystem images} by installing
    those packages. Supports the usual ext2/3/4, ubifs, iso9660, etc..
    but also VM images: vmdk, vdi, qcow2
  \item Finally, images classes or a tool, \code{wic}, can be used to
    create {\bf disk images}
  \item Also able to generate an {\bf SDK} alongside the image to
    allow application developers to 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.
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{buildroot-background.png}}
\begin{frame}{Buildroot: configuration}
  \begin{itemize}
  \item Re-uses {\em kconfig} from the Linux kernel
  \item Simple {\em \{menu,x,n,g\}config} interface
  \item Entire configuration stored in a single
    \code{.config}/\code{defconfig}
  \item Defines all aspects of the system: architecture, kernel
    version/config, bootloaders, user-space packages, etc.
  \item \code{make menuconfig}, \code{make}, profit!
  \item Building the same system for different machines: to be handled
    separately
    \begin{itemize}
    \item A tool can generate \code{defconfig} from fragments
    \item Doable, but not super easy
    \item Complete separate build for each machine
    \end{itemize}
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{yocto-background.png}}
\begin{frame}{Yocto Project: configuration}
  \begin{itemize}
  \item The configuration is separated in multiple parts:
    \begin{itemize}
      \item {\bf Distribution} configuration (general package
        configuration, toolchain and libc selection,...)
    \item {\bf Machine} configuration (defines the architecture,
      machine features, BSP.)
    \item {\bf Image} recipe (what packages should be installed on the
      target.)
    \item Local configuration (distribution and default machine selection, how many
      threads to use when compiling, whether to remove build
      artifacts,...)
    \end{itemize}
  \item It is also necessary to gather the various {\bf layers} that
    will be used and declare them.
  \item Allows to build the same image for different machines or using
    different distributions or different images for one machine.
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{buildroot-background.png}}
\begin{frame}{Buildroot: layers}
  \begin{itemize}
  \item Initially: no concept of layers
  \item All packages are maintained in the official repository
    \begin{itemize}
    \item Allows for very high quality, thanks to review by experts
    \end{itemize}
  \item Addition of \code{BR2_EXTERNAL}
    \begin{itemize}
    \item Allows to store package definitions, configurations and
      other artefacts
    \item One \code{BR2_EXTERNAL} only
    \item Generally used for proprietary/custom packages and
      configurations
    \item Can only add packages, not override the ones in Buildroot
    \end{itemize}
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{yocto-background.png}}
\begin{frame}{Yocto Project: layers}
  \begin{itemize}
    \item Layer mechanism allows to {\bf modify or add} new package or
      image recipes.
  \item Clear separation between the core build system, the BSP and
    custom modifications.
  \item Scales properly, third parties provide their layers with BSPs
    or a set of recipes handling their dedicated applications
  \item Layers have to be compatible and use the same OE branch base.
  \item Beware of layer quality, reviews are not systematic.
  \item OpenEmbedded Metadata Index lists available layers, recipes,
    machines: \url{http://layers.openembedded.org/layerindex/}
  \item Also, there is a powerful {\bf overrides} mechanism allowing
    to adjust recipe variables based on the machine or distribution.
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{both-background.png}}
\begin{frame}{Buildroot/Yocto Project: toolchain}
  Similar capabilities
  \begin{itemize}
  \item Building their own toolchains, based on gcc, a choice of C
    libraries (glibc, uClibc, musl)
  \item Using pre-built external toolchains
    \begin{itemize}
    \item Somewhat easier in Buildroot, since it's built-in
    \item Only really properly supported with additional vendor
      layers in the Yocto Project
    \end{itemize}
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{buildroot-background.png}}
\begin{frame}[fragile]{Buildroot: new package}
\fontsize{7}{6}\selectfont
\begin{block}{package/tmux/Config.in}
\begin{verbatim}
config BR2_PACKAGE_TMUX
        bool "tmux"
        depends on BR2_USE_MMU # fork()
        select BR2_PACKAGE_LIBEVENT
        select BR2_PACKAGE_NCURSES
        help
          tmux is a terminal multiplexer, it enables a number of terminals
          (or windows) to be accessed and controlled from a single terminal.

          https://tmux.github.io/
\end{verbatim}
\end{block}

\begin{block}{package/tmux/tmux.mk}
\begin{verbatim}
TMUX_VERSION = 2.1
TMUX_SITE = https://github.com/tmux/tmux/releases/download/$(TMUX_VERSION)
TMUX_LICENSE = ISC
TMUX_LICENSE_FILES = README
TMUX_DEPENDENCIES = libevent ncurses host-pkgconf

$(eval $(autotools-package))
\end{verbatim}
\end{block}

\begin{block}{package/tmux/tmux.hash}
\begin{verbatim}
# Locally computed:
sha256  31564e7bf4bcef2de...f6176  tmux-2.1.tar.gz
\end{verbatim}
\end{block}

\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{yocto-background.png}}
  \begin{frame}[fragile]{Yocto Project: new package}
\begin{block}{meta-oe/recipes-extended/tmux/tmux\_2.1.bb}
\fontsize{8}{9}\selectfont
\begin{verbatim}
SUMMARY = "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 pkgconfig

PACKAGECONFIG ??= ""
PACKAGECONFIG[utempter] = \
    "ac_cv_header_utempter_h=yes,ac_cv_header_utempter_h=no,libutempter,"
\end{verbatim}
\end{block}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{buildroot-background.png}}
\begin{frame}{Buildroot: complexity}
  \begin{itemize}
  \item Designed to be {\bf simple}
  \item Every proposed feature for the core is analyzed in terms of
    {\bf usefulness/complexity} ratio
  \item Core logic written entirely in make, less than 1000 lines of
    code including 230 lines of comments
    \begin{itemize}
    \item Really easy to understand what is going on, why and how a
      package is built
    \item Almost as simple as a shell script downloading, extracting,
      building and installing your software components one after the
      other
    \end{itemize}
  \item Detailed documentation, lots of resources/talks
  \item One hour talk sufficient to describe all the internals (ELCE
    2014)
  \item Typical feedback on IRC: {\em coming over from Yocto and very
      pleasantly surprised how much easier it is.  This is the first
      thing that's stumped me}
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{yocto-background.png}}
\begin{frame}{Yocto Project: complexity}
  \begin{itemize}
  \item Somewhat steeper learning curve.
  \item The core is \code{bitbake}, a separate project written in python (60kloc).
  \item A set of {\bf classes} define the common tasks.
  \item Recipes are written in a mix of bitbake specific language, python and
    shell script.
  \item Logging and debugging allows to understand what is done for
    each task.
  \item Detailed documentation but many different configuration
    variables.
  \item It is not always easy to understand the best practices (e.g.
    Poky should not be used for production, distro/image modifications
    should not be done in local.conf, removing tmp/)
  \item People are still confused by the terminology (Yocto Project,
    Poky, OpenEmbedded, bitbake)
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{buildroot-background.png}}
\begin{frame}{Buildroot: number/variety of packages}
  \begin{columns}[c]
    \column{0.6\textwidth}
    \begin{itemize}
    \item 1800+ packages
    \item Graphics: X.org, Wayland, Qt4/Qt5, Gtk2/Gtk3, EFL
    \item Multimedia: Gstreamer 0.10/1.x, ffmpeg, Kodi, OpenGL support
      for numerous platforms
    \item Languages: Python 2/3, PHP, Lua, Perl, Erlang, Mono, Ruby, Node.js
    \item Networking: Apache, Samba, Dovecot, Exim, CUPS, lots of servers/tools
    \item Init systems: Busybox (default), initsysv, systemd
    \item No support for a toolchain on the target
    \end{itemize}
    \column{0.4\textwidth}
    \includegraphics[width=\textwidth]{br-number-of-packages.png}
  \end{columns}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{yocto-background.png}}
\begin{frame}{Yocto Project: number/variety of packages}
  \begin{itemize}
  \item Several thousand recipes: around 2200 for oe-core,
    meta-openembedded, meta-qt5. More than 8400 known by the Metadata
    Index (includes duplicates).
  \item Mostly the same packages as Buildroot
  \item Has layers for more languages: Java, Go, Rust, smalltalk
  \item Still has an active layer for Qt3
  \item meta-virtualization (Docker, KVM, LXC, Xen) and meta-openstack layers
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{buildroot-background.png}}
\begin{frame}{Buildroot: approach of dependencies}
  \begin{itemize}
  \item Minimalistic approach
    \begin{itemize}
    \item if a feature can be disabled, it should be disabled by
      default
    \end{itemize}
  \item Lots of automatic dependencies
    \begin{itemize}
    \item i.e., if you enable OpenSSL, you will automatically get SSL
      support in all other packages you have enabled that can provide
      SSL support
    \end{itemize}
  \item Leads to small root filesystems by default, with no effort
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{yocto-background.png}}
\begin{frame}{Yocto Project: approach of dependencies}
  \begin{itemize}
  \item Package configuration is done at the distribution level
    \begin{itemize}
    \item Enabling OpenSSL will enable it for all the packages
    \item but it is still possible to disable it for a few packages
    \item inversely, it is possible to enable a feature only for
      selected packages.
    \end{itemize}
  \item Can be amended at the machine level but this should be
    avoided.
  \item Each recipe can define its own set of default features to lead
    to a sane default configuration.
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{buildroot-background.png}}
\begin{frame}{Buildroot: updates/security}
  \begin{itemize}
  \item Releases published every three months: two months of
    development, one month stabilization.
  \item Every release includes updates of package versions: both
    security updates and major updates.
  \item And also potentially changes in the core infrastructure.
  \item No LTS versions with only security updates so far, users are
    handling this on their own, only for the packages they care about
  \item Script to assess the unfixed CVEs in a given Buildroot
    configuration is being contributed.
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{yocto-background.png}}
\begin{frame}{Yocto Project: updates/security}
  \begin{itemize}
  \item Releases published every six months: one release in April, one
    in October.
  \item Planning and roadmap is available on the wiki:
    \url{https://wiki.yoctoproject.org/wiki/Yocto_Project_v2.1_Status}
  \item Four milestones with 3 months between M1 and the final release
  \item At least the previous and the current releases have appointed
    maintainers, they get {\bf security} and important fixes but no
    recipe upgrade.
  \item Older releases are maintained by the community, on a best
    effort basis.
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{buildroot-background.png}}
\begin{frame}{Buildroot: detection of configuration changes}
  \begin{itemize}
  \item Buildroot does not try to be smart
  \item When doing a change in the configuration, it does not try to
    detect what needs to be rebuilt
  \item Once a package has been built, Buildroot will not rebuild it
    unless you force it
  \item Major configuration changes require a full rebuild
    \begin{itemize}
    \item Starts to be annoying for large systems
    \end{itemize}
  \item Minor configuration changes can often be handled without a
    full rebuild
    \begin{itemize}
    \item Requires understanding a bit what you're doing
    \end{itemize}
  \item No way to share build artefacts between different
    configurations: one configuration, one build.
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{yocto-background.png}}
\begin{frame}{Yocto Project: detection of configuration changes}
  \begin{itemize}
    \item \code{bitbake} maintains a shared State Cache ({\em
      sstate-cache}) to allow incremental builds.
  \item It detects changes in the inputs of task by creating a
    checksum of those inputs
  \item This cache is shared between all the builds. Building for similar
    machines is fast.
  \item It is possible to share that cache across hosts (for example a
    nightly build server and a developer machine), allowing to greatly
    speed up a full build.
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{buildroot-background.png}}
\begin{frame}{Buildroot: architecture support}
  \begin{itemize}
  \item Wide range of architecture support
  \item {\bf Big ones}: ARM(64), MIPS, PowerPC(64), x86/x86-64
  \item But also numerous {\bf more specific} architectures
    \begin{itemize}
    \item Xtensa, Blackfin, ARC, m68k, SPARC, Microblaze, NIOSII
    \item ARM noMMU, especially ARMv7-M
    \end{itemize}
  \item Contributions from architecture vendors
    \begin{itemize}
    \item MIPS by Imagination Technologies
    \item PowerPC64 by IBM
    \item ARC by Synopsys
    \item Blackfin by Analog Devices
    \end{itemize}
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{yocto-background.png}}
\begin{frame}{Yocto Project: architecture support}
  \begin{itemize}
  \item In the core: ARM, MIPS, PowerPC, x86 and their 64-bit variants
  \item In separate layers:
    \begin{itemize}
    \item Microblaze, NIOSII
    \end{itemize}
  \item Usually {\bf silicon vendors maintain} their own BSP layers:
    \begin{itemize}
    \item meta-intel
    \item meta-altera (both ARM and NIOSII)
    \item meta-atmel, meta-fsl, meta-ti, ...
    \item meta-xilinx (both ARM and Microblaze)
    \end{itemize}
  \item But also community effort:
    \begin{itemize}
    \item meta-rockchip, meta-sunxi, ...
    \end{itemize}
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{buildroot-background.png}}
\begin{frame}{Buildroot: minimal build}
  Minimal build (\code{qemu_arm_versatile_defconfig}) takes 15 minutes
  and 25 seconds, image size is 2.2MB.
  \includegraphics[width=.9\textwidth]{buildroot-graph-depends.pdf}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{yocto-background.png}}
\begin{frame}{Yocto Project: minimal build}
  Minimal build (\code{core-image-minimal} for \code{qemuarm}) takes 50 minutes
  and 47 seconds, image size is 4.9MB. With an existing sstate-cache,
  it takes 1 minute 21 seconds.
  \includegraphics[width=\textwidth]{oe-graph-depends.pdf}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{both-background.png}}
\begin{frame}{License compliance}
  \begin{itemize}
  \item Both are able to create a list of used licenses
  \item Both are able to detect a license change
  \item Yocto Project can be configured to exclude GPLv3
  \end{itemize}
\end{frame}

\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{both-background.png}}
\begin{frame}{Buildroot/Yocto Project: choosing}

  \begin{center}
    \includegraphics[width=\textwidth]{chosing.pdf}
  \end{center}

\end{frame}

\usebackgroundtemplate{ }

\begin{frame}
  \begin{center}
  \Huge
  Questions?\\
  \vspace{1.5cm}
  \huge
  Alexandre Belloni\\
  Thomas Petazzoni\\
  \large
  \vspace{0.5cm}
  \code{alexandre.belloni@bootlin.com}\\
  \code{thomas.petazzoni@bootlin.com}
  \vspace{0.5cm}
  \newline Slides under CC-BY-SA 3.0\\
  \scriptsize
  \url{http://bootlin.com/pub/conferences/2016/elc/belloni-petazzoni-buildroot-oe/}
  \end{center}
\end{frame}

\end{document}
