Specifics: Build U-Boot for TI AM69-based SoMs
Introduction
This article describes additional specific steps for compiling and configuring the boot container for Toradex's TI AM69-based System on Modules.
Install Dependencies
For the TI AM69-based modules, you must build U-Boot for both the A72 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.11-venv xz-utils dtc 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 Aquila AM69 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://review.trustedfirmware.org/TF-A/trusted-firmware-a.git
- Get the OP-TEE image source code:
$ git clone https://github.com/OP-TEE/optee_os.git
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 CC32=arm-none-linux-gnueabihf-" >> env-uboot
$ echo "export CC64=aarch64-none-linux-gnu-" >> env-uboot
$ echo "export UBOOT_PATH=$(pwd)/u-boot-toradex" >> env-uboot
$ echo "export LNX_FW_PATH=$(pwd)/ti-linux-firmware" >> env-uboot
$ echo "export TFA_PATH=$(pwd)/trusted-firmware-a" >> env-uboot
$ echo "export OPTEE_PATH=$(pwd)/optee_os" >> env-uboot
$ echo "export PATH=$(pwd)/gcc-linaro-aarch64/bin/:$(pwd)/gcc-linaro-arm/bin/:$PATH" >> env-uboot
- Define the U-Boot configuration variables for the AM69 SoC:
$ echo "export TFA_BOARD=j784s4" >> env-uboot
$ echo "export TFA_EXTRA_ARGS='K3_USART=0x8'" >> env-uboot
$ echo "export OPTEE_PLATFORM=k3-j784s4" >> env-uboot
$ echo "export OPTEE_EXTRA_ARGS='CFG_CONSOLE_UART=0x8'" >> env-uboot
- Define the U-Boot configuration variables for the AM69-based SoM:
$ echo "export UBOOT_CFG_CORTEXR=aquila-am69_r5_defconfig" >> env-uboot
$ echo "export UBOOT_CFG_CORTEXA=aquila-am69_a72_defconfig" >> env-uboot
- Finally, 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 pyelftools cryptography 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_PATH
$ make CROSS_COMPILE=$CC64 ARCH=aarch64 PLAT=k3 SPD=opteed $TFA_EXTRA_ARGS TARGET_BOARD=$TFA_BOARD
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_PATH
$ make CROSS_COMPILE=$CC32 CROSS_COMPILE64=$CC64 CFG_ARM64_core=y $OPTEE_EXTRA_ARGS PLATFORM=$OPTEE_PLATFORM
Build U-Boot for the Cortex-R5
In the U-Boot directory, compile the source code for the R5 core:
$ cd $UBOOT_PATH
$ make $UBOOT_CFG_CORTEXR
$ make CROSS_COMPILE=$CC32 BINMAN_INDIRS=$LNX_FW_PATH
$ cp tiboot3-am69-hs-fs-aquila.bin ../build/
Build U-Boot for the Cortex-A72
In the U-Boot directory, compile the source code for the A72 cores:
$ cd $UBOOT_PATH
$ make $UBOOT_CFG_CORTEXA
$ make CROSS_COMPILE=$CC64 BINMAN_INDIRS=$LNX_FW_PATH BL31=$TFA_PATH/build/k3/$TFA_BOARD/release/bl31.bin TEE=$OPTEE_PATH/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.