Skip to content

Build U-Boot from source code

Toolchain installation for out of builds

To install the toolchain, follow the Debian Flexbuild Toolchain installation guide.

Build U-Boot out of tree

Obtain sources:

$ git clone https://github.com/varigit/uboot-imx -b lf_v2024.04_6.6.52-2.2.0_var01
$ cd uboot-imx

Configure compilation environment:

$ export ARCH=arm64
$ export CROSS_COMPILE=aarch64-linux-gnu-

Cleanup everything:

$ make mrproper

Select configuration:

$ make imx8qm_var_som_defconfig

Build U-Boot:

$ make -j$(nproc)

Build boot image

The final boot image contains multiple firmware files, as explained by NXP in IMX_LINUX_USERS_GUIDE.pdf (Search for "How to build imx-boot image by using imx-mkimage").

The following procedure builds the final image:

Create imx-boot-tools directory:

$ mkdir imx-boot-tools
$ cd imx-boot-tools

Obtain SC firmware: Build SCFW by following the Build SCFW from source code page and copy the SCFW image to the imx-boot-tools directory.

Download SECO firmware:

$ wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/imx-seco-5.9.4.1-0333596.bin
$ chmod +x imx-seco-5.9.4.1-0333596.bin
$ ./imx-seco-5.9.4.1-0333596.bin
$ cp imx-seco-5.9.4.1-0333596/firmware/seco/mx8q*-ahab-container.img .

Download and build imx_mkimage:

$ git clone https://github.com/nxp-imx/imx-mkimage -b lf-6.6.52_2.2.0
$ cd imx-mkimage
$ make
$ cp mkimage_imx8 iMX8QM/soc.mak iMX8QM/*.sh scripts/pad_image.sh ..
$ cd ..

Download and build ATF:

$ git clone https://github.com/varigit/imx-atf -b lf_v2.10_6.6.52-2.2.0_var01

$ cd imx-atf
$ unset LDFLAGS
$ make PLAT=imx8qm bl31
$ cp build/imx8qm/release/bl31.bin ..
$ cd ..

Copy U-Boot binaries:

$ cp ../tools/mkimage mkimage_uboot
$ cp ../u-boot.bin .
$ cp ../spl/u-boot-spl.bin .

Depending on i.MX8QM SOC revision different instructions should be used to build boot image. The SOC revision is printed by u-boot as follows

CPU:   NXP i.MX8QM RevB A53 at 1200 MHz at 54C

or

CPU:   Freescale i.MX8QM revC A35 at 1200 MHz at 36C

Build boot image for SOC revision B:

$ make -f soc.mak clean
$ make -f soc.mak SOC=iMX8QM REV=B0 MKIMG=./mkimage_imx8 PAD_IMAGE=./pad_image.sh flash_spl
$ mv flash.bin imx-boot-sd.bin

Build boot image for SOC revision C:

$ make -f soc.mak clean
$ make -f soc.mak SOC=iMX8QM REV=C0 MKIMG=./mkimage_imx8 PAD_IMAGE=./pad_image.sh flash_spl
$ mv flash.bin imx-boot-sd.bin

Install the built U-Boot on an SD card

$ sudo dd if=imx-boot-sd.bin of=/dev/sdX bs=1K seek=32 conv=fsync

(Replace /dev/sdX with the correct device)

If you want to use our recovery SD card to flash the built U-Boot to NAND flash/eMMC, then copy it to the appropriate location in the SD card:

$ sudo cp imx-boot /media/rootfs/opt/images/…

And eject the SD card gracefully from host machine.

Note: If you manually upgrade an existing U-Boot, and you have an old environment saved, it is a good idea to reset your environment to the new default.)

Update your U-Boot out of Flexbuild source tree

$ git pull