Yocto NAND Flash Burning: Difference between revisions

From Variscite Wiki
(Add support for Debian)
 
(163 intermediate revisions by 7 users not shown)
Line 1: Line 1:
<!-- Set release according to "release" parameter in URL and use MORTY_BETA_DART-6UL as default
<!-- Set release according to "release" parameter in URL and use MORTY_V1.0_DART-6UL as default
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!--
--> {{INIT_RELEASE_PARAM|RELEASE_MORTY_V1.0_DART-6UL}}<!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_MORTY_BETA_DART-6UL}}}} <!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{PageHeader|Yocto NAND Flash Burning}} {{DocImage|category1={{#var:HARDWARE_NAME}}|category2=Yocto}} __toc__
--> {{#lst:Debian_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:B2QT_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#varexists:DEFAULT_IMAGE_BB_NAME | | {{ #vardefine:DEFAULT_IMAGE_BB_NAME | fsl-image-gui }} }} <!--
--> {{#vardefine:PLATFORM_OS | {{#varexists:DEBIAN_NAME | Debian | Yocto }} }} <!--
--> {{#vardefine:BUILD_RELEASE_GUIDE | {{#varexists:DEBIAN_NAME | Yocto_Debian_Build_Release | Yocto_Build_Release }} }} <!--
--> {{#vardefine:BUILD_FOLDER_DISTRO | {{ #varexists:BUILD_FOLDER_X11 | {{#var:BUILD_FOLDER_X11}} | {{ #varexists:BUILD_FOLDER_XWAYLAND | {{#var:BUILD_FOLDER_XWAYLAND}} | {{#var:BUILD_FOLDER_B2QT}} }} }} }}<!--
--> {{#vardefine:SOC_SERIES|{{#var:SOC_SERIES|imx}}}} <!-- SOC_SERIES is not defined in some older YPC
--> {{PageHeader|Installing {{#var:PLATFORM_OS}} to the SOM's internal storage}} {{DocImage|category1={{#var:PLATFORM_OS}}|category2={{#var:HARDWARE_NAME}}}} __toc__
= Introduction =
= Introduction =
All SOMs can either boot from an SD card or from their internal storage.<br>
<br>
The SOM's internal storage:<br>
{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX6 |
{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX6 |
The Variscite VAR-SOM-MX6 / VAR-SOM-SOLO SOMs use the on-SOM NAND flash to boot.<br>
* '''VAR-SOM-MX6 and VAR-SOM-SOLO/DUAL''' SOMs use the on-SOM NAND flash to boot.<br>
The file system can reside either on the NAND flash or the eMMC.<br>
The file system can reside either on the NAND flash or the eMMC.<br>
When the file system resides on NAND, UBIFS file system is used.<br>
When the file system resides on the NAND flash, a UBIFS file system is used.<br>
When file system resides on eMMC, ext4 file system is used.<br>
When the file system resides on the eMMC, an ext4 file system is used.<br>
Regardless of the file system type and location, U-Boot will always boot from NAND.
Regardless of the file system type and location, U-Boot will always boot from the NAND flash.<br>
The only exception is the VAR-DART-MX6, where boot is from eMMC completely.<br>
By default, the kernel image and device tree blob are also written to the NAND flash (again, regardless of the file system type and location).
{{note| NOTE:<br>This Wiki is only valid for VAR-SOM-MX6, VAR-SOM-SOLO/DUAL.
* '''VAR-DART-MX6''' has only an on-SOM eMMC which can be used to boot from and to hold the filesystem.
For DART-MX6 please use: [[VAR-SOM-MX6 DART eMMC flashing Jethro|DART eMMC flashing]]|info}}
|
{{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=
The Variscite {{#var:HARDWARE_NAME}} comes with eMMC, which holds U-Boot, the kernel image and the ext4 root file system.<br>
|
|
The Variscite {{#var:HARDWARE_NAME}} 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>
The Variscite {{#var:HARDWARE_NAME}} 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>
For NAND flash we use a UBI file system and for eMMC we use ext4.
For NAND flash we use a UBI file system and for eMMC we use ext4.
}}
}}
}}


{{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=|#default=
= NAND flash structure =
= NAND flash structure =
{{#ifeq: {{#var:MACHINE_NAME}} | var-som-mx6 |* '''VAR-SOM-MX6 and VAR-SOM-SOLO/DUAL'''
These are the defined MTD partitions on the NAND flash:<br>
These are the defined MTD partitions on the NAND flash:<br>
0x000000000000-0x000000200000 : "spl"<br>
0x000000000000-0x000000200000 : "spl"<br>
0x000000200000-0x000000400000 : "bootloader"<br>
0x000000200000-0x000000400000 : "bootloader"<br>
0x000000400000-0x000000c00000 : "kernel"<br>
0x000000400000-0x000000c00000 : "kernel"'''<br>
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>
0x000000c00000-End &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : "rootfs"
{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX7 |
|
{{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.}}
0x000000000000-0x000000200000 : "spl"<br>
|}}
0x000000200000-0x000000400000 : "u-boot"<br>
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;&nbsp;&nbsp;&nbsp; : "rootfs"<br>}}
}}
 
= eMMC structure =
{{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=
0-8 MiB &nbsp;&nbsp;&nbsp;&nbsp; : Non-partitioned space, saved for U-Boot.<br>
8 MiB-End: "rootfs" - An ext4 partition containing the root file system (including Linux image and the device tree blobs under /boot).
|
{{#ifeq: {{#var:MACHINE_NAME}} | var-som-mx6 |* '''VAR-SOM-MX6 and VAR-SOM-SOLO/DUAL'''
0 MiB-End: "rootfs" - An ext4 partition containing the root file system (including the kernel modules).
* '''VAR-DART-MX6'''|}}
0-4 MiB &nbsp;&nbsp;&nbsp;&nbsp; : Non-partitioned space, saved for U-Boot.<br>
4-12 MiB &nbsp;&nbsp; : {{#var:EMMC_FAT_PARTITION_NAME}} - 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).}}


{{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=|#default=
= Yocto Built binaries for NAND flash / eMMC =
= Yocto Built binaries for NAND flash / eMMC =
The resulted images are located at tmp/deploy/images/{{#var:MACHINE_NAME}}.<br>
 
The resulting images are located at tmp/deploy/images/{{#var:MACHINE_NAME}}.<br>
{{#lst:Yocto_Build_Release|YOCTO_BUILD_RESULTS}}
{{#lst:Yocto_Build_Release|YOCTO_BUILD_RESULTS}}
{{#lst:Yocto_Platform_Customization|{{#var:YOCTO_BUILD_RESULTS_SECTION}}}}
{{#lst:Yocto_Platform_Customization|{{#var:YOCTO_BUILD_RESULTS_SECTION}}}}
{{#ifeq: {{#var:MACHINE_NAME}} | var-som-mx6 | |
= eMMC structure =
0-4 MiB &nbsp;&nbsp;&nbsp;&nbsp; : Non-partitioned space, saved for U-Boot.<br>
4-12 MiB &nbsp;&nbsp; : {{#var:EMMC_FAT_PARTITION_NAME}} - 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>
}}
}}


= Installing the Yocto binaries =
= Installing the {{#var:PLATFORM_OS}} binaries =
If you followed the [[Yocto_Build_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>
If you followed the {{Varlink|{{#var:BUILD_RELEASE_GUIDE}}#Create an extended SD card|{{#var:RELEASE_LINK}}|Create an extended SD card}} steps, the [[#Images locations|{{#var:PLATFORM_OS}} binaries]] and the [[#Flashing scripts|flashing scripts]] will be included in your SD card. <br>
The flashing scripts are easy-to-use example scripts for flashing 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]].
There is also a section below describing how to flash the images manually.


== Images locations ==
== Images locations ==
Following is the directory structure on your SD card, which elaborates the files' location that the below installation scripts are expecting:
Following is the directory structure on your SD card, which elaborates the files' location that the below installation scripts are expecting:
{{#lst:Yocto_Platform_Customization|{{#var:SD_TREE_SECTION}}}}
{{#lst:{{#var:PLATFORM_OS}}_Platform_Customization|{{#var:SD_TREE_SECTION}}}}


{{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=
=== Prepare the images for flashing to eMMC  ===
|#default=
=== Prepare the images for NAND flash / eMMC flashing ===
=== 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>
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:
Copy all the mentioned yocto-built binaries to the SD card:
<br>
<br>
* <span style="color:red">Note:</span> If you followed the [[Yocto_Build_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>
* <span style="color:red">Note:</span> If you followed the [[{{#var:BUILD_RELEASE_GUIDE}}#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>


Setup:
$ export YOCTO_IMGS_PATH={{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_DISTRO}}/tmp/deploy/images/{{#var:MACHINE_NAME}}
$ export P2_MOUNT_DIR=/media/rootfs/
$ sudo mkdir -p ${P2_MOUNT_DIR}/opt/images/{{#var:PLATFORM_OS}}/


$ export YOCTO_IMGS_PATH={{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_X11}}/tmp/deploy/images/{{#var:MACHINE_NAME}}
{{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=|#default=
$ export P2_MOUNT_DIR=/media/rootfs/
Linux:
$ sudo cp ${YOCTO_IMGS_PATH}/{{#var:KERNEL_IMAGE}} ${P2_MOUNT_DIR}/opt/images/{{#var:PLATFORM_OS}}/


Linux:
Device Tree:
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:KERNEL_IMAGE}}                 ${P2_MOUNT_DIR}/opt/images/Yocto/
  $ for f in ${YOCTO_IMGS_PATH}/*.dtb; do if <nowiki>[[ -L $f ]] && [[</nowiki> $f != *{{#var:MACHINE_NAME}}.dtb <nowiki>]]</nowiki>; then sudo cp $f ${P2_MOUNT_DIR}/opt/images/{{#var:PLATFORM_OS}}/; fi done
$ sudo rename 's/{{#var:KERNEL_IMAGE}}-imx/imx/' ${P2_MOUNT_DIR}/opt/images/{{#var:PLATFORM_OS}}/*.dtb


NAND images:
NAND images:
 
  {{#ifeq: {{#var:SPL_SD_IMAGE_NAME}} | N/A ||SPL:
Device Tree:
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:SPL_NAND_IMAGE_NAME}} ${P2_MOUNT_DIR}/opt/images/{{#var:PLATFORM_OS}}/
  {{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
$ sudo cp ${YOCTO_IMGS_PATH}/{{#var:KERNEL_IMAGE}}-imx*.dtb                      ${P2_MOUNT_DIR}/opt/images/Yocto/
|
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:KERNEL_IMAGE}}-imx*nand*.dtb                      ${P2_MOUNT_DIR}/opt/images/Yocto/
$ sudo rename 's/{{#var:KERNEL_IMAGE}}-imx/imx/'                                    ${P2_MOUNT_DIR}/opt/images/Yocto/*.dtb
  }}
  }}
   
   
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX7|
  U-Boot:
  U-Boot:
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:U-BOOT_NAND_IMAGE_NAME}}                 ${P2_MOUNT_DIR}/opt/images/Yocto/u-boot.img
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:U-BOOT_NAND_IMAGE_NAME}} ${P2_MOUNT_DIR}/opt/images/{{#var:PLATFORM_OS}}/
  |
   
  SPL/U-Boot:
  File System:
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:SPL_NAND_IMAGE_NAME}}                           ${P2_MOUNT_DIR}/opt/images/Yocto/SPL
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:DEFAULT_IMAGE_BB_NAME}}-{{#var:MACHINE_NAME}}.ubi ${P2_MOUNT_DIR}/opt/images/{{#var:PLATFORM_OS}}/rootfs.ubi
$ sudo cp ${YOCTO_IMGS_PATH}/{{#var:U-BOOT_NAND_IMAGE_NAME}}                 ${P2_MOUNT_DIR}/opt/images/Yocto/u-boot.img
}}
}}
eMMC images:
 
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|*'''VAR-SOM-MX6 and VAR-SOM-SOLO/DUAL'''
  File System:
  File System:
  $ sudo cp ${YOCTO_IMGS_PATH}/fsl-image-gui-{{#var:KERNEL_IMAGE}}.ubi         ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.ubi.img
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:DEFAULT_IMAGE_BB_NAME}}-{{#var:MACHINE_NAME}}.tar.gz ${P2_MOUNT_DIR}/opt/images/{{#var:PLATFORM_OS}}/rootfs.tar.gz
|}} <!--
 
-->{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|*'''DART-MX6'''|}}
{{#ifeq: {{#var:SPL_SD_IMAGE_NAME}} | N/A ||SPL:
$ sudo cp ${YOCTO_IMGS_PATH}/{{#var:SPL_SD_IMAGE_NAME}} ${P2_MOUNT_DIR}/opt/images/{{#var:PLATFORM_OS}}/
|}}


eMMC images:
{{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=
{{#vardefine:BOOTLOADER_NAME | {{#ifexpr: {{#var:KERNEL_VER}} >= 4.19 | imx-boot | imx-boot-{{#var:MACHINE_NAME}}-sd.bin }}}}
<br>
U-Boot:
$ sudo cp ${YOCTO_IMGS_PATH}/{{#var:BOOTLOADER_NAME}} ${P2_MOUNT_DIR}/opt/images/{{#var:PLATFORM_OS}}/{{#var:U-BOOT_SD_IMAGE_NAME}}
   
   
  {{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6||
  File System:
Device Tree:
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:DEFAULT_IMAGE_BB_NAME}}-{{#var:MACHINE_NAME}}.tar.gz ${P2_MOUNT_DIR}/opt/images/{{#var:PLATFORM_OS}}/rootfs.tar.gz
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:KERNEL_IMAGE}}-imx*emmc*.dtb                      ${P2_MOUNT_DIR}/opt/images/Yocto/
|
$ sudo rename 's/{{#var:KERNEL_IMAGE}}-imx/imx/'                                    ${P2_MOUNT_DIR}/opt/images/Yocto/*.dtb
<br>
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX7|
  U-Boot:  
  U-Boot:  
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:U-BOOT_SD_IMAGE_NAME}}                 ${P2_MOUNT_DIR}/opt/images/Yocto/u-boot.img
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:U-BOOT_SD_IMAGE_NAME}} ${P2_MOUNT_DIR}/opt/images/{{#var:PLATFORM_OS}}/
|
SPL/U-Boot:
$ sudo cp ${YOCTO_IMGS_PATH}/{{#var:SPL_SD_IMAGE_NAME}}                            ${P2_MOUNT_DIR}/opt/images/Yocto/SPL
$ sudo cp ${YOCTO_IMGS_PATH}/{{#var:U-BOOT_SD_IMAGE_NAME}}                 ${P2_MOUNT_DIR}/opt/images/Yocto/u-boot.img
}}
}}
   
   
  File System:
  File System:
  $ sudo cp ${YOCTO_IMGS_PATH}/fsl-image-gui-{{#var:KERNEL_IMAGE}}.tar.bz2 ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.tar.bz2
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:DEFAULT_IMAGE_BB_NAME}}-{{#var:MACHINE_NAME}}.tar.gz ${P2_MOUNT_DIR}/opt/images/{{#var:PLATFORM_OS}}/rootfs.tar.gz
}}


== 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>
{{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=
install_yocto.sh - Flash Yocto into NAND flash or eMMC (Run and follow usage instructions)
install_{{lc:{{#var:PLATFORM_OS}}}}.sh - Flash {{#var:PLATFORM_OS}} into 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!)
|
</pre>
install_{{lc:{{#var:PLATFORM_OS}}}}.sh - Flash {{#var:PLATFORM_OS}} into NAND flash or eMMC (Run and follow usage instructions)
}}
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
(install_{{lc:{{#var:PLATFORM_OS}}}}_emmc.sh - This script is being called by install_{{lc:{{#var:PLATFORM_OS}}}}.sh when choosing to install the rootfs to eMMC - it should not be called directly!)
|}}


== Manual step-by-step flashing to NAND flash / eMMC ==
{{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=
|
== Manual step-by-step flashing to NAND flash ==


Use the prepared SD card to boot the board and run the following:
Use the prepared SD card to boot the board and run the following:
<br>
<br>
<br>
<pre>
<pre>
$ cd /opt/images/Yocto
$ cd /opt/images/{{#var:PLATFORM_OS}}
</pre>
</pre>


Flash SPL & U-Boot:
{{#ifeq: {{#var:SPL_NAND_IMAGE_NAME}} | N/A |Flash U-Boot:| 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
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
$ flash_erase /dev/mtd1 0 0
$ kobs-ng init -x {{#var:SPL_NAND_IMAGE_NAME}} --search_exponent=1 -v
$ nandwrite -p /dev/mtd1 u-boot.img
$ flash_erase /dev/mtd1 0 0
</pre>
$ nandwrite -p /dev/mtd1 {{#var:U-BOOT_NAND_IMAGE_NAME}}
|
{{#ifeq: {{#var:HARDWARE_NAME}}|DART-6UL|
$ kobs-ng init -x {{#var:SPL_NAND_IMAGE_NAME}} --search_exponent=1 -v
$ flash_erase /dev/mtd1 0 0
$ nandwrite -p /dev/mtd1 {{#var:U-BOOT_NAND_IMAGE_NAME}}
$ flash_erase /dev/mtd2 0 0
|}}
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX7|
{{#ifeq: {{#var:SPL_NAND_IMAGE_NAME}} | N/A |
$ kobs-ng init -x {{#var:U-BOOT_NAND_IMAGE_NAME}} --search_exponent=1 -v
|
$ kobs-ng init -x {{#var:SPL_NAND_IMAGE_NAME}} --search_exponent=1 -v
$ flash_erase /dev/mtd1 0 0
$ nandwrite -p /dev/mtd1 {{#var:U-BOOT_NAND_IMAGE_NAME}}
}}
$ flash_erase /dev/mtd2 0 0
|}}
}}


Flash the Linux Kernel image & Device Tree:<br>
Flash the Linux Kernel image & Device Tree:<br>
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.
You need to use the right .dtb file for you hardware setup. See the [[#Yocto Built binaries for NAND flash / eMMC | table]] above for a complete description.
<pre>
 
$ flash_erase /dev/mtd2 0 0
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
$ nandwrite -p /dev/mtd2 uImage
$ flash_erase /dev/mtd2 0 0
$ nandwrite -p /dev/mtd1 -s 0x1e0000 uImage-imx6q-var-som.dtb (Example, select the right one!)
$ nandwrite -p /dev/mtd2 {{#var:KERNEL_IMAGE}}
</pre>
$ nandwrite -p /dev/mtd1 -s 0x1e0000 <DEVICE_TREE_FILE>
|
$ flash_erase /dev/mtd3 0 0
$ nandwrite -p /dev/mtd3 {{#var:KERNEL_IMAGE}}
$ nandwrite -p /dev/mtd3 -s 0x7e0000 <DEVICE_TREE_FILE>
}}


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


Flash the (ext4) File System to eMMC:<br>
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
$ ubiformat /dev/mtd3 -f rootfs.ubi
|
$ ubiformat /dev/mtd4 -f rootfs.ubi
}}
}}
 
== Manual step-by-step flashing to eMMC ==
 
Flashing the eMMC requires several steps including partitioning, file system formatting and image extraction.<br>
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>
Use the prepared SD card to boot the board and run the following:
$ export node=/dev/mmcblk0
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
* '''DART-MX6'''
$ export node=/dev/mmcblk2
$ cd /opt/images/{{#var:PLATFORM_OS}}
* '''VAR-SOM-MX6 and VAR-SOM-SOLO/DUAL'''
}}
$ export node=/dev/{{#var:EMMC_ROOTFS_DEV}}
$ cd /opt/images/{{#var:PLATFORM_OS}}


Make sure the eMMC is not mounted:
Make sure the eMMC is not mounted:
$ umount ${node}p*
$ umount ${node}p*


{{#switch: {{#var:SOC_SERIES}} | imx8 | imx9=
Delete current data on eMMC:
Delete current data on eMMC:
$ dd if=/dev/zero of=${node}p1 bs=1024 count=1024
$ for((i=1; i<=16; i++)); do [ -e ${node}p${i} ] && dd if=/dev/zero of=${node}p${i} bs=1M count=1 conv=fsync; done
$ dd if=/dev/zero of=${node}p2 bs=1024 count=1024
$ dd if=/dev/zero of=${node} bs=1M count=8 conv=fsync
$ 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:
Create a partition table:
$ (echo n; echo p; echo 1; echo; echo; echo p; echo w) | fdisk -u $node
$ (echo n; echo p; echo 1; echo 16384; echo; echo p; echo w) <nowiki>|</nowiki> fdisk -u $node
$ sync
$ sync
 
Format the partitions:
$ mkfs.ext4 ${node}p1 -L rootfs
$ sync


Format the rootfs partition with ext4 file system:
Flash U-Boot:
$ mkfs.ext4 ${node}p1 -L rootfs
$ dd if={{#var:U-BOOT_SD_IMAGE_NAME}} of=${node} bs=1K seek={{#var:U-BOOT_OFFSET}} conv=fsync


Flash the rootfs:
Extract the rootfs archive:
$ mkdir /run/media/mmcblk0p1
$ mkdir /run/media/{{#var:EMMC_ROOTFS_DEV}}{{#var:EMMC_ROOTFS_PARTITION_NUM}}
$ mount ${node}p1 /run/media/mmcblk0p1
$ mount ${node}{{#var:EMMC_ROOTFS_PARTITION_NUM}} /run/media/{{#var:EMMC_ROOTFS_DEV}}{{#var:EMMC_ROOTFS_PARTITION_NUM}}
$ tar xvpf rootfs.tar.bz2 -C /run/media/mmcblk1p1/
$ tar xvpf rootfs.tar.gz -C /run/media/{{#var:EMMC_ROOTFS_DEV}}{{#var:EMMC_ROOTFS_PARTITION_NUM}}
$ sync
{{#ifeq: {{#var:HARDWARE_NAME}} | DART-MX8M |$ (cd /run/media/{{#var:EMMC_ROOTFS_DEV}}{{#var:EMMC_ROOTFS_PARTITION_NUM}}/boot; ln -fs {{#var:DEFAULT_DTB_EMMC}} {{#var:DEFAULT_DTB}})|}}
$ umount /run/media/mmcblk0p1
$ sync
$ umount /run/media/{{#var:EMMC_ROOTFS_DEV}}{{#var:EMMC_ROOTFS_PARTITION_NUM}}
|#default=
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) <nowiki>|</nowiki> fdisk ${node}
$ sync
$ dd if=/dev/zero of=${node} bs=1M count=4
$ sync


Create a partition table:
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
* '''VAR-SOM-MX6 and  VAR-SOM-SOLO/DUAL'''
$ (echo n; echo p; echo 1; echo; echo; echo p; echo w) <nowiki>|</nowiki> fdisk -u ${node}
$ sync
* '''DART-MX6'''
}}
$(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) <nowiki>|</nowiki> fdisk -u ${node}
$ sync


And finally, set the U-Boot env. variable "rootfs_device" to "emmc" by one of the following two methods:
Format the partitions:
$ fw_setenv rootfs_device emmc
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
(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)
* '''VAR-SOM-MX6 and  VAR-SOM-SOLO/DUAL'''
$ mkfs.ext4 ${node}p1 -L rootfs
* '''DART-MX6'''
}}
$ mkfs.vfat ${node}p1 -n {{#var:EMMC_FAT_PARTITION_NAME}}
$ mkfs.ext4 ${node}p2 -L rootfs


or:
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX7|
Reboot and stop at the U-Boot command line, and enter the following:
{{#ifeq: {{#var:SPL_SD_IMAGE_NAME}} | N/A |
=> setenv rootfs_device emmc
Flash U-Boot to eMMC:
=> saveenv
$ dd if={{#var:U-BOOT_SD_IMAGE_NAME}} of=${node} bs=1K seek=1; sync
</pre>
|
Flash SPL and U-Boot to eMMC:
$ dd if={{#var:SPL_SD_IMAGE_NAME}} of=${node} bs=1K seek=1; sync
$ dd if={{#var:U-BOOT_SD_IMAGE_NAME}} of=${node} bs=1K seek=69; sync
}}
}}
{{#ifeq: {{#var:HARDWARE_NAME}}|DART-6UL|
Flash SPL and U-Boot to eMMC:
$ dd if={{#var:SPL_SD_IMAGE_NAME}} of=${node} bs=1K seek=1; sync
$ dd if={{#var:U-BOOT_SD_IMAGE_NAME}} of=${node} bs=1K seek=69; sync
}}
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
Flash SPL and U-Boot to eMMC:
* '''DART-MX6 only'''
$ dd if={{#var:SPL_SD_IMAGE_NAME}} of=${node} bs=1K seek=1; sync
$ dd if={{#var:U-BOOT_SD_IMAGE_NAME}} of=${node} bs=1K seek=69; sync
}}
 
Copy the Linux kernel image and the device tree blobs to the BOOT partition:
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
* '''DART-MX6 only'''
}}
$ mkdir /run/media/{{#var:EMMC_ROOTFS_DEV}}p1
$ mount -t vfat ${node}p1 /run/media/{{#var:EMMC_ROOTFS_DEV}}p1/
$ cp *emmc*.dtb /run/media/{{#var:EMMC_ROOTFS_DEV}}p1/
$ cp {{#var:KERNEL_IMAGE}} /run/media/{{#var:EMMC_ROOTFS_DEV}}p1/
$ sync
$ umount /run/media/{{#var:EMMC_ROOTFS_DEV}}p1
Extract the rootfs archive:
$ mkdir /run/media/{{#var:EMMC_ROOTFS_DEV}}{{#var:EMMC_ROOTFS_PARTITION_NUM}}
$ mount ${node}{{#var:EMMC_ROOTFS_PARTITION_NUM}} /run/media/{{#var:EMMC_ROOTFS_DEV}}{{#var:EMMC_ROOTFS_PARTITION_NUM}}
$ tar xvpf rootfs.tar.gz -C /run/media/{{#var:EMMC_ROOTFS_DEV}}{{#var:EMMC_ROOTFS_PARTITION_NUM}}
$ sync
$ umount /run/media/{{#var:EMMC_ROOTFS_DEV}}{{#var:EMMC_ROOTFS_PARTITION_NUM}}
}}
 
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
Set the U-Boot env. variable "rootfs_device" to "emmc" by one of the following two methods:
* '''VAR-SOM-MX6 and  VAR-SOM-SOLO/DUAL only'''
$ 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 =
= Summary =
{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX6 |
This page is not valid for DART-MX6. For DART-MX6, please follow the link to the relevant page.<br>
|}}
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>
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>
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>
With our extended SD card and our recovery SD card we provide an installation script located at /usr/bin/install_{{lc:{{#var:PLATFORM_OS}}}}.sh. It is much safer to use it instead of flashing the system manually.<br>

Latest revision as of 15:47, 21 April 2024

Warning: This page is designed to be used with a 'release' URL parameter.

This page is using the default release RELEASE_MORTY_V1.0_DART-6UL.
To view this page for a specific Variscite SoM and software release, please follow these steps:

  1. Visit variwiki.com
  2. Select your SoM
  3. Select the software release
Installing Yocto to the SOM's internal storage

Introduction

All SOMs can either boot from an SD card or from their internal storage.

The SOM's internal storage:
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

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

The resulting images are located at tmp/deploy/images/imx6ul-var-dart.


Image Name
How to use
fsl-image-gui-imx6ul-var-dart.sdcard This image is for SD card boot.
It can be flashed as-is on an SD card that can then be used to boot your system,
according to the relevant startup-guide of your product
(usually requires to press the boot select button, or toggle a DIP switch).
For detailed information refer to the Create a bootable SD card section below.
fsl-image-gui-imx6ul-var-dart.tar.gz Tarball with rootfs files.
Can be used to create an NFS root file system on the host.
See the Yocto Setup TFTP/NFS section for more info.
Also used to create our extended SD card.
See the Create a bootable SD card section below.
fsl-image-gui-imx6ul-var-dart.ubi A complete UBI image containing a UBIFS volume, for writing to NAND flash.
zImage Linux kernel image, same binary for SD card/eMMC or NAND flash.
SPL-sd SPL built for SD card boot or eMMC boot.
SPL-nand SPL built for NAND flash.
u-boot.img-sd U-Boot built for SD card boot or eMMC boot.
u-boot.img-nand U-Boot built for NAND flash.
File Name Description
zImage-imx6ul-var-dart-emmc_wifi.dtb Device tree blob for DART-6UL with eMMC & WI-FI enabled. (SD card & NAND disabled)
zImage-imx6ul-var-dart-nand_wifi.dtb Device tree blob for DART-6UL with NAND flash & WI-FI enabled. (SD card & eMMC disabled)
zImage-imx6ul-var-dart-sd_emmc.dtb Device tree blob for DART-6UL with SD card & eMMC enabled (WIFI & NAND disabled)
zImage-imx6ul-var-dart-sd_nand.dtb Device tree blob for DART-6UL with SD card & NAND flash enabled (WIFI & eMMC disabled)
zImage-imx6ull-var-dart-emmc_wifi.dtb Device tree blob for DART-6ULL with eMMC & WI-FI enabled. (SD card & NAND disabled)
zImage-imx6ull-var-dart-nand_wifi.dtb Device tree blob for DART-6ULL with NAND flash & WI-FI enabled. (SD card & eMMC disabled)
zImage-imx6ull-var-dart-sd_emmc.dtb Device tree blob for DART-6ULL with SD card & eMMC enabled (WIFI & NAND disabled)
zImage-imx6ull-var-dart-sd_nand.dtb Device tree blob for DART-6ULL with SD card & NAND flash enabled (WIFI & eMMC disabled)

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
    ├── imx6ul-var-dart-emmc_wifi.dtb
    ├── imx6ul-var-dart-nand_wifi.dtb
    ├── imx6ul-var-dart-sd_emmc.dtb
    ├── imx6ul-var-dart-sd_nand.dtb
    ├── imx6ull-var-dart-emmc_wifi.dtb
    ├── imx6ull-var-dart-nand_wifi.dtb
    ├── imx6ull-var-dart-sd_emmc.dtb
    ├── imx6ull-var-dart-sd_nand.dtb
    ├── rootfs.tar.gz
    ├── 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:

Setup:

$ export YOCTO_IMGS_PATH=~/var-fslc-yocto/build_x11/tmp/deploy/images/imx6ul-var-dart
$ export P2_MOUNT_DIR=/media/rootfs/
$ sudo mkdir -p ${P2_MOUNT_DIR}/opt/images/Yocto/

Linux:

$ sudo cp ${YOCTO_IMGS_PATH}/zImage ${P2_MOUNT_DIR}/opt/images/Yocto/

Device Tree:

$ for f in ${YOCTO_IMGS_PATH}/*.dtb; do if [[ -L $f ]] && [[ $f != *imx6ul-var-dart.dtb ]]; then sudo cp $f ${P2_MOUNT_DIR}/opt/images/Yocto/; fi done
$ sudo rename 's/zImage-imx/imx/' ${P2_MOUNT_DIR}/opt/images/Yocto/*.dtb

NAND images:

SPL:
$ sudo cp ${YOCTO_IMGS_PATH}/SPL-nand ${P2_MOUNT_DIR}/opt/images/Yocto/

U-Boot:
$ 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:

SPL:
$ sudo cp ${YOCTO_IMGS_PATH}/SPL-sd ${P2_MOUNT_DIR}/opt/images/Yocto/


U-Boot: 
$ 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.gz ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.tar.gz

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)

Manual step-by-step flashing to NAND flash

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

$ cd /opt/images/{{#var:PLATFORM_OS}}

Flash SPL & U-Boot:

$ 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 & 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/mtd3 0 0
$ nandwrite -p /dev/mtd3 zImage
$ nandwrite -p /dev/mtd3 -s 0x7e0000 <DEVICE_TREE_FILE>

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


Flash SPL and U-Boot 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 *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.gz -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 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.