Specifics: Build U-Boot for TI AM62Px-based SoMs
Introduction
This article describes additional specific steps about the compilation and the configuration of the boot container of the Toradex TI AM62Px-based System on Module.
Install Dependencies
For the TI AM62P-based modules, you must build U-Boot for both the A53 and R5 processors. The following steps provide instructions on installing the dependencies for both platforms.
- Install the required packages to build U-Boot:
$ sudo apt-get install bc build-essential git libncurses5-dev lzop perl libssl-dev bison flex swig libyaml-dev pkg-config python3-dev python3-venv xz-utils device-tree-compiler u-boot-tools
- Install the 32-bit and 64-bit toolchains by following the instructions available on Prepare the Host Machine for Cross-Compilation. Note that the cross-compilation environment must be configured for both architectures.
Get the Sources
Create a directory to store the build files and repositories:
$ mkdir -p ~/workdir
$ cd ~/workdir
- Get the U-Boot source code: Since Verdin AM62P is a downstream-based module, U-Boot must be fetched from https://git.toradex.com/u-boot-toradex.git. Refer to the U-Boot Version Information table for the correct branch to be used.
$ git clone -b <u-boot-git-branch> https://git.toradex.com/u-boot-toradex.git
- Get the TI Linux Firmware:
$ git clone -b ti-linux-firmware git://git.ti.com/processor-firmware/ti-linux-firmware.git
- Get the ARM Trusted Firmware (ATF/TF-A):
$ git clone https://github.com/ARM-software/arm-trusted-firmware.git
- Get the OP-TEE image source code:
$ git clone https://github.com/OP-TEE/optee_os.git
- Get the K3 Security development package:
$ git clone https://git.ti.com/git/security-development-tools/core-secdev-k3.git -b master
Prepare the Environment
The following steps assume you have:
- Installed both the 32-bit and 64-bit toolchains, as instructed in the Install Dependencies section;
- Created the symbolic links
gcc-linaro-aarch64
andgcc-linaro-arm
to point to the toolchains; - Ensured that both toolchains are available in the
~/workdir
directory.
By following the steps below, you will create the env-uboot
file, which must be sourced every time you open a new shell when building U-Boot.
- Append the following environment variables to the
env-uboot
file.
$ cd ~/workdir
$ echo "export UBOOT_DIR=$(pwd)/u-boot-toradex" >> env-uboot
$ echo "export TI_LINUX_FW_DIR=$(pwd)/ti-linux-firmware" >> env-uboot
$ echo "export TFA_DIR=$(pwd)/arm-trusted-firmware" >> env-uboot
$ echo "export OPTEE_DIR=$(pwd)/optee_os" >> env-uboot
$ echo "export PATH=$(pwd)/gcc-linaro-aarch64/bin/:$(pwd)/gcc-linaro-arm/bin/:$PATH" >> env-uboot
- Source the
env-uboot
file to export the environment variables:
$ source env-uboot
Prepare the Python Environment
The U-Boot build process utilizes third-party Python modules that are not installed by default. Create a Python virtual environment to install these modules:
$ cd ~/workdir
$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install cryptography pyelftools setuptools pyyaml yamllint jsonschema
Make sure to always activate the Python venv
when spawning new shells to use the same setup configured in the Prepare the Environment section. This will ensure the environment has the required dependencies to proceed with the build.
Build U-Boot
Source the env-uboot
and venv/bin/activate
files to activate the Python virtual environment and export all the required environment variables, if you haven't done so already:
$ source env-uboot
$ source venv/bin/activate
Create a directory to store the U-Boot binaries:
$ mkdir build
Build ARM Trusted Firmware (ATF/TF-A)
ATF is used as the initial start code on ARMv8-A cores for all K3 platforms. Go to the directory where you cloned the ARM Trusted Firmware and compile it for the ARM64 architecture:
$ cd $TFA_DIR
$ export ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu-
$ unset TFA_EXTRA_ARGS
$ make PLAT=k3 SPD=opteed $TFA_EXTRA_ARGS TARGET_BOARD=lite
Build OP-TEE Image
OP-TEE is a Trusted Execution Environment (TEE) that runs alongside the non-secure Linux kernel in the Cortex-A, protecting the Trusted Applications (TAs) via hardware support. For further information about OP-TEE, check out the OP-TEE documentation. Go to the directory where you cloned the OP-TEE source and compile it:
$ cd $OPTEE_DIR
$ export OPTEE_EXTRA_ARGS="CFG_WITH_SOFTWARE_PRNG=y"
$ export ARCH=arm
$ export CROSS_COMPILE=arm-none-linux-gnueabihf-
$ export CROSS_COMPILE64=aarch64-none-linux-gnu-
$ make PLATFORM=k3-am62px CFG_ARM64_core=y $OPTEE_EXTRA_ARGS
Build U-Boot for the Cortex-R5
In the U-Boot directory, compile the source code for the R5 core:
$ cd $UBOOT_DIR
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- verdin-am62p_r5_defconfig
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- BINMAN_INDIRS=$TI_LINUX_FW_DIR
$ cp tiboot3-am62px-hs-fs-verdin.bin ../build/
Build U-Boot for the Cortex-A72
In the U-Boot directory, compile the source code for the A72 cores:
$ cd $UBOOT_DIR
$ export ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu-
$ make verdin-am62p_a53_defconfig
$ make BINMAN_INDIRS=$TI_LINUX_FW_DIR BL31=$TFA_DIR/build/k3/lite/release/bl31.bin TEE=$OPTEE_DIR/out/arm-plat-k3/core/tee-raw.bin
$ cp tispl.bin ../build/
$ cp u-boot.img ../build/
Deploy the U-Boot binary to an Image
Now that the adjustments were made, return to the Build U-Boot From Source Code article to deploy the U-Boot binary to an image.