# [bootlin/training-materials updates] master: Remove obsolete boot time labs (87cc20ff)

Michael Opdenacker michael.opdenacker at bootlin.com
Thu May 16 14:17:19 CEST 2019

Repository : https://github.com/bootlin/training-materials
On branch  : master

>---------------------------------------------------------------

commit 87cc20ffbaa23a9f8753231f852348fd15dd7d4a
Author: Michael Opdenacker <michael.opdenacker at bootlin.com>
Date:   Wed May 15 15:04:40 2019 +0200

Remove obsolete boot time labs

Signed-off-by: Michael Opdenacker <michael.opdenacker at bootlin.com>

>---------------------------------------------------------------

87cc20ffbaa23a9f8753231f852348fd15dd7d4a
labs/boottime-install/boottime-install.tex     | 167 -------------
labs/boottime-install/usbdisk-filled.png       | Bin 45232 -> 0 bytes
labs/boottime-install/usbdisk-formated.png     | Bin 37135 -> 0 bytes
labs/boottime-measuring/boottime-measuring.tex | 334 -------------------------
labs/boottime-measuring/videoplayer.dia        | Bin 2322 -> 0 bytes
mk/boot-time.mk                                |   5 +-
6 files changed, 2 insertions(+), 504 deletions(-)

diff --git a/labs/boottime-install/boottime-install.tex b/labs/boottime-install/boottime-install.tex
deleted file mode 100644
index 4625da0a..00000000
--- a/labs/boottime-install/boottime-install.tex
+++ /dev/null
@@ -1,167 +0,0 @@
-\subchapter{Preparing hardware}{Preparing a PC and a USB drive before
-the workshop}.
-
-Make sure the prerequisites are met before the workshop. Make sure you
-do not follow the below instructions on the morning the workshop starts,
-as these preparation steps can take up to several hours, depending
-on the speed of your Internet connection.
-
-Here is the required hardware:
-\begin{itemize}
-\item Microchip SAMA5D3x evaluation kit
-\item 5V power adaptor for the kit
-\item At least one USB-A (male) to micro-USB (male) cable. Two such
-      cables if possible.
-\item Recent PC with at least 2 GB of RAM, a decently fast processor
-      and 20 GB of free contiguous space for installing Linux.
-\item 1 USB flash drive with at least 4 GB of free space
-\end{itemize}
-
-\section{Installing Linux on the PC}
-
-Do this before joining the workshop. This can be either done by
-participants themselves on their own PCs, or on PCs supplied by the
-entity which organizes the event.
-
-For the practical labs in this workshop, we need you to install
-{\bf Ubuntu Desktop 12.04}. We support both 32 and 64 bit variants,
-though 64 bit will probably give you the best performance
-if you have a recent CPU.
-
-Get the Desktop edition of Ubuntu 12.04 at
-instructions.
-
-The way your disk is partition will also matter in the practical labs.
-What matters is that \code{/opt} is in a partition with at least 15 GB
-of disk space. It's still because of the pre-compiled build environment
-which must have a specific path to be useful.
-
-The easiest way to achieve this is to have only one big root (\code{/})
-partition, which would then contain \code{/opt}. If you have enough
-space, you can of course have a dedicated partition for \code{/opt}.
-
-{\bf Important notes}
-\begin{itemize}
-\item We do not support Linux installations in a virtual machine.
-      VMs will suffer from long compile times and will complicate
-\item Using Ubuntu in live mode (from with installing it) will not work
-      either.  Memory may get scarse, compile time will be much longer because
-      of the slow disk, and exporting the root filesystem through NFS
-      won't work.
-\end{itemize}
-
-At the end of installation, we recommend to install the latest updates:
-
-\begin{verbatim}
-sudo apt update
-\end{verbatim}
-
-\section{Preparing a USB disk for the workshop}
-
-The USB disk will be needed by workshop participants:
-
-\begin{itemize}
-\item To access files which could take a long time to download
-      in the workshop venue (if it has a slow connection to the Internet
-      once).
-\item To get the pre-compiled build environment, saving at least
-      one hour of compile time. This file is several hundreds of MB big,
-\end{itemize}
-
-Now take a USB disk with at least 4 GB of free space, and connect it
-to your Ubuntu PC. You should see a window showing its contents.
-
-We are going to reformat this disk, so that every participant
-accesses his disk through the same name and path.
-
-The first thing you need to do is find which device file is
-associated to this newly inserted disk. Type the \code{dmesg} command
-and look at the last lines:
-
-\begin{verbatim}
-...
-[ 6103.687852]  sdb: sdb1
-...
-\end{verbatim}
-
-Let's assume that this disk associated to \code{/dev/sdb}:
-\begin{itemize}
-\item \code{/dev/sdb} represents the whole disk
-\item \code{/dev/sdb1} represents only the first partition on this disk.
-      There could be more partitions.
-\end{itemize}
-
-Now, let's format this first partition for the \code{FAT32} filesystem
-(make sure you replace \code{sdb1} by the right device name, otherwise
-you may destroy data on other disks!):
-
-\begin{verbatim}
-sudo umount /dev/sdb1
-sudo mkfs.vfat -F 32 -n BootTime /dev/sdb1
-\end{verbatim}
-
-Now, remove your USB drive and insert it again. A file explorer window
-should appear:
-\begin{center}
-\includegraphics[width=8cm]{labs/boottime-install/usbdisk-formated.png}
-\end{center}
-
-Now let's fill this disk with data needed during the workshop:
-{\small
-\begin{verbatim}
-cd /media/$USER/BootTime -wget -r -np -nH --cut-dirs=2 --reject "index.html*" https://bootlin.com/labs/boottime/ -sudo umount /media/$USER/BootTime
-\end{verbatim}
-}
-
-take up to several hours.
-
-At the end, your USB drive contents should look like this:
-\begin{center}
-\includegraphics[width=8cm]{labs/boottime-install/usbdisk-filled.png}
-\end{center}
-
-\section{Installing the lab archive}
-
-same directories, your pre-compiled build environment won't work and
-you will waste a lot of time compiling software.
-
-Type the below commands:
-\begin{verbatim}
-cd /opt
-sudo chown -R $USER.$USER .
-wget https://bootlin.com/doc/training/boot-time/boot-time-labs.tar.xz
-sudo tar xf boot-time-labs.tar.xz
-sudo chown -R $USER.$USER .
-\end{verbatim}
-
-\section{Installing software packages needed during the workshop}
-
-This step is recommended for all workshops. It will pre-install all the
-software packages needed during the workshop.
-
-To keep our instructions as close as real life as possible, our labs
-ask to install software packages exactly when they are needed. However,
-if all the participants to a workshop download the same packages at the
-
-This step can be skipped if you are just a few people doing the labs
-from home or from an office with fast Internet access.
-
-Here is the command to pre-install the software packages:
-
-\begin{verbatim}
-/opt/boot-time-labs/setup/install-packages
-\end{verbatim}
-
-
-You are now ready to do the workshop!
diff --git a/labs/boottime-install/usbdisk-filled.png b/labs/boottime-install/usbdisk-filled.png
deleted file mode 100644
index 4d7a0083..00000000
Binary files a/labs/boottime-install/usbdisk-filled.png and /dev/null differ
diff --git a/labs/boottime-install/usbdisk-formated.png b/labs/boottime-install/usbdisk-formated.png
deleted file mode 100644
index cdb6b344..00000000
Binary files a/labs/boottime-install/usbdisk-formated.png and /dev/null differ
diff --git a/labs/boottime-measuring/boottime-measuring.tex b/labs/boottime-measuring/boottime-measuring.tex
deleted file mode 100644
index 0c50b6ce..00000000
--- a/labs/boottime-measuring/boottime-measuring.tex
+++ /dev/null
@@ -1,334 +0,0 @@
-\subchapter{Measuring boot time}{Measuring the various
-components of boot time}
-
-Our first goal is to measure boot time in a coarse way. In a second
-step, we will measure the time spent in the various components of boot
-time.
-
-
-As explained in the lectures, the first thing to do is to choose what do
-measure. In the demo running on this particular board, a natural choice is to
-measure the time taken to start the demo video.
-
-Ideally, we would measure the time elapsed since power-on or since a
-reset event. However, we have no oscilloscope here, and therefore we can only
-rely on messages sent on the serial port.
-
-\begin{itemize}
-\item The earliest message we can have on the serial port is the
-      \code{RomBOOT} one. We will take its time of arrival as the origin of
-      time.
-\item We will implement a way to send a message to the serial line when
-      the video starts playing.
-\end{itemize}
-
-\section{Measuring overall boot time}
-
-We will use \code{grabserial} to measure the time spent while booting.
-It prints the timing information of each message received on the
-serial line\footnote{Beware that grabserial displays the arrival time
-of the beginning of a line on a serial port. If a message was sent
-without a trailing line feed, you could get the impression that
-the following characters have been received much earlier. This is
-particularly true when only a whitespace was first sent to the
-serial line.}, and display the time elapsed since a given event (like
-receiving a special string), used as the origin of time.
-
-You will find \code{grabserial} on \url{http://elinux.org/Grabserial}.
-You can also get it from your USB flash drive:
-
-
-\begin{verbatim}
-cd
-mkdir bin && cd bin
-cp /media/$USER/BootTime/downloads/grabserial . -chmod a+x grabserial -\end{verbatim} - -The command we will be using is: - -\begin{verbatim} -~/bin/grabserial -d /dev/ttyACM0 -m RomBOOT -t -e 30 -\end{verbatim} - -Here are details about this command: - -\begin{itemize} -\item \code{-m "RomBOOT"} specifies the string marking the -origin of time. -\item \code{-t} makes \code{grabserial} show the time when -{\bf the first character of each line is received}. -\item \code{-e 30} tells \code{grabserial} to stop measuring after 30 -seconds. -\end{itemize} - -First, you will have to exit \code{picocom} using \code{C-a C-x} to run -\code{grabserial}. - -Start \code{grabserial} and reset the board using \code{PB1}. You will -see that it takes around 13.5 seconds to reach the Buildroot prompt and -show the demo video: - -\begin{verbatim} -$ ~/bin/grabserial -d /dev/ttyACM0 -m RomBOOT  -t -e 30
-[0.000002 0.000002] RomBOOT
-[0.054440 0.054440]
-[0.054594 0.000154]
-[0.054719 0.000125] AT91Bootstrap 3.5.2 (Wed Jan 30 18:42:28 CET 2013)
-[0.059009 0.004290]
-[0.062645 0.003460] 1-Wire: ROM Searching ... Done, 0x3 1-Wire chips
-found
-[0.110066 0.047421]
-...
-[12.158893 0.064820] Starting portmap: done
-[12.284482 0.125589] Initializing random number generator... done.
-[12.393179 0.108697] ALSA: Restoring mixer settings...
-[12.447447 0.054268] Starting network...
-[13.077587 0.630140] Starting sshd: OK
-[13.467746 0.390159]
-[13.470225 0.002479] Welcome to Buildroot
-\$
-\end{verbatim}
-
-Note that there's no information on exactly when the first user space
-code gets executed. We will fix that in the {\em Add instrumentation}
-section.
-
-You can make a visual check that the \code{buildroot
-login:} message is issued at about the same time as the video
-starts playing. Of course, the accuracy is about 1 or 2 seconds,
-and it's time to measure the video starting time in a more accurate way.
-
-\section{Trick to estimate the video start time}
-
-For this kind of need, finding out when a device starts functioning,
-the ideal solution would be to monitor the LCD screen pins with an
-oscilloscope, and based on the recorded activity, find out when the
-video actually starts playing.
-
-When only software tracing is available, a standard solution is to
-add instrumentation to the application (here the video player) to write a message to
-the serial line.
-
-In our case, however, our video player is based on GStreamer, a very
-complex piece of software. We can write a message on the serial line
-before starting the player application, but the time to load this
-application and actually start playing the video is far from being
-negligible. This time is one of the components of boot time that we want to
-measure.
-
-A trick here is to replace the video by the shortest video possible
-(with the same codecs), containing only one frame. Assuming that
-the time to play the video itself is negligible, we can have a pretty
-accurate measurement of the time to load the video player and start
-playing the video.
-
-\begin{center}
-\includegraphics[width=\textwidth]{labs/boottime-measuring/videoplayer.pdf}
-\end{center}
-
-\section{Reconstitute the build environment for the root filesystem}
-
-In every boot time reduction project, you have to rebuild the root
-filesystem, either by using the original build system, or by compiling
-the software stack with a new build system which could make it
-easier to optimize and simplify the root filesystem.
-
-Another option would have been to make direct changes to the root
-filesystem. However, what you do is difficult to reproduce, and would
-make the system more difficult to maintain. In a real production
-project, it's much better to make changes to the configuration of
-the build system used to generate the root filesystem.
-
-This way, your changes to reduce boot time are always applied,
-whatever the other changes you make on the system.
-
-This is also true when you need to add instrumentation. If you do
-this by hand, you will lose all your instrumentation the next
-time you have to update or optimize a component.
-
-\subsection{Install development software}
-
-To update and recompile the root filesystem and
-components like the Linux kernel, you will need to install several
-software development packages:
-
-\begin{verbatim}
-sudo apt install git libncurses5-dev u-boot-tools g++ bison
-sudo apt install flex gettext texinfo libqt4-dev lzop
-\end{verbatim}
-
-Also install the \code{meld} package. It is a very
-convenient utility to compare different versions of a file, which
-is often useful in an optimization project.
-
-\begin{verbatim}
-sudo apt install meld
-\end{verbatim}
-
-Now, to be able to update the root filesystem, you need to reconstitute
-the Buildroot environment that was used to generate it.
-
-Do it by following the instructions available on
-
-\section{Study how user space boots}
-
-It's important to understand how the various user space programs
-are started in the system. They all originate from the \code{init}
-program, which is the first and only program executed by the Linux
-kernel\footnote{There is one exception: the kernel can also run
-helpers to handle hotplug events.}, when it's done booting the device.
-
-The programs that are executed by the \code{init} program can
-found by reading the \code{/etc/inittab} file, which is a configuration
-file for \code{init}.
-
-Start \code{picocom} if needed and study this file. You will see that
-a \code{/etc/init.d/rcS} script is also executed, and executes more
-scripts at his turn. Take some time to read these scripts, until you
-understand how the video player is started.
-
-
-Make sure you are in the \code{/opt/boot-time-labs/buildroot/buildroot-at91} directory.
-
-Copy the \code{../data/1frame.avi} file\footnote {Here's the command that
-was used to generate a video containing only the first frame of the original video: \\
-\code{avconv -i MPEG2_480_272.avi -vcodec copy -acodec copy -frames 1
-1frame.avi}}
-to \code{board/atmel/sama5d3ek_demo/}, where the original video is
-stored.
-
-Now, modify the \code{board/atmel/sama5d3ek_demo/post-build.sh}
-file\footnote{This script is called after compiling the root filesystem
-components, and is used to add custom scripts and files to the system.}:
-\begin{itemize}
-\item To copy the \code{1frame.avi} video to \code{/root} on the target
-      file system. Do this by looking for the instruction that copies the
-      original video, and by using a similar command.
-\item To modify the contents of the \code{/root/go.sh} script
-      which starts the video player:
-      \begin{itemize}
-      \item To add an \code{echo -e "\nStarting video player"} command
-	    \footnote{We are using a newline (\code{\n}) at the
-beginning of the string because \code{grabserial} only pays attention to
-the arrival time of the first character in each line. Without this, we
-would get the wrong time if the current line already had some
-characters sent earlier. If we didn't use \code{echo -e} (\code{e}:
-suppport for escape characters), \code{\n} wouldn't have been considered
-as a newline.}
-            right before invoking \code{gst-launch}, the video player that the demo
-	    uses.
-      \item To play the \code{1frame.avi} video instead of the original
-  	    one.
-      \item To add an \code{echo -e "\nDone playing video"} right after
- 	    playing the video.
-      \end{itemize}
-\end{itemize}
-
-The next thing we need is to know when the \code{init} program starts to
-execute.
-
-Let's have a look at home this program is built. Run the below command
-to check the configuration of \code{BusyBox}, which implements
-\code{init}:
-
-\begin{verbatim}
-\end{verbatim}
-
-Go to the \code{Init utilities} menu, and disable \code{Be _extra_ quiet
-on boot}. Exit and save your new configuration. This way, we will have
-a message on the serial line when \code{init} starts to execute.
-
-It's now time to rebuild your root filesystem:
-\begin{verbatim}
-make
-\end{verbatim}
-
-The above command should only take a few seconds to run.
-
-Make sure that the \code{output/target/root/go.sh} file
-contains the right modifications and that there are no syntax errors.
-Update the \code{board/atmel/sama5d3ek_demo/post-build.sh} file until
-you get this file right.
-
-If you can't manage to get it right, have a look at the
-\code{../solutions/post-build1.sh} file.
-
-\section{Re-flash the root filesystem}
-
-We will use \code{SAM-BA} again to update the root filesystem.
-
-Let's copy our new root filesystem to it to our \code{SAM-BA} directory:
-
-\begin{verbatim}
-cp output/images/rootfs.ubi \
-/opt/boot-time-labs/flashing/sama5d3xek-demo/
-\end{verbatim}
-
-Put your board in RomBOOT mode (follow the procedure in the previous
-chapter), and assuming that the SAM-BA device is \code{/dev/ttyACM1},
-reflash your board, using the same instructions as before:
-
-\begin{verbatim}
-cd /opt/boot-time-labs/flashing/sama5d3xek-demo/
-sam-ba /dev/ttyACM1 AT91SAMa5d3x-EK sama5d3xek_demo_linux_nandflash.tcl
-\end{verbatim}
-
-Press the reset button and make sure that your board boots as
-expected. You can also check that the new instrumentation messages are
-there. Don't pay attention to timing this time, as SSH keys had to be
-generated from scratch again.
-
-To stop the video player from running in a quick and endless way,
-you can run the below command in the serial console:
-
-\begin{verbatim}
-killall go.sh
-\end{verbatim}
-
-We will remove the endless loop a little bit later.
-
-\section{Measure boot time components}
-
-You can now exit \code{picocom} and run \code{grabserial} again.
-
-We can now time all the various steps of system booting in a pretty
-accurate way. Do it by filling writing down the time stamps in the below
-table.
-
-Then, in each row, compute the elapsed time, which is the difference
-between the time stamp for the next step and the time stamp for the current step.
-For this purpose, you can use the \code{bc -l} command line calculator.
-
-\begin{tabular}{| l | c | c | r |}
-  \hline
-  Boot phase & Start string & Time stamp & Elapsed \\
-  \hline
-  \hline
-  RomBOOT & \code{RomBOOT} & & \\
-  \hline
-  Bootstrap & \code{AT91Bootstrap 3.5.2} & & \\
-  \hline
-  Bootloader & \code{U-Boot 2012.10} & & \\
-  \hline
-  Kernel & \code{Booting Linux on physical CPU 0} & & \\
-  \hline
-  Init scripts & \code{init started: BusyBox v1.21.0} & & \\
-  \hline
-  Critical application & \code{Starting video player} & & \\
-  \hline
-  Critical application ready & \code{Done playing video} & & \\
-  \hline
-  \hline
-  \multicolumn{3}{| c |}{Total} & \\
-  \hline
-\end{tabular}
-
-In the next labs, we will work on reducing boot time for each of the boot phases.
diff --git a/labs/boottime-measuring/videoplayer.dia b/labs/boottime-measuring/videoplayer.dia
deleted file mode 100644
index 5f80c1b6..00000000
Binary files a/labs/boottime-measuring/videoplayer.dia and /dev/null differ
diff --git a/mk/boot-time.mk b/mk/boot-time.mk
index bd72eac3..7ed6b758 100644
--- a/mk/boot-time.mk
+++ b/mk/boot-time.mk
@@ -20,9 +20,8 @@ BOOT_TIME_SLIDES = \
boottime-hardware-init \

-BOOT_TIME_LABS = boottime-install \
-		boottime-getting-started \
-		boottime-measuring \
+BOOT_TIME_LABS = setup \
+		boot-time-board-setup \
boottime-setup \
boottime-init-scripts \
boottime-application \