From e11da41853ddb36745c68adaab352fbe00bebc16 Mon Sep 17 00:00:00 2001
From: Manuel Traut <manut@linutronix.de>
Date: Wed, 18 May 2016 09:44:42 +0200
Subject: split yocto advanced training

use several tex files and include them in the presentation

Signed-off-by: Manuel Traut <manut@linutronix.de>
---
 .../yocto-advanced/yocto-sdcard-generation.tex     | 109 +++++++++++++++++++++
 1 file changed, 109 insertions(+)
 create mode 100644 distribution/yocto-advanced/yocto-sdcard-generation.tex

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

diff --git a/distribution/yocto-advanced/yocto-sdcard-generation.tex b/distribution/yocto-advanced/yocto-sdcard-generation.tex
new file mode 100644
index 0000000..a36e213
--- /dev/null
+++ b/distribution/yocto-advanced/yocto-sdcard-generation.tex
@@ -0,0 +1,109 @@
+\begin{frame}[fragile]
+\frametitle{sdcard generation \#2}
+\begin{verbatim}
+IMAGE_DEPENDS_sdcard = "parted-native:do_populate_sysroot \
+  dosfstools-native:do_populate_sysroot \
+  mtools-native:do_populate_sysroot \
+  virtual/kernel:do_deploy \
+  ${@d.getVar('IMAGE_BOOTLOADER', True) and \
+    'd.getVar('IMAGE_BOOTLOADER', True) + ':do_deploy' or ''}"
+
+SDCARD = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.sdcard"
+SDCARD_GENERATION_COMMAND_ti33x = "generate_ti_sdcard"
+\end{verbatim}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{sdcard generation \#3}
+\begin{verbatim}
+generate_ti_sdcard () {
+  parted -s ${SDCARD} mklabel msdos
+
+  parted -s ${SDCARD} unit KiB mkpart primary fat32 \
+   ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ \
+   ${BOOT_SPACE_ALIGNED})
+
+  parted -s ${SDCARD} unit KiB mkpart primary \
+   $(expr  ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) \
+   $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ \
+     $ROOTFS_SIZE)
+
+  parted -s ${SDCARD} set 1 boot on
+  parted ${SDCARD} print
+
+  BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDCARD} unit b print \
+    | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 1024 }')
+
+  mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C \
+    ${WORKDIR}/boot.img $BOOT_BLOCKS
+\end{verbatim}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{sdcard generation \#4}
+\begin{verbatim}
+  # copy files to /boot
+  mcopy -i ${WORKDIR}/boot.img -s \
+    ${DEPLOY_DIR_IMAGE}/MLO-${MACHINE} ::/MLO
+  mcopy -i ${WORKDIR}/boot.img -s \
+    ${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.img ::/u-boot.img
+  mmd -i ${WORKDIR}/boot.img  ::/boot
+  mcopy -i ${WORKDIR}/boot.img -s \
+    ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin \
+    ::/boot/${KERNEL_IMAGETYPE}
+  mcopy -i ${WORKDIR}/boot.img -s \
+    ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-am335x-boneblack.dtb \
+    ::/boot/am335x-boneblack.dtb
+  mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/uEnv.txt \
+    ::/uEnv.txt
+
+  # Burn Partition
+  dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc seek=1 \
+    bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024)
+  sync
+  dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc seek=1 \
+    bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + \
+         ${IMAGE_ROOTFS_ALIGNMENT} \* 1024)
+  sync
+}
+\end{verbatim}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{sdcard generation \#5}
+\begin{verbatim}
+IMAGE_CMD_sdcard () {
+  if [ -z "${SDCARD_ROOTFS}" ]; then
+    bberror "SDCARD_ROOTFS is undefined."
+    exit 1
+  fi
+
+  # Align boot partition and calculate total SD card image size
+  BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1)
+  BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - \
+    ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT})
+  SDCARD_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + \
+    ${BOOT_SPACE_ALIGNED} + $ROOTFS_SIZE + ${IMAGE_ROOTFS_ALIGNMENT})
+
+  # Initialize a sparse file
+  dd if=/dev/zero of=${SDCARD} bs=1 count=0 \
+    seek=$(expr 1024 \* ${SDCARD_SIZE})
+
+  ${SDCARD_GENERATION_COMMAND}
+}
+
+# The sdcard requires the rootfs filesystem to be built before using
+# it so we must make this dependency explicit.
+IMAGE_TYPEDEP_sdcard = "${@d.getVar('SDCARD_ROOTFS', 1).split('.')[-1]}"
+\end{verbatim}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{configure machine to use sdcard imagetype}
+add the following lines to 'meta-mini/conf/machine/beaglebone-black.conf':
+\begin{verbatim}
+IMAGE_CLASSES += "image_sdcard"
+SDCARD_ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3"
+IMAGE_FSTYPES += "sdcard"
+\end{verbatim}
+\end{frame}
-- 
cgit v1.2.3

