[bootlin/training-materials updates] master: Boot time: compiling the bootloader (cedf8cad)

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
Link       : https://github.com/bootlin/training-materials/commit/cedf8cadbef913b151bc98f5293c7ac9335ee50c

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

commit cedf8cadbef913b151bc98f5293c7ac9335ee50c
Author: Michael Opdenacker <michael.opdenacker at bootlin.com>
Date:   Thu May 16 14:16:26 2019 +0200

    Boot time: compiling the bootloader
    
    Signed-off-by: Michael Opdenacker <michael.opdenacker at bootlin.com>


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

cedf8cadbef913b151bc98f5293c7ac9335ee50c
 .../boot-time-board-setup.tex                      | 27 +-----
 .../boot-time-build-bootloader.tex                 | 97 ++++++++++++++++++++++
 mk/boot-time.mk                                    |  1 +
 3 files changed, 101 insertions(+), 24 deletions(-)

diff --git a/labs/boot-time-board-setup/boot-time-board-setup.tex b/labs/boot-time-board-setup/boot-time-board-setup.tex
index 8753f992..38e21466 100644
--- a/labs/boot-time-board-setup/boot-time-board-setup.tex
+++ b/labs/boot-time-board-setup/boot-time-board-setup.tex
@@ -104,30 +104,9 @@ to stop the U-boot countdown. You should then see the U-Boot prompt:
 =>
 \end{verbatim}
 
-You can now use U-Boot. Run the \code{help} command to see the available
-commands.
-
-Type the \code{help saveenv} command to make sure that the
-\code{saveenv} command exists. We use it in these labs to
-save your U-Boot environment settings to the boards' eMMC storage.
-Some earlier versions do not support this.
-
-If you don't have this command, it's probably because you are doing these labs on your own
-(i.e. without participating to a Bootlin course), we ask you to install the U-Boot binary
-that we compiled and tested. See instructions in
-\url{https://raw.githubusercontent.com/bootlin/training-materials/master/lab-data/common/bootloader/beaglebone-black/README.txt}
-for a simple way to do this.
-
-To avoid trouble because of settings applied in previous practical labs,
-we advise you to clear the U-Boot environment variables:
-
-\begin{verbatim}
-env default -f -a
-saveenv
-\end{verbatim}
-
-We are now ready to compile and use our own bootloader, kernel and root
-filesystem.
+This step was just to check that the serial line was connected
+properly. In a later lab, we will replace the existing bootloader by
+a version that we compiled ourselves.
 
 \section{Attach the LCD cape}
 
diff --git a/labs/boot-time-build-bootloader/boot-time-build-bootloader.tex b/labs/boot-time-build-bootloader/boot-time-build-bootloader.tex
new file mode 100644
index 00000000..f2ed7b89
--- /dev/null
+++ b/labs/boot-time-build-bootloader/boot-time-build-bootloader.tex
@@ -0,0 +1,97 @@
+\subchapter{Build the bootloader}{Objective: compile and install the
+bootloader.}
+
+After this lab, you will be able to compile U-Boot for your target
+platform and run it from a micro SD card provided by your instructor.
+
+\section{Setup}
+
+Go to the /code{~/boot-time-labs/bootloader/u-boot/} directory.
+
+Let's use the 2019.04 version:
+\begin{verbatim}
+git checkout v2019.04
+\end{verbatim}
+
+\section{Compiling environment}
+
+If the previous Buildroot lab is already over, we can use the
+toolchain it built to compile our bootloader and kernel:
+
+\begin{verbatim}
+export PATH=/home/<user>/boot-time-labs/rootfs/buildroot/output/host/bin:$PATH
+export CROSS_COMPILE=arm-buildroot-linux-uclibcgnueabihf-
+\end{verbatim}
+
+Otherwise, let's take a cross-compiling toolchain provided by Ubuntu:
+
+\begin{verbatim}
+sudo apt install gcc-arm-linux-gnueabihf
+export CROSS_COMPILE=arm-linux-gnueabihf-
+\end{verbatim}
+
+\section{Configuring U-Boot}
+
+Let's use the ready-made U-Boot configuration for the Beaglebone Black
+board (you can find such configuration files in the \code{configs/}
+directory:
+
+\begin{verbatim}
+make am335x_boneblack_vboot_defconfig
+\end{verbatim}
+
+\section{Compiling U-Boot}
+
+Just run:
+\begin{verbatim}
+make
+\end{verbatim}
+
+or, to compile faster:
+
+\begin{verbatim}
+make -j 8
+\end{verbatim}
+
+This runs 8 compiler jobs in parallel (for example if you have 4 CPU
+cores on your workstation... using more jobs than cores guarantees that
+the CPUs and I/Os are always fully loaded, for optimum performance.
+
+At the end, you have \code{MLO} and \code{u-boot.img} files that we will
+put on a micro SD card for booting.
+
+\input{../common/boneblack-sdcard-preparation.tex}
+
+\section{Booting your new bootloader}
+
+On a board in a normal state, there should be a bootloader on the on-board MMC
+(eMMC) storage, and this will prevent you from using a bootloader on an
+external SD card (unless you hold the \code{USER} button while powering
+up your board, which is just suitable for exceptional needs).
+
+Therefore, to override this behaviour and use the external SD card,
+instead, let's wipe out the \code{MLO} file on the eMMC.
+
+Power up or reset your board, and in the U-Boot prompt, run:
+
+\begin{verbatim}
+fatls mmc 1
+\end{verbatim}
+
+You should see the \code{MLO} file in the list of files. Let's remove it
+by issuing the below command:
+
+\begin{verbatim}
+fatwrite mmc 1 81000000 100000
+\end{verbatim}
+
+If your board doesn't boot at all, please fix it first using our instructions
+on
+\url{https://raw.githubusercontent.com/bootlin/training-materials/master/lab-data/common/bootloader/beaglebone-black/README.txt}.
+
+Now, copy your newly compiled \code{MLO} and \code{u-boot.img} files to
+the SD card's \code{boot} partition, and after cleanly umounting this
+partition, insert the SD card into the board and reset it.
+
+You should now see your board booting with your own \code{MLO} and U-Boot
+binaries (the versions and compiled dates are shown in the console). 
diff --git a/mk/boot-time.mk b/mk/boot-time.mk
index 5d08f8f0..ae7275b8 100644
--- a/mk/boot-time.mk
+++ b/mk/boot-time.mk
@@ -25,6 +25,7 @@ BOOT_TIME_LABS = boot-time-goals \
 		boot-time-sources-download \
 		boot-time-board-setup \
 		boot-time-build-system \
+		boot-time-build-bootloader \
 		boottime-init-scripts \
 		boottime-application \
 		boottime-kernel \




More information about the training-materials-updates mailing list