Skip to content

2. Make mkimage

Edwin edited this page Dec 27, 2018 · 3 revisions

Make mkimage

To build a boot-able boot loader, we have to make the uboot to a flash.bin binary. To did this we have to do following step.

Get mkimage

Clone from CodeAurora.
Get to your branch.

git clone https://source.codeaurora.org/external/imx/imx-mkimage/
git checkout imx_4.9.123_imx8mm_ga

ARM Trusted Firmware (ATF)

To build ATF, please see ATF Tutorial for detail.
Remind that, if you are using Ubuntu 16.04 just like me.
I strongly skip this step, and using the binary file that provided by NXP.

With Ubuntu 16.04, the is a bug confirmed by GNU, and user.
That with binutils 2.26, you will get the error message when compiling.

Download bl31 from NXP : BL31 (It worked with different branches and OS)

SC Firmware

Download firmware-imx from NXP : firmware-imx

# platform=iMX8dv / iMX8M / iMX8QM / iMX8QX
platform="iMX8M"
wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-7.9.bin
chmod +x firmware-imx-7.9.bin
./firmware-imx-7.9.bin

Copy Require File

Run my script and copy all the required files from util folder.
Of course, if you want to did it manually, here you go :

1. Copy files from UBoot

# platform=iMX8dv / iMX8M / iMX8QM / iMX8QX
platform="iMX8M"
cp uboot/tools/mkimage                     mkimage/$platform/mkimage_uboot
cp uboot/arch/arm/dts/fsl-imx8mq-evk.dtb   mkimage/$platform/
cp uboot/spl/u-boot-spl.bin                mkimage/$platform/
cp uboot/u-boot-nodtb.bin                  mkimage/$platform/

2. Copy BL31 and firmware-imx

copy from util folder.

cp util/bl31.bin    mkimage/$platform/

cp firmware-imx-7.9/firmware/hdmi/cadence/signed_hdmi_imx8m.bin         mkimage/$platform/
cp firmware-imx-7.9/firmware-imx-7.9/firmware/ddr/synopsys/lpddr4*.bin  mkimage/$platform/

Make flash.bin

Now your mkimage folder might be like this:

mkimage
├── COPYING
├── iMX8dv
├── iMX8M
│   ├── bl31.bin
│   ├── fsl-imx8mq-evk.dtb
│   ├── lib
│   │   └── ddr_memory_map.h
│   ├── lpddr4_pmu_train_1d_dmem.bin
│   ├── lpddr4_pmu_train_1d_imem.bin
│   ├── lpddr4_pmu_train_2d_dmem.bin
│   ├── lpddr4_pmu_train_2d_imem.bin
│   ├── mkimage_fit_atf.sh
│   ├── mkimage_imx8.c
│   ├── mkimage_uboot
│   ├── print_fit_hab.sh
│   ├── README
│   ├── signed_hdmi_imx8m.bin
│   ├── soc.mak
│   ├── u-boot-nodtb.bin
│   └── u-boot-spl.bin
├── iMX8QM
├── iMX8QX
├── Makefile
├── mksdcard.sh
├── README
├── scripts
│   ├── fspi_header
│   ├── fspi_packer.sh
│   └── qspi_header
└── src


Run make with your platform, and option for hdmi setting. ``` make -j 16 SOC=iMX8M flash_hdmi_spi_uboot ```

Dump Bootloader to SD card

Make sure you already did Setup SD Card Partition
dd image to specific address.

# platform=iMX8dv / iMX8M / iMX8QM / iMX8QX
platform="iMX8M"
sudo dd if=mkimage/$platform/flash.bin of=/dev/sd<x> bs=1k seek=33 status=progress && sync

Now your can boot with SD Card!
Enjoy!