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

From Variscite Wiki
 
(14 intermediate revisions by the same user not shown)
Line 10: Line 10:
For DART-MX6 please use: [[VAR-SOM-MX6 DART eMMC flashing Jethro|DART eMMC flashing]]|info}}
For DART-MX6 please use: [[VAR-SOM-MX6 DART eMMC flashing Jethro|DART eMMC flashing]]|info}}


== NAND Structure ==
= NAND flash structure =
When system boots, kernel logs will present 4 relevant partitions defined.
These are the defined MTD partitions on the NAND flash:<br>
<br>0x000000000000-0x000000200000 : "spl"
0x000000000000-0x000000200000 : "spl"<br>
<br>0x000000200000-0x000000400000 : "bootloader"
0x000000200000-0x000000400000 : "bootloader"<br>
<br>0x000000400000-0x000000c00000 : "kernel"
0x000000400000-0x000000c00000 : "kernel"<br>
<br>0x000000c00000-0x000040000000 : "rootfs"
0x000000c00000-End &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : "rootfs"<br>


== Yocto Built binaries for NAND flash ==
= Yocto Built binaries for NAND flash / eMMC =
The resulted images are located at tmp/deploy/images/var-som-mx6.<br>
The resulted images are located at tmp/deploy/images/var-som-mx6.<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/>
Looking at tmp/deploy/images/var-som-mx6 you will find the following five required files for a complete NAND flash based system:<br/>
Line 39: Line 39:
| style="padding: 5px;"| The SPL is pre-U-Boot SW component, required for DDR intialization ("spl")
| style="padding: 5px;"| The SPL is pre-U-Boot SW component, required for DDR intialization ("spl")
|-
|-
| style="padding: 5px;"| u-boot-nand-2015.04-r0.img
| style="padding: 5px;"| u-boot.img-nand
| style="padding: 5px;"| U-Boot built for NAND ("bootloader")
| style="padding: 5px;"| U-Boot built for NAND ("bootloader")
|-
|-
Line 104: Line 104:
|}
|}


== NAND Flashing scripts==
= Installing the Yocto binaries =
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>
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 [[#Images locations|Yocto binaries]] and the [[#Flashing scripts|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>
The flashing scripts are easy-to-use example scripts for flashing images into NAND flash / eMMC.<br>
There is also a section below describing how to [[#Manual step-by-step flashing to NAND flash / eMMC|flash the images manually]].


=== NAND flash images locations ===
== Images locations ==
Following is the directory structure on your SD card, which elaborates the files' location that the below flashing scripts are expecting:
Following is the directory structure on your SD card, which elaborates the files' location that the below installation scripts are expecting:
<pre>
<pre>
/opt/images/
/opt/images/
Line 129: Line 130:
</pre>
</pre>


== Prepare images for NAND flash / eMMC flashing ==
=== Prepare the images for NAND flash / eMMC flashing ===
Plug the bootable SD card into your host machine.
Plug the bootable SD card into your host machine and mount the rootfs partition - here we assume it is mounted on /media/rootfs.<br>
Then your host machine should mount the rootfs partition on /media/rootfs.<br>
Copy all the mentioned yocto-built binaries to the SD card:
Copy all the mentioned yocto-built binaries to the SD card:
<br>
<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>
* <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 [[#Flashing scripts|flashing scripts]] and all relevant binaries are already included in your SD card, and the below commands are redundant!<br>


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


Line 164: Line 164:
</pre>
</pre>


== NAND flash flashing scripts ==
== Flashing scripts ==
The flashing scripts are located on the SD card at /usr/bin/:
The flashing scripts are located on the SD card at /usr/bin/:
<pre>
<pre>
Line 171: Line 171:
</pre>
</pre>


== Manual step-by-step flashing to NAND ==
== Manual step-by-step flashing to NAND flash / eMMC ==
Assuming you followed the [[#Prepare images for NAND flash / eMMC flashing|Prepare images for NAND flash / eMMC flashing]] section above:
 
=== Flash SPL & U-Boot ===
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 SPL & U-Boot:
<pre>
$ 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
Line 182: Line 188:
</pre>
</pre>


=== Flash Linux Kernel image & Device Tree ===
Flash the Linux Kernel image & Device Tree:<br>
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 need to use the right .dtb file for you hardware setup. See the [[#Yocto Built binaries for NAND flash|table]] above for a complete description.
<pre>
<pre>
$ cd /opt/images/Yocto
$ flash_erase /dev/mtd2 0 0
$ flash_erase /dev/mtd2 0 0
$ nandwrite -p /dev/mtd2 uImage
$ nandwrite -p /dev/mtd2 uImage
Line 191: Line 196:
</pre>
</pre>


=== Flash UBIFS ===
Flash the (UBI) File System to NAND flash:
<pre>
<pre>
$ cd /opt/images/Yocto
$ ubiformat /dev/mtd3 -f rootfs.ubi.img
$ ubiformat /dev/mtd3 -f rootfs.ubi.img
</pre>
</pre>


== Flash File System to eMMC ==
Flash the (ext4) File System to eMMC:<br>
Flashing eMMC requires several steps including partition, format and untar of the file system.
Flashing the eMMC requires several steps including partitioning, file system formatting and image extraction.<br>
We recommend to use our provided scripts to perform this task.<br>
We recommend to use our provided scripts to perform this task.<br>
<br>
<pre>
<pre>
$ export node=/dev/mmcblk0
$ export node=/dev/mmcblk0
$ cd /opt/images/Yocto
</pre>


Make sure the eMMC is not mounted:
Make sure the eMMC is not mounted:
<pre>
$ umount ${node}p*
$ umount ${node}p*
</pre>


Delete current data on eMMC:
Delete current data on eMMC:
<pre>
$ dd if=/dev/zero of=${node}p1 bs=1024 count=1024
$ 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}p2 bs=1024 count=1024
Line 225: Line 223:
$ dd if=/dev/zero of=$node bs=1M count=4
$ dd if=/dev/zero of=$node bs=1M count=4
$ sync
$ sync
</pre>


Create partition table:
Create a partition table:
<pre>
$ (echo n; echo p; echo 1; echo; echo; echo p; echo w) | fdisk -u $node
$ (echo n; echo p; echo 1; echo; echo; echo p; echo w) | fdisk -u $node
$ sync
$ sync
</pre>


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


Flash the rootfs:
Flash the rootfs:
<pre>
$ mkdir /run/media/mmcblk0p1
$ mkdir /run/media/mmcblk0p1
$ mount ${node}p1 /run/media/mmcblk0p1
$ mount ${node}p1 /run/media/mmcblk0p1
Line 245: Line 237:
$ sync
$ sync
$ umount /run/media/mmcblk0p1
$ umount /run/media/mmcblk0p1
</pre>




And finally, set the U-Boot env. variable "rootfs_device" to "emmc" by one of the following two methods:
And finally, set the U-Boot env. variable "rootfs_device" to "emmc" by one of the following two methods:
<pre>
$ fw_setenv rootfs_device emmc
$ 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)
(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:
or:
<pre>
Reboot and stop at the U-Boot command line, and enter the following:
Reboot and stop at the U-Boot command line, and enter the following:
=> setenv rootfs_device emmc
=> setenv rootfs_device emmc

Latest revision as of 12:12, 20 December 2018

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: DART eMMC flashing

NAND flash structure

These are the defined MTD partitions on the NAND flash:
0x000000000000-0x000000200000 : "spl"
0x000000200000-0x000000400000 : "bootloader"
0x000000400000-0x000000c00000 : "kernel"
0x000000c00000-End                       : "rootfs"

Yocto Built binaries for NAND flash / eMMC

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, 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.img-nand 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

Installing the Yocto binaries

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

Images locations

Following is the directory structure on your SD card, which elaborates the files' location that the below installation 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 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-som-mx6-yocto-jethro/build_x11/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/

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 flash / eMMC

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

$ cd /opt/images/Yocto

Flash SPL & U-Boot:

$ 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 the Linux Kernel image & Device Tree:
You need to use the right .dtb file for you hardware setup. See the table above for a complete description.

$ 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 the (UBI) File System to NAND flash:

$ ubiformat /dev/mtd3 -f rootfs.ubi.img

Flash the (ext4) File System to eMMC:
Flashing the eMMC requires several steps including partitioning, file system formatting and image extraction.
We recommend to use our provided scripts to perform this task.

$ export node=/dev/mmcblk0

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.