Personal tools

Difference between revisions of "Yocto Build Release"

From ICOP tech wiki

Jump to: navigation, search
(Created page with "<!-- Set release according to "release" parameter in URL and use RELEASE_MORTY_V1.0_DART-6UL as default --> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!-- --> {{#lst:Yo...")
 
 
Line 1: Line 1:
<!-- Set release according to "release" parameter in URL and use RELEASE_MORTY_V1.0_DART-6UL as default
+
<!-- Set release according to "release" parameter in URL and use MORTY_BETA_DART-6UL as default
 
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!--
 
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_MORTY_V1.0_DART-6UL}}}} <!--
+
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_MORTY_BETA_DART-6UL}}}} <!--
--> {{PageHeader|{{#var:HARDWARE_NAME}} - Yocto {{#var:YOCTO_NAME}} {{#var:YOCTO_VERSION}} based on FSL Community BSP {{#var:FSLC_BSP_VERSION}} with {{#var:FSL_BSP_VERSION}} Linux release}} {{DocImage|category1=Yocto|category2={{#var:HARDWARE_NAME}}}} __toc__
+
--> {{PageHeader|Installing Yocto to the SOM's internal storage}} {{DocImage|category1={{#var:HARDWARE_NAME}}|category2=Yocto}} __toc__
= Installing required packages =
+
= Introduction =
 
+
All SOMs can either boot from an SD card or from their internal storage.<br>
Please make sure your host PC is running Ubuntu {{#ifeq: {{#var:YOCTO_NAME}}|Morty|14.04/|}}16.04 64-bit and install the following packages:
 
<pre>
 
$ sudo apt-get install gawk wget git diffstat unzip texinfo gcc-multilib \
 
build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \
 
xz-utils debianutils iputils-ping libsdl1.2-dev xterm
 
 
 
$ sudo apt-get install autoconf libtool libglib2.0-dev libarchive-dev python-git \
 
sed cvs subversion coreutils texi2html docbook-utils python-pysqlite2 \
 
help2man make gcc g++ desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev \
 
mercurial automake groff curl lzop asciidoc u-boot-tools dos2unix mtd-utils pv \
 
libncurses5 libncurses5-dev libncursesw5-dev libelf-dev zlib1g-dev
 
</pre>
 
 
 
= Reference documentation =
 
  {{#lst:Yocto_Platform_Customization|YOCTO_DOC_{{#var:YOCTO_VERSION}}}} <!--
 
-->{{#if:{{#var:FSLC_BSP_VERSION}}|{{#lst:Yocto_Platform_Customization|YOCTO_DOC_FSLC_BSP_{{#var:FSLC_BSP_VERSION}}}}|}} <!--
 
-->{{#lst:Yocto_Platform_Customization|YOCTO_DOC_FSL_BSP_{{#var:FSL_BSP_VERSION}}}}
 
 
 
= Download Yocto {{#var:YOCTO_NAME}} based on Freescale Community BSP =
 
<pre>
 
$ git config --global user.name "Your Name"
 
$ git config --global user.email "Your Email"
 
 
 
$ mkdir ~/bin (this step may not be needed if the bin folder already exists)
 
$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
 
$ chmod a+x ~/bin/repo
 
$ export PATH=~/bin:$PATH
 
</pre>
 
 
 
$ mkdir {{#var:BUILD_FOLDER}}
 
$ cd {{#var:BUILD_FOLDER}}
 
 
 
Now, choose between downloading a release tag, and downloading the latest revision (recommended) and '''follow only one of the next two bullet sections''', accordingly:<br>
 
 
<br>
 
<br>
* '''Download a release tag'''<br>
+
The SOM's internal storage:<br>
Each release in https://github.com/varigit/variscite-bsp-platform/releases corresponds to a tag.<br>
+
{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX6 |
The tags are also listed in https://github.com/varigit/variscite-bsp-platform/tags<br>
+
* '''VAR-SOM-MX6 and VAR-SOM-SOLO/DUAL''' SOMs use the on-SOM NAND flash to boot.<br>
To specify a specific release/tag, run the following:
+
The file system can reside either on the NAND flash or the eMMC.<br>
$ repo init -u https://github.com/varigit/variscite-bsp-platform.git -b refs/tags/TAG_NAME
+
When the file system resides on the NAND flash, a UBIFS file system is used.<br>
+
When the file system resides on the eMMC, an ext4 file system is used.<br>
For example:
+
Regardless of the file system type and location, U-Boot will always boot from the NAND flash.<br>
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
+
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).
$ repo init -u https://github.com/varigit/variscite-bsp-platform.git -b refs/tags/{{#var:RELEASE_NAME}} -m {{#var:YOCTO_MANIFEST}}
+
* '''VAR-DART-MX6''' has only an on-SOM eMMC which can be used to boot from and to hold the filesystem.
$ repo sync -j4
 
 
|
 
|
$ repo init -u https://github.com/varigit/variscite-bsp-platform.git -b refs/tags/{{#var:RELEASE_NAME}}
 
$ repo sync -j4
 
}}
 
<br>
 
or<br>
 
<br>
 
* '''Download the latest revision (recommended)'''<br>
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
 
$ repo init -u {{#var:YOCTO_GIT}} -b {{#var:YOCTO_BRANCH}} -m {{#var:YOCTO_MANIFEST}}
 
$ repo sync -j4
 
|
 
$ repo init -u {{#var:YOCTO_GIT}} -b {{#var:YOCTO_BRANCH}}
 
$ repo sync -j4
 
}}
 
 
= Setup and build Yocto =
 
== Supported images ==
 
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
The following images are provided by Variscite for evaluation purpose
+
The Variscite {{#var:HARDWARE_NAME}} comes with eMMC, which holds U-Boot, the kernel image and the ext4 root file system.<br>
* '''fsl-image-gui''': Default Variscite demo image with GUI and without any Qt5 content. This image recipe works for Xwayland and Wayland backends.
 
* '''fsl-image-qt5''': Extends fsl-image-gui image with Qt5 support and various Qt samples for Xwayland and Wayland backends.  
 
 
|
 
|
The following images are provided by Variscite for evaluation purpose
+
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>
* '''fsl-image-gui''': Default Variscite demo image with GUI and without any Qt5 content. This image recipe works on all backends for X11, Frame Buffer and Wayland and the content is optimized to fit 512MB NAND flash.
+
For NAND flash we use a UBI file system and for eMMC we use ext4.
* '''fsl-image-qt5''': Extends fsl-image-gui image with Qt5 support and various Qt samples for X11, Frame Buffer and Wayland backends.
 
{{Note| Will result in image size greater than 512 MB, which will not fit into NAND flash. Use SD card or eMMC to test.}}
 
 
}}
 
}}
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
 
|
 
The following images are provided by FSL Community BSP:
 
* '''fsl-image-machine-test''': A console-only image that includes gstreamer packages{{#if:{{#var:GSTREAMER_SUPPORT}}|, Freescale’s multimedia packages (VPU and GPU),|}} and test and benchmark applications.
 
* '''fsl-image-mfgtool-initramfs''': Small image to be used with Manufacturing Tool (mfg-tool) in a production environment.
 
{{#if:{{#var:GSTREAMER_SUPPORT}}|
 
* '''fsl-image-multimedia'''/'''fsl-image-multimedia-full''': A console-only image that includes gstreamer packages and Freescale’s multimedia packages (VPU and GPU).
 
|}}
 
 
}}
 
}}
See the list of Yocto Project’s reference images in [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html#ref-images Yocto Project Reference Manual]
 
  
== Supported distros ==
 
The following distros can be used:
 
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
* '''fsl-imx-wayland''': Distro for Wayland without X11. This distro includes wayland feature but doesn’t have X11 support.
 
* '''fsl-imx-xwayland''': Distro for Wayland with X11. This distro includes both wayland and X11 features.
 
 
|
 
|
* '''fslc-x11''': Distro for X11 without wayland. This distro include x11 feature and doesn’ has wayland support.
+
= NAND flash structure =
* '''fslc-framebuffer''': Distro for Framebuffer graphical backend. This distro doesn’t include X11 and wayland features.
+
{{#ifeq: {{#var:MACHINE_NAME}} | var-som-mx6 |* '''VAR-SOM-MX6 and VAR-SOM-SOLO/DUAL'''
* '''fslc-wayland''': Distro for Wayland without X11. This distro includes wayland feature but doesn’t have x11 support.
+
These are the defined MTD partitions on the NAND flash:<br>
* '''fslc-xwayland''': Distro for Wayland with X11. This distro includes both wayland and X11 features.
+
0x000000000000-0x000000200000 : "spl"<br>
}}
+
0x000000200000-0x000000400000 : "bootloader"<br>
Note: Also [http://www.informit.com/articles/article.aspx?p=2514911&seqNum=4 standard Poky distros] can be used
+
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"
{{#if:{{#var:GSTREAMER_SUPPORT}}|
 
== GStreamer support ==
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
 
 
|
 
|
FSL community BSP comes with [https://github.com/Freescale/gstreamer-imx/blob/master/README.md gstreamer-imx], a set of GStreamer1.0 plugins for i.MX platform, which make use of the i.MX multimedia capabilities.<br>
+
0x000000000000-0x000000200000 : "spl"<br>
Some of the multimedia plugins do not work well with X11 and Wayland backends.<br>
+
0x000000200000-0x000000400000 : "u-boot"<br>
To get the most from gstreamer-imx, it is recommended to use fslc-framebufer distro with one of the demo images
+
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 =
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
== Build XWayland GUI demo image ==
+
0-8 MiB &nbsp;&nbsp;&nbsp;&nbsp; : Non-partitioned space, saved for U-Boot.<br>
$ cd {{#var:BUILD_FOLDER}}
+
8 MiB-End: "rootfs" - An ext4 partition containing the root file system (including Linux image and the device tree blobs under /boot).
$ MACHINE={{#var:MACHINE_NAME}} DISTRO={{#var:BUILD_DISTRO}} {{#var:BUILD_SCRIPT}} -b {{#var:BUILD_FOLDER_XWAYLAND}}
 
 
|
 
|
== Build X11 GUI demo image ==
+
{{#ifeq: {{#var:MACHINE_NAME}} | var-som-mx6 |* '''VAR-SOM-MX6 and VAR-SOM-SOLO/DUAL'''
$ cd {{#var:BUILD_FOLDER}}
+
0 MiB-End: "rootfs" - An ext4 partition containing the root file system (including the kernel modules).
$ MACHINE={{#var:MACHINE_NAME}} DISTRO={{#var:BUILD_DISTRO}} {{#var:BUILD_SCRIPT}} {{#var:BUILD_FOLDER_X11}}
+
* '''VAR-DART-MX6'''|}}
}}
+
0-4 MiB &nbsp;&nbsp;&nbsp;&nbsp; : Non-partitioned space, saved for U-Boot.<br>
<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>
Optional steps: [[#local.conf customization|local.conf customization]]
+
12 MiB-End: "rootfs" - An ext4 partition containing the root file system (including the kernel modules).}}
 
 
launch bitbake:
 
<pre>
 
Without Qt content:
 
$ bitbake fsl-image-gui
 
 
 
Or with Qt content:
 
$ bitbake fsl-image-qt5
 
</pre>
 
  
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
 
|
 
|
{{#if:{{#var:GSTREAMER_SUPPORT}}|
+
= Yocto Built binaries for NAND flash / eMMC =
NOTE: Some of the [https://github.com/Freescale/gstreamer-imx/blob/master/docs/blitter-architecture.md blitter-based i.MX GStreamer plugins] do not work with X11 and Wayland backends. To get the most of the i.MX GPU/VPU acceleration, use the fslc-framebuffer backend.
 
|}}
 
  
== Build console-only demo image {{#if:{{#var:GSTREAMER_SUPPORT}}|with Freescale’s multimedia packages (VPU and GPU)|}} ==
+
The resulting images are located at tmp/deploy/images/{{#var:MACHINE_NAME}}.<br>
$ cd {{#var:BUILD_FOLDER}}
+
{{#lst:Yocto_Build_Release|YOCTO_BUILD_RESULTS}}
$ MACHINE={{#var:MACHINE_NAME}} DISTRO={{#var:BUILD_DISTRO_FB}} {{#var:BUILD_SCRIPT}} {{#var:BUILD_FOLDER_FB}}
+
{{#lst:Yocto_Platform_Customization|{{#var:YOCTO_BUILD_RESULTS_SECTION}}}}
 
 
<br>
 
Optional steps: [[#local.conf customization|local.conf customization]]
 
 
 
<pre>
 
Without Qt content:
 
$ bitbake fsl-image-gui
 
 
 
Or with Qt content:
 
$ bitbake fsl-image-qt5
 
</pre>
 
 
}}
 
}}
  
== local.conf customization ==
+
= Installing the Yocto binaries =
=== Change the downloads directory ===
+
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>
 
+
The flashing scripts are easy-to-use example scripts for flashing images into NAND flash / eMMC.<br>
Create a /opt/yocto_downloads directory and set its permissions:
+
There is also a section below describing how to [[#Manual step-by-step flashing to NAND flash / eMMC|flash the images manually]].
<pre>
 
$ sudo mkdir /opt/yocto_downloads
 
$ sudo chmod 777 /opt/yocto_downloads/
 
</pre>
 
 
 
Direct downloads to it, by replacing 'DL_DIR ?= "${BSPDIR}/downloads/"' with 'DL_DIR = "/opt/yocto_downloads/"' in conf/local.conf under your build directory:
 
<pre>
 
$ sed -i 's/DL_DIR ?= "${BSPDIR}\/downloads/DL_DIR = "\/opt\/yocto_downloads/g' conf/local.conf
 
</pre>
 
  
=== Add Eclipse debug and Qt creator support to your images ===
+
== Images locations ==
Append the following to the conf/local.conf file in your Yocto build directory, to add Eclipse debug and Qt creator support to your images:
+
Following is the directory structure on your SD card, which elaborates the files' location that the below installation scripts are expecting:
<pre>
+
{{#lst:Yocto_Platform_Customization|{{#var:SD_TREE_SECTION}}}}
EXTRA_IMAGE_FEATURES = " \
 
    debug-tweaks \
 
    tools-debug \
 
    eclipse-debug \
 
    "
 
 
 
IMAGE_INSTALL_append = " \
 
    tcf-agent \
 
    openssh-sftp-server \
 
    "
 
</pre>
 
  
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
 +
=== Prepare the images for flashing to eMMC  ===
 
|
 
|
=== Use systemd instead of SysV init ===
+
=== Prepare the images for NAND flash / eMMC flashing ===
Append the following to the conf/local.conf file in your Yocto build directory, to use systemd instead of SysV init in your images:
 
<pre>
 
DISTRO_FEATURES_append = " systemd"
 
VIRTUAL-RUNTIME_init_manager = "systemd"
 
DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
 
VIRTUAL-RUNTIME_initscripts = ""
 
IMX_DEFAULT_DISTRO_FEATURES_append = " systemd"
 
</pre>
 
 
}}
 
}}
 +
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 [[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>
  
=== Create a read-only root file system ===
+
Setup:
Append the following to the conf/local.conf file in your Yocto build directory, to create a read-only rootfs:
+
$ export YOCTO_IMGS_PATH={{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_X11}}/tmp/deploy/images/{{#var:MACHINE_NAME}}
<pre>
+
$ export P2_MOUNT_DIR=/media/rootfs/
EXTRA_IMAGE_FEATURES += "read-only-rootfs"
+
$ sudo mkdir -p ${P2_MOUNT_DIR}/opt/images/Yocto/
</pre>
 
  
== Build Results ==
+
{{#ifeq: {{#var:SOC_SERIES}} | imx8 ||
The resulted images are located in tmp/deploy/images/{{#var:MACHINE_NAME}}.
+
Linux:
 +
$ sudo cp ${YOCTO_IMGS_PATH}/{{#var:KERNEL_IMAGE}} ${P2_MOUNT_DIR}/opt/images/Yocto/
  
{{#lst:Yocto_Platform_Customization|{{#var:YOCTO_BUILD_RESULTS_SECTION}}}}
+
Device Tree:
 +
$ 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/Yocto/; fi done
 +
$ sudo rename 's/{{#var:KERNEL_IMAGE}}-imx/imx/' ${P2_MOUNT_DIR}/opt/images/Yocto/*.dtb
  
= Create a bootable SD card =
 
  
== SD card structure ==
+
{{#ifeq: {{#var:SOC_SERIES}} | imx8 ||
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
+
NAND images:
This is the structure of our Recovery/Extended SD card:<br>
+
{{#ifeq: {{#var:SPL_SD_IMAGE_NAME}} | N/A ||SPL:
[[File:SD_card_part_mx8m.png]]<br><br>
+
$ sudo cp ${YOCTO_IMGS_PATH}/{{#var:SPL_NAND_IMAGE_NAME}} ${P2_MOUNT_DIR}/opt/images/Yocto/
 
+
}}
 
+
The SD card is divided into 2 sections as shown in the picture above:<br>
+
U-Boot:
* The first unallocated 8MiB section reserved for U-Boot. It can be replaced using the dd command as described in the {{Varlink2|Yocto Build U-Boot|{{#var:RELEASE_LINK}}}} section.<br>
+
$ sudo cp ${YOCTO_IMGS_PATH}/{{#var:U-BOOT_NAND_IMAGE_NAME}} ${P2_MOUNT_DIR}/opt/images/Yocto/
* The first partition is an ext4 partition that contains the complete root filesystem (including kernel image and device tree files under /boot).<br><br>
+
|
+
File System:
This is the structure of our Recovery/Extended SD card:<br>
+
$ sudo cp ${YOCTO_IMGS_PATH}/fsl-image-gui-{{#var:MACHINE_NAME}}.ubi ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.ubi
[[File:SD_card_part_v50.png]]<br><br>
 
 
 
 
 
The SD card is divided into 3 sections as shown in the picture above:<br>
 
* The first unallocated 4MiB are saved space for U-Boot. It can be replaced using the dd command as described in the {{Varlink2|Yocto Build U-Boot|{{#var:RELEASE_LINK}}}} section.<br>
 
* The first partition is a fat16 partition used for the device tree files and the kernel image file. You can copy them as described in the {{Varlink2|Yocto Build Linux|{{#var:RELEASE_LINK}}}} section.<br>
 
* The second partition is an ext4 partition that contains the complete root filesystem (including the kernel modules).<br><br>
 
 
}}
 
}}
 +
eMMC images:
 +
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|*'''VAR-SOM-MX6 and VAR-SOM-SOLO/DUAL'''
 +
File System:
 +
$ sudo cp ${YOCTO_IMGS_PATH}/fsl-image-gui-{{#var:MACHINE_NAME}}.tar.gz ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.tar.gz
 +
|}} <!--
  
Note:<br>
+
-->{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|*'''DART-MX6'''|}}
The last unallocated area is not used. It is there so that the rootfs will fit on any 4GB SD card, as not all 4GB SD cards are really the same size. If you want, you can use a program such as GParted to resize the roofs partition and make it end at the end of your specific SD card (of course, you can also use SD cards with much bigger capacity than 4GB, and then it makes more sense to resize the partition).<br>
+
{{#ifeq: {{#var:SPL_SD_IMAGE_NAME}} | N/A ||SPL:
Also, if you create the extended SD card yourself by following the [[#Create_an_extended_SD_card | Create an extended SD card]] section below, and you use the '-a' option, the rootfs partition will end at the end of your specific SD card automatically.<br>
+
$ sudo cp ${YOCTO_IMGS_PATH}/{{#var:SPL_SD_IMAGE_NAME}} ${P2_MOUNT_DIR}/opt/images/Yocto/
 +
|}}
  
==Yocto pre-built bootable SD card==
 
 
The Yocto build products contains many files as explained in the [[#Build_Results | Build Results section]]. For example, fsl-image-gui-{{#var:MACHINE_NAME}}.{{#var:SDCARD_IMG_EXT}}, depending on your build. This is a complete image to be flashed directly to an SD card.<br>
 
 
Example usage:
 
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
 
  <br>
 
  <br>
  $ sudo umount /dev/sdX*
+
  U-Boot:
 
+
  $ sudo cp ${YOCTO_IMGS_PATH}/imx-boot-{{#var:MACHINE_NAME}}-sd.bin ${P2_MOUNT_DIR}/opt/images/Yocto/{{#var:U-BOOT_SD_IMAGE_NAME}}
# For GUI-XWAYLAND & Qt5-XWAYLAND
 
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_XWAYLAND}}
 
Or
 
# For GUI-WAYLAND & Qt5-WAYLAND
 
$ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_WAYLAND}}
 
 
   
 
   
  # For fsl-image-gui image (GUI-XWAYLAND & GUI-WAYLAND)
+
  File System:
  $ zcat tmp/deploy/images/{{#var:MACHINE_NAME}}/fsl-image-gui-{{#var:MACHINE_NAME}}.sdcard.gz <nowiki>|</nowiki> sudo dd of=/dev/sdX bs=1M conv=fsync
+
  $ sudo cp ${YOCTO_IMGS_PATH}/fsl-image-gui-{{#var:MACHINE_NAME}}.tar.gz ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.tar.gz
Or
 
# For fsl-image-qt5 image (Qt5-XWAYLAND & Qt5-WAYLAND)
 
$ zcat tmp/deploy/images/{{#var:MACHINE_NAME}}/fsl-image-qt5-{{#var:MACHINE_NAME}}.sdcard.gz <nowiki>|</nowiki> sudo dd of=/dev/sdX bs=1M conv=fsync
 
 
|
 
|
 
  <br>
 
  <br>
  $ sudo umount /dev/sdX*
+
  U-Boot:
 
+
  $ sudo cp ${YOCTO_IMGS_PATH}/{{#var:U-BOOT_SD_IMAGE_NAME}} ${P2_MOUNT_DIR}/opt/images/Yocto/
# For GUI-X11 & Qt5-X11
 
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_X11}}
 
Or
 
# For Qt5-FB
 
$ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_FB}}
 
 
   
 
   
  # For fsl-image-gui image (GUI-X11)
+
  File System:
{{#ifeq: {{#var:SDCARD_IMG_EXT}} | wic.gz |
+
  $ sudo cp ${YOCTO_IMGS_PATH}/fsl-image-gui-{{#var:MACHINE_NAME}}.tar.gz ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.tar.gz
  $ zcat tmp/deploy/images/{{#var:MACHINE_NAME}}/fsl-image-gui-{{#var:MACHINE_NAME}}.{{#var:SDCARD_IMG_EXT}} <nowiki>|</nowiki> sudo dd of=/dev/sdX bs=1M && sync
 
|
 
$ sudo dd if=tmp/deploy/images/{{#var:MACHINE_NAME}}/fsl-image-gui-{{#var:MACHINE_NAME}}.{{#var:SDCARD_IMG_EXT}} of=/dev/sdX bs=1M && sync
 
}}
 
Or
 
# For fsl-image-qt5 image (Qt5-X11 & Qt5-FB)
 
{{#ifeq: {{#var:SDCARD_IMG_EXT}} | wic.gz |
 
$ zcat tmp/deploy/images/{{#var:MACHINE_NAME}}/fsl-image-qt5-{{#var:MACHINE_NAME}}.{{#var:SDCARD_IMG_EXT}} <nowiki>|</nowiki> sudo dd of=/dev/sdX bs=1M && sync
 
|
 
$ sudo dd if=tmp/deploy/images/{{#var:MACHINE_NAME}}/fsl-image-qt5-{{#var:MACHINE_NAME}}.{{#var:SDCARD_IMG_EXT}} of=/dev/sdX bs=1M && sync
 
}}
 
 
}}
 
}}
  
Replace sdX with the right device name. This can be obtained by "dmesg" command on your host Linux PC, after the SD card reader is inserted.
+
== Flashing scripts ==
 +
The flashing scripts are located on the SD card at /usr/bin/:
  
* <span style="color:red">Note:</span> Booting your system from an SD card requires pressing the boot-select button, or switching the relevant DIP switch to "Boot from SD card", according to the relevant start-up guide of your system<br><br>
+
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
 
+
install_yocto.sh - Flash Yocto into eMMC (Run and follow usage instructions)
 
 
Drawbacks of the native .{{#var:SDCARD_IMG_EXT}} yocto-built image, (relative to the Recovery/Extended SD card):
 
* The rootfs partition doesn't use the entire SD card.
 
* The rootfs partition is not labeled as rootfs.
 
* The NAND flash and eMMC installation scripts and images are not included.
 
 
 
== Create an extended SD card ==
 
Variscite provides the var-create-yocto-sdcard.sh script which creates our NAND/eMMC recovery SD card - an SD card based on the fsl-image-gui filesystem, which copies the NAND flash burning scripts and relevant binaries for your convenience.<br>
 
Later, you will be able to follow either the more automatic {{Varlink2|Yocto Recovery SD card|{{#var:RELEASE_LINK}}}} guide or the more manual [[VAR-SOM-MX6 NAND Flash Burning| VAR-SOM-MX6 NAND flash burning]] guide to burn your images to NAND flash or eMMC.<br><br>
 
 
 
Note:<br>
 
This is essentially the same as our pre-built Recovery SD image, with the following main differences:<br>
 
{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX6 |
 
* The Android recovery (Android-eMMC) is only present on the pre-built SD image, and not on the SD card built from the Yocto script.<br>
 
}}
 
* The pre-built image's rootfs partition size is 3700MiB, which is also the default size when using the script, but the script also has an option to set the rootfs partition size to fill the whole free space of the used SD card. Anyway, you can always resize the partition later with an external tool such as gparted.<br>
 
Naturally, the pre-built image is more straight forward and easier to use, while the script method is easier to customize.<br><br>
 
 
 
Usage:<br>
 
* Follow the [[#Setup and build Yocto|Setup and build Yocto]] guide, and bitbake fsl-image-gui.
 
* Plug-in the SD card to your Linux HOST PC, run dmesg and see which device is added (i.e. /dev/sdX or /dev/mmcblkX)
 
 
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
 
<br>
 
$ cd {{#var:BUILD_FOLDER}}
 
$ sudo MACHINE={{#var:MACHINE_NAME}} sources/meta-variscite-imx/scripts/var_mk_yocto_sdcard/var-create-yocto-sdcard.sh <options> /dev/sdX
 
 
|
 
|
  <br>
+
  install_yocto.sh - Flash Yocto into NAND flash or eMMC (Run and follow usage instructions)
$ cd {{#var:BUILD_FOLDER}}
 
$ sudo MACHINE={{#var:MACHINE_NAME}} sources/meta-variscite-fslc/scripts/var_mk_yocto_sdcard/var-create-yocto-sdcard.sh <options> /dev/sdX
 
 
}}
 
}}
  (Replace /dev/sdX with your actual device)
+
  {{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
 
+
(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!)
options:
+
|}}
  -h            Display help message
 
  -s            Only show partition sizes to be written, without actually write them
 
  -a            Automatically set the rootfs partition size to fill the SD card
 
  -r            Select alternative rootfs for recovery images (default: {{#var:BUILD_FOLDER_X11}}/tmp/deploy/images/{{#var:MACHINE_NAME}}/fsl-image-gui-{{#var:MACHINE_NAME}}.*)
 
 
 
If you don't use the '-a' option, a default rootfs size of 3700MiB will be used
 
The '-r' option allows you to create a bootable SD card with an alternative image for the installation to NAND flash or eMMC.
 
Example: "-r tmp/deploy/images/{{#var:MACHINE_NAME}}/fsl-image-qt5-{{#var:MACHINE_NAME}}" -- selected the "Qt5 image with X11" recovery image
 
 
 
= Boot the board with a bootable SD card =
 
{{#ifeq: {{#var:HARDWARE_NAME}} | DART-6UL |
 
Note: <span style="color:red">The WiFi is not operational when booting from SD card</span>, as the WiFi and SD card are using the same SDIO interface.<br>
 
A typical use-case is to boot from an SD card, flash the eMMC/NAND flash, and re-boot from the eMMC/NAND flash to have the WiFi operational.
 
|}}
 
{{#ifeq: {{#var:HARDWARE_NAME}} | DART-MX8M |
 
Note: <span style="color:red">The WiFi is not operational when booting from SD card</span>, as the WiFi and SD card are using the same SDIO interface.<br>
 
A typical use-case is to boot from an SD card, flash the eMMC, and re-boot from the eMMC to have the WiFi operational.
 
|}}
 
== Setting the Boot Mode ==
 
{{#lst:Yocto_Platform_Customization|{{#var:YOCTO_BOOT_BOARD_SECTION}}}}
 
  
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
 
|
 
|
== Automatic device tree selection in U-Boot ==
+
== Manual step-by-step flashing to NAND flash ==
As shown in the [[#Build_Results| Build Results]] table above, we have different kernel device trees, corresponding to our different H/W configurations.<br>
 
We implemented a script in U-Boot's environment, which sets the fdt_file environment variable based on the detected hardware.
 
  
=== Enable/Disable automatic device tree selection ===
+
Use the prepared SD card to boot the board and run the following:
To enable the automatic device tree selection in U-Boot (already enabled by default):
+
<br>
 
<pre>
 
<pre>
$ setenv fdt_file undefined
+
$ cd /opt/images/Yocto
$ saveenv
 
 
</pre>
 
</pre>
To disable the automatic device tree selection in U-Boot, set the device tree file manually:
 
<pre>
 
$ setenv fdt_file YOUR_DTB_FILE
 
$ saveenv
 
</pre>
 
Useful example: To list all files in the boot partition (where the dtb files are by default) of an SD card:
 
<pre>
 
$ ls mmc 0:1
 
</pre>
 
<!-- Make NOTE for DART-6UL only -->
 
{{#ifeq: {{#var:HARDWARE_NAME}} | DART-6UL |
 
{{note|Comment:<br>Make sure you don't set an inappropriate dtb file, like a dtb with nand on a SOM that has eMMC, or a dtb for mx6ull on a SOM with an mx6ul SOC.|info}}
 
|}}
 
}}
 
  
= Flash images to NAND/eMMC =
+
{{#ifeq: {{#var:SPL_NAND_IMAGE_NAME}} | N/A |Flash U-Boot:| Flash SPL & U-Boot:}}
Please refer to {{Varlink2|Yocto NAND Flash Burning|{{#var:RELEASE_LINK}}}} guide.
 
  
= Yocto Image Customization =
+
$ flash_erase /dev/mtd0 0 0
== Update Yocto {{#var:YOCTO_NAME}} to latest revision ==
+
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
From time to time we update the Yocto sources (especially meta-variscite) with new features and bug fixes.<br>
+
$ kobs-ng init -x {{#var:SPL_NAND_IMAGE_NAME}} --search_exponent=1 -v
Follow the '''Download the latest revision (recommended)''' bullet section of the [[#Download Yocto {{#var:YOCTO_NAME}} based on Freescale Community BSP|Download Yocto {{#var:YOCTO_NAME}} based on Freescale Community BSP]] step again to update your tree to the latest revision, and rebuild your image.
+
$ flash_erase /dev/mtd1 0 0
 +
$ 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
 +
|}}
 +
}}
  
== Update Yocto {{#var:YOCTO_NAME}} to a Release Tag ==
+
Flash the Linux Kernel image & Device Tree:<br>
Follow the '''Download a release tag''' bullet section of the [[#Download Yocto {{#var:YOCTO_NAME}} based on Freescale Community BSP|Download Yocto {{#var:YOCTO_NAME}} based on Freescale Community BSP]] step to update your tree to a release tag, and rebuild your image.
+
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.
  
== Forcing Clean Build ==
+
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
<pre>
+
$ flash_erase /dev/mtd2 0 0
In order to update the kernel, U-Boot and rootfs:
+
$ nandwrite -p /dev/mtd2 {{#var:KERNEL_IMAGE}}
$ bitbake -c cleanall u-boot-variscite linux-variscite kernel-module-imx-gpu-viv ti-compat-wireless-wl18xx wl18xx-firmware cryptodev-module
+
$ 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>
 +
}}
  
for GUI image
+
Flash the (UBI) File System to NAND flash:
$ bitbake -c clean fsl-image-gui
 
for Qt5 image
 
$ bitbake -c clean fsl-image-qt5
 
</pre>
 
  
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
+
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
|
+
$ ubiformat /dev/mtd3 -f rootfs.ubi
== Qt5 for Embedded Linux ==
+
|
To run Qt5 applications without X11 backend the platform specific plugins (e.g. EGLFS or LinuxFB) should be configured with QT_QPA_PLATFORM environment variable or with -platform command-line.
+
$ ubiformat /dev/mtd4 -f rootfs.ubi
{{Note| See more information on Qt5 customization for Embedded Linux [http://doc.qt.io/qt-5.6/embedded-linux.html here]}}
+
}}
 
 
{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX6 |
 
=== Configure EGLFS Plugin ===
 
<pre>
 
export QT_QPA_EGLFS_PHYSICAL_HEIGHT=95
 
export QT_QPA_EGLFS_PHYSICAL_WIDTH=160
 
export QT_QPA_EGLFS_HEIGHT=480
 
export QT_QPA_EGLFS_WIDTH=800
 
export QT_EGLFS_IMX6_NO_FB_MULTI_BUFFER=1
 
export QT_QPA_EGLFS_DEPTH=24
 
export QT_QPA_PLATFORM=eglfs
 
</pre>
 
|
 
=== Configure LinuxFB Plugin ===
 
{{#var:HARDWARE_NAME}} supports only LinuxFB plugin
 
<pre>
 
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:size=800x480:mmSize=160x95
 
</pre>
 
 
}}
 
}}
  
=== Configure Touch Input ===
+
== Manual step-by-step flashing to eMMC ==
When no windowing system is present, the mouse, keyboard, and touch input are read directly via evdev or tslib.
 
==== Evdev ====
 
By default, the Qt5 uses automatic device discovery based on libudev.
 
In case you want to override the default touchscreen configuration the following parameters can be used:
 
*/dev/input/... - Specifies the name of the input device. When not given, Qt looks for a suitable device either via libudev or by walking through the available nodes.
 
* rotate - On some touch screens the coordinates must be rotated, which is done by setting rotate to 90, 180, or 270.
 
* invertx and inverty - To invert the X or Y coordinates in the input events, pass invertx or inverty.
 
<pre>export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS='/dev/input/touchscreen0'</pre>
 
  
==== Tslib ====
+
Flashing the eMMC requires several steps including partitioning, file system formatting and image extraction.<br>
Tslib is used for resistive single-touch touchscreens and should be pre-configured with:
+
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 TSLIB_TSEVENTTYPE='INPUT'
+
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
export TSLIB_TSDEVICE='/dev/input/touchscreen0'
+
* '''DART-MX6'''
export TSLIB_CALIBFILE='/etc/pointercal'
+
  $ export node=/dev/mmcblk2
export TSLIB_CONFFILE='/etc/ts.conf'
+
  $ cd /opt/images/Yocto
export TSLIB_CONSOLEDEVICE='none'
+
* '''VAR-SOM-MX6 and VAR-SOM-SOLO/DUAL'''
export TSLIB_FBDEVICE='/dev/fb0'
 
export TSLIB_PLUGINDIR='/usr/lib/ts'
 
export QT_QPA_EGLFS_TSLIB=1
 
export QT_QPA_FB_TSLIB=1
 
</pre>
 
It is recommended to put the above setup inside /etc/profile.d/tslib.sh.
 
 
 
=== Running Qt5 Applications ===
 
 
 
$ cd /usr/share/qt5/examples/
 
$ touch/dials/dials --platform {{#var:QT_PLATFORM_PLUGIN}}
 
$ gui/rasterwindow/rasterwindow --platform {{#var:QT_PLATFORM_PLUGIN}}
 
  $ touch/fingerpaint/fingerpaint  --platform {{#var:QT_PLATFORM_PLUGIN}}
 
  $ widgets/mainwindows/mainwindow/mainwindow --platform {{#var:QT_PLATFORM_PLUGIN}}
 
 
 
== UBIFS ==
 
By default we create ubifs image for 512MB NAND flash size.
 
You can change the size by editing {{#var:BUILD_FOLDER}}/sources/meta-variscite-fslc/conf/machine/include/variscite.inc <br>and comment / uncomment the relevant section based on size.
 
 
}}
 
}}
 +
$ export node=/dev/{{#var:EMMC_ROOTFS_DEV}}
 +
$ cd /opt/images/Yocto
  
{{#if:{{#var:GSTREAMER_SUPPORT}}|
+
Make sure the eMMC is not mounted:
== DDR size and Contiguous Memory Allocator ==
+
$ umount ${node}p*
By default Freescale allocates 256MB of RAM to the Contiguous Memory allocator.
 
This is for proper operation of the IPU VPU, X11 etc.
 
On VAR-SOM-SOLO with 256MB DDR RAM size, it will cause a kernel freeze during boot.
 
Adding cma=32MB to the bootargs parameters is required to fix.
 
|}}
 
  
= Make changes to the rootfs =
+
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
The following is usually not the recommended way to work with Yocto.<br>
+
Delete current data on eMMC:
You should usually create new specific recipes (.bb files) and/or append to specific present recipes by using .bbappend files.<br>
+
$ 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
However, if you are not yet experienced enough with Yocto, and you just want to quickly add your files to the resultant file system (or make any other change to it), you can do it in a general way, by using the following variable:
+
$ dd if=/dev/zero of=${node} bs=1M count=8 conv=fsync
<pre>
 
ROOTFS_POSTPROCESS_COMMAND
 
  
    Specifies a list of functions to call once the OpenEmbedded build system has created the root filesystem.
+
Create a partition table:
    You can specify functions separated by semicolons:
+
$ (echo n; echo p; echo 1; echo 16384; echo; echo p; echo w) <nowiki>|</nowiki> fdisk -u $node
 +
$ sync
  
        ROOTFS_POSTPROCESS_COMMAND += "function; ... "                 
+
Format the partitions:
 +
$ mkfs.ext4 ${node}p1 -L rootfs
 +
$ sync
  
    If you need to pass the root filesystem path to a command within a function, you can use ${IMAGE_ROOTFS},
+
Flash U-Boot:
    which points to the directory that becomes the root filesystem image. See the IMAGE_ROOTFS variable for more information.
+
$ dd if={{#var:U-BOOT_SD_IMAGE_NAME}} of=${node} bs=1K seek={{#var:U-BOOT_OFFSET}} conv=fsync
</pre>
 
  
The functions will be called right after the root filesystem is created and right before it is packed to images (.{{#var:SDCARD_IMG_EXT}}, .ubi, .tar.gz, etc.).<br>
+
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}}
 +
{{#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}})|}}
 +
$ sync
 +
$ umount /run/media/{{#var:EMMC_ROOTFS_DEV}}{{#var:EMMC_ROOTFS_PARTITION_NUM}}
 +
|
 +
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
  
== Example ==
+
Create a partition table:
Let's say you have your files that you want to put in the filesystem arranged on your host under a directory called /my_rootfs_additions, like the following:
+
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
<pre>
+
* '''VAR-SOM-MX6 and  VAR-SOM-SOLO/DUAL'''
my_rootfs_additions/
+
$ (echo n; echo p; echo 1; echo; echo; echo p; echo w) <nowiki>|</nowiki> fdisk -u ${node}
├── data
+
$ sync
│  ├── example.m4v
+
* '''DART-MX6'''
│  └── example.bin
+
}}
├── etc
+
$(echo n; echo p; echo 1; echo 8192; echo 24575; echo t; echo c; \
│  └── example.conf
+
  echo n; echo p; echo 2; echo 24576; echo; \
└── home
+
  echo p; echo w) <nowiki>|</nowiki> fdisk -u ${node}
    └── root
+
$ sync
        └── .example
 
</pre>
 
And let's say you want to build the fsl-image-gui image.<br>
 
<br>
 
Create a file called {{#var:BUILD_FOLDER}}/sources/meta-variscite-fslc/recipes-images/images/fsl-image-gui.bbappend<br>
 
with the following content:
 
<pre>
 
add_my_files() {
 
    cp -r /my_rootfs_additions/*  ${IMAGE_ROOTFS}/
 
}
 
  
ROOTFS_POSTPROCESS_COMMAND += "add_my_files;"
+
Format the partitions:
</pre>
+
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6|
Now, when you bitbake fsl-image-gui, the files in /my_rootfs_additions will be added to the rootfs (be careful when overwriting files).<br>
+
* '''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
  
= Useful Bitbake commands =
+
{{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX7|
 +
{{#ifeq: {{#var:SPL_SD_IMAGE_NAME}} | N/A |
 +
Flash U-Boot to eMMC:
 +
$ dd if={{#var:U-BOOT_SD_IMAGE_NAME}} of=${node} bs=1K seek=1; sync
 +
|
 +
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
 +
}}
  
[http://elinux.org/Bitbake_Cheat_Sheet Bitbake Cheat Sheet]
+
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}}
 +
}}
  
[https://community.freescale.com/docs/DOC-94953 Useful bitbake commands]
+
{{#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
 +
|}}
  
[https://community.freescale.com/docs/DOC-94874 i.MX Yocto Project: ltib versus bitbake]
+
= 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.<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>

Latest revision as of 17:17, 10 March 2020

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/

{{#ifeq: | imx8 || 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/Yocto

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.