\documentclass[aspectratio=169,obeyspaces,spaces,hyphens,dvipsnames]{beamer}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}% http://ctan.org/pkg/lm
\usepackage{minted}
\usepackage{hyperref}
\usepackage{xcolor}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage[normalem]{ulem}

\mode<presentation>
\usetheme{Bootlin}

\def\signed #1{{\leavevmode\unskip\nobreak\hfil\penalty50\hskip2em
  \hbox{}\nobreak\hfil(#1)
  \parfillskip=0pt \finalhyphendemerits=0 \endgraf}}

\newsavebox\mybox
\newenvironment{aquote}[1]
  {\savebox\mybox{#1}\begin{quotation}}
  {\signed{\usebox\mybox}\end{quotation}}

\title{Keep your layer simple -- and here's how}
\authors{Luca Ceresoli}
\email{luca.ceresoli@bootlin.com}
\slidesurl{https://bootlin.com/pub/conferences/}
\institute{Bootlin}
\conference{Yocto Project Summit 2023.11}

\begin{document}

\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}
\section{Keep your layer simple -- and here's how}
\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}

\begin{frame}{Luca Ceresoli}
  \begin{itemize}
  \item Embedded Linux engineer at {\bf Bootlin}
    \begin{itemize}
    \item Embedded Linux experts
    \item Engineering services: Linux BSP development, kernel porting
      and drivers, Yocto/Buildroot integration, real-time, boot-time,
      security, multimedia
    \item Training services: Embedded Linux, Linux kernel drivers, Yocto,
      Buildroot, graphics stack, boot-time, real-time, debugging, audio
    \end{itemize}
  \item Linux kernel and bootloader development, Buildroot and
    Yocto integration
  \item Open-source contributor
  \item Living in {\bf Bergamo}, Italy
  \item \code{luca.ceresoli@bootlin.com}
  \end{itemize}
  {\small \url{https://bootlin.com/company/staff/luca-ceresoli/}}
\end{frame}

\subsection{Great power = great responsibility}

 \begin{frame}{Great power = great responsibility}
  \begin{itemize}
  \item Bitbake is very powerful and flexible
    \begin{itemize}
    \item Layers, \code{.bbappends}, overrides\dots
    \item Lots of ways to modify the build system behaviour
    \end{itemize}
  \item A very useful feature\dots{} but open to misuse
  \item A desired effect can be obtained in lots of different ways
    \begin{itemize}
    \item Most of which are wrong is some way
    \end{itemize}
  \item The ``correct'', clean way is not always easy to find
    \begin{itemize}
    \item Copy\&paste from the Internet without understanding opens to bad
      surprises
    \item \url{https://docs.yoctoproject.org/} is better
    \item Investing some time in learning is necessary
    \end{itemize}
  \end{itemize}
\end{frame}

\subsection{A real world example}

\begin{frame}{{\em Real} Yocto/OpenEmbedded setup of a customer}
  \begin{itemize}
  \item 20 layers
    \begin{itemize}
    \item Including: 2 customer layers, 2 SoC vendor layers, 2 SoM vendor
      layers, meta-mingw
    \item And an additional repository with the git repo manifest
    \end{itemize}
    \pause
  \item 4000+ lines in \code{.bbappend} files in non-core layers
    \begin{itemize}
    \item Largely unneeded, sometimes hurting
    \item Time spent in discovering the origin of issues
    \end{itemize}
    \pause
  \item As of October 2022 based on Yocto sumo, released April 2018
    \begin{itemize}
    \item Does not build on recent distros, needs a container
    \item Custom scripts to set it up
    \item Using a vendor kernel based on 4.9 (December 2016), almost EOL
    \item \code{linux-backports} for drivers
    \item Several recipes copied and adapted from more recent releases
    \end{itemize}
    \pause
  \item Attempts to upgrade broke lots of things
    \pause
  \item 1 product
  \end{itemize}
\end{frame}

\subsection{The proposed solution}

\begin{frame}{Can't fix it? Throw it!}
  \begin{itemize}
  \item Write a new setup from scratch
  \item Based on the latest Yocto LTS (Kirkstone)
  \item Using only the {\em really} useful layers
  \item Using recent mainline Linux and U-Boot
    \begin{itemize}
    \item Product based on i.MX6, well supported
    \item Send to mainline any additional patches needed
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}{The result}
  \begin{itemize}
  \item 5 layers: oe-core, meta-oe, meta-qt5, meta-rauc (new!), meta-{\em company-name}
    \begin{itemize}
    \item meta-{\em company-name} total: 60 files, ~3150 lines
    \item Recipe to build mainline Linux: 29 lines using \code{kernel.bbclass}
    \item Recipe to build mainline U-Boot: 25 lines using \code{u-boot.inc} from oe-core
    \item Recipe to build product Device Tree: 5 lines using \code{devicetree.bbclass}
    \end{itemize}
  \item Image size: less than half
  \item 1 git repository, including \code{kas} config file
  \item Quick and easy to set up {\em without custom scripts}
  \item Builds without containers on modern distributions
    \pause
  \item Customer happy
  \end{itemize}
\end{frame}

\subsection{Cool!\\
  How can I do it?\\
  \pause
  Here's how!}

\begin{frame}{Keep your layer simple\dots}
  \begin{itemize}
  \item We wrote a fictitious but realistic YP/OE setup for a product
    company
    \begin{itemize}
    \item To act as an example for companies making products
    \item Not for BSP/Distro/Software layers
    \end{itemize}
  \item Clean
    \begin{itemize}
    \item 1 layer
    \item 2 (fictitious) products
    \item 1 distro
    \item A few recipes: mainline Linux and U-Boot and a userspace
      application
    \item Two \code{.bbappend} files for fixes
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}{Keep your layer simple\dots}
  \begin{itemize}
  \item Goal: provide a practical example of how to cleanly achieve common needs
    \begin{itemize}
    \item Fetching layers
    \item Writing clean, simple, maintainable recipes
    \item Use overrides
    \item Use mysterious things such as
      \code{MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS}
    \item Have distro, machine and image settings in the proper place
    \item Avoid too many 3rd-party layers (cost/benefit ratio)
    \item Keep it simple!
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}{\dots{}and here's how}
  \begin{center}
    \Large\url{https://github.com/bootlin/simplest-yocto-setup}
  \end{center}
\end{frame}

\questionslide

\end{document}
