i.MX8 - iMX8MEVK - Yocto - Installing an Image

From RidgeRun Developer Connection
< IMX8‎ | iMX8MEVK‎ | Yocto
Jump to: navigation, search


NXP Partner Program Registered Vertical.jpg NXP Partner Program Horizontal.jpg
Previous: iMX8MEVK/Yocto/Building_Yocto Index Next: iMX8MEVK/Yocto/Alternative image loading





Installing on EMMC

The image installation process on EMMC is similar to system recovery, first take a look to iMX8MEVK system recovery page to be familiar with the process explained here.

Required files

In order to install a Yocto image, download MFG Tool from NXP Support page MFGTool

The downloaded file has 2 compressed files, mfgtool-with-roots-mx8 and mfgtool-without-rootfs-mx8, use mfgtool-with-roots-mx8 because it is already configured with all the required files.

The installation requires 5 files, 2 provided by MFG Tool and 3 provided by Yocto, check list below for more details.

  • Flash script: provided by MFG Tools, this file will flash the board using the specified files (more details in next section).
  • Initramfs: provided by MFG Tools, this file contains a set of memory directions to be loaded into RAM, used before loading the file system.
  • Kernel image: provided by Yocto, this file has drivers and system configurations.
  • Device-Tree: provided by Yocto, this file provides a system description.
  • File system: provided by Yocto, this compressed file contains programs and other files.

Considerations

Before downloading MFG Tool, check which Linux version was used by Yocto. If you used Rocko branch, you must download MFG Tool with linux 4.9.88_2.0.0 to avoid issues while flashing.

Warning: The MFG Tool for Linux has been deprecated and its support is limited. Please, use the Windows version.

MFG Tool description

MFG Tool is used through scripts, those scripts will choose a device to flash (EMMC, SDCARD, others) according to the board. There is a script for flashing IMX8MQ evaluation kit using EMMC, at the end this script will flash the desired image to the board but some changes are needed before.

MFG Tools contains a file named Universal Command List which contains all the commands for each script, check <MFGTOOL_DIR>/Profiles/Linux/OS Firmware/ucl2.xml. Each command has multiple details but the relevant ones are Description, file and ifdev.

Command example:

<CMD state="BootStrap" type="load" file="firmware/Image" address="0x80280000" loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX8QXP MX8QM">Loading Kernel.</CMD>

The ifdev refers to device, as example, IMX8MQ Evaluation Kit is used as MX8MQ so only the commands with ifdev="MX8MQ" will run.

In the section EMMC, the commands with ifdev="MX8MQ" and file must be changed, set file to your desired file. By default, those commands will use files from <MFGTOOL_DIR>/Profiles/Linux/OS Firmware/firmware. In order to use your files, you can replace the files under the firmware folder or create a new folder under OS Firmware.

Configuration Example

As example, a new folder named imx8 was created under OS Firmware with 5 files, check list below:

  • imx-boot.bin-flash_evk: script copied from firmware folder.
  • initramfs.cpio.gz.u-boot: file copied from firmware folder.
  • rootfs.tar.bz2: rootfs renamed from Yocto.
  • Image.bin: file extracted from Yocto.
  • imx8mq-evk.dtb: device-tree renamed from Yocto

Example command list (only EMMC section):

<LIST name="eMMC" desc="Choose eMMC as media">
<CMD state="BootStrap" type="boot" body="BootStrap" file="firmware/imx-boot-imx8qm%ddr%%board%-sd.bin-flash_dcd" ifdev="MX8QM">Loading U-boot</CMD>
<CMD state="BootStrap" type="boot" body="BootStrap" file="firmware/imx-boot-imx8qxp%ddr%%board%-sd.bin-flash_dcd" ifdev="MX8QXP">Loading U-boot</CMD>
<CMD state="BootStrap" type="boot" body="BootStrap" file="imx8/imx-boot.bin-flash_evk" ifdev="MX8MQ">Loading U-boot</CMD>
<CMD state="BootStrap" type="load" file="firmware/Image" address="0x80280000" loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX8QXP MX8QM">Loading Kernel.</CMD>
<CMD state="BootStrap" type="load" file="imx8/Image.bin" address="0x40480000" loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX8MQ">Loading Kernel.</CMD>
<CMD state="BootStrap" type="load" file="firmware/%initramfs%" address="0x83800000" loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX8QM MX8QXP">Loading Initramfs.</CMD>
<CMD state="BootStrap" type="load" file="imx8/initramfs.cpio.gz.u-boot" address="0x43800000" loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX8MQ">Loading Initramfs.</CMD>
<CMD state="BootStrap" type="load" file="firmware/fsl-imx8qm%dash%%ddr%-%board%.dtb" address="0x83000000" loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX8QM">Loading device tree.</CMD>
<CMD state="BootStrap" type="load" file="firmware/fsl-imx8qxp%dash%%ddr%-%board%.dtb" address="0x83000000" loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX8QXP">Loading device tree.</CMD>
<CMD state="BootStrap" type="load" file="imx8/imx8mq-evk.dtb" address="0x43000000" loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX8MQ">Loading device tree.</CMD>
<CMD state="BootStrap" type="jump"> Jumping to OS image. </CMD>
<!-- create partition -->
<CMD state="Updater" type="push" body="send" file="mksdcard.sh.tar">Sending partition shell</CMD>
<CMD state="Updater" type="push" body="$ tar xf $FILE "> Partitioning...</CMD>
<CMD state="Updater" type="push" body="$ sh mksdcard.sh /dev/mmcblk%mmc%"> Partitioning...</CMD>
<!-- burn uboot -->
<CMD state="Updater" type="push" body="$ dd if=/dev/zero of=/dev/mmcblk%mmc% bs=1k seek=4096 conv=fsync count=8">clear u-boot arg</CMD>
<!-- access boot partition -->
<CMD state="Updater" type="push" body="$ echo 0 > /sys/block/mmcblk%mmc%boot0/force_ro">access boot partition 1</CMD>
<CMD state="Updater" type="push" body="send" file="files/imx-boot-imx8qm%ddr%%board%-sd.bin-flash" ifdev="MX8QM">Sending u-boot.bin</CMD>
<CMD state="Updater" type="push" body="send" file="files/imx-boot-imx8qxp%ddr%%board%-sd.bin-flash" ifdev="MX8QXP">Sending u-boot.bin</CMD>
<CMD state="Updater" type="push" body="send" file="imx8/imx-boot.bin-flash_evk" ifdev="MX8MQ">Sending u-boot.bin</CMD>
<CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mmcblk%mmc%boot0 bs=1k seek=33">write U-Boot to sd card</CMD>
<CMD state="Updater" type="push" body="$ echo 1 > /sys/block/mmcblk%mmc%boot0/force_ro"> re-enable read-only access </CMD>
<CMD state="Updater" type="push" body="$ mmc bootpart enable 1 1 /dev/mmcblk%mmc%">enable boot partion 1 to boot</CMD>
<!-- create fat partition -->
<CMD state="Updater" type="push" body="$ while [ ! -e /dev/mmcblk%mmc%p1 ]; do sleep 1; echo waiting...; done ">Waiting for the partition ready</CMD>
<CMD state="Updater" type="push" body="$ mkfs.vfat /dev/mmcblk%mmc%p1">Formatting rootfs partition</CMD>
<CMD state="Updater" type="push" body="$ mkdir -p /mnt/mmcblk%mmc%p1"/>
<CMD state="Updater" type="push" body="$ mount -t vfat /dev/mmcblk%mmc%p1 /mnt/mmcblk%mmc%p1"/>
<!-- burn zImage -->
<CMD state="Updater" type="push" body="send" file="imx8/Image.bin">Sending kernel</CMD>
<CMD state="Updater" type="push" body="$ cp $FILE /mnt/mmcblk%mmc%p1/Image">write kernel image to sd card</CMD>
<!-- burn dtb -->
<CMD state="Updater" type="push" body="send" file="files/fsl-imx8qm%dash%%ddr%-%board%.dtb" ifdev="MX8QM">Sending Device Tree file</CMD>
<CMD state="Updater" type="push" body="send" file="files/fsl-imx8qxp%dash%%ddr%-%board%.dtb" ifdev="MX8QXP">Sending Device Tree file</CMD>
<CMD state="Updater" type="push" body="send" file="imx8/imx8mq-evk.dtb" ifdev="MX8MQ">Sending Device Tree file</CMD>
<CMD state="Updater" type="push" body="$ cp $FILE /mnt/mmcblk%mmc%p1/fsl-imx8qm%dash%%ddr%-%board%.dtb" ifdev="MX8QM">write device tree to sd card</CMD>
<CMD state="Updater" type="push" body="$ cp $FILE /mnt/mmcblk%mmc%p1/fsl-imx8qxp%dash%%ddr%-%board%.dtb" ifdev="MX8QXP">write device tree to sd card</CMD>
<CMD state="Updater" type="push" body="$ cp $FILE /mnt/mmcblk%mmc%p1/fsl-imx8mq-evk.dtb" ifdev="MX8MQ">write device tree to sd card</CMD>
<!-- burn m4 demo bins-->
<CMD state="Updater" type="push" body="$ umount /mnt/mmcblk%mmc%p1">Unmounting vfat partition</CMD>
<!-- burn rootfs -->
<CMD state="Updater" type="push" body="$ mkfs.ext3 -F -E nodiscard /dev/mmcblk%mmc%p2">Formatting rootfs partition</CMD>
<CMD state="Updater" type="push" body="$ mkdir -p /mnt/mmcblk%mmc%p2"/>
<CMD state="Updater" type="push" body="$ mount -t ext3 /dev/mmcblk%mmc%p2 /mnt/mmcblk%mmc%p2"/>
<CMD state="Updater" type="push" body="pipe tar -jxv -C /mnt/mmcblk%mmc%p2" file="imx8/rootfs.tar.bz2">Sending and writting rootfs</CMD>
<CMD state="Updater" type="push" body="frf">Finishing rootfs write</CMD>
<CMD state="Updater" type="push" body="$ umount /mnt/mmcblk%mmc%p2">Unmounting rootfs partition</CMD>
<CMD state="Updater" type="push" body="$ echo Update Complete!">Done</CMD>
</LIST>

Flashing Board

After updating the ucl2.xml file, set your board to serial download mode and run mfgtool2-yocto-mx8-evk-emmc1.vbs.

When the process finished, your IMX8MQ Evaluation Kit will be running the Yocto image.

Known Issues

The files copied from MFG Tool can be generated with Yocto but, in our tests those files with did not work and MFG Tool ended in a flashing loop. For a successful flash, use the files provided in MFG Tool.

MFG Tool should be launched after plugging in the board in serial download mode, otherwise MFG Tool will not detect the board.

Installing on SDcard

In order to install an image, you must identify your device ID. Check it as follows:

blkid -o list

This is an output example:

user@laptop:~$ blkid -o list
device                     fs_type         label            mount point                     UUID
--------------------------------------------------------------------------------------------------------------------------------
/dev/sda1                  ext4                             /                               819c76f8-187f-46e9-b0c0-350032625bb3
/dev/sda3                  ext4            data             /media/user/data                571e7aea-202e-4daa-8071-a1fc1207f458
/dev/sda5                  swap                             [SWAP]                          4018cfb5-4201-4656-a005-4fe04d06dde1
/dev/sdb1                  ext4            sdcard           (not mounted)                   fe2353ea-7436-457e-9447-8e3f721b0c43
/dev/sdb2

Considerations

Each device has numbers at the end, those numbers are related to partitions and they must not be specified to install the image. As example, instead of /dev/sdb1, use /dev/sdb.

Also, the device must be not mounted to successfully write the image.

If the required device appears with an mount point, unmount each partition with umount command.

PARTITION=/dev/sdb1 # The device may change in your system
sudo umount $PARTITION

Installing

Yocto supports several image formats, as example ext4, img, sdcard and wic.

Those files will be created in <Yocto_Dir>/build/tmp/deploy/images/imx8mevk.

In old Yocto versions (before Sumo) the most common image type was sdcard, use dd with this image type.

IMAGE=fsl-image-multimedia-full-imx8mqevk-20181018224131.rootfs.sdcard
DEVICE=/dev/sdb # The device may change in your system
sudo dd if=$IMAGE of=$DEVICE bs=4M && sync

Recent Yocto versions (Sumo and newer) have wic image type as default format, use bmaptool as follows:

IMAGE=fsl-image-multimedia-full-imx8mqevk-20181018224131.rootfs.wic
DEVICE=/dev/sdb # The device may change in your system
sudo bmaptool copy $IMAGE $DEVICE --nobmap

In case the image file (.sdcard) is not found in the image directory, decompress the image file from the .bz2 file. To decompress it, use:

IMAGE=fsl-image-multimedia-full-imx8mqevk-20181018224131.rootfs.bzip2
bzip2 $IMAGE


Previous: iMX8MEVK/Yocto/Building_Yocto Index Next: iMX8MEVK/Yocto/Alternative image loading