Build from source - UEFI EDK II

EDK II is a modern, feature-rich, cross-platform firmware development environment for the UEFI and PI specifications. MACCHATIObin supports to use EDK II plus ATF as its bootloader.


MACCHIATObin supports EDK II mainline master branch and the porting activity is currently ongoing. The activation of the various interfaces on the board is in progress. Please expect there will be existing bugs to be addressed or features to be enabled.

Build EDK II

First, set your $BASEDIR environment variable, as it will be used in the commands/scripts below. It is supposed to point to the working directory, where all repositories will be placed.

mcbin@buildserver:~$ export BASEDIR=/home/mcbin

Now the toolchain needs to be set up in order to build the EDK II. Please download the gcc-5.3 at https://releases.linaro.org/components/toolchain/binaries/5.3-2016.05/aarch64-linux-gnu/gcc-linaro-5.3.1-2016.05-x86_64_aarch64-linux-gnu.tar.xz .

mcbin@buildserver:~$ mkdir gcc5
mcbin@buildserver:~$ cd gcc5
mcbin@buildserver:~/gcc5$ wget https://releases.linaro.org/components/toolchain/binaries/5.3-2016.05/aarch64-linux-gnu/gcc-linaro-5.3.1-2016.05-x86_64_aarch64-linux-gnu.tar.xz
mcbin@buildserver:~/gcc5$ tar -xf gcc-linaro-5.3.1-2016.05-x86_64_aarch64-linux-gnu.tar.xz

Once the toolchain is extracted, setup the path and the compiler prefix to the environment variable GCC5_AARCH64_PREFIX.

mcbin@buildserver:~$ export GCC5_AARCH64_PREFIX=${BASEDIR}/gcc5/gcc-linaro-5.3.1-2016.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-



In order to create the UEFI image, ACPI tables compiler (iasl) has to be installed on your build machine. Please isse sudo apt-get install uuid-dev iasl to install the iasl complier.

Now, obtain the EDK II source code by cloning the repository.

mcbin@buildserver:~$ git clone https://github.com/tianocore/edk2

When the clone process is done, 'edk2' will be created with the source code. A default master branch should be used as a baseline for MACCHIATObin.

Next, let's download the OpenPlatformPkg for MACCHIATObin.

mcbin@buildserver:~$ git clone https://github.com/MarvellEmbeddedProcessors/edk2-open-platform.git

Check out to the branch marvell-armada-wip.

mcbin@buildserver:~$ cd edk2-open-platform
mcbin@buildserver:~/edk2-open-platform$ git checkout -b marvell-armada-wip origin/marvell-armada-wip
Branch marvell-armada-wip set up to track remote branch marvell-armada-wip from origin.
Switched to a new branch 'marvell-armada-wip'

Change to the edk2 directory, create a sym link OpenPlatformPkg to point to the directory of edk2-open-platform.

mcbin@buildserver:~/edk2-open-platform$ cd ~/edk2
mcbin@buildserver:~/edk2$ ln -s ${BASEDIR}/edk2-open-platform OpenPlatformPkg

Additional environment setup need to run before build the EDK II binaries. Please make sure the commands below finish without error.

mcbin@buildserver:~/edk2$ export ARCH=AARCH64
mcbin@buildserver:~/edk2$ make -C BaseTools
mcbin@buildserver:~/edk2$ source edksetup.sh

Now, to build the RELEASE version (DEBUG can be used alternatively) of the EDK II binary for MACCHIATObin, run the build command with parameters as below:

mcbin@buildserver:~/edk2$ build -a AARCH64 -t GCC5 -b RELEASE -p OpenPlatformPkg/Platforms/Marvell/Armada/Armada80x0McBin.dsc

Please wait until the build process finish without failure, the output binary will be available at the directory of Build/Armada80x0McBin-AARCH64/RELEASE_GCC5/FV/

mcbin@buildserver:~/edk2$ ls Build/Armada80x0McBin-AARCH64/RELEASE_GCC5/FV/
ARMADA_EFI.fd      FVMAIN_COMPACT.Fv.map  FVMAIN.ext     FVMAIN.Fv.txt           Guid.xref
Ffs                FVMAIN_COMPACT.Fv.txt  FVMAIN.Fv      FVMAIN.inf
FVMAIN_COMPACT.Fv  FVMAIN_COMPACT.inf     FVMAIN.Fv.map  GuidedSectionTools.txt

Setup the EDK II binary as the payload of the ARM Trusted Firmware. This step is needed to build the bootloader image including ATF and EDK II for MACCHIATObin.

mcbin@buildserver:~/edk2$ export BL33=${BASEDIR}/edk2/Build/Armada80x0McBin-AARCH64/RELEASE_GCC5/FV/ARMADA_EFI.fd


Build ATF

Before building the ARM Trusted Firmware for MACCHIATObin with EDK II binary packaged, please make sure you have exported BL33 correctly to point to the EDK II binary for ATF. If you have gone through the previous Build EDK II section, you should have already done so.

mcbin@buildserver:~/edk2$ export BL33=${BASEDIR}/edk2/Build/Armada80x0McBin-AARCH64/RELEASE_GCC5/FV/ARMADA_EFI.fd


In order to create the ATF image, it requires openssl headers to be installed on your build machine. Please do sudo apt-get install libssl-dev to install the openssl headers before starting to build the ATF.

Now you'll need to create the directory to hold the ATF source code.

mcbin@buildserver:~$ mkdir atf
mcbin@buildserver:~$ cd atf/

Then please clone the source code repository atf-marvell to the directory you have just created.

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

When the clone is done, check out atf-v1.3-armada-17.10 branch, this is a valid branch working for MACCHIATObin.

mcbin@buildserver:~/atf$ git checkout -b atf-v1.3-armada-17.10 origin/atf-v1.3-armada-17.10
Branch atf-v1.3-armada-17.10 set up to track remote branch atf-v1.3-armada-17.10 from origin.
Switched to a new branch '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 as well to build the bootloader binary. Exit from the atf directory, make a directory to keep the ddr training repo and clone the repository to your local build machine. Please see the example instructions below:

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

Check out the proper branch for MACCHIATObin - mv_ddr-armada-17.10

mcbin@buildserver:~/mv-ddr$ git checkout -b mv_ddr-armada-17.10 origin/mv_ddr-armada-17.10
Branch mv_ddr-armada-17.10 set up to track remote branch mv_ddr-armada-17.10 from origin.
Switched to a new branch 'mv_ddr-armada-17.10'

Next step is to setup the CROSS_COMPILE and ARCH properly on your build machine.

export ARCH=arm64
export CROSS_COMPILE=${BASEDIR}/gcc5/gcc-linaro-5.3.1-2016.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-

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

mcbin@buildserver:~/mv-ddr$ cd ../atf/
mcbin@buildserver:~/atf$ make USE_COHERENT_MEM=0 LOG_LEVEL=20 MV_DDR_PATH=${BASEDIR}/mv-ddr PLAT=a80x0_mcbin all fip

The example instruction above makes release version of the ATF image with the assumption of your ddr training source code locating at the ${BASEDIR}/mv-ddr directory. Please change it properly in accordance of the actual path for the ddr training code.

When the build process is done, the bootloader image flash-image.bin will be located at the build/a80x0_mcbin/release/ directory.

mcbin@buildserver:~/atf$ 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

Now you have your bootloader image flash-image.bin ready, the image file can be flashed into the MACCHIATObin boot devices.


Please find the file in your atf source tree docs/marvell/build.txt for a complete reference of the build parameters to make bootloader image for MACCHIATObin.


Quick build

In case all the prerequisites above are ready, there is no need to repeat all the steps every time. It is enough to setup the environment as below only once.

mcbin@buildserver:~$ export BASEDIR=/home/mcbin
mcbin@buildserver:~$ export GCC5_AARCH64_PREFIX=${BASEDIR}/gcc5/gcc-linaro-5.3.1-2016.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
mcbin@buildserver:~$ cd edk2
mcbin@buildserver:~/edk2$ make -C BaseTools
mcbin@buildserver:~/edk2$ source edksetup.sh

Then following script may be handy for issuing a quick build of the firmware.

mcbin@buildserver:~/edk2$ cat a8040mcbin.sh

build -a AARCH64 -t GCC5 -b ${1} -p OpenPlatformPkg/Platforms/Marvell/Armada/Armada80x0McBin.dsc
cd ../atf
export ARCH=arm64
export CROSS_COMPILE=${BASEDIR}/gcc5/gcc-linaro-5.3.1-2016.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
export BL33=${BASEDIR}/edk2/Build/Armada80x0McBin-AARCH64/${1}_GCC5/FV/ARMADA_EFI.fd
make USE_COHERENT_MEM=0 LOG_LEVEL=20 MV_DDR_PATH=${BASEDIR}/mv-ddr PLAT=a80x0_mcbin all fip
export ARCH=
cd -

Above script takes one argument - edk2 build target (RELEAS/DEBUG). Example usage:

mcbin@buildserver:~$ cd edk2
mcbin@buildserver:~/edk2$ ./a8040mcbin.sh RELEASE