VAR-SOM-MX6 NAND Flash Burning

From Variscite Wiki
Revision as of 18:18, 21 March 2016 by Eran (talk | contribs) (Reverted edits by Eran (talk) to last revision by Admin)
VAR-SOM-MX6 - NAND Flash Burning

Introduction

The Variscite VAR-SOM-MX6 / VAR-SOM-SOLO SOMs use the on-SOM NAND-Flash to boot.
The file system can reside either on the NAND-Flash or the eMMC.
When file system resides on NAND, UBIFS file system will be used.
When file system resides on eMMC, EXT3 file system will be used.
Regardless if the file system is on NAND/UBIFS or eMMC/EXT3 the u-boot will always boot from NAND. The only exception is the VAR-DART-MX6, where boot is from eMMC completely.

NOTE:
This WIKI is only valid for VAR-SOM-MX6, VAR-SOM-SOLO/DUAL. For DART-MX6 please use: NAND Flash Burning Dart

NAND Structure

When system boots, kernel logs will present 4 relevant partitions defined.
0x000000000000-0x000000200000 : "spl"
0x000000200000-0x000000400000 : "bootloader"
0x000000400000-0x000000a00000 : "kernel"
0x000000a00000-0x000040000000 : "rootfs"

Yocto Built binaries for NAND-Flash

The resulted images are locaated in tmp/deploy/images/var-som-mx6.
Looking at tmp/deploy/images/var-som-mx6 you will find 5 required files for a complete NAND-Flash based system that are linked to the actual file:
SPL,U-Boot, zImage, <dtb file>, fsl-image-qt5-minimal-var-som-mx6.ubi

Image Name
How to use
fsl-image-qt5-minimal-var-som-mx6.ubi A complete UBIFS file-system binary. ("rootfs")
uImage Linux kernel image ("kernel")
SPL-nand The SPL is pre-u-boot SW component, required for DDR intialization ("spl")
u-boot-nand-2014.04-r0.img u-boot built for nand ("bootloader")
Device Tree Name
(Choose only one, according to your SOM and carrier board
SOM type
Carrier Board type
LCD Type
Evaluation Kit name
uImage-imx6q-var-som.dtb VAR-SOM-MX6_V2 (Quad / Dual) VAR-MX6CustomBoard Capacitive/Resistive touch VAR-DVK-MX6_V2-PRO
VAR-STK-MX6_V2
uImage-imx6q-var-som-vsc.dtb VAR-SOM-MX6_V2 (Quad / Dual) VAR-SOLOCustomBoard Capacitive LVDS touch N/A
uImage-imx6dl-var-som.dtb VAR-SOM-MX6_V2 (DualLite/ Solo) VAR-MX6CustomBoard Capacitive/Resistive touch N/A
uImage-imx6dl-var-som-solo-vsc.dtb VAR-SOM-SOLO / VAR-SOM-DUAL VAR-SOLOCustomBoard Capacitive LVDS touch VAR-DVK-SOLO/DUAL VAR-STK-SOLO/DUAL
uImage-imx6dl-var-som-solo.dtb VAR-SOM-SOLO / VAR-SOM-DUAL VAR-MX6CustomBoard Capacitive/Resistive touch N/A
uImage-imx6q-var-dart.dtb VAR-SOM-SOLO / VAR-SOM-DUAL VAR-DT6CustomBoard Capacitive LVDS touch VAR-STK-DT6.VAR-DVK-DT6

NAND Flashing scripts

If you followed Create an extended SD-Card 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


NAND-Flash images locations

The below directory stucture on your SD-Card, elaborates the files' location which the below burning scripts are expecting

/media/rootfs/opt/images/
├── Android
│   └── Emmc
│       ├── boot.img
│       ├── boot-imx6q-var-dart.img
│       ├── boot-som-mx6dl-c.img
│       ├── boot-som-mx6dl-r.img
│       ├── boot-som-mx6q-c.img
│       ├── boot-som-mx6q-r.img
│       ├── boot-som-mx6q-vsc.img
│       ├── boot-som-solo-c.img
│       ├── boot-som-solo-r.img
│       ├── boot-som-solo-vsc.img
│       ├── recovery.img
│       ├── recovery-imx6q-var-dart.img
│       ├── recovery-som-mx6dl-c.img
│       ├── recovery-som-mx6dl-r.img
│       ├── recovery-som-mx6q-c.img
│       ├── recovery-som-mx6q-r.img
│       ├── recovery-som-mx6q-vsc.img
│       ├── recovery-som-solo-c.img
│       ├── recovery-som-solo-r.img
│       ├── recovery-som-solo-vsc.img
│       ├── SPL
│       ├── SPL.mmc
│       ├── SPL.new
│       ├── system.img
│       ├── u-boot-var-imx6-nand.img
│       └── u-boot-var-imx6-sd.img
└── Yocto
    ├── rootfs.tar.bz2
    ├── rootfs.ubi.img
    ├── SPL
    ├── SPL.mmc
    ├── u-boot.img
    ├── u-boot.img.mmc
    ├── uImage
    ├── uImage-imx6dl-var-som.dtb
    ├── uImage-imx6dl-var-som-solo.dtb
    ├── uImage-imx6dl-var-som-solo-vsc.dtb
    ├── uImage-imx6q-var-dart.dtb
    ├── uImage-imx6q-var-som.dtb
    └── uImage-imx6q-var-som-vsc.dtb

Prepare images for NAND-Flash / eMMC burning

Plug the bootable SDCARD into your host machine. Then your host machine should mount the rootfs partition on /media/rootfs.
Copy all yocto-built binaries into SD-Card:

$ export YOCTO_ROOT=~/var-som-mx6-yocto-fido

Linux:
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/var-som-mx6/uImage /media/rootfs/opt/images/Yocto
U-boot:
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/var-som-mx6/SPL-nand /media/rootfs/opt/images/Yocto/SPL
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/var-som-mx6/u-boot-nand-2014.04-r0.img /media/rootfs/opt/images/Yocto/u-boot.img
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/var-som-mx6/SPL-sd /media/rootfs/opt/images/Yocto/SPL.mmc
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/var-som-mx6/u-boot-sd-2014.04-r0.img /media/rootfs/opt/images/Yocto/u-boot.img.mmc
File System:
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/var-som-mx6/fsl-image-qt5-var-som-mx6.tar.bz2 /media/rootfs/opt/images/Yocto/rootfs.tar.bz2
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/var-som-mx6/fsl-image-qt5-minimal-var-som-mx6.ubi /media/rootfs/opt/images/Yocto/rootfs.ubi.img
Device Tree:
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/var-som-mx6/uImage-imx6dl-var-som-solo.dtb /media/rootfs/opt/images/Yocto/
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/var-som-mx6/uImage-imx6dl-var-som-solo-vsc.dtb /media/rootfs/opt/images/Yocto/
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/var-som-mx6/uImage-imx6dl-var-som.dtb /media/rootfs/opt/images/Yocto/
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/var-som-mx6/uImage-imx6q-var-som.dtb /media/rootfs/opt/images/Yocto/
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/var-som-mx6/uImage-imx6q-var-som-vsc.dtb /media/rootfs/opt/images/Yocto/
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/var-som-mx6/uImage-imx6q-var-dart.dtb /media/rootfs/opt/images/Yocto/

NAND-Flash Flashing scripts

The flashing scripts are located at /media/rootfs/sbin/

 
$ android-emmc.sh - flash Android into eMMC
$ yocto-emmc.sh - flash Yocto into eMMC (See note below)
$ yocto-dart.sh - flash Yocto into eMMC DART only.
$ yocto-nand.sh - flash Yocto into nand
  • in case of yocto-emmc.sh, change boot arguments to :
$ setenv bootargs console=ttymxc0,115200 video=mxcfb1:off root=/dev/mmcblk1p1 rootwait rw
$ saveenv

Manual step-by-step flashing to NAND

Flash U-BOOT

Flashing U-BOOT reguire to flash 2 parts: SPL and u-boot.img. Assume you copy SPL-nand and u-boot-nand-2014.04-r0.img to the right directory as showed above.

$ 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

Flashing Linux kernel reguire to flash 2 parts: uImage and device tree. Assume you copy uImage and device tree to the right directory as showed above. You also need to pick and coose the right DTB file. See 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

The parameters for the UBIFS UBI_SUB_PAGE_SIZE=2048 and UBI_VID_HDR_OFFSET=2048.

$ cd /opt/images/Yocto
$ flash_erase /dev/mtd3 0 0
$ ubiformat /dev/mtd3 -f rootfs.ubi.img -s 2048 -O 2048

Flash File System to eMMC

Flashing eMMC is a complex task. It requires several steps including partition, format and untar the file system. We highly recommend to use our provided scripts to perform this task. Assuming that you use our NAND recovery utility.

Make sure the eMMC is not mounted.

$ cd /opt/images/Yocto
$ umount /dev/mmcblk1p*
$ node=/dev/mmcblk1 

Delete all partition from the eMMC.

$ fdisk ${node} <<EOF
d
1
d
2
d
3
d
w
EOF

$ sync 

Delete MBR

$ dd if=/dev/zero of=${node} bs=512 count=1000
$ sync

Call sfdisk to create partition table

$ node=/dev/mmcblk1
$ seprate=40
$ total_size=`sfdisk -s ${node}`
$ total_size=`expr ${total_size} / 1024`

$ sfdisk --force -uM ${node} << EOF
,${total_size},83
EOF

Format Linux

$ mkfs.ext4 ${node} -Lrootfs

Flash Linux

$ mkdir /run/media/mmcblk1p1
$ mount ${node}  /run/media/mmcblk1p1
$ tar xvpf rootfs.tar.bz2 -C /run/media/mmcblk1p1/

in case of Yocto eMMC file system stop at u-boot and change boot arguments to :

$ setenv bootargs console=ttymxc0,115200 video=mxcfb1:off root=/dev/mmcblk1p1 rootwait rw
$ saveenv

Summary

We describe the results of Yocto build, how to copy it to SDCARD and how to flash it to NAND and eMMC. This page is not valid for DART-MX6. Please follow the link to the relevant page. With the NAND recovery utility we provide a set of scripts located on /sbin and listed below. It is much safer to use them instead of the manual operation.
/media/rootfs/sbin/:
android-emmc.sh mkmmc_yocto.sh yocto-dart.sh yocto-nand.sh mkmmc_android.sh nand-recovery.sh yocto-emmc.sh. Some of the scripts are used by the others.
Please use:

  • android-emmc.sh to flash Android int eMMC
  • yocto-dart.sh To flash Yocto into eMMC on DART-MX6
  • yocto-nand.sh To flash Yocto into NAND (not relevant on DART-MX6)
  • yocto-emmc.sh To flash Yocto into eMMC (not relevant on DART-MX6)