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.
The Linaro cross-toolchain for Aarch64 is required to build the Bootloaders/Linux from scratch. The toolchain can be found at linaro.org/downloads/. 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=arm64export PATH=~/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu/bin/:$PATHexport CROSS_COMPILE=aarch64-linux-gnu-
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.
Currently there are no changes necessary for ARM Trusted Firmware. Hence ATF can be build directly from sources provided by NXP:
git clone https://source.codeaurora.org/external/imx/imx-atfcd imx-atfgit checkout imx_4.9.51_imx8_beta2
Build the firmware for i.MX 8QuadMax
make PLAT=imx8qm bl31
build/imx8qm/release/bl31.bin will be used in the final container.
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 https://git.toradex.com/u-boot-toradex.gitcd u-boot-toradexgit checkout toradex_imx_v2017.03_4.9.51_imx8_beta2-bring_up
make apalis-imx8_defconfigmake -j 4
u-boot.bin will be used in the final 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 https://source.codeaurora.org/external/imx/imx-mkimage/cd imx-mkimagegit checkout imx_4.9.51_imx8_beta2curl https://raw.githubusercontent.com/toradex/meta-fsl-bsp-release/toradex_morty-4.9.51-8qm_beta2-bring_up/imx/meta-bsp/recipes-bsp/imx-mkimage/files/0001-add-board-support-for-DCD-memory-timings.patch | patch -p 1curl https://raw.githubusercontent.com/toradex/meta-fsl-bsp-release/toradex_morty-4.9.51-8qm_beta2-bring_up/imx/meta-bsp/recipes-bsp/imx-mkimage/files/0002-add-memory-timings-for-Apalis-iMX8.patch | patch -p 1
Copy all required binaries in place
cp ../apalis-imx8-scfw-tcm.bin iMX8QM/scfw_tcm.bincp ../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
The kernel and device tree is somewhat alreade
git clone https://git.toradex.com/linux-toradex.gitcd linux-toradexgit checkout toradex_imx_4.9.51_imx8_beta2-bring_up
make defconfigmake -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.