[FE training-materials-updates] U-Boot lab: reduce the u-boot.bin size

Michael Opdenacker michael.opdenacker at free-electrons.com
Thu Nov 2 12:47:27 CET 2017


Repository : git://git.free-electrons.com/training-materials.git
On branch  : master
Link       : http://git.free-electrons.com/training-materials/commit/?id=2cdd6e904b057aae4a90e3a11d809f7f35ee343e

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

commit 2cdd6e904b057aae4a90e3a11d809f7f35ee343e
Author: Michael Opdenacker <michael.opdenacker at free-electrons.com>
Date:   Tue Oct 31 11:06:50 2017 +0100

    U-Boot lab: reduce the u-boot.bin size
    
    - This allows to use the latest U-Boot without
      having to change the default offset for U-Boot
      (in at91bootstrap) or to change the offset for
      U-Boot's environment storage.
    
    Signed-off-by: Michael Opdenacker <michael.opdenacker at free-electrons.com>


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

2cdd6e904b057aae4a90e3a11d809f7f35ee343e
 labs/sysdev-u-boot/sysdev-u-boot.tex | 43 +++++++++++++++++++++++++++++++++---
 1 file changed, 40 insertions(+), 3 deletions(-)

diff --git a/labs/sysdev-u-boot/sysdev-u-boot.tex b/labs/sysdev-u-boot/sysdev-u-boot.tex
index 463976e..867172d 100644
--- a/labs/sysdev-u-boot/sysdev-u-boot.tex
+++ b/labs/sysdev-u-boot/sysdev-u-boot.tex
@@ -90,8 +90,8 @@ If you wish to exit \code{picocom}, press \code{[Ctrl][a]} followed by
 \section{AT91Bootstrap Setup}
 
 The boot process is done in two steps with the ROM monitor trying to
-execute a first piece of software, called \code{AT91Bootstrap}, from
-its internal SRAM, that will initialize the DRAM, load \code{U-Boot}
+execute a first piece of software, called \em{AT91Bootstrap}, from
+its internal SRAM, that will initialize the DRAM, load \em{U-Boot}
 that will in turn load Linux and execute it.
 
 As far as bootloaders are concerned, the layout of the NAND flash will
@@ -196,7 +196,6 @@ Download U-Boot:
 wget ftp://ftp.denx.de/pub/u-boot/u-boot-2017.09.tar.bz2
 \end{verbatim}
 
-
 More recent versions may also work, but we have not tested them.
 
 Extract the source archive and get an understanding of U-Boot's
@@ -230,6 +229,44 @@ sudo apt-get install device-tree-compiler
 
 \end{itemize}
 
+\section{Shrinking U-Boot}
+
+Look at the size of the \code{u-boot.bin} binary. According to the above
+flash layout, the U-Boot binary is supposed to fit between flash offset
+\code{0x40000} and offset \code{0xc00000}, corresponding to a maximum
+size of \code{524288} bytes. Is \code{u-boot.bin} bigger than this
+maximum?
+
+The first offset is what AT91Bootstrap expects
+(though it can be changed in AT91Bootstrap's configuration.
+The second one, corresponding to where U-Boot stores its environment
+settings, is board dependent but but apparently cannot be changed
+through \code{make menuconfig}. 
+
+To avoid recompiling AT91Bootstrap, we propose to compile U-Boot with
+less features, to make its binary small. That's probably something you
+will do too during real-life projects.
+
+So, in U-Boot sources, run \code{make menuconfig}, look for and disable
+the below options:
+
+\begin{itemize}
+\item \code{ext4} options
+\item \code{nfs} options
+\item \code{EFI} options
+\item \code{imxtract} support
+\item \code{bootelf} command
+\item Regular expression support
+\item \code{dm} support
+\item \code{loadb} support
+\item \code{mii} commands
+\end{itemize}
+
+Now, recompile U-Boot and check that \code{u-boot.bin} is smaller
+than our maximum size.
+
+\section{Flashing U-Boot}
+
 Now, in \code{sam-ba}, in the \code{Send File Name} field, set the path to
 the \code{u-boot.bin} that was just compiled, and set the address to
 \code{0x40000}. Click on the \code{Send File} button.




More information about the training-materials-updates mailing list