From 5d9043ce4f07dbc63a2996874e798de4a83538c2 Mon Sep 17 00:00:00 2001
From: Manuel Traut <manut@linutronix.de>
Date: Tue, 27 Nov 2018 22:57:33 +0100
Subject: add 'yocto-layer-example'

This is a first attemp to create a new slideset for day2 of yocto-trainig.

The slideset is based on 'yocto-advanced' but with integration of
'meta-schulung' explanations.

I used a slightly modified version of 'meta-schulung'. The following changes
are currently not available in git:

I don't use linux-yocto in meta-schulung, but use an own kernel-recipe and
integrate the RT-PREEMPT patch.

wic: i can't see the need for the second partition and the need for huge files
in the kconfig. It works for me by adding ' --align 1024 ' to the wic setup.
I decided to use ext2 instead of ext4.

I renamed the rootfs.bb file into schulung-base.bb

I use the u-boot recipe from poky. However i don't use u-boot for anything atm.
  But bootloader is on our agenda..

Signed-off-by: Manuel Traut <manut@linutronix.de>
---
 distribution/yocto-example-layer/base-files.tex | 184 ++++++++++++++++++++++++
 1 file changed, 184 insertions(+)
 create mode 100644 distribution/yocto-example-layer/base-files.tex

(limited to 'distribution/yocto-example-layer/base-files.tex')

diff --git a/distribution/yocto-example-layer/base-files.tex b/distribution/yocto-example-layer/base-files.tex
new file mode 100644
index 0000000..ee17aaf
--- /dev/null
+++ b/distribution/yocto-example-layer/base-files.tex
@@ -0,0 +1,184 @@
+\subsection{Add base-files/busybox}
+\begin{frame}
+\frametitle{Workflow}
+\begin{itemize}
+\item busybox provides common commands, init and sh
+\item symlinks need to be created
+\item inittab and rcS needs to be provided
+\end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Add a busybox recipe}
+\begin{lstlisting}
+$ cd ~/poky/meta-schulung
+$ mkdir -p recipes-core/busybox
+$ pluma recipes-core/busybox/busybox_1.29.3.bb
+\end{lstlisting}
+\begin{verbatim}
+LICENSE = "GPLv2 & bzip2"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=de10de48642ab74318e893a61105afbb"
+
+SRC_URI = "http://www.busybox.net/downloads/${P}.tar.bz2;name=upstream"
+SRC_URI[upstream.md5sum] = "0a367e19cdfd157e8258d87f893ee516"
+SRC_URI[upstream.sha256sum] =
+"97648636e579462296478e0218e65e4bc1e9cd69089a3b1aeb810bff7621efb7"
+
+DEPENDS += "virtual/crypt"
+EXTRA_OEMAKE += "CROSS_COMPILE=${TARGET_PREFIX}"
+EXTRA_OEMAKE += "CONFIG_SYSROOT=${PKG_CONFIG_SYSROOT_DIR}"
+EXTRA_OEMAKE += "V=1"
+
+FILES_${PN}-dev += " ${datadir}/busybox/busybox.links"
+\end{verbatim}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Add a busybox recipe \#2}
+\begin{verbatim}
+do_configure() {
+    oe_runmake defconfig
+}
+
+do_compile() {
+    export CFLAGS="${TARGET_CC_ARCH} $CFLAGS"
+    oe_runmake busybox_unstripped
+    oe_runmake busybox.links
+}
+
+do_install() {
+    test "${prefix}" != "/usr" && \
+        sed -i -e "s:^/usr/:DONE${prefix}/:" busybox.links
+    test "${base_sbindir}" != "/sbin" && \
+        sed -i -e "s:^/sbin/:DONE${base_sbindir}/:" busybox.links
+    test "${base_bindir}" != "/bin" && \
+        sed -i -e "s:^/bin/:DONE${base_bindir}/:" busybox.links
+    sed -i -e "s:^DONE::" busybox.links
+
+    install -D -m 0755 busybox_unstripped ${D}${base_bindir}/busybox
+    install -D -m 0644 busybox.links ${D}${datadir}/busybox/busybox.links
+}
+\end{verbatim}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Add inittab}
+\begin{lstlisting}
+$ cd ~/poky/meta-schulung
+$ mkdir -p recipes-core/rootfs/files
+$ pluma recipes-core/rootfs/files/busybox_inittab
+\end{lstlisting}
+\begin{verbatim}
+::sysinit:/etc/rcS
+::askfirst:-/bin/sh
+::restart:/sbin/init
+::ctrlaltdel:/sbin/reboot
+::shutdown:/bin/umount -a -r
+\end{verbatim}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Add startscript}
+\begin{lstlisting}
+$ cd ~/poky/meta-schulung
+$ pluma recipes-core/rootfs/files/rcS
+\end{lstlisting}
+\begin{verbatim}
+#!/bin/sh
+
+mount -t proc proc /proc
+mount -t sysfs sys /sys
+mount -t tmpfs tmpfs /dev
+mount -t tmpfs tmpfs /run
+
+mdev -s
+echo /sbin/mdev > /proc/sys/kernel/hotplug
+
+mkdir -p /dev/pts
+mount -t devpts devpts /dev/pts
+mkdir -p /run/lock/subsys
+\end{verbatim}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Add base-files recipe}
+\begin{lstlisting}
+$ cd ~/poky/meta-schulung
+$ pluma recipes-core/rootfs/schulung-base.bb
+\end{lstlisting}
+\begin{verbatim}
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+RDEPENDS_${PN} = "busybox"
+
+SRC_URI = "file://busybox_inittab file://rcS"
+
+do_install() {
+  install -D -m 0755 ${WORKDIR}/rcS ${D}${sysconfdir}/rcS
+  install -D -m 0644 ${WORKDIR}/busybox_inittab ${D}${sysconfdir}/inittab
+  install -d ${D}/run
+  install -d ${D}/tmp
+  install -d ${D}/dev
+  install -d ${D}/proc
+  install -d ${D}/sys
+}
+
+FILES_${PN} += "/run /tmp /dev /proc /sys"
+\end{verbatim}
+\end{frame}
+
+
+\begin{frame}[fragile]
+\frametitle{Use base-files recipe in image}
+\begin{lstlisting}
+$ cd ~/poky/meta-schulung
+$ pluma recipes-core/images/core-image-schulung.bb
+\end{lstlisting}
+\begin{verbatim}
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+inherit core-image
+
+IMAGE_LINGUAS = ""
+CORE_IMAGE_BASE_INSTALL = " \
+                           schulung-base \
+                           kernel-modules \
+                           example \
+                          "
+DEPENDS += "busybox"
+
+setup_busybox_links() {
+    LINKS="${PKG_CONFIG_SYSROOT_DIR}${datadir}/busybox/busybox.links"
+    for lnfile in `cat $LINKS`; do
+        test $lnfile = /linuxrc && continue
+        install -d ${IMAGE_ROOTFS}`dirname $lnfile`
+        ln -s ${base_bindir}/busybox ${IMAGE_ROOTFS}$lnfile || true
+    done
+}
+do_rootfs[postfuncs] += "setup_busybox_links"
+\end{verbatim}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Build and run image}
+\begin{lstlisting}
+$ cd ~/poky/build-schulung
+$ bitbake core-image-schulung
+$ ./tmp/sysroots-components/x86_64/qemu-native/usr/bin/qemu-system-arm \
+    -M vexpress-a9 -nographic \
+    -net nic -net user,hostfwd=tcp::1534-:1534,hostfwd=tcp::2345-:2345 \
+    -drive if=sd,format=raw,\
+file=tmp/deploy/images/vexpress/core-image-schulung-vexpress.wic \
+    -dtb    tmp/deploy/images/vexpress/vexpress-v2p-ca9.dtb \
+    -kernel tmp/deploy/images/vexpress/zImage \
+    -append "console=ttyAMA0,115200 root=/dev/mmcblk0p1 rw ip=dhcp"
+[..]
+Please press Enter to activate this console.
+/ # df -h
+Filesystem                Size      Used Available Use% Mounted on
+/dev/root                81.9M      8.4M     69.3M  11% /
+[..]
+\end{lstlisting}
+\end{frame}
-- 
cgit v1.2.3

