#Compiling AT91bootstrap 3.7

<div class="text-success lead">
AT91bootstrap is the 2nd level bootloader used by the Atmel/Microchip ARM MPUs
to initializate the internal hardware (clocks, peripherals, DDR DRAM, etc) 
at startup and load the Linux Kernel image from the first microSD partition.
<br/>
<br/>
This article illustrates how to compile at91bootstrap 3.7 for Acqua A5, 
Aria G25 and Arietta G25 modules
</div>

For the FOX Board G20 users please read: @article='acmeboot'

The at91bootstrap binary is called __boot.bin__ and is saved on the first microSD
partition. This partition must be FAT16 or FAT32.

At startup **RomBOOT**, that is the 1st levet booloader saved in the Atmel MPU ROM,
searches and loads **boot.ini** from microSD card to the SRAM 
located inside the MPU itself and runs it from there.

##Toolchain installation

First of all you need to install the toolchain (cross compiler, linker, etc) on your Linux 
Ubuntu PC following this article (tested on Ubuntu 15.04):

* @article='arm9_toolchain'

##Download AT91bootstrap v 3.7 from sources

Download from GitHub the Atmel AT91boostrap version 3.7 sources:

* [at91bootstrap-3.7.zip](./at91bootstrap-3.7.zip)

Uncompress it by typing:

<pre class="terminal">
$ <b>unzip at91bootstrap-3.7.zip</b>
</pre>

Move inside the new directory and download the patch from our GitHub repository:

* [at91bootstrap-3.7.patch](https://raw.githubusercontent.com/AcmeSystems/acmepatches/master/at91bootstrap-3.7.patch)

Applying the patch:

<pre class="terminal">
~/at91bootstrap-3.7 $ <b>patch -p1 <  at91bootstrap-3.7.patch</b>
</pre>
</b>
</pre>

Check which is the defconfig filename of your board. Form the right column it is possible to 
download the binary file for your board to save on the first partition and rename as boot.bin.

| Board       | Ram size | defconfig              | binary files (to rename in boot.bin)               |
|-------------|----------|------------------------|----------------------------------------------------|
| Acqua A5    | 256 MB   | acqua-256m_defconfig   | [acqua-256m-boot.bin](./acqua-256m-boot.bin)       |
| Acqua A5    | 512 MB   | acqua-512m_defconfig   | [acqua-512m-boot.bin](./acqua-512m-boot.bin)       |
| Aria G25    | 128 MB   | aria-128m_defconfig    | [aria-128m-boot.bin](./aria-128m-boot.bin)         |
| Aria G25    | 256 MB   | aria-256m_defconfig    | [aria-256m-boot.bin](./aria-256m-boot.bin)         |
| Arietta G25 | 128 MB   | arietta-128m_defconfig | [arietta-128m-boot.bin](./arietta-128m-boot.bin)   |
| Arietta G25 | 256 MB   | arietta-256m_defconfig | [arietta-256m-boot.bin](./arietta-256m-boot.bin)   |

<br/>
and use it on the following command:

<pre class="terminal">
~/at91bootstrap-3.7 $ <b>make</b> <i>defconfig</i></b>
</pre>

###Check the configuration menu

If you want to take a look to the at91bootstrap config launch:

<pre class="terminal">
~/at91bootstrap-3.7 $ <b>make menuconfig</b>
</pre>

then save and exit.

###Launch the compilation

To launch the compilation type:

<pre class="terminal">
~/at91bootstrap-3.7 $ <b>make CROSS_COMPILE=arm-linux-gnueabi-</b>
...
</pre>

###Installation

Copy the binary just created on the first partition of SD card renaming 
it in **boot.bin**. These exaamples are valid if you are using a __zImage__
format for your Linux image:

For Acqua A5:

<blockquote>
<pre class="terminal">
~/at91bootstrap-3.7 $ <b>cp binaries/sama5d3_acqua-sdcardboot-linux-zimage-dt-3.7.bin /media/$USER/boot/boot.bin</b>
</pre>
</blockquote>

For Aria G25:

<blockquote>
<pre class="terminal">
~/at91bootstrap-3.7 $ <b>cp binaries/at91sam9x5_aria-sdcardboot-linux-zimage-dt-3.7.bin /media/$USER/boot/boot.bin</b>
</pre>
</blockquote>

For Arietta G25:

<blockquote>
<pre class="terminal">
~/at91bootstrap-3.7 $ <b>cp binaries/at91sam9x5_arietta-sdcardboot-linux-zimage-dt-3.7.bin /media/$USER/boot/boot.bin</b>
</pre>
</blockquote>
