From fa79f13b6164276029aec895cc1812171fae9baa Mon Sep 17 00:00:00 2001
From: Manuel Traut <manut@linutronix.de>
Date: Thu, 28 Aug 2014 22:44:07 +0200
Subject: add own layer and own distro

Signed-off-by: Manuel Traut <manut@linutronix.de>
---
 .../yocto-advanced/pres_yocto-advanced.tex         | 379 ++++++++++++++++-----
 1 file changed, 285 insertions(+), 94 deletions(-)

(limited to 'distribution/yocto-advanced/pres_yocto-advanced.tex')

diff --git a/distribution/yocto-advanced/pres_yocto-advanced.tex b/distribution/yocto-advanced/pres_yocto-advanced.tex
index 480712b..f7b3bec 100644
--- a/distribution/yocto-advanced/pres_yocto-advanced.tex
+++ b/distribution/yocto-advanced/pres_yocto-advanced.tex
@@ -8,14 +8,72 @@
 \begin{itemize}
 \item Using BSP layers (sabrelite)
 \item Build a predefined image (sabrelite)
+\item Creating a layer
 \item Define a distribution
-\item Create layers \& recipes
+\item Writing recipes
 \item Create images
 \item Yocto \& ELBE combined
 \end{itemize}
 \end{frame}
 
 \subsection{Using BSP layers}
+
+\begin{frame}[fragile]
+	\frametitle{meta-*/conf/layer.conf}
+	each layer needs a configuration file
+	\begin{itemize}
+		\item add conf and class directories to BBPATH
+			\begin{verbatim}BBPATH =. "${LAYERDIR}"\end{verbatim}
+		\pause
+		\item add recipe directories to BBFILES
+			\begin{verbatim}BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
+			${LAYERDIR}/recipes-*/*/*.bbappend"\end{verbatim}
+		\pause
+		\item add layer name to BBFILE\_COLLECTIONS
+			\begin{verbatim}BBFILE_COLLECTIONS += "mylayer"\end{verbatim}
+		\pause
+		\item set root of the layer
+			\begin{verbatim}BBFILE_PATTERN_mylayer = "^${LAYERDIR}/"\end{verbatim}
+		\pause
+		\item set default priority of the layer
+			\begin{verbatim}BBFILE_PRIORITY_mylayer = "5"\end{verbatim}
+		\pause
+		\item set version of layer (only increment if dependencies with other
+			layers are affected)
+			\begin{verbatim}LAYERVERSION_mylayer = "2"\end{verbatim}
+		\pause
+		\item set dependencies to other layers
+			\begin{verbatim}LAYERDEPENDS_mylayer = "meta-yocto"\end{verbatim}
+	\end{itemize}
+\end{frame}
+
+
+\begin{frame}
+\frametitle{bitbake-layers}
+is useful to debug relations between different layers, options are:
+\begin{description}
+\item [show-layers] shows the current configured layers
+\item [show-recipes] lists available recipes and the layers that provide them.
+\item [show-overlayed] lists overlayed recipes
+\item [show-appends] lists .bbappend files
+	and the recipe files to which they apply
+\item [show-cross-depends] lists dependency relationships
+	between recipes that cross layer boundaries
+\item [flatten] flattens the layer configuration
+	into a separate output directory.
+\end{description}
+\end{frame}
+
+\begin{frame}
+\frametitle{definitions}
+\begin{itemize}
+	\item It is possible for a recipe with a lower version number PV in a layer
+that has a higher priority to take precedence.
+	\item Also, the layer priority does not currently affect the precedence
+order of .conf or .bbclass files. Future versions of BitBake might address this.
+\end{itemize}
+\end{frame}
+
 \begin{frame}[fragile]
 \frametitle{get an existing layer}
 retrive the layer from your BSP/SoC vendor
@@ -35,14 +93,10 @@ check dependencies again
 \begin{verbatim}
 poky % cat meta-fsl-arm/conf/layer.conf | grep LAYERDEPENDS
 \end{verbatim}
-\dots no dependencies?! \dots OK - finished.
-
-\vspace{2em}
-README says sth. different (openembedded-core) but we have this one already;
-it is called 'meta' in poky.
+\dots no more dependencies?! \dots OK - finished.
 \end{frame}
 
-\begin{frame}
+\begin{frame}[fragile]
 \frametitle{generate a new build environment}
 \begin{verbatim}
 poky % . oe-init-build-env build-fsl
@@ -143,9 +197,10 @@ is used to configure
 	\item sstate mirrors
 	\item qemu configuration
 	\item layer priorities
-\subsection{Freescale}
-\begin{frame}
+\end{itemize}
+\end{frame}
 
+\subsection{sabrelite configuration}
 \begin{frame}[fragile]
 \frametitle{configure the machine}
 to get a list of currently available machines configs:
@@ -205,7 +260,7 @@ BBLAYERS ?= " \
 \end{verbatim}
 \end{frame}
 
-\begin{frame}
+\begin{frame}[fragile]
 \frametitle{build a fsl demo image}
 \begin{verbatim}
 poky/build-fsl % source toaster start
@@ -215,94 +270,242 @@ Currently 4 running tasks (26 of 4459):
 \dots coffee break!
 \end{frame}
 
-\begin{frame}
-\frametitle{define a distribution}
-bla
-DISTRO\_FEATURES
-\end{frame}
-
-\begin{frame}
-\frametitle{creating a layer}
-bla
+\begin{frame}[fragile]
+\frametitle{build a fsl demo image}
+\dots back from coffee break
+\begin{verbatim}
+ERROR: No new tasks can be executed since the disk space monitor action is
+"STOPTASKS"!
+\end{verbatim}
+what happened??
+\begin{verbatim}
+poky/build-fsl % df -h
+Filesystem      Size  Used Avail Use% Mounted on
+/dev/sda4       367G  348G  850M 100% /
+poky/build-fsl % du -sm .
+31026   .
+poky/build-fsl % du -sm ../build
+29172   ../build/
+\end{verbatim}
+\dots so the solution is to cleanup the disk and run
+\begin{verbatim}
+poky/build-fsl % bitbake qt-in-use-image
+\end{verbatim}
+again.
 \end{frame}
 
 \begin{frame}[fragile]
-	\frametitle{meta-*/conf/layer.conf}
-	\begin{itemize}
-		\item add conf and class directories to BBPATH
-			\begin{verbatim}BBPATH =. "${LAYERDIR}"\end{verbatim}
-		\pause
-		\item add recipe directories to BBFILES
-			\begin{verbatim}BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
-			${LAYERDIR}/recipes-*/*/*.bbappend"\end{verbatim}
-		\pause
-		\item add layer name to BBFILE\_COLLECTIONS
-			\begin{verbatim}BBFILE_COLLECTIONS += "mylayer"\end{verbatim}
-		\pause
-		\item set root of the layer
-			\begin{verbatim}BBFILE_PATTERN_mylayer = "^${LAYERDIR}/"\end{verbatim}
-		\pause
-		\item set default priority of the layer
-			\begin{verbatim}BBFILE_PRIORITY_mylayer = "5"\end{verbatim}
-		\pause
-		\item set version of layer (only increment if dependencies with other
-			layers are affected)
-			\begin{verbatim}LAYERVERSION_mylayer = "2"\end{verbatim}
-		\pause
-		\item set dependencies to other layers
-			\begin{verbatim}LAYERDEPENDS_mylayer = "meta-yocto"\end{verbatim}
-	\end{itemize}
+\frametitle{build a fsl demo image}
+\dots one more error
+\begin{verbatim}
+ERROR: To use 'gpu-viv-bin-mx6q' you need to accept the Freescale EULA
+at '/home/local/src/poky/meta-fsl-arm/EULA'. Please read it and in case
+you accept it, write: ACCEPT_FSL_EULA = "1" in your local.conf.
+ERROR: Function failed: do_unpack
+ERROR: Logfile of failure stored in: /home/local/src/poky/build-fsl/tmp
+/work/cortexa9hf-vfp-neon-mx6-poky-linux-gnueabi/gpu-viv-bin-mx6q/1_3.1
+0.17-1.0.0-hfp-r0/temp/log.do_unpack.6795
+ERROR: Task 1105 (/home/local/src/poky/meta-fsl-arm/recipes-graphics/gp
+u-viv-bin-mx6q/gpu-viv-bin-mx6q_3.10.17-1.0.0-hfp.bb, do_unpack) failed
+with exit code '1'
+\end{verbatim}
+to solve this issue:
+\begin{verbatim}
+poky/build-fsl % echo 'ACCEPT\_FSL\_EULA = "1"' >> conf/local.conf
+\end{verbatim}
+\dots and run
+\begin{verbatim}
+poky/build-fsl % bitbake qt-in-use-image
+\end{verbatim}
+again.
 \end{frame}
 
-It is possible for a recipe with a lower version number PV in a layer that has a higher priority to take precedence.
-
-Also, the layer priority does not currently affect the precedence order of .conf or .bbclass files. Future versions of BitBake might address this.
-
-itbake-layers <command> [arguments]
-                
-
-The following list describes the available commands:
-
-    help: Displays general help or help on a specified command.
 
-    show-layers: Shows the current configured layers.
+\subsection{creating a layer}
+\begin{frame}[fragile]
+\frametitle{with yocto helper script}
+\begin{verbatim}
+poky/build-fsl % cd ..
+poky % yocto-layer create linutronix
+Please enter the layer priority you'd like to use for the layer: [default: 6]
+<return>
+Would you like to have an example recipe created? (y/n) [default: n]
+<return>
+Would you like to have an example bbappend file created? (y/n) [default: n]
+<return>
+\end{verbatim}
+\end{frame}
 
-    show-recipes: Lists available recipes and the layers that provide them.
+\begin{frame}[fragile]
+\frametitle{manage the layer with git}
+\begin{verbatim}
+poky % cd meta-linutronix
+poky/meta-linutronix % git init .
+poky/meta-linutronix % git add *
+poky/meta-linutronix % git commit -sam 'inital version'
+\end{verbatim}
+\end{frame}
 
-    show-overlayed: Lists overlayed recipes. A recipe is overlayed when a recipe with the same name exists in another layer that has a higher layer priority.
+\subsection{define a distro}
+\begin{frame}
+\frametitle{why define a distribution?}
+\begin{itemize}
+\item naming of the toolchain (codenames, vendor)
+\item version numbers
+\item enable default features
+\end{itemize}
+\end{frame}
 
-    show-appends: Lists .bbappend files and the recipe files to which they apply.
+\begin{frame}
+\frametitle{distro features: file-systems}
+\begin{description}
+\item[cramfs] CramFS support
+\item[ext2] tools for supporting for devices with internal HDD/Microdrive
+	for storing files (instead of Flash only devices)
+\item[nfs] NFS client support (for mounting NFS exports on device)
+\item[smbfs] SMB networks client support
+	(for mounting Samba/Microsoft Windows shares on device)
+\end{description}
+\end{frame}
 
-    show-cross-depends: Lists dependency relationships between recipes that cross layer boundaries.
+\begin{frame}
+\frametitle{distro features: hardware support}
+\begin{description}
+\item[alsa] ALSA/sound support
+	(OSS compatibility kernel modules installed if available)
+\item[bluetooth] bluetooth support (integrated BT only)
+\item[irda] IrDA support
+\item[wifi] WiFi support (integrated only).
+\item[keyboard] keyboard support (e.g. keymaps will be loaded during boot)
+\end{description}
+\end{frame}
 
-    flatten: Flattens the layer configuration into a separate output directory. Flattening your layer configuration builds a "flattened" directory that contains the contents of all layers, with any overlayed recipes removed and any .bbappend files appended to the corresponding recipes. You might have to perform some manual cleanup of the flattened layer as follows:
+\begin{frame}
+\frametitle{distro features: grahpics}
+\begin{description}
+\item[opengl] the Open Graphics Library, which is a cross-language,
+	multi-platform application programming interface used for rendering two
+	and three-dimensional graphics
+\item[directfb] DirectFB support
+\end{description}
+\end{frame}
 
-        Non-recipe files (such as patches) are overwritten. The flatten command shows a warning for these files.
+\begin{frame}
+\frametitle{distro features: networking}
+\begin{description}
+\item[ipsec] IPSec support
+\item[ipv6] IPv6 support
+\item[ppp] PPP dialup support
+\end{description}
+\end{frame}
 
-        Anything beyond the normal layer setup has been added to the layer.conf file. Only the lowest priority layer's layer.conf is used.
+\begin{frame}
+\frametitle{distro features: bus support}
+\begin{description}
+\item[pci] PCI bus support
+\item[pcmcia] PCMCIA/CompactFlash support
+\item[usbgadget] USB Gadget Device support (for USB networking/serial/storage)
+\item[usbhost] USB Host support
+	(allows to connect external keyboard, mouse, storage, network etc)
+\end{description}
+\end{frame}
 
-        Overridden and appended items from .bbappend files need to be cleaned up. The contents of each .bbappend end up in the flattened recipe. However, if there are appended or changed variable values, you need to tidy these up yourself. Consider the following example. Here, the bitbake-layers command adds the line #### bbappended ... so that you know where the following lines originate:
+\begin{frame}
+\frametitle{distro features: software}
+\begin{description}
+\item[systemd] support for this init manager, which is a full replacement of
+	for init with parallel starting of services, reduced shell overhead,
+	and other features. This init manager is used by many distributions
+\item[wayland] the Wayland display server protocol
+	and the library that supports it
+\item[x11] X server and libraries
+\end{description}
+\end{frame}
 
-             ...
-             DESCRIPTION = "A useful utility"
-             ...
-             EXTRA_OECONF = "--enable-something"
-             ...
+\begin{frame}[fragile]
+\frametitle{use a DISTRO\_FEATURE}
+Normally the distro features are used in package groups in a core layer.
+e.g. 'meta/recipes-core/packagegroups/packagegroup-base.bb':
+\begin{verbatim}
+PACKAGES = ' \
+	..
+	${@base_contains("DISTRO_FEATURES", "opengl", "packagegroup-opengl", "", d)} \
+	..
+	'
+\end{verbatim}
+\end{frame}
 
-             #### bbappended from meta-anotherlayer ####
+\begin{frame}[fragile]
+\frametitle{exkurs: package groups}
+are recipes that are used to group packages together:
+\begin{verbatim}
+DESCRIPTION = “My Package Group”
+LICENSE = “MIT”
+LIC_FILES_CHECKSUM = “file://<licfile>;md5=<chksum>
+inherit packagegroup
+PROVIDES = “${PACKAGES}”
+PACKAGES = “packagegroup-mypkg-apps packagegroup-mypkg-tools”
+RDEPENDS_packagegroup-mypkg-apps = “sqlite3 python-core python-sqlite3”
+RDEPENDS_pacakgegroup-mypkg-tools = “sudo gzip tar”
+\end{verbatim}
+it can be used, to simplify image definitions
+\end{frame}
 
-             DESCRIPTION = "Customized utility"
-             EXTRA_OECONF += "--enable-somethingelse"
-                                        
+\begin{frame}[fragile]
+\frametitle{linutronix distribution}
+distros are defined in a layer, e.g.
+meta-linutronix/conf/distro/linutronix.conf:
+\begin{verbatim}
+DISTRO = "linutronix"
+DISTRO_NAME = "linutronix 1.0 (for foo devices)"
+DISTRO_VERSION = "1.0"
+DISTRO_CODENAME = "bar"
+SDK_VENDOR = "-linutronix"
+SDK_VERSION := "${@'${DISTRO_VERSION}'}"
+MAINTAINER = "Manuel Traut <manut@linutronix.de>"
+TARGET_VENDOR = "-linutronix"
+LOCALCONF_VERSION = "1"
+LAYER_CONF_VERSION ?= "6"
+DISTRO_FEATURES_append = " opengl"
+\end{verbatim}
+\end{frame}
 
-        Ideally, you would tidy up these utilities as follows:
+\begin{frame}[fragile]
+\frametitle{add distro to git repo}
+\begin{verbatim}
+poky/meta-linutronix % git add conf/distro/linutronix.conf
+poky/meta-linutronix % git commit -sam 'add linutronix distro'
+\end{verbatim}
+\end{frame}
 
-             ...
-             DESCRIPTION = "Customized utility"
-             ...
-             EXTRA_OECONF = "--enable-something --enable-somethingelse"
+\begin{frame}[fragile]
+\frametitle{enable linutronix layer}
+\begin{verbatim}
+poky/meta-linutronix % cd ../build-fsl
+poky/build-fsl % edit conf/bblayers.conf
+\end{verbatim}
+to match
+\begin{verbatim}
+BBLAYERS ?= " \
+  /home/local/src/poky/meta \
+  /home/local/src/poky/meta-yocto \
+  /home/local/src/poky/meta-yocto-bsp \
+  /home/local/src/poky/meta-fsl-arm \
+  /home/local/src/poky/meta-fsl-arm-extra \
+  /home/local/src/poky/meta-openembedded/meta-oe \
+  /home/local/src/poky/meta-fsl-demos \
+  /home/local/src/poky/meta-linutronix \
+  "
+\end{verbatim}
+\end{frame}
 
-$ yocto-layer create mylayer
+\begin{frame}[fragile]
+\frametitle{use linutronix distro}
+edit DISTRO var in conf/local.conf
+\begin{verbatim}
+DISTRO ?= "linutronix"
+\end{verbatim}
+\end{frame}
 
 \begin{frame}
 \frametitle{adding a kernel}
@@ -315,22 +518,10 @@ already available? check http://layers.openembedded.org
 bla
 \end{frame}
 
-use PR Service
-
-Package Groups
-•Package Group Recipe
-  DESCRIPTION = “My Package Group”
-  LICENSE = “MIT”
-  LIC_FILES_CHECKSUM = “file://<licfile>;md5=<chksum>
-  inherit packagegroup
-  PROVIDES = “${PACKAGES}”
-  PACKAGES = “packagegroup-mypkg-apps packagegroup-mypkg-tools”
-  RDEPENDS_packagegroup-mypkg-apps = “sqlite3 python-core python-sqlite3”
-  RDEPENDS_pacakgegroup-mypkg-tools = “sudo gzip tar”
-•Image Recipe
-  IMAGE_INSTALL = “packagegroup-core-boot packagegroup-mypkg-apps”
-  Inherit core-image
-
+\begin{frame}
+\frametitle{use PR Service}
+bla
+\end{frame}
 
 
 \begin{frame}
-- 
cgit v1.2.3

