From 5d9043ce4f07dbc63a2996874e798de4a83538c2 Mon Sep 17 00:00:00 2001 From: Manuel Traut 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 --- distribution/Kconfig | 1 + distribution/yocto-example-layer/Kconfig | 5 + distribution/yocto-example-layer/Makefile | 1 + distribution/yocto-example-layer/application.tex | 64 +++++++ distribution/yocto-example-layer/base-files.tex | 184 +++++++++++++++++++++ distribution/yocto-example-layer/bootloader.tex | 35 ++++ distribution/yocto-example-layer/customization.tex | 79 +++++++++ distribution/yocto-example-layer/devtool.tex | 14 ++ distribution/yocto-example-layer/distro.tex | 147 ++++++++++++++++ distribution/yocto-example-layer/image.tex | 23 +++ distribution/yocto-example-layer/kernel.tex | 64 +++++++ distribution/yocto-example-layer/machine.tex | 49 ++++++ .../pres_yocto-example-layer.tex | 48 ++++++ distribution/yocto-example-layer/rtpreempt.tex | 86 ++++++++++ distribution/yocto-example-layer/sdcard.tex | 45 +++++ distribution/yocto-example-layer/tcf-agent.tex | 58 +++++++ .../yocto-add-autotools-based-src.tex | 18 ++ .../yocto-add-qt-cmake-projects.tex | 43 +++++ distribution/yocto-example-layer/yocto-layers.tex | 84 ++++++++++ distribution/yocto-example-layer/yocto-resume.tex | 10 ++ 20 files changed, 1058 insertions(+) create mode 100644 distribution/yocto-example-layer/Kconfig create mode 100644 distribution/yocto-example-layer/Makefile create mode 100644 distribution/yocto-example-layer/application.tex create mode 100644 distribution/yocto-example-layer/base-files.tex create mode 100644 distribution/yocto-example-layer/bootloader.tex create mode 100644 distribution/yocto-example-layer/customization.tex create mode 100644 distribution/yocto-example-layer/devtool.tex create mode 100644 distribution/yocto-example-layer/distro.tex create mode 100644 distribution/yocto-example-layer/image.tex create mode 100644 distribution/yocto-example-layer/kernel.tex create mode 100644 distribution/yocto-example-layer/machine.tex create mode 100644 distribution/yocto-example-layer/pres_yocto-example-layer.tex create mode 100644 distribution/yocto-example-layer/rtpreempt.tex create mode 100644 distribution/yocto-example-layer/sdcard.tex create mode 100644 distribution/yocto-example-layer/tcf-agent.tex create mode 100644 distribution/yocto-example-layer/yocto-add-autotools-based-src.tex create mode 100644 distribution/yocto-example-layer/yocto-add-qt-cmake-projects.tex create mode 100644 distribution/yocto-example-layer/yocto-layers.tex create mode 100644 distribution/yocto-example-layer/yocto-resume.tex (limited to 'distribution') diff --git a/distribution/Kconfig b/distribution/Kconfig index b9571e5..4e36da5 100644 --- a/distribution/Kconfig +++ b/distribution/Kconfig @@ -19,4 +19,5 @@ if YOCTO source "distribution/yocto-basic/Kconfig" source "distribution/yocto-advanced/Kconfig" source "distribution/yocto-x86/Kconfig" + source "distribution/yocto-example-layer/Kconfig" endif diff --git a/distribution/yocto-example-layer/Kconfig b/distribution/yocto-example-layer/Kconfig new file mode 100644 index 0000000..b40ebbb --- /dev/null +++ b/distribution/yocto-example-layer/Kconfig @@ -0,0 +1,5 @@ +config YOCTO_EXAMPLE + bool "Yocto Example Layer" + default y + help + Building an ARM BSP Image and customize it with an RT Kernel diff --git a/distribution/yocto-example-layer/Makefile b/distribution/yocto-example-layer/Makefile new file mode 100644 index 0000000..4bfe915 --- /dev/null +++ b/distribution/yocto-example-layer/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_YOCTO_EXAMPLE) = pres_yocto-example-layer.pdf diff --git a/distribution/yocto-example-layer/application.tex b/distribution/yocto-example-layer/application.tex new file mode 100644 index 0000000..801a645 --- /dev/null +++ b/distribution/yocto-example-layer/application.tex @@ -0,0 +1,64 @@ +\subsection{Applications} +\begin{frame} +\frametitle{Adding own applications} +\begin{itemize} +\item Recipe already available? check http://layers.openembedded.org +\item Look for a similar recipe +\item Proper bbclass available? +\end{itemize} +On the next slides, we have a look what is useful for very simple applications, +autotools and Cmake based projects and QT applications. +\end{frame} + +\begin{frame}[fragile] +\frametitle{Simple (overview)} +file layout +\begin{verbatim} +example +├── files +│   └── example.c +└── example_0.1.bb +\end{verbatim} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Simple (add source)} +\begin{lstlisting} +$ cd ~/poky/meta-schulung +$ mkdir -p recipes-example/example/files +$ pluma recipes-example/example/files/example.c +\end{lstlisting} +\begin{verbatim} +#include +int main(int argc, char **argv) { + printf("Hello, world!\n"); + return 0; +} +\end{verbatim} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Simple (add recipe)} +\begin{lstlisting} +$ cd ~/poky/meta-schulung +$ pluma recipes-example/example/example_0.1.bb +\end{lstlisting} +\begin{verbatim} +DESCRIPTION = "Simple Example" +LICENSE = "CLOSED" + +SRC_URI = "file://example.c" + +do_compile() { + $CC $CFLAGS -o example ${WORKDIR}/example.c $LDFLAGS +} + +do_install() { + install -D -m 0755 example ${D}${base_bindir}/example +} +\end{verbatim} +\begin{lstlisting} +$ cd ~/poky/build-schulung +$ bitbake example +\end{lstlisting} +\end{frame} 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} diff --git a/distribution/yocto-example-layer/bootloader.tex b/distribution/yocto-example-layer/bootloader.tex new file mode 100644 index 0000000..1a4c6a5 --- /dev/null +++ b/distribution/yocto-example-layer/bootloader.tex @@ -0,0 +1,35 @@ +\subsection{Bootloader} + +\begin{frame}[fragile] +\frametitle{Configure and add u-boot} +\begin{lstlisting} +$ cd ~/poky/meta-schulung +$ pluma conf/machine/vexpress.conf +\end{lstlisting} +\begin{verbatim} +DEFAULTTUNE ?= "armv7athf-neon" +require conf/machine/include/tune-cortexa8.inc +SERIAL_CONSOLE = "115200 ttyAMA0" +PREFERRED_PROVIDER_virtual/kernel = "linux-vanilla" +UBOOT_MACHINE = "vexpress_ca9x4_defconfig" +IMAGE_FSTYPES = "wic" +\end{verbatim} +\begin{lstlisting} +$ pluma recipes-core/images/core-image-schulung.bb +\end{lstlisting} +\begin{verbatim} +[..] +CORE_IMAGE_BASE_INSTALL = " \ + u-boot \ + schulung-base \ + kernel-modules \ + example \ + ${@bb.utils.contains('SCHULUNG_FEATURES', 'devel','${DEVPKGS}','',d)} \ +" +[..] +\end{verbatim} +\begin{lstlisting} +$ cd ~/poky/build-schulung +$ bitbake core-image-schulung +\end{lstlisting} +\end{frame} diff --git a/distribution/yocto-example-layer/customization.tex b/distribution/yocto-example-layer/customization.tex new file mode 100644 index 0000000..0cd7969 --- /dev/null +++ b/distribution/yocto-example-layer/customization.tex @@ -0,0 +1,79 @@ +\subsection{Image customizations} +\begin{frame}[fragile] +\frametitle{Adding a bootscript} +\begin{itemize} +\item Add 'systemd' to DISTRO\_FEATURES +\item Inherit from systemd.bbclass +\item Your package needs to set SYSTEMD\_SERVICE variable; e.g. +\begin{verbatim} +SYSTEMD_SERVICE_${PN} = "connman.service" +\end{verbatim} +\item To disable the service, set SYSTEMD\_AUTO\_ENABLE to 'disable' +\end{itemize} +\end{frame} + +\begin{frame}[fragile] +\frametitle{User and group configuration} +Use this in an image recipe: +\begin{verbatim} +inherit extrausers +EXTRA_USERS_PARAMS = "\ + useradd -p '' tester; \ + groupadd developers; \ + userdel nobody; \ + groupdel -g video; \ + groupmod -g 1020 developers; \ + usermod -s /bin/sh tester; \ + " +\end{verbatim} +Or the useradd class for creating a user if a package is installed. +For an example see useradd-example.bb +\end{frame} + +\begin{frame}[fragile] +\frametitle{External sources} +E.g. for a heavily customized kernel +\begin{itemize} +\item Kernel source directory on the development machine +\item Inherit externalsrc class +\item Set EXTERNALSRC variable to point to your external source code +\end{itemize} + +This local.conf extension: +\begin{verbatim} +INHERIT += "externalsrc" +EXTERNALSRC_pn-myrecipe = "/some/path/to/your/source/tree" +\end{verbatim} +overrides the SOURCE\_URI of pn-myrecipe.bb +\end{frame} + +\begin{frame}[fragile] +\frametitle{Blacklist packages} +To blacklist a package, inherit the blacklist.bbclass globally and set +PNBLACKLIST for each recipe you wish to blacklist. + + +Specify the PN value as a variable flag (varflag) and provide a reason, +which is reported, if the package is requested to be built as the value: +\begin{verbatim} +INHERIT += "blacklist" +PNBLACKLIST[exoticware] = "Not supported by our organization." +\end{verbatim} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Override oe-init-buildenv templates} +Default templates can be overridden by setting TEMPLATECONF +to e.g. meta-foo/conf during ./oe-init-buildenv. + +Then meta-foo/conf bblayers.conf.sample and local.conf.sample will +be used. + +The default location is specified in + +\begin{verbatim} +% cat .templateconf +# Template settings +TEMPLATECONF=${TEMPLATECONF:-meta-yocto/conf} +\end{verbatim} +\end{frame} diff --git a/distribution/yocto-example-layer/devtool.tex b/distribution/yocto-example-layer/devtool.tex new file mode 100644 index 0000000..57e65ad --- /dev/null +++ b/distribution/yocto-example-layer/devtool.tex @@ -0,0 +1,14 @@ +\subsection{Devtool} + +\begin{frame}[fragile] +\frametitle{Integrate sw with devtool} +Generate bitbake recipe for existing source +\begin{verbatim} +devtool add ~/mysrc +devtool edit-recipe mysrc +devtool build mysrc +devtool build-image core-image-minimal +\end{verbatim} +Howto continue: Review conf/bblayers.conf and local.conf, replace EXTERNALSRC by +setting up a valid SRC\_URI and integrate recipe into an existing layer. +\end{frame} diff --git a/distribution/yocto-example-layer/distro.tex b/distribution/yocto-example-layer/distro.tex new file mode 100644 index 0000000..8861c1b --- /dev/null +++ b/distribution/yocto-example-layer/distro.tex @@ -0,0 +1,147 @@ +\subsection{Define a distribution} +\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} + +\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} + +\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} + +\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} + +\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} + +\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} + +\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} + +\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} + +\begin{frame}[fragile] +\frametitle{Yocto with local mirror} +\begin{description} +\item [PREMIRRORS] list of mirrors that are tried before SRC\_URI +\item [MIRRORS] list of mirrors that are tried after SRC\_URI +\item [BB\_FETCH\_PREMIRRORONLY = "1"] only use sources from PREMIRRORS +\item [BB\_NO\_NETWORK = "1"] throws error instead of accessing internet +\end{description} +typical in local.conf to generate the mirror: +\begin{description} +\item [BB\_GENERATE\_MIRROR\_TARBALLS = "1"] generates a tarball that can be + used as mirror +\end{description} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Define an own distribution} +\begin{lstlisting} +$ cd ~/poky/meta-schulung +$ mkdir conf/distro +$ pluma conf/distro/schulung.conf +\end{lstlisting} +\begin{verbatim} +require conf/distro/poky.conf +DISTRO = "schulung" +DISTRO_NAME = "Schulung (Yocto Schulung Example Distro)" +DISTRO_VERSION = "1.0" +DISTRO_CODENAME = "pengin" +MAINTAINER = "Your Name " +SDK_VENDOR = "-schulungsdk" +TARGET_VENDOR = "-schulung" +DISTROOVERRIDES = "schulung:poky" +\end{verbatim} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Use own distribution} +\begin{lstlisting} +$ cd ~/poky/build-schulung +$ pluma conf/local.conf +\end{lstlisting} +\begin{verbatim} +#STATE_DIR ?= "/home/prebuilt/qemuarm/sstate-cache" +#BB_NO_NETWORK = "1" +MACHINE ??= "qemuarm" +DL_DIR ?= "/home/downloads" +DISTRO ?= "schulung" +PACKAGE_CLASSES ?= "package_ipk" +EXTRA_IMAGE_FEATURES ?= "debug-tweaks" +USER_CLASSES ?= "buildstats image-mklibs image-prelink" +PATCHRESOLVE = "noop" +CONF_VERSION = "1" +\end{verbatim} +\begin{lstlisting} +$ bitbake core-image-minimal +\end{lstlisting} +\end{frame} diff --git a/distribution/yocto-example-layer/image.tex b/distribution/yocto-example-layer/image.tex new file mode 100644 index 0000000..071519d --- /dev/null +++ b/distribution/yocto-example-layer/image.tex @@ -0,0 +1,23 @@ +\subsection{Creating images} +\begin{frame}[fragile] +\frametitle{Based on core-image class} +\begin{lstlisting} +$ cd ~/poky/meta-schulung +$ mkdir -p recipes-core/images +$ 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 = "" +IMAGE_INSTALL = "example" +\end{verbatim} +\begin{lstlisting} +$ cd ~/poky/build-schulung +$ bitbake core-image-schulung +\end{lstlisting} +\end{frame} diff --git a/distribution/yocto-example-layer/kernel.tex b/distribution/yocto-example-layer/kernel.tex new file mode 100644 index 0000000..336a6f3 --- /dev/null +++ b/distribution/yocto-example-layer/kernel.tex @@ -0,0 +1,64 @@ +\subsection{Add own kernel} +\begin{frame} +\frametitle{Workflow} +\begin{itemize} +\item Configure and build kernel without yocto +\item Extract Kernel configuration and source/patches +\item Integrate source, config and patches into yocto +\end{itemize} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Kernel configuration} +\begin{lstlisting} +$ cd ~ +$ git clone linux.git +$ cd linux +$ git checkout -b linux-4.19.1 v4.19.1 +$ git archive --format=tar.gz \ + --prefix=linux-4.19.1/ \ + -o ../linux-4.19.1.tar.gz HEAD +$ ARCH=arm make vexpress_defconfig +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Add a kernel recipe} +\begin{lstlisting} +$ cd ~/poky/meta-schulung +$ mkdir -p recipes-bsp/linux-vanilla/files/vexpress +$ mv ~/linux-4.19.1.tar.gz recipes-bsp/linux-vanilla/files +$ cp ~/linux/.config recipes-bsp/linux-vanilla/files/vexpress/defconfig +$ pluma recipes-bsp/linux-vanilla/linux-vanilla_4.19.1.bb +\end{lstlisting} +\begin{verbatim} +SECTION = "kernel" +DESCRIPTION = "Linux vanilla kernel" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=bbea815ee2795b2f4230826c0c6b8814" +inherit kernel +COMPATIBLE_MACHINE_vexpress = "vexpress" +KERNEL_DEVICETREE_vexpress = "vexpress-v2p-ca9.dtb" +SRC_URI = "file://linux-${PV}.tar.gz file://defconfig" +S = "${WORKDIR}/linux-${PV}" +\end{verbatim} +\end{frame} + + +\begin{frame}[fragile] +\frametitle{Use own kernel recipe} +\begin{lstlisting} +$ cd ~/poky/meta-schulung +$ pluma conf/machine/vexpress.conf +\end{lstlisting} +\begin{verbatim} +DEFAULTTUNE ?= "armv7athf-neon" +require conf/machine/include/tune-cortexa8.inc +SERIAL_CONSOLE = "115200 ttyAMA0" +PREFERRED_PROVIDER_virtual/kernel = "linux-vanilla" +\end{verbatim} +\begin{lstlisting} +$ cd ~/poky/build-schulung +$ bitbake core-image-schulung +\end{lstlisting} +\end{frame} diff --git a/distribution/yocto-example-layer/machine.tex b/distribution/yocto-example-layer/machine.tex new file mode 100644 index 0000000..a8e0ba9 --- /dev/null +++ b/distribution/yocto-example-layer/machine.tex @@ -0,0 +1,49 @@ +\subsection{Machines} +\begin{frame}[fragile] +\frametitle{machine configs aka BSP} +to get a list of currently available machine configs: +\begin{lstlisting} +$ cd ~/poky +$ ls meta*/conf/machine/*.conf +\end{lstlisting} +If no machine fits your needs, search at 'http://layers.openembedded.org' or +define your own! +\end{frame} + +\begin{frame}[fragile] +\frametitle{Create a vexpress machine config} +\begin{lstlisting} +$ cd ~/poky/meta-schulung +$ mkdir conf/machine +$ pluma conf/machine/vexpress.conf +\end{lstlisting} +\begin{verbatim} +DEFAULTTUNE ?= "armv7athf-neon" +require conf/machine/include/tune-cortexa8.inc +SERIAL_CONSOLE = "115200 ttyAMA0" +\end{verbatim} +\end{frame} + + +\begin{frame}[fragile] +\frametitle{Use the vexpress BSP in the build} +\begin{lstlisting} +$ cd ~/poky/build-schulung +$ pluma conf/local.conf +\end{lstlisting} +\begin{verbatim} +#STATE_DIR ?= "/home/prebuilt/vexpress/sstate-cache" +#BB_NO_NETWORK = "1" +MACHINE ??= "vexpress" +DL_DIR ?= "/home/downloads" +DISTRO ?= "schulung" +PACKAGE_CLASSES ?= "package_ipk" +EXTRA_IMAGE_FEATURES ?= "debug-tweaks" +USER_CLASSES ?= "buildstats image-mklibs image-prelink" +PATCHRESOLVE = "noop" +CONF_VERSION = "1" +\end{verbatim} +\begin{lstlisting} +$ bitbake core-image-minimal +\end{lstlisting} +\end{frame} diff --git a/distribution/yocto-example-layer/pres_yocto-example-layer.tex b/distribution/yocto-example-layer/pres_yocto-example-layer.tex new file mode 100644 index 0000000..ac85c48 --- /dev/null +++ b/distribution/yocto-example-layer/pres_yocto-example-layer.tex @@ -0,0 +1,48 @@ +\input{configpres} + +\title{YOCTO - Advanced Example Layer} +\date{} +\maketitle + +\begin{frame} +\frametitle{Agenda 1/2} +\begin{itemize} +\item Own Layer +\item Distribution +\item BSP +\item Application Integration +\item Minimal Image +\item Kernel +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{Agenda 2/2} +\begin{itemize} +\item SDCard Image +\item Busybox Image +\item Remote Debugging Support +\item Bootloader +\item Add PREEMPT\_RT\_PATCH +\item Image customizations +\item Devtool +\end{itemize} +\end{frame} + +\input{yocto-layers} +\input{distro} +\input{machine} +\input{application} +\input{yocto-add-autotools-based-src} +\input{yocto-add-qt-cmake-projects} +\input{image} +\input{kernel} +\input{sdcard} +\input{base-files} +\input{tcf-agent} +\input{bootloader} +\input{rtpreempt} +\input{customization} +\input{devtool} +\input{yocto-resume} +\input{tailpres} diff --git a/distribution/yocto-example-layer/rtpreempt.tex b/distribution/yocto-example-layer/rtpreempt.tex new file mode 100644 index 0000000..037ca58 --- /dev/null +++ b/distribution/yocto-example-layer/rtpreempt.tex @@ -0,0 +1,86 @@ +\subsection{Add RT PREEMPT Linux kernel patch} + +\begin{frame}[fragile] +\frametitle{Define an 'rt' override} +\begin{lstlisting} +$ cd ~/poky/meta-schulung +$ pluma conf/machine/vexpress.conf +\end{lstlisting} +\begin{verbatim} +DEFAULTTUNE ?= "armv7athf-neon" +require conf/machine/include/tune-cortexa8.inc +SERIAL_CONSOLE = "115200 ttyAMA0" +PREFERRED_PROVIDER_virtual/kernel = "linux-vanilla" +UBOOT_MACHINE = "vexpress_ca9x4_defconfig" +IMAGE_FSTYPES = "wic" +MACHINEOVERRIDES .= ":rt" +\end{verbatim} +NOTE: this could also be done e.g. in distro/schulung.conf within +DISTROOVERRIDES. +\end{frame} + +\begin{frame}[fragile] +\frametitle{Add patch to kernel recipe} +\begin{lstlisting} +$ cd ~/poky/meta-schulung +$ pluma recipes-bsp/linux-vanilla/linux-vanilla-4.19.1.bb +\end{lstlisting} +\begin{verbatim} +SECTION = "kernel" +DESCRIPTION = "Linux vanilla kernel" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=bbea815ee2795b2f4230826c0c6b8814" + +inherit kernel + +COMPATIBLE_MACHINE_vexpress = "vexpress" +KERNEL_DEVICETREE_vexpress = "vexpress-v2p-ca9.dtb" +SRC_URI = "file://linux-${PV}.tar.gz file://defconfig" + +RTPATH = "pub/linux/kernel/projects/rt" +SRC_URI_rt := "${SRC_URI} \ + https://kernel.org/${RTPATH}/4.19/patch-4.19.1-rt3.patch.gz;name=rt" + +SRC_URI[rt.md5sum] = "ce96db835c310c195dd0f0046b2ea993" +SRC_URI[rt.sha256sum] = "649334844cfa427b08dc72debb1d5e672a3dcafc64089770fcdfa06dcc433e31" + +S = "${WORKDIR}/linux-${PV}" +\end{verbatim} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Enable full preemption} +\begin{lstlisting} +$ cd ~/poky/build-schulung +$ bitbake -c menuconfig linux-vanilla +\end{lstlisting} +select from the menu: +\begin{verbatim} + | 'General Setup + | 'Preemption Model'('Fully Preemtpible Kernel (RT)') +\end{verbatim} +Exit and save changes +\begin{lstlisting} +$ bitbake -c diffconfig linux-vanilla +$ mv tmp/work/vexpress-schulung-*/linux-vanilla/*/fragment.cfg \ + ../meta-schulung/recipes-bsp/linux-vanilla/files/rt.cfg +$ cd ~/poky/meta-schulung +$ pluma recipes-bsp/linux-vanilla/linux-vanilla-4.19.1.bb +\end{lstlisting} +\begin{verbatim} +[..] +SRC_URI_rt := "${SRC_URI} \ + https://kernel.org/${RTPATH}/4.19/patch-4.19.1-rt3.patch.gz;name=rt \ + file://rt.cfg \ +[..] +" +\end{verbatim} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Rebuild image} +\begin{lstlisting} +$ cd ~/poky/build-schulung +$ bitbake core-image-schulung +\end{lstlisting} +\end{frame} diff --git a/distribution/yocto-example-layer/sdcard.tex b/distribution/yocto-example-layer/sdcard.tex new file mode 100644 index 0000000..01ac667 --- /dev/null +++ b/distribution/yocto-example-layer/sdcard.tex @@ -0,0 +1,45 @@ +\subsection{Creating SDCard images} + +\begin{frame}[fragile] +\frametitle{using wic} +\begin{lstlisting} +$ cd ~/poky/meta-schulung +$ mkdir -p scripts/lib/wic/canned-wks +$ pluma scripts/lib/wic/canned-wks/core-image-schulung.vexpress.wks +\end{lstlisting} +\begin{verbatim} +part / --source rootfs --fstype=ext2 --label rootfs \ + --ondisk mmc --align 1024 --use-uuid +\end{verbatim} +\begin{lstlisting} +$ pluma conf/machine/vexpress.conf +\end{lstlisting} +\begin{verbatim} +DEFAULTTUNE ?= "armv7athf-neon" +require conf/machine/include/tune-cortexa8.inc +SERIAL_CONSOLE = "115200 ttyAMA0" +PREFERRED_PROVIDER_virtual/kernel = "linux-vanilla" +IMAGE_FSTYPES = "wic" +\end{verbatim} +\begin{lstlisting} +$ cd ~/poky/build-schulung +$ bitbake core-image-schulung +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Run SDCard Image in qemu} +\begin{lstlisting} +$ cd ~/poky/build-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 init=/bin/example" +\end{lstlisting} +Qemu can be quit by pressing 'ctrl-a x' +\end{frame} diff --git a/distribution/yocto-example-layer/tcf-agent.tex b/distribution/yocto-example-layer/tcf-agent.tex new file mode 100644 index 0000000..a70b506 --- /dev/null +++ b/distribution/yocto-example-layer/tcf-agent.tex @@ -0,0 +1,58 @@ +\subsection{Remote Debugging} +\begin{frame} +\frametitle{Workflow} +\begin{itemize} +\item Introduce 'SCHULUNG\_FEATURES' variable +\item Check feature variable in image recipe +\item Use debugging tools from poky layer +\end{itemize} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Extend image recipe} +\begin{lstlisting} +$ cd ~/poky/meta-schulung +$ pluma recipes-core/image/core-image-schulung.bb +\end{lstlisting} +\begin{verbatim} +[..] +DEVPKGS = "gdbserver tcf-agent procps strace" +CORE_IMAGE_BASE_INSTALL = " \ + schulung-base \ + kernel-modules \ + example \ + ${@bb.utils.contains('SCHULUNG_FEATURES','devel','${DEVPKGS}','', d)} \ +" +[..] +\end{verbatim} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Define SCHULUNG\_FEATURES and rebuild image} +\begin{lstlisting} +$ cd ~/poky/build-schulung +$ pluma conf/local.conf +\end{lstlisting} +\begin{verbatim} +#STATE_DIR ?= "/home/prebuilt/vexpress/sstate-cache" +#BB_NO_NETWORK = "1" +MACHINE ??= "vexpress" +DL_DIR ?= "/home/downloads" +DISTRO ?= "schulung" +PACKAGE_CLASSES ?= "package_ipk" +EXTRA_IMAGE_FEATURES ?= "debug-tweaks" +SCHULUNG_FEATURES = "devel" +USER_CLASSES ?= "buildstats image-mklibs image-prelink" +PATCHRESOLVE = "noop" +CONF_VERSION = "1" +\end{verbatim} +\begin{lstlisting} +$ bitbake core-image-schulung +$ bitbake -c populate_sdk core-image-schulung +\end{lstlisting} +If image is started in qemu tcf-agent needs to be started manually: +\begin{lstlisting} +Please press Enter to activate this console. +/ # /etc/init.d/tcf-agent start +\end{lstlisting} +\end{frame} diff --git a/distribution/yocto-example-layer/yocto-add-autotools-based-src.tex b/distribution/yocto-example-layer/yocto-add-autotools-based-src.tex new file mode 100644 index 0000000..3cc0767 --- /dev/null +++ b/distribution/yocto-example-layer/yocto-add-autotools-based-src.tex @@ -0,0 +1,18 @@ +\begin{frame}[fragile] +\frametitle{Autools based project} +\begin{verbatim} +├── autohello_1.0.bb +└── files + └── autohello-1.0.tar.gz +\end{verbatim} +\begin{verbatim} +DESCRIPTION = "GNU Helloworld application" +SECTION = "examples" +LICENSE = "GPLv2+" +LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504" +PR = "r0" +SRC_URI = "file://${PN}-${PV}.tar.gz" +SRC_URI[md5sum] = "4bfc9bed4d5d67a266d93e99e5883211" +inherit autotools +\end{verbatim} +\end{frame} diff --git a/distribution/yocto-example-layer/yocto-add-qt-cmake-projects.tex b/distribution/yocto-example-layer/yocto-add-qt-cmake-projects.tex new file mode 100644 index 0000000..e1a0176 --- /dev/null +++ b/distribution/yocto-example-layer/yocto-add-qt-cmake-projects.tex @@ -0,0 +1,43 @@ +\begin{frame}[fragile] +\frametitle{Cmake based project} +\begin{verbatim} +. +├── files +│   └── hellocm-0.1.tar.bz2 +└── hellocm_0.1.bb +\end{verbatim} +\begin{verbatim} +DESCRIPTION = "hellocm cmake example" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" +SECTION = "examples" +SRC_URI = "file://${PN}-${PV}.tar.bz2" +inherit cmake + +#export EXTRA_OECMAKE = '-DBLUBB="bla" + +FILES_{PN} = "${bindir}/hellocm" +\end{verbatim} +\end{frame} + +\begin{frame}[fragile] +\frametitle{QT application} +\begin{verbatim} +├── files +│   └── helloqt-1.0.tar.bz2 +└── helloqt_1.0.bb +\end{verbatim} +\begin{verbatim} +DESCRIPTION = "helloqt QT example" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" +SECTION = "examples" +SRC_URI = "file://${PN}-${PV}.tar.bz2" +inherit qt4e +PR = "r4" +do_install() { + install -d ${D}${bindir} + install -m 0755 helloqt ${D}${bindir} +} +\end{verbatim} +\end{frame} diff --git a/distribution/yocto-example-layer/yocto-layers.tex b/distribution/yocto-example-layer/yocto-layers.tex new file mode 100644 index 0000000..a9eebb6 --- /dev/null +++ b/distribution/yocto-example-layer/yocto-layers.tex @@ -0,0 +1,84 @@ +\subsection{Yocto Layers} + +\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}[fragile] +\frametitle{Create and use own layer} +\begin{lstlisting} +$ cd ~/poky +$ . ./oe-init-build-env build-schulung +$ cd .. +$ bitbake-layers create-layer -p 10 meta-schulung +NOTE: Starting bitbake server... +Add your new layer with 'bitbake-layers add-layer meta-schulung' +$ cd build-schulung +$ bitbake-layers add-layer ../meta-schulung +NOTE: Starting bitbake server... +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Folder layout} +\begin{verbatim} +meta-schulung ++ conf +| + layer.conf ++ classes +| + class1.bbclass +| + class2.bbclass ++ recipes-category1 +| + package-1 +| + package-1.bb +| + package-2 +| + package-2.bb ++ recipes-category2 +| .. +\end{verbatim} +\end{frame} + +\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} +\item add recipe directories to BBFILES +\begin{verbatim}BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ + ${LAYERDIR}/recipes-*/*/*.bbappend"\end{verbatim} +\item add layer name to BBFILE\_COLLECTIONS +\begin{verbatim}BBFILE_COLLECTIONS += "mylayer"\end{verbatim} +\item set root of the layer +\begin{verbatim}BBFILE_PATTERN_mylayer = "^${LAYERDIR}/"\end{verbatim} +\item set default priority of the layer +\begin{verbatim}BBFILE_PRIORITY_mylayer = "5"\end{verbatim} +\item set version of layer (only increment if dependencies with other + layers are affected) +\begin{verbatim}LAYERVERSION_mylayer = "2"\end{verbatim} +\item set dependencies to other layers +\begin{verbatim}LAYERDEPENDS_mylayer = "meta-yocto"\end{verbatim} +\end{itemize} +\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} diff --git a/distribution/yocto-example-layer/yocto-resume.tex b/distribution/yocto-example-layer/yocto-resume.tex new file mode 100644 index 0000000..3be1e43 --- /dev/null +++ b/distribution/yocto-example-layer/yocto-resume.tex @@ -0,0 +1,10 @@ +\subsection{Resume} +\begin{frame} +\begin{itemize} +\item Yocto is a huge collection of tools +\item Bitbake can be used to describe/build a distribution +\item The quality of the Images depend on the maintainance of the Layers +\item Only build your own distribution if you really need to! +\item Poky can be used as an example / reference. +\end{itemize} +\end{frame} -- cgit v1.2.3