Skip to content

Latest commit

 

History

History
155 lines (138 loc) · 4.55 KB

imx_boot_image_hab_build.md

File metadata and controls

155 lines (138 loc) · 4.55 KB

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.16.bin
CompuLab release export CPL_RELEASE=${MACHINE}_r3.2
CompuLab branch name export CPL_BRANCH=lf-5.15.32-2.0.0_${MACHINE}
ATF revision export ATF=lf-5.15.32-2.0.0
OPTEE revision export OPTEE=lf-5.15.32-2.0.0
U-Boot revision export UBOOT=lf-5.15.32-2.0.0

Prerequisites

It is up to developer to setup arm64 build environment:

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://github.com/nxp-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://github.com/nxp-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://github.com/nxp-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://github.com/nxp-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 -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