Skip to main content
Version: BSP 7.x.y

Build U-Boot for NXP i.MX 93-based SoMs

Introduction

This article guides you on how to build from source and deploy U-Boot for Toradex's NXP i.MX 93-based System on Modules (SoMs).

Install Tools and Dependencies

Run the command below to install the dependencies necessary to build U-Boot from source:

$ sudo apt-get install bc build-essential git wget libncurses5-dev lzop perl libssl-dev bison flex swig libyaml-dev pkg-config python3-dev python3-venv xz-utils xxd device-tree-compiler u-boot-tools

Prepare the Environment for Cross-Compilation

info

You can use versions 9.2 or higher of the Arm releases binary toolchains to cross-compile software for Toradex modules. The instructions below reference version 12.3, which is the version used in Toradex build environments.

To install the toolchain on your host machine, download and unpack the .tar.xz file with the command below. Alternatively, you can obtain the toolchain directly from the Arm website.

$ cd ~
$ wget -O arm-gnu-toolchain-12.3.rel1-x86_64-aarch64-none-linux-gnu.tar.xz "https://developer.arm.com/-/media/Files/downloads/gnu/12.3.rel1/binrel/arm-gnu-toolchain-12.3.rel1-x86_64-aarch64-none-linux-gnu.tar.xz?rev=cf8baa0ef2e54e9286f0409cdda4f66c&hash=4E1BA6BFC2C09EA04DBD36C393C9DD3A"
$ tar xvf arm-gnu-toolchain-12.3.rel1-x86_64-aarch64-none-linux-gnu.tar.xz && rm arm-gnu-toolchain-12.3.rel1-x86_64-aarch64-none-linux-gnu.tar.xz
$ ln -s arm-gnu-toolchain-12.3.rel1-x86_64-aarch64-none-linux-gnu gcc-linaro-aarch64

U-Boot and Linux Makefiles use environment variables such as ARCH and CROSS_COMPILE to configure and call the appropriate compiler. Therefore, you must set these variables in the current shell when compiling the Kernel or U-Boot.

To facilitate this process, create an export-compiler-64 setup file with the commands below.

export-compiler-64
export ARCH=arm64
export PATH=${HOME}/gcc-linaro-aarch64/bin/:${PATH}
export DTC_FLAGS='-@'
export CROSS_COMPILE=aarch64-none-linux-gnu-
tip

Please note that creating the setup file is not mandatory, it serves only to simplify executing the commands above. You could also run each command individually on every new shell, or create a different environment setup file during the build process.

Source the setup file. Note that you will also need to source it every time you open a new shell to build the Kernel/U-Boot.

$ source ~/export-compiler-64

Get the Sources and Artifacts

To build U-Boot for NXP i.MX 93-based SoMs, you will need additional components during the compilation process. Toradex provides these components through the Artifacts Server, which hosts the files used in our Yocto builds. For the remainder of this article, we will refer to these components as artifacts.

Create a directory to store the build files and repositories:

$ mkdir -p ~/workdir
$ cd ~/workdir

Follow the steps below to get all the necessary sources and artifacts:

  1. Get the U-Boot source code: For the i.MX 93-based modules, clone U-Boot from Toradex's Downstream source, on the branch toradex_imx_lf_v2024.04.

    $ git clone -b toradex_imx_lf_v2024.04 https://git.toradex.cn/u-boot-toradex.git
  2. Get the Required Artifacts: The necessary artifacts to build U-Boot for i.MX 93-based modules are listed below:

    • Advanced High-Assurance Boot container image
    • DDR Phy Firmware Image
    • OEI Images
    • System Manager Image
    • ARM Trusted Firmware

    Access the Toradex Artifacts Server and download the binaries for each artifact into the workdir directory on your host machine. The location of each required artifact is shown below. The <build-number> indicates the Quarterly Release for which the artifacts were built. In general, select the highest number, as it corresponds to the latest Quarterly Release. Additionally, replace <SoM> with the name of your SoM.

    Artifacts file paths
    tdxref-oe-prod-frankfurt
    └── scarthgap-7.x.y
    └── release
    └── <build-number>
    └── <SoM>
    └── tdx-xwayland
    └── tdx-reference-minimal-image
    └── oedeploy
    ├── bl31-imx93.bin
    ├── lpddr4_dmem_1d_v202201.bin
    ├── lpddr4_dmem_2d_v202201.bin
    ├── lpddr4_imem_1d_v202201.bin
    ├── lpddr4_imem_2d_v202201.bin
    └── mx93a1-ahab-container.img

Build U-Boot

In the U-Boot directory, compile the source code for your specific module. For this step, make sure you are using the shell for which you've set the Cross Compilation Toolchain.

$ cd u-boot-toradex
$ make lino-imx93_defconfig
$ make
$ ls u-boot.bin

Assemble the Boot Container

As the last step, you need to build the flash.bin boot container. The boot container consists of the u-boot.bin and all other artifacts necessary to boot the image in the module. Follow the steps below to build the container:

  1. Clone the imx-mkimage utility to assemble the final boot container:

    $ cd ~/workdir
    $ git clone -b lf-6.6.52-2.2.1 https://github.com/nxp-imx/imx-mkimage.git
  2. Copy all the artifacts to the imx-mkimage directory:

    $ mv bl31-imx93.bin bl31.bin
    $ cp *.bin *.img imx-mkimage/iMX93/
    $ cp u-boot-toradex/u-boot.bin imx-mkimage/iMX93/
    $ cp u-boot-toradex/spl/u-boot-spl.bin imx-mkimage/iMX93/
  3. Build the flash.bin binary:

    $ cd imx-mkimage/iMX93
    $ make SOC=iMX93 OEI=YES flash_singleboot
    $ ls flash.bin

Deploy the U-Boot Binary to an Image

To deploy your custom U-Boot binary to an image, follow the steps described below:

  1. Download and extract one of the Toradex prebuilt images appropriate for your SoM.

  2. Replace the imx-boot file inside the extracted image with the flash.bin container you built, renaming the file.

    $ cd ~/workdir
    cp imx-mkimage/iMX93/flash.bin <path-to-your-image>/imx-boot
  3. Deploy the modified Toradex Easy Installer image with Toradex Easy Installer.

Send Feedback!