How to build I.MX Bootloader for i.MX 8QuadMax MEK CPU Board.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to build I.MX Bootloader for i.MX 8QuadMax MEK CPU Board.

How to build I.MX Bootloader for i.MX 8QuadMax MEK CPU Board.

     The following steps allow you to build a bootable image in two different ways and also how to enable and use SCFW debug monitor. There are four files needed to generate a bootable image:

├── bl31.bin
├── u-boot.bin  
├── mx8qm-ahab-container.img    
└── scfw_tcm.bin

There are some ways to get the four files, one way is with Yocto and other way is with stand alone build.

Get the four files needed to generate a bootable image with Yocto.

 

To get the four files needed with Yocto, you have to build an i.MX 8QuadMax image, maybe some steps are not necessary.

1.-Host packages.

sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \ 
build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \ xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa \ 
libsdl1.2-dev pylint3 xterm rsync curl

2.-Setting up the Repo utility.

mkdir ~/bin (this step may not be needed if the bin folder already exists)

curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo

chmod a+x ~/bin/repo

export PATH=~/bin:$PATH

3.-Yocto Project Setup.

git config --global user.name "Your Name"

git config --global user.email "Your Email"

git config --list

mkdir imx-yocto-bsp

cd imx-yocto-bsp

repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-linux-hardknott -m imx-5.10.72-2.2.0.xml

repo sync

4.-Build configurations.

DISTRO=fsl-imx-xwayland MACHINE=imx8qmmek source imx-setup-release.sh -b imx8qmmek

5.-Building an image.

bitbake imx-image-full

The four files needed to generate a bootable image are in:

~/imx-yocto-bsp/imx8qmmek/tmp/deploy/images/imx8qmmek/imx-boot-tools

Note: With Yocto you can not enable the SCFW debug monitor.

For more information see the i.MX Yocto Project User's Guide.

Get the four files needed to generate a bootable image with stand alone build.

 

To build all required binaries from source you can use standard aarch64 Linux toolchain, on Ubuntu 20.04 LTS:

sudo apt-get install gcc-aarch64-linux-gnu

Get the bl31.bin file - Arm Trust Firmware.

 

Download source from:

git clone -b lf-5.10.72-2.2.0 https://source.codeaurora.org/external/imx/imx-atf

Build:

cd imx-atf

make clean PLAT=imx8qm CROSS_COMPILE=aarch64-linux-gnu-

make PLAT=imx8qm CROSS_COMPILE=aarch64-linux-gnu- bl31

The compiled bl31.bin location:

build/imx8qm/release/bl31.bin

Get the u-boot.bin file - u-boot.

 

Download source from:

git clone -b lf-5.10.72-2.2.0 https://source.codeaurora.org/external/imx/uboot-imx

Build:

cd uboot-imx

make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- imx8qm_mek_defconfig

make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu-

The compiled u-boot.bin location:

./u-boot.bin

Get the mx8qmb0-ahab-container.img file - iMX Seco.

wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/imx-seco-3.7.4.bin

chmod +x imx-seco-3.7.4.bin

./imx-seco-3.7.4.bin --auto-accept

The mx8qmb0-ahab-container.img file location:

imx-seco-3.7.4/firmware/seco/mx8qmb0-ahab-container.img

Get the scfw_tcm.bin file - SCFW.

 

Download and Install a GNU Toolchain.

 

Look at the packages/imx-scfw-porting-kit-1.7.4/doc/pdf/, chapter Porting Guide, sub-chapter Tool Chain to check which GNU Toolchain version corresponds to the SCFW you are building. The imx-scfw-porting-kit-1.7.4 version uses the GNU Toolchain version gcc-arm-none-eabi-8-2018-q4-major. It is recommended to install toolchain in “opt” folder:

cd /opt

sudo wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/8-2018q4/gcc-arm-none-eabi-8-2018-q4-major-linux.tar.bz2

sudo tar xjf gcc-arm-none-eabi-8-2018-q4-major-linux.tar.bz2

Download and Install a Arm GCC toolchain.

It is recommended to install toolchain in “opt” folder:

sudo wget https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz

sudo tar -Jxvf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz

After installing the toolchain, set up the environment variable relevant for building.

export ARCH=arm

CROSS_COMPILE=/opt/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-

export TOOLS=/opt

Build the scfw_tcm.bin file.

cd ~

wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/imx-scfw-porting-kit-1.7.4.bin

chmod +x imx-scfw-porting-kit-1.7.4.bin

./imx-scfw-porting-kit-1.7.4.bin --auto-accept

cd imx-scfw-porting-kit-1.7.4/src

Extract the desired scfw porting kit:

tar -xvf scfw_export_mx8qm_b0.tar.gz

cd scfw_export_mx8qm_b0/

Build without debug monitor:

make clean

make qm B=mek R=B0

Build with debug monitor:

make clean

make qm B=mek D=1 M=1 R=B0 DDR_CON=imx8qm_dcd_1.6GHz

The scfw_tcm.bin file location:

build_mx8qm_b0/scfw_tcm.bin

 

Generate the bootable image.

 

Once you have the four files needed to generate a bootable image, use imx-mkimage tool.

Download source from:

git clone -b lf-5.10.72-2.2.0 https://source.codeaurora.org/external/imx/imx-mkimage

Copy the four binaries to iMX8QM folder.

You have to rename some files.

If you got the four binaries with Yocto.

cp ~/imx-yocto-bsp/imx8qmmek/tmp/deploy/images/imx8qmmek/imx-boot-tools/bl31-imx8qm.bin ~/imx-mkimage/iMX8QM/bl31.bin

cp ~/imx-yocto-bsp/imx8qmmek/tmp/deploy/images/imx8qmmek/imx-boot-tools/u-boot-imx8qmmek.bin-sd ~/imx-mkimage/iMX8QM/u-boot.bin

cp ~/imx-yocto-bsp/imx8qmmek/tmp/deploy/images/imx8qmmek/imx-boot-tools/mx8qmb0-ahab-container.img ~/imx-mkimage/iMX8QM

cp ~/imx-yocto-bsp/imx8qmmek/tmp/deploy/images/imx8qmmek/imx-boot-tools/mx8qm-mek-scfw-tcm.bin ~/imx-mkimage/iMX8QM/scfw_tcm.bin

If you got the four binaries with stand alone build.

cp ~/imx-atf/build/imx8qm/release/bl31.bin ~/imx-mkimage/iMX8QM

cp ~/uboot-imx/u-boot.bin ~/imx-mkimage/iMX8QM

cp ~/imx-seco-3.7.4/firmware/seco/mx8qmb0-ahab-container.img ~/imx-mkimage/iMX8QM

cp ~/imx-scfw-porting-kit-1.7.4/src/scfw_export_mx8qm_b0/build_mx8qm_b0/scfw_tcm.bin ~/imx-mkimage/iMX8QM

Build the bootable image.

cd ~/imx-mkimage

make SOC=iMX8QM flash

The compiled file is flash.bin and its location is:

iMX8QM/flash.bin

 

Flash the bootable image.

 

To flash the bootable image follow the next steps:

-Copy the flash.bin and uuu.exe in a folder.

-Change SW2 on the base board to 000100 (from MSB to LSB, 1-ON and 0-OFF) to boot from the Serial Downloader.

-Run the following command in Command Prompt:

uuu.exe -b sd flash.bin

-Power on the MEK CPU board.

 

SCFW debug monitor.

 

     If the SCFW is compiled using the M=1 option (default is M=0) then it will include a debug monitor. This can be used to R/W memory or registers, R/W power state, and dump some resource manager state. Production SCFW should never have the monitor enabled (M=0, the default)!

     The debug monitor allows command-line interaction via the SCU UART. Inclusion of the debug monitor affects SCFW timing and therefore should never be deployed in a product! Note the terminal needs to be in a mode that sends CR or LF for a new line (not CR+LF).

The following commands are supported:

Command                                   Description

exit                                              exit the debug monitor

quit                                              exit the debug monitor

reset [mode]                                request reset with mode (default = board)

reboot partition [type]                  request partition reboot with type (default = cold)

md.b address [count]                  display count bytes at address

md.w address [count]                 display count words at address

md[.l] address [count]                 display count long-words at address

mm.b address value                   modify byte at address

mm.w address value                  modify word at address

mm[.l] address value                  modify long-word at address

ai.r ss sel addr                            read analog interface (AI) register

ai.w ss sel addr data                  write analog interface (AI) register

fuse.r word                                 read OTP fuse word

fuse.w word value                      write value to OTP fuse word

dump rm                                    dump all the resource manager (RM) info

dump rm part [part]                    dump all partition info for part (default = all)

dump rm rsrc [part]                    dump all resource info for part (default = all)

dump rm mem [part]                  dump all memory info for part (default = all)

dump rm pad [part]                    dump all pad info for part (default = all)

power.r [resource]                     read/get power mode of resource (default = all)

power.w resource mode            write/set power mode of resource to mode (off, stby, lp, on)

info                                             display SCFW/SoC info like unique ID, etc.

seco lifecycle change                send SECO lifecycle update command (change) to SECO

seco info                                    display SECO info like Lifecycle, SNVS state, etc.

seco debug                                dump SECO debug log

seco events                               dump SECO event log

seco commit                              commit SRK and/or SECO FW version update

pmic.r id reg                               read pmic register

pmic.w id reg val                        write pmic register

pmic.l id                                      list pmic info (rail voltages, etc)

Resource and subsystem (ss) arguments are specified by name. All numeric arguments are decimal unless prefixed with 0x (for hex) or 0 (for octal).

Testing SCFW debug monitor to display count long-words at address on Linux side and on SCU side.

-Change SW2 on the base board to 001100 (from MSB to LSB, 1-ON and 0-OFF) to boot from the SD card.

-Power on the MEK CPU board.

-Open Tera Term and you will see:

Hello from SCU (Build 5263, Commit 9b3d006e, Aug 20 2021 12:20:10)

DDR frequency = 1596000000
 ROM boot time = 262368 usec
     Boot time = 24583 usec
        Banner = 10 usec
          Init = 9038 usec
        Config = 3232 usec
           DDR = 2677 usec
       SConfig = 444 usec
          Prep = 5039 usec

*** Debug Monitor ***

>$

-Run the following commands:

power.r

power.w db on

power.w dblogic on

power.w mu_1a on

-Example reading on Linux side:

md.l 0x5d1c0000 10

-You will see:

>$ md.l 0x5d1c0000 10
5d1c0000: 00000000 00000000 00000000 00000000
5d1c0010: 00010201 23c34600 d63fdb21 00000000
5d1c0020: 00f00200 18000000

-Example reading on SCU side:

md.l 0x41cac080 10

-You will see:

>$ md.l 0x41cac080 10
41cac080: 00000000 00000000 00000000 00000000
41cac090: 0d070201 ff0001f1 ffff8000 ffff00fb
41cac0a0: 00f00000 18000000

For more information see the System Controller Firmware Porting Guide.

No ratings
Version history
Last update:
‎02-21-2022 03:48 PM
Updated by: