Loading...
 

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.

 Note

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/7.2-2017.11/aarch64-linux-gnu/gcc-linaro-7.2.1-2017.11-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/7.2-2017.11/aarch64-linux-gnu/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu.tar.xz
mcbin@buildserver:~/gcc5$ tar -xf gcc-linaro-7.2.1-2017.11-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-7.2.1-2017.11-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-

 

 Information

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


Also make, gcc and g++ are required, for that execute: 'sudo apt install make gcc g++'


Now, obtain the Marvell combined branch with the edk2 and edk2-platforms code, that contains Armada platform support. First, clone the repository:

mcbin@buildserver:~$ cd ${BASEDIR}
mcbin@buildserver:~$ git clone https://github.com/MarvellEmbeddedProcessors/uefi-marvell


When the clone process is done, check out the uefi-2.7-armada-18.09 branch.

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


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

mcbin@buildserver:~/uefi-marvell$ export WORKSPACE=$PWD
mcbin@buildserver:~/uefi-marvell$ export PACKAGES_PATH=$PWD:$PWD/edk2-platforms
mcbin@buildserver:~/uefi-marvell$ make -C BaseTools
mcbin@buildserver:~/uefi-marvell$ 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:~/uefi-marvell$ build -a AARCH64 -t GCC5 -b RELEASE -D INCLUDE_TFTP_COMMAND -p Platform/SolidRun/Armada80x0McBin/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:~/uefi-marvell$ 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:~/uefi-marvell$ export BL33=${BASEDIR}/uefi-marvell/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:~/uefi-marvell$ export BL33=${BASEDIR}/uefi-marvell/Build/Armada80x0McBin-AARCH64/RELEASE_GCC5/FV/ARMADA_EFI.fd

 Information

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:~$ cd ${BASEDIR}
mcbin@buildserver:~$ mkdir atf
mcbin@buildserver:~$ cd atf/
mcbin@buildserver:~/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.5-armada-18.09​ branch, this is a valid branch working for MACCHIATObin.

mcbin@buildserver:~/atf$ git checkout -b atf-v1.5-armada-18.09 origin/atf-v1.5-armada-18.09
Branch atf-v1.5-armada-18.09 set up to track remote branch atf-v1.5-armada-18.09 from origin.
Switched to a new branch 'atf-v1.5-armada-18.09'


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-18.09

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

 

In the newest versions it is obligatory to use an auxiliary firmware on the SoC co-processors. For that purpose it is required to download and appropriately expose a pre-built image.

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


Check-out binaries-marvell-armada-18.06 and export SCP_BL2 variable, which points to the image.

mcbin@buildserver:~$ git checkout -b binaries-marvell-armada-18.06 remotes/origin/binaries-marvell-armada-18.06
Branch binaries-marvell-armada-18.06 set up to track remote branch binaries-marvell-armada-18.06 from origin.
Switched to a new branch 'binaries-marvell-armada-18.06'
mcbin@buildserver:~$ export SCP_BL2=${BASEDIR}/binaries-marvell/mrvl_scp_bl2_mss_ap_cp1_a8040.img


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-7.2.1-2017.11-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-


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

mcbin@buildserver:~/binaries-marvell$ 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.

 Information

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-7.2.1-2017.11-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
mcbin@buildserver:~$ export SCP_BL2=${BASEDIR}/binaries-marvell/mrvl_scp_bl2_mss_ap_cp1_a8040.img
mcbin@buildserver:~$ cd uefi-marvell
mcbin@buildserver:~/uefi-marvell$ export WORKSPACE=$PWD
mcbin@buildserver:~/uefi-marvell$ export PACKAGES_PATH=$PWD:$PWD/edk2-platforms
mcbin@buildserver:~/uefi-marvell$ make -C BaseTools
mcbin@buildserver:~/uefi-marvell$ source edksetup.sh


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

mcbin@buildserver:~/uefi-marvell$ cat a8040mcbin.sh
#!/bin/bash

build -a AARCH64 -t GCC5 -b ${1} -D INCLUDE_TFTP_COMMAND -p Platform/SolidRun/Armada80x0McBin/Armada80x0McBin.dsc
cd ../atf
export ARCH=arm64
export CROSS_COMPILE=${BASEDIR}/gcc5/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
export SCP_BL2=${BASEDIR}/binaries-marvell/mrvl_scp_bl2_mss_ap_cp1_a8040.img
export BL33=${BASEDIR}/uefi-marvell/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 uefi-marvell
mcbin@buildserver:~/uefi-marvell$ ./a8040mcbin.sh RELEASE