DART-6UL NAND Flash Burning: Difference between revisions

From Variscite Wiki
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{PageHeader|DART-6UL - NAND Flash Burning}} {{DocImage|category1=DART-6UL|category2=Yocto}} __toc__
{{PageHeader|DART-6UL - Flashing the internal storage device}} {{DocImage|category1=DART-6UL|category2=Yocto}} __toc__
 
= Introduction =
= Introduction =
The Variscite DART-6UL use the on-SOM NAND-Flash or eMMC-Flash to boot.<br>
The file system can reside either on the NAND-Flash or the eMMC.
<br>When file system resides on NAND, UBIFS file system will be used.
<br>When file system resides on eMMC, EXT3 file system will be used.
{{note| NOTE:<br>This WIKI is only valid for DART-6UL.|info}}


== NAND Structure ==
The Variscite DART-6UL has either an on-SOM NAND flash or eMMC, and either of them can be used to boot from and to hold the file system.<br>
When system boots, kernel logs will present 5 relevant partitions defined.
For NAND flash we use a UBI file system and for eMMC we use ext4.
<pre>
 
0x000000000000-0x000000200000 : "spl"
= NAND flash structure =
0x000000200000-0x000000400000 : "uboot"
 
0x000000400000-0x000000600000 : "uboot-env"
These are the defined MTD partitions on the NAND flash:<br>
0x000000600000-0x000000e00000 : "kernel"
0x000000000000-0x000000200000 : "spl"<br>
0x000000e00000-0x000040000000 : "rootfs"
0x000000200000-0x000000400000 : "u-boot"<br>
</pre>
0x000000400000-0x000000600000 : "u-boot_env"<br>
0x000000600000-0x000000e00000 : "kernel"<br>
0x000000e00000-End &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : "rootfs"<br>
 
= eMMC structure =
0-4 MiB &nbsp;&nbsp;&nbsp;&nbsp; : Non-partitioned space, saved for U-Boot.<br>
4-12 MiB &nbsp;&nbsp; : "BOOT-VAR6UL" - A FAT16 partition containing the Linux image and the device tree blob/s.<br>
12 MiB-End: "rootfs" - An ext4 partition containing the root file system (including the kernel modules).<br>
 
= Yocto Built binaries for eMMC/NAND flash =


== Yocto Built binaries for NAND-Flash ==
The resulted images are located at tmp/deploy/images/imx6ul-var-dart:
The resulted images are located in tmp/deploy/images/imx6ul-var-dart/.<br/>Looking at tmp/deploy/images/imx6ul-var-dart/ you will find 6 main files that are linked to the actual file<br/>


{| class="wikitable"
{| class="wikitable"
|-
|-
! scope="col" | Image Name<br/>
! scope="col" | File Name
! scope="col" | How to use<br/>
! scope="col" | Description
|-
| fsl-image-gui-imx6ul-var-dart.ext3<br/>
| Not in Use<br/>
|-
| fsl-image-gui-imx6ul-var-dart.sdcard
| This image is for SD-Card boot. Default u-boot is built for SDCARD. Booting from SD-Card is explained in details below. See section 8.1 below for the sdcard structure.
|-
|-
| fsl-image-gui-imx6ul-var-dart.tar.bz2
| style="padding: 5px" | fsl-image-gui-imx6ul-var-dart.tar.bz2
| Used to create an NFS root file system on the host. See apendix for setting an NFS server
| style="padding: 5px" | Tarball with rootfs files. Used here for writing to eMMC.
|-
|-
| fsl-image-gui-imx6ul-var-dart.ubi
| style="padding: 5px" | fsl-image-gui-imx6ul-var-dart.ubi
| Use the sdcard created above. Copy the file into it and use the following commands to flash them into nand.<br/>Coping files (mount the sd-card created above first):
| style="padding: 5px" | A complete UBI image containing a UBIFS volume, for writing to NAND flash.
|-
|-
| zImage
| style="padding: 5px" | zImage
| Linux kernel image
| style="padding: 5px" | Linux kernel image. Used here for both eMMC and NAND flash.
|-
|-
| u-boot-nand-2015.04-r0.imx
| style="padding: 5px" | SPL-sd
| u-boot built for nand
| style="padding: 5px" | SPL image. Used here for eMMC.
|-
|-
| u-boot-sd-2015.04-r0.imx
| style="padding: 5px" | SPL-nand
| u-boot built for sdcard/eMMC
| style="padding: 5px" | SPL built for NAND flash.
|-
|-
! scope="col" | Device Tree Name<br/>
| style="padding: 5px" | u-boot.img-sd
! scope="col" | Boot Device<br/>
| style="padding: 5px" | U-Boot image. Used here for eMMC.
|-
|-
| zImage-imx6ul-var-dart-emmc_wifi.dtb
| style="padding: 5px" | u-boot.img-nand
| Boot from internal eMMC with WI-FI enabled. (SDCARD & NAND disabled)
| style="padding: 5px" | U-Boot built for NAND flash.
|-
|-
| zImage-imx6ul-var-dart-nand_wifi.dtb
| style="padding: 5px" | zImage-imx6ul-var-dart-emmc_wifi.dtb
| Boot from internal NAND with WI-FI enabled. (SDCARD & eMMC disabled)
| style="padding: 5px" | eMMC and WiFi enabled (SD card and NAND flash disabled).
|-
|-
| zImage-imx6ul-var-dart-sd_emmc.dtb
| style="padding: 5px" | zImage-imx6ul-var-dart-nand_wifi.dtb
| SDCARD and eMMC enabled (WIFI & NAND disabled). You can boot from eMMC or SDCARD
| style="padding: 5px" | NAND flash and WiFi enabled (SD card and eMMC disabled).
|-
|-
| zImage-imx6ul-var-dart-sd_nand.dtb
| style="padding: 5px" | zImage-imx6ul-var-dart-sd_emmc.dtb
| SDCARD and NAND enabled (WIFI & eMMC disabled). You can boot from NAND or SDCARD
| style="padding: 5px" | eMMC and SD card enabled (NAND flash and WiFi disabled).
|-
|-
| style="padding: 5px" | zImage-imx6ul-var-dart-sd_nand.dtb
| style="padding: 5px" | NAND flash and SD card enabled (eMMC and WiFi disabled).
|}
|}


== NAND Flashing scripts==
= Installing the Yocto binaries =


If you followed [[DART-6UL Yocto Fido R1 Build Yocto release#Create an extended SD-Card |Create an extended SD-Card]] the [[DART-6UL NAND_Flash_Burning#NAND-Flash_Flashing_scripts|NAND flashing scripts]] will be included in your SD-Card. <br>
If you followed the [[DART-6UL_Yocto_Jethro_R1_build#Create_an_extended_SD_card|Create an extended SD card]] steps, the [[#Images_locations|Yocto binaries]] and the [[#Flashing_script|flashing script]] will be included in your SD card.<br>
The [[DART-6UL NAND_Flash_Burning#NAND-Flash_Flashing_scripts |NAND flashing scripts]] are easy-to-use example scripts for burning images into NAND Flash<br>
The flashing script is an easy-to-use example script for flashing images into NAND flash / eMMC.<br>
There are also sections below describing how to flash the images manually to [[#Manual_step-by-step_flashing_to_NAND_flash|NAND flash]] and to [[#Manual_step-by-step_flashing_to_eMMC|eMMC]].


== Images locations ==


=== NAND-Flash images locations ===
Following is the directory structure on your SD card, which elaborates the files' location that the below installation script is expecting:
The below directory stucture on your SD-Card, elaborates the files' location which the below burning scripts are expecting
<pre>
<pre>
/media/rootfs/opt/images/
/opt/images/
└── Yocto
└── Yocto
     ├── rootfs.sdcard
     ├── imx6ul-var-dart-emmc_wifi.dtb
    ├── imx6ul-var-dart-nand_wifi.dtb
    ├── imx6ul-var-dart-sd_emmc.dtb
    ├── imx6ul-var-dart-sd_nand.dtb
     ├── rootfs.tar.bz2
     ├── rootfs.tar.bz2
     ├── rootfs.ubi.img
     ├── rootfs.ubi
     ├── SPL-nand
     ├── SPL-nand
     ├── SPL-sd
     ├── SPL-sd
     ├── u-boot-nand-2015.04-r0.img
     ├── u-boot.img-nand
     ├── u-boot-sd-2015.04-r0.img
     ├── u-boot.img-sd
    ├── zImage
     └── zImage
    ├── zImage-imx6ul-var-dart-emmc_wifi.dtb
    ├── zImage-imx6ul-var-dart-nand_wifi.dtb
    ├── zImage-imx6ul-var-dart-sd_emmc.dtb
     └── zImage-imx6ul-var-dart-sd_nand.dtb
</pre>
</pre>
=== Prepare the images for NAND flash / 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.<br>
Copy all the mentioned yocto-built binaries to the SD card:<br>
* <span style="color:red">Note:</span> If you followed the [[DART-6UL_Yocto_Jethro_R1_build#Create_an_extended_SD_card|Create an extended SD card]] steps, the [[#Flashing script|flashing script]] and all relevant binaries are already included in your SD card, and the below commands are redundant!<br>


<pre>
<pre>
Script files located on /media/rootfs/sbin/
$ export YOCTO_IMGS_PATH=~/var-mx6ul-mx7-yocto-jethro/build_x11/tmp/deploy/images/imx6ul-var-dart
yocto-nand.sh
$ export P2_MOUNT_DIR=/media/rootfs/
nand-recovery.sh
yocto-emmc.sh
</pre>
</pre>


== Prepare images for NAND-Flash / eMMC burning ==
<pre>
Plug the bootable SDCARD into your host machine.
Linux:
Then your host machine should mount the rootfs partition on /media/rootfs.<br>
$ sudo cp ${YOCTO_IMGS_PATH}/zImage ${P2_MOUNT_DIR}/opt/images/Yocto/
Copy all yocto-built binaries into SD-Card:
</pre>
<br>
* <span style="color:red">Note:</span> If you followed [[DART-6UL Yocto Fido R1 Build Yocto release#Create an extended SD-Card |Create an extended SD-Card]] the  [[DART-6UL  NAND Flash Burning#NAND-Flash Flashing scripts |NAND flashing scripts]] and all relevant binaries are already included in your SD-Card! and below commands are redundant<br>


NAND images:
<pre>
<pre>
$ export YOCTO_ROOT=~/var-dart-6ul-yocto-fido
Device Trees:
$ sudo cp ${YOCTO_IMGS_PATH}/zImage-imx6ul-var-dart-nand_wifi.dtb ${P2_MOUNT_DIR}/opt/images/Yocto/imx6ul-var-dart-nand_wifi.dtb
$ sudo cp ${YOCTO_IMGS_PATH}/zImage-imx6ul-var-dart-sd_nand.dtb ${P2_MOUNT_DIR}/opt/images/Yocto/imx6ul-var-dart-sd_nand.dtb
 
U-Boot and SPL:
$ sudo cp ${YOCTO_IMGS_PATH}/SPL-nand ${P2_MOUNT_DIR}/opt/images/Yocto/
$ sudo cp ${YOCTO_IMGS_PATH}/u-boot.img-nand ${P2_MOUNT_DIR}/opt/images/Yocto/


Linux:
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/imx6ul-var-dart/zImage  /media/rootfs/opt/images/Yocto
U-boot:
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/imx6ul-var-dart/SPL-nand /tmp/rootfs/opt/images/Yocto/
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/imx6ul-var-dart/SPL-sd  /tmp/rootfs/opt/images/Yocto/
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/imx6ul-var-dart/u-boot-nand-2015.04-r0.img /tmp/rootfs/opt/images/Yocto/
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/imx6ul-var-dart/u-boot-sd-2015.04-r0.img  /tmp/rootfs/opt/images/Yocto/
File System:
File System:
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/imx6ul-var-dart/fsl-image-gui-imx6ul-var-dart.tar.bz2 /media/rootfs/opt/images/Yocto/rootfs.tar.bz2
$ sudo cp ${YOCTO_IMGS_PATH}/fsl-image-gui-imx6ul-var-dart.ubi ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.ubi
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/imx6ul-var-dart/fsl-image-gui-imx6ul-var-dart.ubi /media/rootfs/opt/images/Yocto/rootfs.ubi.img
Device Tree:
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/imx6ul-var-dart/zImage-imx6ul-var-dart-emmc_wifi.dtb /media/rootfs/opt/images/Yocto/
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/imx6ul-var-dart/zImage-imx6ul-var-dart-nand_wifi.dtb /media/rootfs/opt/images/Yocto/
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/imx6ul-var-dart/zImage-imx6ul-var-dart-sd_emmc.dtb /media/rootfs/opt/images/Yocto/
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/imx6ul-var-dart/zImage-imx6ul-var-dart-sd_nand.dtb /media/rootfs/opt/images/Yocto/
</pre>
</pre>


== NAND-Flash Flashing scripts ==
eMMC images:
The flashing scripts are located at /media/rootfs/sbin/
<pre>
<pre>$ yocto-emmc.sh - flash Yocto into eMMC
Device Trees:
$ yocto-nand.sh - flash Yocto into nand
$ sudo cp ${YOCTO_IMGS_PATH}/zImage-imx6ul-var-dart-emmc_wifi.dtb ${P2_MOUNT_DIR}/opt/images/Yocto/imx6ul-var-dart-emmc_wifi.dtb
$ sudo cp ${YOCTO_IMGS_PATH}/zImage-imx6ul-var-dart-sd_emmc.dtb ${P2_MOUNT_DIR}/opt/images/Yocto/imx6ul-var-dart-sd_emmc.dtb
 
U-Boot and SPL:
$ sudo cp ${YOCTO_IMGS_PATH}/SPL-sd ${P2_MOUNT_DIR}/opt/images/Yocto/
$ sudo cp ${YOCTO_IMGS_PATH}/u-boot.img-sd ${P2_MOUNT_DIR}/opt/images/Yocto/
 
File System:
$ sudo cp ${YOCTO_IMGS_PATH}/fsl-image-gui-imx6ul-var-dart.tar.bz2 ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.tar.bz2
</pre>
</pre>


== Manual step-by-step flashing to NAND ==
== Flashing script ==
=== Flash U-BOOT ===
 
Flashing U-BOOT reguire to flash 2 parts: SPL and u-boot.img.
The flashing script is located on the SD card at /usr/bin/:
Assume you copy SPL-nand and u-boot-nand-2014.04-r0.img to the right directory as showed above.
<pre>
install_yocto.sh - Flash Yocto into NAND flash or eMMC (Run and follow usage instructions)
</pre>
 
== Manual step-by-step flashing to NAND flash ==
 
Use the prepared SD card to boot the board and run the following:
<br><br>
<pre>
<pre>
$ cd /opt/images/Yocto
$ cd /opt/images/Yocto
</pre>
Flash U-Boot and SPL to NAND flash:
<pre>
$ flash_erase /dev/mtd0 0 0
$ flash_erase /dev/mtd0 0 0
$ kobs-ng init -x SPL-nand --search_exponent=1 -v
$ kobs-ng init -x SPL-nand --search_exponent=1 -v
$ flash_erase /dev/mtd1 0 0
$ flash_erase /dev/mtd1 0 0
$ nandwrite -p /dev/mtd1 u-boot-nand-2015.04-r0.img
$ nandwrite -p /dev/mtd1 u-boot.img-nand
$ flash_erase /dev/mtd2 0 0
</pre>
</pre>


=== Flash Linux Kernel ===
Flash the Linux Kernel image & the selected Device Tree blob to NAND flash:
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.
<pre>
<pre>
$ cd /opt/images/Yocto
$ flash_erase /dev/mtd3 0 0
$ flash_erase /dev/mtd3 0 0
$ nandwrite -p /dev/mtd3 zImage
$ nandwrite -p /dev/mtd3 zImage
$ nandwrite -p /dev/mtd3 -s 0x7e0000 zImage-imx6ul-var-dart-nand_wifi.dtb (Example, select the right one!)
 
$ nandwrite -p /dev/mtd3 -s 0x7e0000 imx6ul-var-dart-nand_wifi.dtb
or
$ nandwrite -p /dev/mtd3 -s 0x7e0000 imx6ul-var-dart-sd_nand.dtb
</pre>
</pre>


=== Flash UBIFS ===
Flash the UBI File System to NAND flash:
The parameters for the UBIFS UBI_SUB_PAGE_SIZE=2048 and UBI_VID_HDR_OFFSET=2048.
<pre>
<pre>
$ cd /opt/images/Yocto
$ ubiformat /dev/mtd4 -f rootfs.ubi
$ flash_erase /dev/mtd4 0 0
$ ubiformat /dev/mtd4 -f rootfs.ubi.img -s 2048 -O 2048
</pre>
</pre>


== Flash File System to eMMC ==
== Manual step-by-step flashing to eMMC ==
We highly recommend to use our above mentioned provided scripts to perform this task as an example


 
Flashing the eMMC requires several steps including flashing of U-Boot and the Linux kernel, partitioning, file system formatting and image extraction.<br>
Make sure the eMMC is not mounted.
We recommend to use our provided scripts to perform this task.<br>
<br>
Use the prepared SD card to boot the board and run the following:
<br><br>
<pre>
<pre>
$ export node=/dev/mmcblk1
$ cd /opt/images/Yocto
$ cd /opt/images/Yocto
$ umount /dev/mmcblk1p*
$ node=/dev/mmcblk1
</pre>
</pre>


Delete all partition from the eMMC.
Make sure the eMMC is not mounted:
<pre>
<pre>
$fdisk /dev/mmcblk1 1>/dev/null <<EOF
$ umount ${node}p*
d
</pre>
1
d
2
d
3
d
w
EOF


$ sync  
Delete current data on eMMC:
<pre>
$ 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
</pre>
</pre>


Delete MBR
Create a partition table:
<pre>
<pre>
$ dd if=/dev/zero of=${node} bs=512 count=1000
$ (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
$ sync
</pre>
</pre>


Call fdisk to create partition table
Format the partitions:
<pre>
<pre>
$ fdisk /dev/mmcblk1 <<EOF
$ mkfs.vfat ${node}p1 -n BOOT-VAR6UL
n
$ mkfs.ext4 ${node}p2 -L rootfs
p
$ sync
1
</pre>
8192
24575
t
c
n
p
2
24576


p
Flash U-Boot and SPL to eMMC:
w
<pre>
EOF
$ dd if=SPL-sd of=${node} bs=1K seek=1; sync
$ dd if=u-boot.img-sd of=${node} bs=1K seek=69; sync
</pre>
</pre>


Format Linux
Copy the Linux kernel image and the device tree blobs to the BOOT partition:
<pre>$ mkfs.vfat /dev/mmcblk1p1 -nBOT_DART6UL
<pre>
$ mkfs.ext4 /dev/mmcblk1p2 -Lrootfs
$ mkdir /run/media/mmcblk1p1
$ mount -t vfat ${node}p1 /run/media/mmcblk1p1
$ cp imx6ul-var-dart-emmc_wifi.dtb /run/media/mmcblk1p1/
$ cp imx6ul-var-dart-sd_emmc.dtb /run/media/mmcblk1p1/
$ cp zImage /run/media/mmcblk1p1/
$ sync
$ umount /run/media/mmcblk1p1
</pre>
</pre>


Flash the file system and copy the relevant files to tjhe boot partition.
Extract the rootfs archive:
<pre>
<pre>
$ mount | grep mmcblk1 
$ mkdir /run/media/mmcblk1p2
u-boot:
$ mount ${node}p2 /run/media/mmcblk1p2
$ sudo dd if=SPL-sd of=/dev/mmcblk1 bs=1K seek=1; sync
$ tar xvpf rootfs.tar.bz2 -C /run/media/mmcblk1p2
$ sudo dd if=u-boot-sd-2015.04-r0.img of=/dev/mmcblk1 bs=1K seek=69; sync
$ sync
Mount:
$ umount /run/media/mmcblk1p2
$ mkdir -p /tmp/media/mmcblk1p1
$ mkdir -p /tmp/media/mmcblk1p2
$ mount -t vfat /dev/mmcblk1p1  /tmp/media/mmcblk1p1
$ mount /dev/mmcblk1p2  /tmp/media/mmcblk1p2
Copy files to Yocto BOOT partition:
$ cp zImage-imx6ul-var-dart-emmc_wifi.dtb /tmp/media/mmcblk1p1/imx6ul-var-dart-emmc_wifi.dtb
$ cp zImage-imx6ul-var-dart-nand_wifi.dtb /tmp/media/mmcblk1p1/imx6ul-var-dart-nand_wifi.dtb
$ cp zImage-imx6ul-var-dart-sd_emmc.dtb /tmp/media/mmcblk1p1/imx6ul-var-dart-sd_emmc.dtb
$ cp zImage-imx6ul-var-dart-sd_nand.dtb /tmp/media/mmcblk1p1/imx6ul-var-dart-sd_nand.dtb
$ cp zImage      /tmp/media/mmcblk1p1/zImage
flashing Yocto Root file System:
$ rm -rf /tmp/media/mmcblk1p2/*
$ tar xvf rootfs.tar.bz2 -C /tmp/media/mmcblk1p2/
</pre>
</pre>


= Summary =
= Summary =
We described the results of Yocto build, how to copy it to SDCARD and than flash it to NAND or eMMC.
 
With the NAND recovery utility we provide a set of scripts located on /sbin and listed below. It is much easier to use them instead of the manual operation.
We described the results of a Yocto build, how to copy it to a bootable SD card and how to flash it to NAND flash or eMMC.<br>
<br/>/media/rootfs/sbin/:
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.
<br/>yocto-nand.sh nand-recovery.sh yocto-emmc.sh.
Some of the scripts are used by the others. <br/>Please use:
* yocto-nand.sh To flash Yocto into NAND
* yocto-emmc.sh To flash Yocto into eMMC

Latest revision as of 15:06, 1 September 2016

DART-6UL - Flashing the internal storage device

Introduction

The Variscite DART-6UL has either an on-SOM NAND flash or eMMC, and either of them can be used to boot from and to hold the file system.
For NAND flash we use a UBI file system and for eMMC we use ext4.

NAND flash 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-End                       : "rootfs"

eMMC structure

0-4 MiB      : Non-partitioned space, saved for U-Boot.
4-12 MiB    : "BOOT-VAR6UL" - 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).

Yocto Built binaries for eMMC/NAND flash

The resulted images are located at tmp/deploy/images/imx6ul-var-dart:

File Name Description
fsl-image-gui-imx6ul-var-dart.tar.bz2 Tarball with rootfs files. Used here for writing to eMMC.
fsl-image-gui-imx6ul-var-dart.ubi A complete UBI image containing a UBIFS volume, for writing to NAND flash.
zImage Linux kernel image. Used here for both eMMC and NAND flash.
SPL-sd SPL image. Used here for eMMC.
SPL-nand SPL built for NAND flash.
u-boot.img-sd U-Boot image. Used here for eMMC.
u-boot.img-nand U-Boot built for NAND flash.
zImage-imx6ul-var-dart-emmc_wifi.dtb eMMC and WiFi enabled (SD card and NAND flash disabled).
zImage-imx6ul-var-dart-nand_wifi.dtb NAND flash and WiFi enabled (SD card and eMMC disabled).
zImage-imx6ul-var-dart-sd_emmc.dtb eMMC and SD card enabled (NAND flash and WiFi disabled).
zImage-imx6ul-var-dart-sd_nand.dtb NAND flash and SD card enabled (eMMC and WiFi disabled).

Installing the Yocto binaries

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

Images locations

Following is the directory structure on your SD card, which elaborates the files' location that the below installation script is expecting:

/opt/images/
└── Yocto
    ├── imx6ul-var-dart-emmc_wifi.dtb
    ├── imx6ul-var-dart-nand_wifi.dtb
    ├── imx6ul-var-dart-sd_emmc.dtb
    ├── imx6ul-var-dart-sd_nand.dtb
    ├── rootfs.tar.bz2
    ├── rootfs.ubi
    ├── SPL-nand
    ├── SPL-sd
    ├── u-boot.img-nand
    ├── u-boot.img-sd
    └── zImage

Prepare the images for NAND flash / 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-mx6ul-mx7-yocto-jethro/build_x11/tmp/deploy/images/imx6ul-var-dart
$ export P2_MOUNT_DIR=/media/rootfs/
Linux:
$ sudo cp ${YOCTO_IMGS_PATH}/zImage					${P2_MOUNT_DIR}/opt/images/Yocto/

NAND images:

Device Trees:
$ sudo cp ${YOCTO_IMGS_PATH}/zImage-imx6ul-var-dart-nand_wifi.dtb	${P2_MOUNT_DIR}/opt/images/Yocto/imx6ul-var-dart-nand_wifi.dtb
$ sudo cp ${YOCTO_IMGS_PATH}/zImage-imx6ul-var-dart-sd_nand.dtb		${P2_MOUNT_DIR}/opt/images/Yocto/imx6ul-var-dart-sd_nand.dtb

U-Boot and SPL:
$ sudo cp ${YOCTO_IMGS_PATH}/SPL-nand					${P2_MOUNT_DIR}/opt/images/Yocto/
$ sudo cp ${YOCTO_IMGS_PATH}/u-boot.img-nand				${P2_MOUNT_DIR}/opt/images/Yocto/

File System:
$ sudo cp ${YOCTO_IMGS_PATH}/fsl-image-gui-imx6ul-var-dart.ubi		${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.ubi

eMMC images:

Device Trees:
$ sudo cp ${YOCTO_IMGS_PATH}/zImage-imx6ul-var-dart-emmc_wifi.dtb	${P2_MOUNT_DIR}/opt/images/Yocto/imx6ul-var-dart-emmc_wifi.dtb
$ sudo cp ${YOCTO_IMGS_PATH}/zImage-imx6ul-var-dart-sd_emmc.dtb		${P2_MOUNT_DIR}/opt/images/Yocto/imx6ul-var-dart-sd_emmc.dtb

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

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

Flashing script

The flashing script is located on the SD card at /usr/bin/:

install_yocto.sh	- Flash Yocto into NAND flash or eMMC (Run and follow usage instructions)

Manual step-by-step flashing to NAND flash

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

$ cd /opt/images/Yocto

Flash U-Boot and SPL to NAND flash:

$ flash_erase /dev/mtd0 0 0
$ kobs-ng init -x SPL-nand --search_exponent=1 -v
$ flash_erase /dev/mtd1 0 0
$ nandwrite -p /dev/mtd1 u-boot.img-nand
$ flash_erase /dev/mtd2 0 0

Flash the Linux Kernel image & the selected Device Tree blob to NAND flash:

$ flash_erase /dev/mtd3 0 0
$ nandwrite -p /dev/mtd3 zImage

$ nandwrite -p /dev/mtd3 -s 0x7e0000 imx6ul-var-dart-nand_wifi.dtb
or
$ nandwrite -p /dev/mtd3 -s 0x7e0000 imx6ul-var-dart-sd_nand.dtb

Flash the UBI File System to NAND flash:

$ ubiformat /dev/mtd4 -f rootfs.ubi

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/mmcblk1
$ 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-VAR6UL
$ mkfs.ext4 ${node}p2 -L rootfs
$ sync

Flash U-Boot and SPL to eMMC:

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

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

$ mkdir /run/media/mmcblk1p1
$ mount -t vfat ${node}p1		/run/media/mmcblk1p1
$ cp imx6ul-var-dart-emmc_wifi.dtb	/run/media/mmcblk1p1/
$ cp imx6ul-var-dart-sd_emmc.dtb	/run/media/mmcblk1p1/
$ cp zImage				/run/media/mmcblk1p1/
$ sync
$ umount /run/media/mmcblk1p1

Extract the rootfs archive:

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

Summary

We described the results of a Yocto build, how to copy it to a bootable SD card and how to flash it to NAND flash or 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.