VAR-SOM-MX6 DART eMMC flashing Jethro

From Variscite Wiki
VAR-SOM-MX6 - DART eMMC flashing

1 Introduction

The Variscite DART-MX6 SOM has an on-SOM eMMC which can be used to boot from and to hold the filesystem.

NOTE:
This Wiki is only valid for DART-MX6

2 eMMC structure

0-4 MiB      : Non-partitioned space, saved for U-Boot.
4-12 MiB    : "BOOT-VARSOM" - A FAT16 partition containing the Linux image and the device tree blob/s.
12 MiB-End: "rootfs" - An ext4 partition containing the root file system (including the kernel modules).

3 Yocto Build results

The resulted images are located at tmp/deploy/images/var-som-mx6.
Looking at tmp/deploy/images/var-som-mx6 you will find the following five required files for a complete system:
SPL, U-Boot, uImage, dtb file, file system image file.

Image Name
How to use
fsl-image-gui-var-som-mx6.tar.bz2 Tarball of the rootfs
uImage Linux kernel image
SPL-sd SPL for SD/eMMC
u-boot-sd-2015.04-r0.img U-Boot for SD/eMMC
Device Tree Name
SOM type
Carrier Board type
LCD Type
Evaluation Kit name
uImage-imx6q-var-dart.dtb VAR-SOM-SOLO / VAR-SOM-DUAL VAR-DT6CustomBoard Capacitive LVDS touch VAR-DVK-DT6
VAR-STK-DT6

4 Installing the Yocto binaries

If you followed the Create an extended SD card steps, the Yocto binaries and the eMMC flashing scripts will be included in your SD card.
The eMMC flashing scripts are easy-to-use example scripts for flashing images into eMMC.
There is also a section below describing how to flash the images manually.

4.1 eMMC images locations

Following is the directory structure on your SD card, which elaborates the files' location that the below flashing scripts are expecting:

/opt/images/
└── Yocto
    ├── SPL.mmc
    ├── rootfs.tar.bz2
    ├── u-boot.img.mmc
    ├── uImage
    └── uImage-imx6q-var-dart.dtb

4.1.1 Prepare the images for eMMC flashing

Plug the bootable SD card into your host machine and mount the rootfs partition - here we assume it is mounted on /media/rootfs.
Copy all the mentioned yocto-built binaries to the SD card:

$ export YOCTO_IMGS_PATH=~/var-som-mx6-yocto-jethro/tmp/deploy/images/var-som-mx6
$ export P2_MOUNT_DIR=/media/rootfs/

Linux:
$ sudo cp ${YOCTO_IMGS_PATH}/uImage			${P2_MOUNT_DIR}/opt/images/Yocto/

SPL/U-Boot:
$ sudo cp ${YOCTO_IMGS_PATH}/SPL-sd			${P2_MOUNT_DIR}/opt/images/Yocto/SPL.mmc
$ sudo cp ${YOCTO_IMGS_PATH}/u-boot-sd-2015.04-r0.img	${P2_MOUNT_DIR}/opt/images/Yocto/u-boot.img.mmc

File System:
$ sudo cp ${YOCTO_IMGS_PATH}/fsl-image-gui-var-som-mx6.tar.bz2	${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.tar.bz2

Device Tree:
$ sudo cp ${YOCTO_IMGS_PATH}/uImage-imx6q-var-dart.dtb	${P2_MOUNT_DIR}/opt/images/Yocto/

4.2 eMMC flashing scripts

The flashing scripts are located on the SD card at /usr/bin/:

install_yocto.sh	- Flash Yocto into NAND flash or eMMC (Run and follow usage instructions to install Yocto to DART eMMC)
(install_yocto_emmc.sh	- This script is being called by install_yocto.sh - it should not be called directly!)

4.3 Manual step-by-step flashing to eMMC

Flashing the eMMC requires several steps including flashing of U-Boot and the Linux kernel, partitioning, file system formatting and image extraction.
We recommend to use our provided scripts to perform this task.

Use the prepared SD card to boot the board and run the following:

$ export node=/dev/mmcblk2
$ cd /opt/images/Yocto

Make sure the eMMC is not mounted:

$ umount ${node}p*

Delete current data on eMMC:

$ dd if=/dev/zero of=${node}p1 bs=1024 count=1024
$ dd if=/dev/zero of=${node}p2 bs=1024 count=1024
$ dd if=/dev/zero of=${node}p3 bs=1024 count=1024
$ dd if=/dev/zero of=${node}p4 bs=1024 count=1024
$ dd if=/dev/zero of=${node}p5 bs=1024 count=1024
$ dd if=/dev/zero of=${node}p6 bs=1024 count=1024
$ dd if=/dev/zero of=${node}p7 bs=1024 count=1024
$ sync
$ (echo d; echo 1; echo d; echo 2; echo d; echo 3; echo d; echo w) | fdisk $node
$ sync
$ dd if=/dev/zero of=$node bs=1M count=4
$ sync

Create a partition table:

$ (echo n; echo p; echo 1; echo 8192; echo 24575; echo t; echo c; \
   echo n; echo p; echo 2; echo 24576; echo; \
   echo p; echo w) | fdisk -u $node
$ sync

Format the partitions:

$ mkfs.vfat ${node}p1 -n BOOT-VARSOM
$ mkfs.ext4 ${node}p2 -L rootfs
$ sync

Flash SPL and U-Boot:

$ sudo dd if=SPL.mmc of=${node} bs=1K seek=1; sync
$ sudo dd if=u-boot.img.mmc of=${node} bs=1K seek=69; sync

Copy the Linux kernel image and the device tree blob to the BOOT partition:

$ mkdir /run/media/mmcblk2p1
$ mount -t vfat ${node}p1	/run/media/mmcblk2p1
$ cp uImage-imx6q-var-dart.dtb	/run/media/mmcblk2p1/imx6q-var-dart.dtb
$ cp uImage			/run/media/mmcblk2p1/uImage
$ sync
$ umount /run/media/mmcblk2p1

Extract the rootfs archive:

$ mkdir /run/media/mmcblk2p2
$ mount ${node}p2 /run/media/mmcblk2p2
$ tar xvpf rootfs.tar.bz2 -C /run/media/mmcblk2p2
$ sync
$ umount /run/media/mmcblk2p2

5 Summary

This page is only valid for DART-MX6. We described the results of a Yocto build, how to copy it to a bootable SD card and how to flash it to eMMC.
With our extended SD card and our recovery SD card we provide an installation script located at /usr/bin/install_yocto.sh. It is much safer to use it instead of flashing the system manually.