mirror of
https://github.com/feyisay07/meta-bsp-imx8mm.git
synced 2026-09-24 06:10:13 +01:00
4.7 KiB
4.7 KiB
Building Boot Firmware for CompuLab's i.MX8M Mini products with Mkimage
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.0 |
| CompuLab branch name | export CPL_BRANCH=lf-5.10.72-2.2.0_${MACHINE} |
| Mkimage revision | export MKIMG=lf-5.10.72-2.2.0 |
| 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
- 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
export SRC_ROOT=$(readlink -f imx8mm)
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
Mkimage setup
- Download the mkimage:
git clone https://source.codeaurora.org/external/imx/imx-mkimage.git
git -C imx-mkimage checkout ${MKIMG}
export RESULTS=${SRC_ROOT}/imx-mkimage/iMX8M
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
ARCHenvironment variables:
export ARCH=arm64
- Compile U-Boot flash.bin:
make -j 16 -C uboot-imx -f defconfig.mk make -j 16 -C uboot-imx
- Copy files to the results directory
cp -v $(find uboot-imx | awk -v v=${MACHINE} '(/u-boot-spl.bin$|u-boot.bin$|u-boot-nodtb.bin$|tools\/mkimage$/)||($0~v".dtb$")' ORS=" ") ${RESULTS}
Compiling the flash.bin imx-boot image
- Unset these variables:
unset ARCH CROSS_COMPILE
Issue:
cd ${RESULTS}
sed "s/\(^dtbs \).*/\1= ${MACHINE}.dtb/;s/\(mkimage\)_uboot/\1/;s/\(^TEE_LOAD_ADDR \).*/\1= 0x56000000/g" soc.mak > Makefile
make clean
make flash_evk SOC=iMX8MM
Issue the following commands to generate log files for the HAB signing operation:
make SOC=iMX8MM flash_evk 2>&1 | tee flash_evk.log make SOC=iMX8MM print_fit_hab 2>&1 | tee print_fit_hab.log
Flashing
echo 0 > /sys/class/block/mmcblk2boot0/force_ro dd if=flash.bin of=/dev/mmcblk2boot0 bs=1K seek=33 status=progress echo 1 > /sys/class/block/mmcblk2boot0/force_ro