# Building Boot Firmware for CompuLab's i.MX8M Mini products Supported machines: * `IOT-GATE-iMX8` Define a `MACHINE` environment variable for the target product: |Machine|Command Line| |---|---| |ucm-imx8m-mini|export MACHINE=iot-gate-imx8 Define the following environment variables: |Description|Command Line| |---|---| |NXP firmware name|export NXP_FIRMWARE=firmware-imx-8.14.bin| |CompuLab release|export CPL_RELEASE=${MACHINE}_r3.1| |CompuLab branch name|export CPL_BRANCH=lf-5.10.72-2.2.0_${MACHINE}| |ATF revision|export ATF=lf-5.10.72-2.2.0| |OPTEE revision|export OPTEE=lf-5.10.72-2.2.0| |U-Boot revision|export UBOOT=lf-5.10.72-2.2.0| ## Prerequisites It is up to developer to setup arm64 build environment: * Download the [ARM tool chain](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads/9-2-2019-12) * Set environment variables:
export ARCH=arm64 export CROSS_COMPILE=/opt/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-* Create a folder to organize the files:
mkdir -p imx8mm/{sources,results}
export SRC_ROOT=$(readlink -f imx8mm/sources)
export RESULTS=$(readlink -f imx8mm/results)
cd ${SRC_ROOT}
* Download CompuLab BSP
git clone -b ${CPL_RELEASE} https://github.com/compulab-yokneam/meta-bsp-imx8mm.git
export LAYER_DIR=$(pwd)/meta-bsp-imx8mm
## Build Procedure
### Firmware iMX setup
* Download the firmware-imx file:
wget http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/${NXP_FIRMWARE}
bash -x ${NXP_FIRMWARE} --auto-accept
cp -v $(find firmware* | awk '/train|hdmi_imx8|dp_imx8/' ORS=" ") ${RESULTS}
### Arm Trusted Firmware (ATF) setup
* Download the ATF:
git clone https://source.codeaurora.org/external/imx/imx-atf.git
git -C imx-atf checkout ${ATF} -b ${CPL_BRANCH}
* Apply patches if applicable:
[[ -d ${LAYER_DIR}/recipes-bsp/imx-atf/compulab/imx8mm ]] && { \
git -C imx-atf am ${LAYER_DIR}/recipes-bsp/imx-atf/compulab/imx8mm/*.patch
}
* Make bl31.bin
|Mode |Command
|---|---|
|optee build|make -j 16 -C imx-atf PLAT=imx8mm BUILD_BASE=build PLAT=imx8mm IMX_BOOT_UART_BASE=0x30880000 BL32_BASE=0x56000000 BL32_SIZE=0x2000000 SPD=opteed bl31
|non-optee build|make -j 16 -C imx-atf PLAT=imx8mm BUILD_BASE=build PLAT=imx8mm IMX_BOOT_UART_BASE=0x30880000 BL32_BASE=0x56000000 BL32_SIZE=0x2000000 bl31
* Ceate a symlink in the ${RESULTS} folder:
ln -s $(readlink -f imx-atf/build/imx8mm/release/bl31.bin) ${RESULTS}/
### OP-TEE Setup
| Skip this for a non-optee build |
| --- |
* Download the OP-TEE:
git clone https://source.codeaurora.org/external/imx/imx-optee-os
git -C imx-optee-os checkout ${OPTEE} -b ${CPL_BRANCH}
* Apply patches if applicable:
[[ -d ${LAYER_DIR}/recipes-security/optee-imx/compulab/imx8mm ]] && { \
git -C imx-optee-os am ${LAYER_DIR}/recipes-security/optee-imx/compulab/imx8mm/*.patch
}
* Set environment variables:
export ARCH=arm
export CROSS_COMPILE64=${CROSS_COMPILE}
* Make tee.bin
make -j 16 -C imx-optee-os PLATFORM=imx PLATFORM_FLAVOR=mx8mm_cl_iot_gate
ln -s $(readlink -f imx-optee-os/out/arm-plat-imx/core/tee-raw.bin) ${RESULTS}/tee.bin
### U-Boot
* Download the U-Boot source and apply CompuLab BSP patches:
git clone https://source.codeaurora.org/external/imx/uboot-imx.git
git -C uboot-imx checkout ${UBOOT} -b ${CPL_BRANCH}
git -C uboot-imx am ${LAYER_DIR}/recipes-bsp/u-boot/compulab/imx8mm/*.patch
* Restore `ARCH` environment variables:
export ARCH=arm64* Compile U-Boot flash.bin:
make -j 16 -C uboot-imx O=${RESULTS} -f defconfig.mk
make -j 16 -C uboot-imx O=${RESULTS}
## Flashing
dd if=${RESULTS}/flash.bin of=/dev/ bs=1K seek=33 status=progress