VAR-SOM-MX7 NAND Flash Burning
Introduction
The Variscite VAR-SOM-MX7 has either an on-SOM NAND flash or eMMC, and either of them can be used to boot from and to hold the filesystem.
For NAND flash we use a UBI file system and for eMMC we use ext4.
NAND Structure
These are the defined MTD partitions on the NAND flash:
0x000000000000-0x000000200000 : "spl"
0x000000200000-0x000000400000 : "u-boot"
0x000000400000-0x000000600000 : "u-boot_env"
0x000000600000-0x000000e00000 : "kernel"
0x000000e00000-0x000040000000 : "rootfs"
Note: Since currently there's no SPL support for the i.MX7, the first partition is actually used for U-Boot and the second one is for future use.
Yocto Built binaries for NAND flash
The resulted images are located at tmp/deploy/images/imx7-var-som:
File Name | Description |
---|---|
fsl-image-gui-imx7-var-som.ubi | A complete UBI image containing a UBIFS volume, for writing to NAND flash. |
zImage | Linux kernel image, same binary for SD card/eMMC/NAND flash. |
u-boot.imx-nand | U-Boot built for NAND Flash. |
zImage-imx7d-var-som-nand.dtb | Device tree blob for SOMs with NAND flash. |
NAND Flashing scripts
If you followed the Create an extended SD card steps, the NAND flashing scripts will be included in your SD card.
The NAND flashing scripts are easy-to-use example scripts for burning images into NAND flash / eMMC.
NAND flash 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 ├── rootfs.tar.bz2 ├── rootfs.ubi.img ├── u-boot.img ├── uImage ├── uImage-imx6dl-var-som-cap.dtb ├── uImage-imx6dl-var-som-res.dtb ├── uImage-imx6dl-var-som-solo-cap.dtb ├── uImage-imx6dl-var-som-solo-res.dtb ├── uImage-imx6dl-var-som-solo-vsc.dtb ├── uImage-imx6dl-var-som-vsc.dtb ├── uImage-imx6q-var-som-cap.dtb ├── uImage-imx6q-var-som-res.dtb └── uImage-imx6q-var-som-vsc.dtb
Prepare images for NAND flash / eMMC flashing
Plug the bootable SD card into your host machine.
Then your host machine should mount the rootfs partition on /media/rootfs.
Copy all the mentioned yocto-built binaries to the SD card:
- Note: If you followed the Create an extended SD card steps, the NAND flashing scripts and all relevant binaries are already included in your SD card, and the below commands are redundant!
$ 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-nand ${P2_MOUNT_DIR}/opt/images/Yocto/SPL $ sudo cp ${YOCTO_IMGS_PATH}/u-boot-nand-2015.04-r0.img ${P2_MOUNT_DIR}/opt/images/Yocto/u-boot.img File System: $ sudo cp ${YOCTO_IMGS_PATH}/fsl-image-gui-var-som-mx6.tar.bz2 ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.tar.bz2 $ sudo cp ${YOCTO_IMGS_PATH}/fsl-image-gui-var-som-mx6.ubi ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.ubi.img Device Tree: $ sudo cp ${YOCTO_IMGS_PATH}/uImage-imx6dl-var-som-cap.dtb ${P2_MOUNT_DIR}/opt/images/Yocto/ $ sudo cp ${YOCTO_IMGS_PATH}/uImage-imx6dl-var-som-res.dtb ${P2_MOUNT_DIR}/opt/images/Yocto/ $ sudo cp ${YOCTO_IMGS_PATH}/uImage-imx6dl-var-som-solo-cap.dtb ${P2_MOUNT_DIR}/opt/images/Yocto/ $ sudo cp ${YOCTO_IMGS_PATH}/uImage-imx6dl-var-som-solo-res.dtb ${P2_MOUNT_DIR}/opt/images/Yocto/ $ sudo cp ${YOCTO_IMGS_PATH}/uImage-imx6dl-var-som-solo-vsc.dtb ${P2_MOUNT_DIR}/opt/images/Yocto/ $ sudo cp ${YOCTO_IMGS_PATH}/uImage-imx6dl-var-som-vsc.dtb ${P2_MOUNT_DIR}/opt/images/Yocto/ $ sudo cp ${YOCTO_IMGS_PATH}/uImage-imx6q-var-dart.dtb ${P2_MOUNT_DIR}/opt/images/Yocto/ $ sudo cp ${YOCTO_IMGS_PATH}/uImage-imx6q-var-som-cap.dtb ${P2_MOUNT_DIR}/opt/images/Yocto/ $ sudo cp ${YOCTO_IMGS_PATH}/uImage-imx6q-var-som-res.dtb ${P2_MOUNT_DIR}/opt/images/Yocto/ $ sudo cp ${YOCTO_IMGS_PATH}/uImage-imx6q-var-som-vsc.dtb ${P2_MOUNT_DIR}/opt/images/Yocto/
NAND flash 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) (install_yocto_emmc.sh - This script is being called by install_yocto.sh when choosing to install the rootfs to eMMC - it should not be called directly!)
Manual step-by-step flashing to NAND
Assuming you followed the Prepare images for NAND flash / eMMC flashing section above:
Flash SPL & U-Boot
$ cd /opt/images/Yocto $ flash_erase /dev/mtd0 0 0 $ kobs-ng init -x SPL --search_exponent=1 -v $ flash_erase /dev/mtd1 0 0 $ nandwrite -p /dev/mtd1 u-boot.img
Flash Linux Kernel image & Device Tree
You need to pick and choose the right .dtb file. See the table above for a complete description.
$ cd /opt/images/Yocto $ flash_erase /dev/mtd2 0 0 $ nandwrite -p /dev/mtd2 uImage $ nandwrite -p /dev/mtd1 -s 0x1e0000 uImage-imx6q-var-som.dtb (Example, select the right one!)
Flash UBIFS
$ cd /opt/images/Yocto $ ubiformat /dev/mtd3 -f rootfs.ubi.img
Flash File System to eMMC
Flashing eMMC requires several steps including partition, format and untar of the file system.
We recommend to use our provided scripts to perform this task.
$ export node=/dev/mmcblk0 $ 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; echo; echo p; echo w) | fdisk -u $node $ sync
Format the rootfs partition with ext4 file system:
$ mkfs.ext4 ${node}p1 -L rootfs
Flash the rootfs:
$ mkdir /run/media/mmcblk0p1 $ mount ${node}p1 /run/media/mmcblk0p1 $ tar xvpf rootfs.tar.bz2 -C /run/media/mmcblk1p1/ $ sync $ umount /run/media/mmcblk0p1
And finally, set the U-Boot env. variable "rootfs_device" to "emmc" by one of the following two methods:
$ fw_setenv rootfs_device emmc (A "Warning: Bad CRC, using default environment" message is expected, since this is the first write of the U-Boot environment to the NAND flash)
or:
Reboot and stop at the U-Boot command line, and enter the following: => setenv rootfs_device emmc => saveenv
Summary
This page is not valid for DART-MX6. For DART-MX6, please follow the link to the relevant page.
We described the results of a Yocto build, how to copy it to a bootable SD card and how to flash it to NAND and 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.