Loading...
 

Build from source - Bootloader


The MACCHIATObin board is preloaded with ARM Trusted Firmware(ATF) + U-Boot as its default bootloader. This page shows a step-by-step tutorial for downloading and building the bootloader for MACCHIATObin. The instructions below assume that you have already setup the toolchain on your build machine. If you have not done so, please refer to the page Toolchain Installation for detail. If you already got a copy of the bootloader image for the MACCHIATObin and want to update your board with the new bootloader, see Update the Bootloader.

Prerequisites


Install the necessary prerequisites for building the bootloader binaries with:

mcbin@buildserver:~$ sudo apt-get install device-tree-compiler swig libpython-dev libssl-dev

Build U-Boot


First, you need to make the directory into which you will contain all the bootloader-related sources (e.g./home/mcbin/u-boot) and enter into that directory:

mcbin@buildserver:~$ mkdir u-boot && cd u-boot


In order to build U-Boot binaries for MACCHIATObin, setup the CROSS_COMPILE variable properly on your build machine:

mcbin@buildserver:~/u-boot$ export CROSS_COMPILE=aarch64-linux-gnu-


Now clone the u-boot-marvell repository with the command below and head into the newly created directory:

mcbin@buildserver:~/u-boot$ git clone https://github.com/MarvellEmbeddedProcessors/u-boot-marvell
mcbin@buildserver:~/u-boot$ cd u-boot-marvell/


Checkout the latest working branch for MACCHIATObin (u-boot-2017.03-armada-17.10):

mcbin@buildserver:~/u-boot/u-boot-marvell$ git checkout -b u-boot-2017.03-armada-17.10 origin/u-boot-2017.03-armada-17.10


The currently used U-Boot version supports saving U-Boot environment variables in the SPI ROM. To save the desired variables on the micro SD card, download the 0001-mcbin-save-environment-to-the-SD-card.patch and apply it on top of the 17.10 release to fix this issue:

mcbin@buildserver:~/u-boot/u-boot-marvell$ git apply 0001-mcbin-u-boot-and-env-on-SD-card-mmc-1.patch


Now you'll need to create the .config file using the default values from one of the default config file in the configs directory. For the MACCHIATObin board we will use mvebu_mcbin-88f8040_defconfig:

mcbin@buildserver:~/u-boot/u-boot-marvell$ make mvebu_mcbin-88f8040_defconfig


Once the .config is generated, use make to build the u-boot binary:

mcbin@buildserver:~/u-boot/u-boot-marvell$ make -j4


Wait for the make command until it finishes, and you will see the binary file u-boot.bin created under the current directory:

mcbin@buildserver:~/u-boot/u-boot-marvell$ ls u-boot*
u-boot          u-boot-nodtb.bin  u-boot.cfg          u-boot.dtb  u-boot.map   u-boot.sym
u-boot-dtb.bin  u-boot.bin        u-boot.cfg.configs  u-boot.lds  u-boot.srec


The file u-boot.bin will be used in the next step.

Building ATF


After you finish building the u-boot, you will need to setup the environment variable on your build machine to make the u-boot binary as the valid payload for the ARM Trusted Firmware. Make sure to adjust the path of the u-boot.bin binary according to your setup.

mcbin@buildserver:~/u-boot/u-boot-marvell$ export BL33=$(pwd)/u-boot.bin

 
Now, setup the SCL_BL2 to point to the MSS firmware image. To download the MSS firmware image, do:

mcbin@buildserver:~/u-boot/u-boot-marvell$ cd ..
mcbin@buildserver:~/u-boot$ git clone https://github.com/MarvellEmbeddedProcessors/binaries-marvell
mcbin@buildserver:~/u-boot$ cd binaries-marvell/
mcbin@buildserver:~/u-boot/binaries-marvell$ git checkout -b binaries-marvell-armada-17.10 origin/binaries-marvell-armada-17.10
mcbin@buildserver:~/u-boot/binaries-marvell$ export SCP_BL2=$(pwd)/mrvl_scp_bl2_8040.img


Now you will need to create the directory where we will clone the atf-marvell source code repository:

mcbin@buildserver:~/u-boot/binaries-marvell$ cd ..
mcbin@buildserver:~/u-boot$ git clone https://github.com/MarvellEmbeddedProcessors/atf-marvell.git
mcbin@buildserver:~/u-boot$ cd atf-marvell/


When the clone is done, checkout the atf-v1.3-armada-17.10, which is a valid working branch for MACCHIATObin:

mcbin@buildserver:~/u-boot/atf-marvell$ git checkout -b atf-v1.3-armada-17.10 origin/atf-v1.3-armada-17.10


Marvell uses a separate repository to hold the algorithm for ddr training. It is necessary to download the ddr training code to build the bootloader binary. Exit from the atf-marvell directory, make a directory to keep the ddr training repository and clone the repository to your local build machine. Please see the example instructions below:

mcbin@buildserver:~/u-boot/atf-marvell$ cd ..
mcbin@buildserver:~/u-boot$ mkdir mv-ddr && cd mv-ddr/
mcbin@buildserver:~/u-boot/mv-ddr$ git clone https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.git .


Check out the mv_ddr-armada-17.10 branch:

mcbin@buildserver:~/u-boot/mv-ddr$ git checkout -b mv_ddr-armada-17.10 origin/mv_ddr-armada-17.10


Now, go back to your atf-marvell directory and issue the make command:

mcbin@buildserver:~/u-boot/mv-ddr$ cd ../atf-marvell/
mcbin@buildserver:~/u-boot/atf-marvell$ make USE_COHERENT_MEM=0 LOG_LEVEL=20 MV_DDR_PATH=/home/mcbin/u-boot/mv-ddr PLAT=a80x0_mcbin all fip


In the above command change the path of your ddr training code according to your setup. When the build process is done, the bootloader image flash-image.bin will be located at the build/a80x0_mcbin/release/ directory.

mcbin@buildserver:~/u-boot/atf-marvell$ ls build/a80x0_mcbin/release/
bl1  bl1.bin  bl2  bl2.bin  bl31  bl31.bin  ble  ble.bin  boot-image.bin  fip.bin  flash-image.bin

 

 Information

For a more complete reference of available build parameters for creating MACCHIATObin bootloader images, consult docs/marvell/build.txt in your atf source directory.


Now head to Update the Bootloader page to see how to update the MACCHIATObin with your new bootloader image.