Search by Tags

Build Apalis iMX8 Boot Image/Linux from Scratch

Subscribe for this article updates

The NXP i.MX 8QuadMax SoC boot process is a bit more involved then the typical SoC used by Toradex. This article describes how to build the boot image (including required integration of firmwares and boot loader) and Linux manually.


The NXP i.MX 8QuadMax boots using a Cortex-M4 boot CPU called System Controller Unit (SCU). The SCU firmware is to a large part provided by NXP, but has been slightly altered by Toradex for the Apalis iMX8. The firmware also loads an intermediate firmware running on the Cortex-A class CPUs: The ARM trusted firmware (ATF). The ARM trusted firmware then hands over control to U-Boot which then is able to boot Linux.

The DDR memory timings, the SCU, the ATF and U-Boot as well as any potential Cortex-M4 auxiliary firmwares are all stored in a single boot container. This boot container is read by the boot ROM and located at an offset of 33kB on the boot device.

Prepare Cross Compiler

The Linaro cross-toolchain for Aarch64 is required to build the Bootloaders/Linux from scratch. The toolchain can be found at The latest aarch64-linux-gnu toolchain should work fine. At Toradex we tested the 2017.11 release which comes with GCC 7.2.1.

Make sure you extract the toolchain and setup the environment accordingly:

cd ~/
tar xJf gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu.tar.xz
export ARCH=arm64
export PATH=~/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu/bin/:$PATH
export CROSS_COMPILE=aarch64-linux-gnu-

Build the Boot Container

Obtain SCU

Currently the SCU Firmware for Apalis iMX8 is stored in the Bring-up BSP layer in imx/meta-bsp/recipes-bsp/imx-sc-firmware/files/apalis-imx8-scfw-tcm.bin.


Build ARM Trusted Firmware

Currently there are no changes necessary for ARM Trusted Firmware. Hence ATF can be build directly from sources provided by NXP:

git clone
cd imx-atf
git checkout imx_4.9.51_imx8_beta2

Build the firmware for i.MX 8QuadMax

make PLAT=imx8qm bl31

The binary build/imx8qm/release/bl31.bin will be used in the final container.

Build U-Boot

Toradex uses a customized version of the U-Boot boot loader provided by the NXP BSP. It can be found on our git server in the u-boot-toradex repository.

git clone
cd u-boot-toradex
git checkout toradex_imx_v2017.03_4.9.51_imx8_beta2-bring_up
make apalis-imx8_defconfig
make -j 4

The binary u-boot.bin will be used in the final container.

Assemble the Boot Container

The utility imx-mkimage allows to build the final bootable image. It needs small modifications which are available as patches from the Bring-up BSP layer.

git clone
cd imx-mkimage
git checkout imx_4.9.51_imx8_beta2
curl | patch -p 1
curl | patch -p 1

Copy all required binaries in place

cp ../apalis-imx8-scfw-tcm.bin iMX8QM/scfw_tcm.bin
cp ../imx-atf/build/imx8qm/release/bl31.bin iMX8QM/
cp ../u-boot-toradex/u-boot.bin iMX8QM/

Use make to build the boot image

make SOC=iMX8QM DCD_BOARD=apalis-imx8 flash_dcd

Flash the boot container onto the boot device, typically an SD card:

dd if=iMX8QM/flash.bin of=/dev/<your device> bs=1k seek=33

Build Linux

The kernel and device tree is somewhat alreade

git clone
cd linux-toradex
git checkout toradex_imx_4.9.51_imx8_beta2-bring_up
make defconfig
make -j 4

On successful compilation, the kernel will be available at arch/arm64/boot/Image and the device tree in arch/arm64/boot/dts/freescale/fsl-imx8qm-apalis.dtb. By default the U-Boot boot scripts try to load the kernel and device tree from the first FAT partition of the SD card.