VAR-SOM-MX6 NAND Flash Burning Jethro: Difference between revisions

From Variscite Wiki
No edit summary
Line 1: Line 1:
{{PageHeader|VAR-SOM-MX6 - NAND Flash Burning}} {{DocImage|category1=VAR-SOM-MX6|category2=Yocto}} __toc__
{{PageHeader|VAR-SOM-MX6 - NAND Flash Burning}} {{DocImage|category1=VAR-SOM-MX6|category2=Yocto}} __toc__
= Introduction =
= Introduction =
The Variscite VAR-SOM-MX6 / VAR-SOM-SOLO SOMs use the on-SOM NAND-Flash to boot.<br>
The Variscite VAR-SOM-MX6 / VAR-SOM-SOLO SOMs use the on-SOM NAND flash to boot.<br>
The file system can reside either on the NAND-Flash or the eMMC.
The file system can reside either on the NAND flash or the eMMC.<br>
<br>When file system resides on NAND, UBIFS file system will be used.
When the file system resides on NAND, UBIFS file system is used.<br>
<br>When file system resides on eMMC, EXT3 file system will be used.
When file system resides on eMMC, ext4 file system is used.<br>
<br>Regardless if the file system is on NAND/UBIFS or eMMC/EXT3 the u-boot will always boot from NAND.
Regardless of the file system type and location, U-Boot will always boot from NAND.
The only exception is the VAR-DART-MX6, where boot is from eMMC completely.
The only exception is the VAR-DART-MX6, where boot is from eMMC completely.
{{note| NOTE:<br>This WIKI is only valid for VAR-SOM-MX6, VAR-SOM-SOLO/DUAL.
{{note| NOTE:<br>This Wiki is only valid for VAR-SOM-MX6, VAR-SOM-SOLO/DUAL.
For DART-MX6 please use: [[VAR-SOM-MX6 NAND Flash Burning Dart |NAND Flash Burning Dart]]|info}}
For DART-MX6 please use: [[VAR-SOM-MX6 NAND Flash Burning Dart |NAND Flash Burning Dart]]|info}}


Line 14: Line 14:
<br>0x000000000000-0x000000200000 : "spl"
<br>0x000000000000-0x000000200000 : "spl"
<br>0x000000200000-0x000000400000 : "bootloader"
<br>0x000000200000-0x000000400000 : "bootloader"
<br>0x000000400000-0x000000a00000 : "kernel"
<br>0x000000400000-0x000000c00000 : "kernel"
<br>0x000000a00000-0x000040000000 : "rootfs"
<br>0x000000c00000-0x000040000000 : "rootfs"


== Yocto Built binaries for NAND-Flash ==
== Yocto Built binaries for NAND flash ==
The resulted images are locaated in tmp/deploy/images/var-som-mx6.<br/>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:<br/>
The resulted images are located at tmp/deploy/images/var-som-mx6.<br>
SPL,U-Boot, zImage, <dtb file>, fsl-image-gui-var-som-mx6.ubi <br>
Looking at tmp/deploy/images/var-som-mx6 you will find the following five required files for a complete NAND flash based system:<br/>
SPL, U-Boot, uImage, dtb file, (UBI) file system image file.<br>


{| class="wikitable"
{| class="wikitable"
Line 26: Line 27:
! scope="col" | How to use<br/>
! scope="col" | How to use<br/>
|-
|-
| fsl-image-gui-var-som-mx6.ubi
| style="padding: 5px;"| fsl-image-gui-var-som-mx6.tar.bz2
| A complete UBIFS file-system binary. ("rootfs")
| style="padding: 5px;"| Tarball of the rootfs used for eMMC (for extracting into the ext4 partition on eMMC)<br> (Needed only in case of using the eMMC for file system)
|-
|-
| uImage
| style="padding: 5px;"| fsl-image-gui-var-som-mx6.ubi
| Linux kernel image ("kernel")
| style="padding: 5px;"| A complete UBI file system binary ("rootfs")<br> (Needed only in case of using the NAND flash for file system)
|-
|-
| SPL-nand
| style="padding: 5px;"| uImage
| The SPL is pre-u-boot SW component, required for DDR intialization ("spl")
| style="padding: 5px;"| Linux kernel image ("kernel")
|-
|-
| u-boot-nand-2014.04-r0.img
| style="padding: 5px;"| SPL-nand
| u-boot built for nand ("bootloader")
| style="padding: 5px;"| The SPL is pre-U-Boot SW component, required for DDR intialization ("spl")
|-
|-
! scope="col" | Device Tree Name <br>(Choose only one, according to your SOM and carrier board<br/>
| style="padding: 5px;"| u-boot-nand-2015.04-r0.img
| style="padding: 5px;"| U-Boot built for NAND ("bootloader")
|-
! scope="col" | Device Tree Name <br>(Choose only one, according to your SOM and carrier board)<br/>
! scope="col" | SOM type<br/>
! scope="col" | SOM type<br/>
! scope="col" | Carrier Board type<br/>
! scope="col" | Carrier Board type<br/>
Line 44: Line 48:
! scope="col" | Evaluation Kit name<br/>
! scope="col" | Evaluation Kit name<br/>
|-
|-
| uImage-imx6q-var-som.dtb
| style="padding: 5px;"| uImage-imx6q-var-som-cap.dtb
| VAR-SOM-MX6_V2 (Quad / Dual)
| style="padding: 5px;"| VAR-SOM-MX6_V2 (Quad / Dual)
| VAR-MX6CustomBoard
| style="padding: 5px;"| VAR-MX6CustomBoard
| Capacitive/Resistive touch
| style="padding: 5px;"| Capacitive touch
| VAR-DVK-MX6_V2-PRO<br/>VAR-STK-MX6_V2
| style="padding: 5px;"| VAR-DVK-MX6_V2-PRO<br>VAR-STK-MX6_V2
|-
| style="padding: 5px;"| uImage-imx6q-var-som-res.dtb
| style="padding: 5px;"| VAR-SOM-MX6_V2 (Quad / Dual)
| style="padding: 5px;"| VAR-MX6CustomBoard
| style="padding: 5px;"| Resistive touch
| style="padding: 5px;"| VAR-DVK-MX6_V2-PRO<br>VAR-STK-MX6_V2
|-
| style="padding: 5px;"| uImage-imx6q-var-som-vsc.dtb
| style="padding: 5px;"| VAR-SOM-MX6_V2 (Quad / Dual)
| style="padding: 5px;"| VAR-SOLOCustomBoard
| style="padding: 5px;"| Capacitive LVDS touch
| style="padding: 5px;"| N/A
|-
| style="padding: 5px;"| uImage-imx6dl-var-som-cap.dtb
| style="padding: 5px;"| VAR-SOM-MX6_V2 (DualLite/ Solo)
| style="padding: 5px;"| VAR-MX6CustomBoard
| style="padding: 5px;"| Capacitive touch
| style="padding: 5px;"| N/A
|-
|-
| uImage-imx6q-var-som-vsc.dtb
| style="padding: 5px;"| uImage-imx6dl-var-som-res.dtb
| VAR-SOM-MX6_V2 (Quad / Dual)
| style="padding: 5px;"| VAR-SOM-MX6_V2 (DualLite/ Solo)
| VAR-SOLOCustomBoard
| style="padding: 5px;"| VAR-MX6CustomBoard
| Capacitive LVDS touch
| style="padding: 5px;"| Resistive touch
| N/A
| style="padding: 5px;"| N/A
|-
|-
| uImage-imx6dl-var-som.dtb
| style="padding: 5px;"| uImage-imx6dl-var-som-vsc.dtb
| VAR-SOM-MX6_V2 (DualLite/ Solo)
| style="padding: 5px;"| VAR-SOM-MX6_V2 (DualLite/ Solo)
| VAR-MX6CustomBoard
| style="padding: 5px;"| VAR-SOLOCustomBoard
| Capacitive/Resistive touch
| style="padding: 5px;"| Capacitive LVDS touch
| N/A
| style="padding: 5px;"| N/A
|-
|-
| uImage-imx6dl-var-som-solo-vsc.dtb
| style="padding: 5px;"| uImage-imx6dl-var-som-solo-vsc.dtb
| VAR-SOM-SOLO / VAR-SOM-DUAL
| style="padding: 5px;"| VAR-SOM-SOLO / VAR-SOM-DUAL
| VAR-SOLOCustomBoard
| style="padding: 5px;"| VAR-SOLOCustomBoard
| Capacitive LVDS touch
| style="padding: 5px;"| Capacitive LVDS touch
| VAR-DVK-SOLO/DUAL VAR-STK-SOLO/DUAL
| style="padding: 5px;"| VAR-DVK-SOLO/DUAL<br>VAR-STK-SOLO/DUAL
|-
|-
| uImage-imx6dl-var-som-solo.dtb
| style="padding: 5px;"| uImage-imx6dl-var-som-solo-cap.dtb
| VAR-SOM-SOLO / VAR-SOM-DUAL
| style="padding: 5px;"| VAR-SOM-SOLO / VAR-SOM-DUAL
| VAR-MX6CustomBoard
| style="padding: 5px;"| VAR-MX6CustomBoard
| Capacitive/Resistive touch
| style="padding: 5px;"| Capacitive touch
| N/A
| style="padding: 5px;"| N/A
|-
|-
| uImage-imx6q-var-dart.dtb
| style="padding: 5px;"| uImage-imx6dl-var-som-solo-res.dtb
| VAR-SOM-SOLO / VAR-SOM-DUAL
| style="padding: 5px;"| VAR-SOM-SOLO / VAR-SOM-DUAL
| VAR-DT6CustomBoard
| style="padding: 5px;"| VAR-MX6CustomBoard
| Capacitive LVDS touch
| style="padding: 5px;"| Resistive touch
| VAR-STK-DT6.VAR-DVK-DT6
| style="padding: 5px;"| N/A
|-
|-
|}
|}


== NAND Flashing scripts==
== NAND Flashing scripts==
If you followed the [[VAR-SOM-MX6 Yocto Jethro R4 Build Yocto release#Create_an_extended_SD_card |Create an extended SD card]] steps, the [[VAR-SOM-MX6 NAND Flash Burning Jethro#NAND flash flashing scripts |NAND flashing scripts]] will be included in your SD card. <br>
The [[VAR-SOM-MX6 NAND Flash Burning Jethro#NAND flash flashing scripts |NAND flashing scripts]] are easy-to-use example scripts for burning images into NAND flash / eMMC.<br>


If you followed [[VAR-SOM-MX6 Yocto Jethro R4 Build Yocto release#Create_an_extended_SD-Card |Create an extended SD-Card]] the [[VAR-SOM-MX6 NAND Flash Burning Jethro#NAND-Flash Flashing scripts |NAND flashing scripts]] will be included in your SD-Card. <br>
=== NAND flash images locations ===
The [[VAR-SOM-MX6 NAND Flash Burning Jethro#NAND-Flash Flashing scripts |NAND flashing scripts]] are easy-to-use example scripts for burning images into NAND Flash<br>
Following is the directory structure on your SD card, which elaborates the files' location that the below flashing scripts are expecting:
 
 
=== NAND-Flash images locations ===
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/
├── 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
└── Yocto
    ├── SPL
     ├── rootfs.tar.bz2
     ├── rootfs.tar.bz2
     ├── rootfs.ubi.img
     ├── rootfs.ubi.img
    ├── SPL
    ├── SPL.mmc
     ├── u-boot.img
     ├── u-boot.img
    ├── u-boot.img.mmc
     ├── uImage
     ├── uImage
     ├── uImage-imx6dl-var-som.dtb
     ├── uImage-imx6dl-var-som-cap.dtb
     ├── uImage-imx6dl-var-som-solo.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-solo-vsc.dtb
     ├── uImage-imx6q-var-dart.dtb
    ├── uImage-imx6dl-var-som-vsc.dtb
     ├── uImage-imx6q-var-som.dtb
     ├── uImage-imx6q-var-som-cap.dtb
     ├── uImage-imx6q-var-som-res.dtb
     └── uImage-imx6q-var-som-vsc.dtb
     └── uImage-imx6q-var-som-vsc.dtb
</pre>
</pre>


== Prepare images for NAND-Flash / eMMC burning ==
== Prepare images for NAND flash / eMMC flashing ==
Plug the bootable SDCARD into your host machine.
Plug the bootable SD card into your host machine.
Then your host machine should mount the rootfs partition on /media/rootfs.<br>
Then your host machine should mount the rootfs partition on /media/rootfs.<br>
Copy all yocto-built binaries into SD-Card:
Copy all the mentioned yocto-built binaries to the SD card:
<br>
<br>
* <span style="color:red">Note:</span> If you followed [[VAR-SOM-MX6 Yocto Jethro R4 Build Yocto release#Create an extended SD-Card |Create an extended SD-Card]] the [[VAR-SOM-MX6 NAND Flash Burning Jethro#NAND-Flash Flashing scripts |NAND flashing scripts]] and all relevant binaries are already included in your SD-Card! and below commands are redundant<br>
* <span style="color:red">Note:</span> If you followed the [[VAR-SOM-MX6 Yocto Jethro R4 Build Yocto release#Create an extended SD card |Create an extended SD card]] steps, the [[VAR-SOM-MX6 NAND Flash Burning Jethro#NAND flash flashing scripts|NAND flashing scripts]] and all relevant binaries are already included in your SD card, and the below commands are redundant!<br>


<pre>
<pre>
$ export YOCTO_ROOT=~/var-som-mx6-yocto-fido
$ export YOCTO_IMGS_PATH=~/var-som-mx6-yocto-jethro/tmp/deploy/images/var-som-mx6
$ export P2_MOUNT_DIR=/media/rootfs/


Linux:
Linux:
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/var-som-mx6/uImage /media/rootfs/opt/images/Yocto
$ sudo cp ${YOCTO_IMGS_PATH}/uImage ${P2_MOUNT_DIR}/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
SPL/U-Boot:
$ 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_IMGS_PATH}/SPL-nand ${P2_MOUNT_DIR}/opt/images/Yocto/SPL
$ sudo cp ${YOCTO_ROOT}/build_x11/tmp/deploy/images/var-som-mx6/SPL-sd /media/rootfs/opt/images/Yocto/SPL.mmc
$ sudo cp ${YOCTO_IMGS_PATH}/u-boot-nand-2015.04-r0.img ${P2_MOUNT_DIR}/opt/images/Yocto/u-boot.img
$ 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:
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_IMGS_PATH}/fsl-image-gui-var-som-mx6.tar.bz2 ${P2_MOUNT_DIR}/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
$ sudo cp ${YOCTO_IMGS_PATH}/fsl-image-gui-var-som-mx6.ubi ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.ubi.img
 
Device Tree:
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_IMGS_PATH}/uImage-imx6dl-var-som-cap.dtb ${P2_MOUNT_DIR}/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_IMGS_PATH}/uImage-imx6dl-var-som-res.dtb ${P2_MOUNT_DIR}/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_IMGS_PATH}/uImage-imx6dl-var-som-solo-cap.dtb ${P2_MOUNT_DIR}/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_IMGS_PATH}/uImage-imx6dl-var-som-solo-res.dtb ${P2_MOUNT_DIR}/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_IMGS_PATH}/uImage-imx6dl-var-som-solo-vsc.dtb ${P2_MOUNT_DIR}/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/
$ 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/
</pre>
</pre>


== NAND-Flash Flashing scripts ==
== NAND flash flashing scripts ==
The flashing scripts are located at /media/rootfs/sbin/
The flashing scripts are located on the SD card at /usr/bin/:
<pre>
$ 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
</pre>
* in case of yocto-emmc.sh, change boot arguments to : <br>
<pre>
<pre>
$ setenv bootargs console=ttymxc0,115200 video=mxcfb1:off root=/dev/mmcblk1p1 rootwait rw
install_yocto.sh - Flash Yocto into NAND flash or eMMC (Run and follow usage instructions)
$ saveenv
(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!)
</pre>
</pre>


== Manual step-by-step flashing to NAND ==
== Manual step-by-step flashing to NAND ==
=== Flash U-BOOT ===
Assuming you followed the [[#Prepare images for NAND flash / eMMC flashing|Prepare images for NAND flash / eMMC flashing]] section above:
Flashing U-BOOT reguire to flash 2 parts: SPL and u-boot.img.
=== Flash SPL & U-Boot ===
Assume you copy SPL-nand and u-boot-nand-2014.04-r0.img to the right directory as showed above.
<pre>
<pre>
$ cd /opt/images/Yocto
$ cd /opt/images/Yocto
$ flash_erase /dev/mtd0 0 0
$ flash_erase /dev/mtd0 0 0
$ kobs-ng init -x SPL --search_exponent=1 -v
$ kobs-ng init -x SPL --search_exponent=1 -v
$ flash_erase /dev/mtd1 0 0
$ flash_erase /dev/mtd1 0 0
$ nandwrite -p /dev/mtd1 u-boot.img
$ nandwrite -p /dev/mtd1 u-boot.img
</pre>
</pre>
=== Flash Linux Kernel ===
 
Flashing Linux kernel reguire to flash 2 parts: uImage and device tree.
=== Flash Linux Kernel image & Device Tree ===
Assume you copy uImage and device tree to the right directory as showed above.
You need to pick and choose the right .dtb file. See the [[#Yocto Built binaries for NAND flash|table]] above for a complete description.
You also need to pick and coose the right DTB file. See table above for a complete description.
<pre>
<pre>
$ cd /opt/images/Yocto
$ cd /opt/images/Yocto
Line 202: Line 192:


=== Flash UBIFS ===
=== Flash UBIFS ===
The parameters for the UBIFS UBI_SUB_PAGE_SIZE=2048 and UBI_VID_HDR_OFFSET=2048.
<pre>
<pre>
$ cd /opt/images/Yocto
$ cd /opt/images/Yocto
$ flash_erase /dev/mtd3 0 0
$ ubiformat /dev/mtd3 -f rootfs.ubi.img
$ ubiformat /dev/mtd3 -f rootfs.ubi.img -s 2048 -O 2048
</pre>
</pre>


== Flash File System to eMMC ==
== Flash File System to eMMC ==
Flashing eMMC is a complex task. It requires several steps including partition, format and untar the file system.
Flashing eMMC requires several steps including partition, format and untar of the file system.
We highly recommend to use our provided scripts to perform this task.
We recommend to use our provided scripts to perform this task.<br>
Assuming that you use our NAND recovery utility.
<br>
 
Make sure the eMMC is not mounted.
<pre>
<pre>
$ export node=/dev/mmcblk0
$ 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 ${node} <<EOF
$ umount ${node}p*
d
1
d
2
d
3
d
w
EOF
 
$ sync
</pre>
</pre>


Delete MBR
Delete current data on eMMC:
<pre>
<pre>
$ dd if=/dev/zero of=${node} bs=512 count=1000
$ 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
$ sync
</pre>
</pre>


Call sfdisk to create partition table
Create partition table:
<pre>
<pre>
$ node=/dev/mmcblk1
$ (echo n; echo p; echo 1; echo; echo; echo p; echo w) | fdisk -u $node
$ seprate=40
$ sync
$ total_size=`sfdisk -s ${node}`
$ total_size=`expr ${total_size} / 1024`
 
$ sfdisk --force -uM ${node} << EOF
,${total_size},83
EOF
 
</pre>
</pre>


Format Linux
Format the rootfs partition with ext4 file system:
<pre>
<pre>
$ mkfs.ext4 ${node} -Lrootfs
$ mkfs.ext4 ${node}p1 -L rootfs
</pre>
</pre>


Flash Linux
Flash the rootfs:
<pre>
<pre>
$ mkdir /run/media/mmcblk1p1
$ mkdir /run/media/mmcblk0p1
$ mount ${node} /run/media/mmcblk1p1
$ mount ${node}p1 /run/media/mmcblk0p1
$ tar xvpf rootfs.tar.bz2 -C /run/media/mmcblk1p1/
$ tar xvpf rootfs.tar.bz2 -C /run/media/mmcblk1p1/
</pre>
</pre>


in case of Yocto eMMC file system stop at u-boot and change boot arguments to :
In case of installing the rootfs to eMMC, set the "rootfs_device" U-Boot env. variable to "emmc" by one of the following two methods:
<pre>
$ 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)
</pre>
or:
<pre>
<pre>
$ setenv bootargs console=ttymxc0,115200 video=mxcfb1:off root=/dev/mmcblk1p1 rootwait rw
Reboot and stop at the U-Boot command line, and enter the following:
$ saveenv
=> setenv rootfs_device emmc
=> saveenv
</pre>
</pre>


= Summary =
= Summary =
We describe the results of Yocto build, how to copy it to SDCARD and how to flash it to NAND and eMMC.
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.<br>
This page is not valid for DART-MX6. Please follow the link to the relevant page.
This page is not valid for DART-MX6. Please follow the link to the relevant page.<br>
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.
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>
<br/>/media/rootfs/sbin/:
<br/>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. <br/>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)

Revision as of 15:36, 31 July 2016

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 the file system resides on NAND, UBIFS file system is used.
When file system resides on eMMC, ext4 file system is used.
Regardless of the file system type and location, 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-0x000000c00000 : "kernel"
0x000000c00000-0x000040000000 : "rootfs"

Yocto Built binaries for NAND flash

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 NAND flash based system:
SPL, U-Boot, uImage, dtb file, (UBI) file system image file.

Image Name
How to use
fsl-image-gui-var-som-mx6.tar.bz2 Tarball of the rootfs used for eMMC (for extracting into the ext4 partition on eMMC)
(Needed only in case of using the eMMC for file system)
fsl-image-gui-var-som-mx6.ubi A complete UBI file system binary ("rootfs")
(Needed only in case of using the NAND flash for file system)
uImage Linux kernel image ("kernel")
SPL-nand The SPL is pre-U-Boot SW component, required for DDR intialization ("spl")
u-boot-nand-2015.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-cap.dtb VAR-SOM-MX6_V2 (Quad / Dual) VAR-MX6CustomBoard Capacitive touch VAR-DVK-MX6_V2-PRO
VAR-STK-MX6_V2
uImage-imx6q-var-som-res.dtb VAR-SOM-MX6_V2 (Quad / Dual) VAR-MX6CustomBoard 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-cap.dtb VAR-SOM-MX6_V2 (DualLite/ Solo) VAR-MX6CustomBoard Capacitive touch N/A
uImage-imx6dl-var-som-res.dtb VAR-SOM-MX6_V2 (DualLite/ Solo) VAR-MX6CustomBoard Resistive touch N/A
uImage-imx6dl-var-som-vsc.dtb VAR-SOM-MX6_V2 (DualLite/ Solo) VAR-SOLOCustomBoard Capacitive LVDS 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-cap.dtb VAR-SOM-SOLO / VAR-SOM-DUAL VAR-MX6CustomBoard Capacitive touch N/A
uImage-imx6dl-var-som-solo-res.dtb VAR-SOM-SOLO / VAR-SOM-DUAL VAR-MX6CustomBoard Resistive touch N/A

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
    ├── SPL
    ├── 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:

$ 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 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/

In case of installing the rootfs to eMMC, set the "rootfs_device" U-Boot env. variable 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

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.
This page is not valid for DART-MX6. Please follow the link to the relevant page.
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.