Sometimes it is helpful/faster to build a i.MX8MM boot binary outside of the Yocto environment.
There are instructions on how to accomplish this on different places, this document tries to provide an example for the i.MX8M Mini LPDDR4 EVK, whenever possible pointing how to build for other boards.
For the 8MM SoC a boot image is generated by imx-mkimage tool and requires:
- u-boot
- ARM trusted firmware image
- ddr training firmware
1. Download and Build u-boot:
mkdir imx-boot-bin
cdimx-boot-bin
git clone https://source.codeaurora.org/external/imx/uboot-imx.git
cd uboot-imx/
git checkout -b imx_v2019.04_4.19.35_1.1.0 origin/imx_v2019.04_4.19.35_1.1.0
(Optional) Here you can "git log -1" to check that the commit matches SRCREV on the recipe.
Next, use the BSP SDK script to setup the cross compilation environment, instructions on how to build it are here.
source /opt/fsl-imx-wayland/4.19-warrior/environment-setup-aarch64-poky-linux
export ARCH=arm
Build
make clean
Supported boards have configuration files on "configs". Using the LPDDR4 EVK here:
make imx8mm_evk_defconfig
make
2. Download and build the ARM Trusted Firmware
cd ..
git clone https://source.codeaurora.org/external/imx/imx-atf.git
cd imx-atf/
git checkout -b imx_4.19.35_1.1.0 origin/imx_4.19.35_1.1.0
(Optional) Again, you can "git log -1" to check that the commit matches SRCREV on the recipe.
https://source.codeaurora.org/external/imx/meta-fsl-bsp-release/tree/imx/meta-bsp/recipes-bsp/imx-at...
Build:
make PLAT=imx8mm bl31
If you run into this error:
aarch64-poky-linux-ld.bfd: unrecognized option '-Wl,-O1'
aarch64-poky-linux-ld.bfd: use the --help option for usage information
make: *** [Makefile:712: build/imx8mm/release/bl31/bl31.elf] Error 1
try:
unset LDFLAGS
make PLAT=imx8mm bl31
3. Download the LPDDR4 training binaries
It is on firmware-imx, recipe is here:
https://source.codeaurora.org/external/imx/meta-fsl-bsp-release/tree/imx/meta-bsp/recipes-bsp/firmwa...
cd ..
mkdir firmware-imx
cd firmware-imx
wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-8.5.bin
chmod a+x firmware-imx-8.5.bin
./firmware-imx-8.5.bin
4. Download imx-mkimage and build the boot image
cd ..
git clone https://source.codeaurora.org/external/imx/imx-mkimage.git
cd imx-mkimage/
git checkout -b imx_4.19.35_1.1.0 origin/imx_4.19.35_1.1.0
(Optional) "git log -1" matches SRCREV on:
https://source.codeaurora.org/external/imx/meta-fsl-bsp-release/tree/imx/meta-bsp/recipes-bsp/imx-mk...
Now, you can check the build targets and required binaries at iMX8M/soc.mak
For the flash_evk for the imx8mm we will need binaries:
u-boot: u-boot-spl.bin, u-boot-nodtb.bin, fsl-imx8mm-evk.dtb
ARM trusted firmware: bl31.bin
LPDDR4 files: lpddr4_pmu_train_1d_imem.bin lpddr4_pmu_train_1d_dmem.bin lpddr4_pmu_train_2d_imem.bin lpddr4_pmu_train_2d_dmem.bin
mkimage for mkimage_uboot
Copy all these to imx-mkimage/iMX8M/
cp ../uboot-imx/spl/u-boot-spl.bin iMX8M/
cp ../uboot-imx/u-boot-nodtb.bin iMX8M/
cp ../uboot-imx/arch/arm/dts/fsl-imx8mm-evk.dtb iMX8M/
cp ../imx-atf/build/imx8mm/release/bl31.bin iMX8M/
cp ../firmware-imx/firmware-imx-8.5/firmware/ddr/synopsys/lpddr4_pmu_train_* iMX8M/
cp ../uboot-imx/tools/mkimage iMX8M/mkimage_uboot
Build:
make SOC=iMX8MM flash_evk
Output binary is on ./iMX8M/flash.bin
5. Program on the SD Card:
sudo dd if=iMX8M/flash.bin of=/dev/<path to your sd> bs=1024 seek=33