U-Boot 4.1.15 features: Difference between revisions

From Variscite Wiki
(Undo revision 8257 by Aviad (talk))
 
(27 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{PageHeader|VAR-SOM-MX6 - U-Boot features}} {{DocImage|category1=VAR-SOM-MX6|category2=}}
<span style="color:red">Note:</span> The default environment has changed in the our 4.1.15 branch of U-Boot.<br>
:: If you manually upgrade U-Boot, and you have an old environment saved, you need to reset your environment to the new default (see [[U-Boot 4.1.15 features#Environment handling commands|Environment handling commands]]).<br>
:: (There is no need to do that manually if you install U-Boot using our recovery SD card image).<br><br>
= New features introduced in Variscite U-Boot 2015.04: =
= New features introduced in Variscite U-Boot 2015.04: =


== Splash Screen ==
== Splash Screen ==
A splash screen is enabled by default, and is shown on the LVDS LCD.<br>
A splash screen is enabled by default, and is shown on the LVDS LCD.<br>
To disable the splash screen, stop the boot at u-boot command prompt and enter:
To disable the splash screen, enter the following in the U-Boot command line interface:
<pre>
<pre>
=> run disable_splash
=> run disable_splash
Line 15: Line 20:
The splash image is taken from /boot/splash.bmp in the root file system.<br><br>
The splash image is taken from /boot/splash.bmp in the root file system.<br><br>


Notes:<br>
=== Automatic Splash source selection ===
* The splash image will be taken from whichever rootfs that is going to be mounted later at boot.
The splash image will be taken from whichever rootfs that is going to be mounted later at boot.
To enable the automatic selection (already enabled by default):
<pre>
$ setenv splashsourceauto yes
$ saveenv
</pre>
To disable the automatic selection:
<pre>
$ setenv splashsourceauto no
$ setenv splashsource YOUR_SELECTION
$ saveenv
 
YOUR_SELECTION should be one of {sd, emmc, nand} (nand means UBIFS)
</pre>
 
Note:<br>
* In case the rootfs is a UBIFS, mounting it in order to load the splash file will add ~1.8 seconds to the boot time.
* In case the rootfs is a UBIFS, mounting it in order to load the splash file will add ~1.8 seconds to the boot time.
<br>
<br>
Line 22: Line 42:
=== Using your own LVDS LCD screen ===
=== Using your own LVDS LCD screen ===
There is support for the three different 800x480 LCD screen types that Variscite uses.<br>
There is support for the three different 800x480 LCD screen types that Variscite uses.<br>
If you want to add support for a different LCD that is not currently supported, you need to edit the <span style="font-family:Consolas;">displays</span> array in <span style="font-family:Consolas;">board/variscite/mx6var_som/mx6var_som.c</span> in the U-Boot source code, according to your LCD parameters.<br><br>
If you want to add support for a different LCD that is not currently supported, you need to edit the <span style="font-family:Consolas;">displays[]</span> array (and possibly the <span style="font-family:Consolas;">setup_display()</span> function) in <span style="font-family:Consolas;">board/variscite/mx6var_som/mx6var_som.c</span> in the U-Boot source code, according to your LCD parameters.<br><br>


== USB Mass Storage gadget ==
== USB Mass Storage gadget ==
Line 78: Line 98:
So, for example:
So, for example:
<pre>
<pre>
=> setenv usbnet_devaddr f8:dc:7a:00:00:01
=> setenv usbnet_devaddr f8:dc:7a:00:00:02
=> setenv usbnet_hostaddr f8:dc:7a:00:00:02
=> setenv usbnet_hostaddr f8:dc:7a:00:00:01
=> setenv ethact usb_ether
=> setenv ethact usb_ether
=> setenv ipaddr 192.168.0.100
=> setenv ipaddr 192.168.0.100
Line 88: Line 108:


Notes:
Notes:
* Once you run a network command, e.g. tftpboot, the gadget will be connected to your host PC and a new network adapter will be added to it, for the duration of the network ineraction.
* Once you run a network command, e.g. tftpboot, the gadget will be connected to your host PC and a new network adapter will be added to it, for the duration of the network interaction.
* Note that you may need to configure your host PC to use the new network adapter properly - this configuration is OS dependent.<br><br>
* Note that you may need to configure your host PC to use the new network adapter properly - this configuration is OS dependent.<br><br>


Line 110: Line 130:
If you're using a SOM with both NAND flash and eMMC, and you want to manually set the rootfs location to eMMC when booting from NAND, set the following environment variable:
If you're using a SOM with both NAND flash and eMMC, and you want to manually set the rootfs location to eMMC when booting from NAND, set the following environment variable:
<pre>
<pre>
=> setenv chosen_rootfs emmc
=> setenv rootfs_device emmc
</pre>
</pre>
Otherwise, it will try to mount the rootfs from NAND.<br><br>
Otherwise, it will try to mount the rootfs from NAND.<br><br>


What it actually does is choose between running "<span style="font-family:Consolas;">run bootargs_ubifs</span>" or "<span style="font-family:Consolas;">run bootargs_emmc</span>" which sets <span style="font-family:Consolas;">bootargs</span> accordingly:<br>
What it actually does is choose between running "<span style="font-family:Consolas;">run bootargs_nand</span>" or "<span style="font-family:Consolas;">run bootargs_emmc</span>" which sets <span style="font-family:Consolas;">bootargs</span> accordingly:<br>


<span style="font-family:Consolas;">
<span style="font-family:Consolas;">
bootargs_ubifs=setenv bootargs console=${console},${baudrate} ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs; run videoargs<br>
bootargs_nand=setenv bootargs console=${console},${baudrate} ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs; run videoargs<br>
bootargs_emmc=setenv bootargs console=${console},${baudrate} root=/dev/mmcblk1p1 rootwait rw; run videoargs
bootargs_emmc=setenv bootargs console=${console},${baudrate} root=/dev/mmcblk1p1 rootwait rw; run videoargs
</span><br><br>
</span><br><br>


Note: If you use our NAND/eMMC recovery SD card ver. 50 and above to flash Yocto, the chosen rootfs will be updated automatically to the location that you install the rootfs to - no need to manually change the environment.<br><br>
Note: If you use our NAND/eMMC recovery SD card ver. 50 and above to flash Yocto, the rootfs device will be updated automatically to the device that you install the rootfs to - no need to manually change the environment.<br><br>


== DART-MX6 features previously missing ==
== DART-MX6 features previously missing ==
* U-Boot now supports both SD card and eMMC at the same time, also on DART-MX6 SOMs, regardless of where you boot from.<br>
* U-Boot now supports both SD card and eMMC at the same time, also on DART-MX6 SOMs, regardless of where you boot from.<br>
:On DART-MX6 SOMs, the device you boot from is always mmc 0, and the other is mmc 1.
:SD card is mmc 0, and eMMC is mmc1, like in all of our boards.
* U-Boot now supports USB also on DART-MX6 SOMs.<br><br>
* U-Boot now supports USB also on DART-MX6 SOMs.<br><br>


Line 131: Line 151:


== Automatic Device Tree selection ==
== Automatic Device Tree selection ==
[[VAR-SOM-MX6_Yocto_Fido_R3_Build_Yocto_release#Automatic_Device_Tree_selection_in_U-Boot|Automatic Device Tree selection]]<br>
[[VAR-SOM-MX6_Yocto_Jethro_R4_Build_Yocto_release#Automatic_Device_Tree_selection_in_U-Boot|Automatic Device Tree selection]]<br>
[[VAR-SOM-MX6_Yocto_Fido_R3_Build_Yocto_release#Disable Automatic Device Tree selection|Disable Automatic Device Tree selection]]<br><br>


= General U-Boot commands =
= General U-Boot commands =
Line 270: Line 289:
Assuming you are reading the kernel image from our Recovery SD card:
Assuming you are reading the kernel image from our Recovery SD card:
<pre>
<pre>
=> mw.b 0x18100000 0xff 0x600000                                 # Write 0xFF to RAM in order to pad the image and align it to the NAND erase block size
=> mw.b 0x18100000 0xff 0x800000                                 # Write 0xFF to RAM in order to pad the image and align it to the NAND erase block size
=> load mmc 0:2 0x18100000 /opt/images/Yocto/uImage              # Load the Linux kernel image from the SD card to RAM
=> load mmc 0:2 0x18100000 /opt/images/Yocto/uImage              # Load the Linux kernel image from the SD card to RAM
=> nand erase.part kernel                                        # Erase the 'kernel' MTD partition
=> nand erase.part kernel                                        # Erase the 'kernel' MTD partition
=> nand write 0x18100000 kernel 0x600000                         # Write the Linux kernel image from RAM to MTD partition 'kernel'
=> nand write 0x18100000 kernel 0x800000                         # Write the Linux kernel image from RAM to MTD partition 'kernel'
</pre><br>
</pre><br>


Line 279: Line 298:
Assuming you are reading the .dtb file from our Recovery SD card:
Assuming you are reading the .dtb file from our Recovery SD card:
<pre>
<pre>
=> mw.b 0x18100000 0xff 0x20000                                       # Write 0xFF to RAM in order to pad the image and align it to the NAND erase block size (128KiB)
=> mw.b 0x18100000 0xff 0x20000                                           # Write 0xFF to RAM in order to pad the image and align it to the NAND erase block size (128KiB)
=> load mmc 0:2 0x18100000 /opt/images/Yocto/uImage-imx6q-var-som.dtb # Load the dtb from the SD card to RAM - Change to the correct .dtb filename for your setup
=> load mmc 0:2 0x18100000 /opt/images/Yocto/imx6q-var-som-cap.dtb         # Load the dtb from the SD card to RAM - Change to the correct .dtb filename for your setup
=> nand erase 0x3e0000 0x20000                                         # Erase the part of the NAND saved for the device tree
=> nand erase 0x3e0000 0x20000                                             # Erase the part of the NAND saved for the device tree
=> nand write 0x18100000 0x3e0000 0x20000                             # Write the device tree from RAM to NAND
=> nand write 0x18100000 0x3e0000 0x20000                                 # Write the device tree from RAM to NAND
</pre><br>
</pre><br>


Line 291: Line 310:
Assuming you are reading the UBI image from our Recovery SD card:
Assuming you are reading the UBI image from our Recovery SD card:
<pre>
<pre>
=> load mmc 0:2 0x18100000 /opt/images/Yocto/rootfs.ubi.img      # Load the UBI image from the SD card to RAM
=> load mmc 0:2 0x18100000 /opt/images/Yocto/rootfs.ubi         # Load the UBI image from the SD card to RAM
=> nand erase.part rootfs                                        # Erase the 'rootfs' MTD partition
=> nand erase.part rootfs                                        # Erase the 'rootfs' MTD partition
=> nand write.trimffs 0x18100000 rootfs $filesize                # Write the UBI image from RAM to MTD partition 'rootfs'
=> nand write.trimffs 0x18100000 rootfs $filesize                # Write the UBI image from RAM to MTD partition 'rootfs'
Line 305: Line 324:
=> ubi write 0x18100000 rootfs $filesize                        # Write the volume from RAM
=> ubi write 0x18100000 rootfs $filesize                        # Write the volume from RAM
</pre>
</pre>
= SD card detect =
By default, our U-Boot uses the card detect pin on the SD card connector of our evaluation boards.<br>
If you don't use card detect in your design, apply the following U-Boot patch to disable it:
<syntaxhighlight lang="diff">
Subject: [PATCH] mx6var_som: Disable mmc card detect
---
board/variscite/mx6var_som/mx6var_som.c | 40 +--------------------------------
1 file changed, 1 insertion(+), 39 deletions(-)
diff --git a/board/variscite/mx6var_som/mx6var_som.c b/board/variscite/mx6var_som/mx6var_som.c
index 196a54d..cb9b775 100644
--- a/board/variscite/mx6var_som/mx6var_som.c
+++ b/board/variscite/mx6var_som/mx6var_som.c
@@ -467,17 +467,6 @@ static iomux_v3_cfg_t const usdhc2_pads[] = {
IOMUX_PADS(PAD_SD2_DAT3__SD2_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
};
-static iomux_v3_cfg_t const usdhc2_cd_pad[][1*2] = {
- {
- /* DART */
- IOMUX_PADS(PAD_GPIO_6__GPIO1_IO06 | MUX_PAD_CTRL(NO_PAD_CTRL)),
- },
- {
- /* Non-DART */
- IOMUX_PADS(PAD_KEY_COL4__GPIO4_IO14 | MUX_PAD_CTRL(NO_PAD_CTRL)),
- }
-};
-
static iomux_v3_cfg_t const usdhc3_pads[] = {
IOMUX_PADS(PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
IOMUX_PADS(PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
@@ -536,30 +525,8 @@ static int mmc_map_to_kernel_blk(int dev_no)
}
#endif
-static int usdhc2_cd_gpio[] = {
- /* DART */
- IMX_GPIO_NR(1, 6),
- /* Non-DART */
- IMX_GPIO_NR(4, 14)
-};
-
int board_mmc_getcd(struct mmc *mmc)
{
- struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
- int board = is_dart_board() ? 0 : 1;
-
- /* SD card */
- if (cfg->esdhc_base == USDHC2_BASE_ADDR) {
- return !gpio_get_value(usdhc2_cd_gpio[board]);
- }
-
- /*
- * On DART SOMs eMMC is always present.
- *
- * On non DART SOMs eMMC can be present or not,
- * but we can't know until we try to init it
- * so return 1 here anyway
- */
return 1;
}
@@ -581,7 +548,7 @@ static enum mmc_boot_device get_mmc_boot_device(void)
int board_mmc_init(bd_t *bis)
{
#ifndef CONFIG_SPL_BUILD
- int ret, i, board;
+ int ret, i;
/*
* According to the board_mmc_init() the following map is done:
@@ -598,11 +565,6 @@ int board_mmc_init(bd_t *bis)
switch (i) {
case 0:
SETUP_IOMUX_PADS(usdhc2_pads);
-
- board = is_dart_board() ? 0 : 1;
- SETUP_IOMUX_PADS(usdhc2_cd_pad[board]);
- gpio_direction_input(usdhc2_cd_gpio[board]);
-
usdhc_cfg[0].esdhc_base = USDHC2_BASE_ADDR;
usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
usdhc_cfg[0].max_bus_width = 4;
</syntaxhighlight>

Latest revision as of 16:38, 23 May 2017

VAR-SOM-MX6 - U-Boot features

Note: The default environment has changed in the our 4.1.15 branch of U-Boot.

If you manually upgrade U-Boot, and you have an old environment saved, you need to reset your environment to the new default (see Environment handling commands).
(There is no need to do that manually if you install U-Boot using our recovery SD card image).

New features introduced in Variscite U-Boot 2015.04:

Splash Screen

A splash screen is enabled by default, and is shown on the LVDS LCD.
To disable the splash screen, enter the following in the U-Boot command line interface:

=> run disable_splash
=> saveenv && reset

And to re-enable it:

=> run enable_splash
=> saveenv && reset

The splash image is taken from /boot/splash.bmp in the root file system.

Automatic Splash source selection

The splash image will be taken from whichever rootfs that is going to be mounted later at boot. To enable the automatic selection (already enabled by default):

$ setenv splashsourceauto yes
$ saveenv

To disable the automatic selection:

$ setenv splashsourceauto no
$ setenv splashsource YOUR_SELECTION
$ saveenv

YOUR_SELECTION should be one of {sd, emmc, nand} (nand means UBIFS)

Note:

  • In case the rootfs is a UBIFS, mounting it in order to load the splash file will add ~1.8 seconds to the boot time.


Using your own LVDS LCD screen

There is support for the three different 800x480 LCD screen types that Variscite uses.
If you want to add support for a different LCD that is not currently supported, you need to edit the displays[] array (and possibly the setup_display() function) in board/variscite/mx6var_som/mx6var_som.c in the U-Boot source code, according to your LCD parameters.

USB Mass Storage gadget

You can use the board as a USB Mass Storage device:
You will be able to access all the partitions of any block device that is on the board or connected to it, from your host PC - You will see them as /dev/sdXX, just like connecting a regular USB storage to your PC, and you'll be able to mount them, and have full read/write access to them. You can even use it to flash a new U-Boot, re-partition the storage, re-format it, etc.
This is especially useful for updating the internal eMMC.

To do this you need to connect a USB cable between the OTG/Client port of the board and a regular USB Host port on your PC, and use U-Boot's ums command.

General ums usage is:

ums <USB_controller> [<devtype>] <devnum>  e.g. ums 0 mmc 0
    devtype defaults to mmc

devtype can be any block device (e.g. mmc, usb)

To mount the eMMC:

=> ums 0 mmc 1

To mount an SD card:

=> ums 0 mmc 0

Depending on your host PC, it may automatically mount it or not. If not, you can use dmesg to see the names of the device and its partitions (it should be in the form of /dev/sdXX) and mount them yourself.
To exit the ums command and disconnect the USB device press ctrl+c.

Note: You should use a Linux PC host as Windows can't naturally read ext file systems.

USB Ethernet Gadget

The USB Ethernet gadget allows you to make the board act as a USB Ethernet device when connecting its USB OTG/Client port to a host PC using a USB cable.
Basically, it allows for "Ethernet over USB".
This is especially useful if you build a custom board without an Ethernet interface and you want to boot via network using TFTP.

This feature is disabled by default. To enable it, you need to un-comment the defines of the following configs in include/configs/mx6var_som.h in the U-Boot source code:
CONFIG_USB_ETHER
CONFIG_USB_ETH_CDC

Now you should have a new Ethernet interface called usb_ether.

Before actually using it you should get to know the following environment variables:
Variables specific to this gadget:

usbnet_devaddr  - The virtual MAC address of the device (the board side).
usbnet_hostaddr - The virtual MAC address of the host (the PC side).

General network variables:

ethprime - Sets the primary Ethernet interface. This is the interface that will be tried first.
ethact   - Sets the currently active Ethernet interface. Normally, it is modified by the Ethernet driver, but you can change it if you want to override.
ipaddr   - IP address of the device - needed for tftp command.
netmask  - Subnet Mask.
serverip - TFTP server IP address - needed for tftp command.

So, for example:

=> setenv usbnet_devaddr f8:dc:7a:00:00:02
=> setenv usbnet_hostaddr f8:dc:7a:00:00:01
=> setenv ethact usb_ether
=> setenv ipaddr 192.168.0.100
=> setenv netmask 255.255.255.0
=> setenv serverip 192.168.0.101

And now your are ready to use tftpboot over the usb_ether interface.

Notes:

  • Once you run a network command, e.g. tftpboot, the gadget will be connected to your host PC and a new network adapter will be added to it, for the duration of the network interaction.
  • Note that you may need to configure your host PC to use the new network adapter properly - this configuration is OS dependent.

HDMI auto-detection

If an HDMI screen is connected to the board, it will auto-detect it on boot and use it as its display.
No need to manually change anything.

What it actually does is use the hdmidet command to detect the hdmi and automatically add "video=mxcfb0:dev=hdmi,1920x1080M@60,if=RGB24;" to bootargs, accordingly.

Host/Client mode on VAR-MX6CustomBoard's micro-USB port

On VAR-MX6CustomBoard the micro-USB port is not a fully native OTG - it supports either Client or Host mode.
When using it in U-Boot, it is set to Client mode by default and you can change it to Host mode by setting the following environment variable:

=> setenv usbmode host

You can change it back and forth in real time when using this USB port in U-Boot, but pay attention that you are using the USB port correctly, according to the mode you set it to.

Note: The rest of the USB ports on VAR-MX6CustomBoard are always Hosts.

Choosing Root File System location when booting from NAND

If you're using a SOM with both NAND flash and eMMC, and you want to manually set the rootfs location to eMMC when booting from NAND, set the following environment variable:

=> setenv rootfs_device emmc

Otherwise, it will try to mount the rootfs from NAND.

What it actually does is choose between running "run bootargs_nand" or "run bootargs_emmc" which sets bootargs accordingly:

bootargs_nand=setenv bootargs console=${console},${baudrate} ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs; run videoargs
bootargs_emmc=setenv bootargs console=${console},${baudrate} root=/dev/mmcblk1p1 rootwait rw; run videoargs


Note: If you use our NAND/eMMC recovery SD card ver. 50 and above to flash Yocto, the rootfs device will be updated automatically to the device that you install the rootfs to - no need to manually change the environment.

DART-MX6 features previously missing

  • U-Boot now supports both SD card and eMMC at the same time, also on DART-MX6 SOMs, regardless of where you boot from.
SD card is mmc 0, and eMMC is mmc1, like in all of our boards.
  • U-Boot now supports USB also on DART-MX6 SOMs.

Other Variscite U-Boot features

Automatic Device Tree selection

Automatic Device Tree selection

General U-Boot commands

List all supported commands and their description/usage (help command)

List all supported commands with a brief description for each one:

=> help

Print the description and usage of 'command':

=> help command


Environment handling commands

Print the values of all environment variables:

=> printenv

Print value of environment variable 'name':

=> printenv name

Set environment variable 'name' to 'value ...':

=> setenv name value ...

Delete environment variable 'name':

=> setenv name

Reset default environment:

=> env default -a

Save environment variables to persistent storage:

=> saveenv


File System access

List files in a directory (default /):

=> ls <interface> [<dev[:part]>] [directory]

For example:

List files in the BOOT partition of our NAND/eMMC Recovery SD card (after booting from it):
=> ls mmc 0:1

List files in directory /opt/images/Yocto in the rootfs partition of our NAND/eMMC Recovery SD card (after booting from it):
=> ls mmc 0:2 /opt/images/Yocto


Load binary file 'filename' from a partition to RAM address 'addr':

=> load <interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]

For example:

Load /boot/splash.bmp from the rootfs partition of our NAND/eMMC Recovery SD card (after booting from it) to RAM address 0x18100000:
=> load mmc 0:2 0x18100000 /boot/splash.bmp


UBI File System

This is the FS we use on our NAND flash.
UBIFS is very different to any traditional file system - it does not work on top of block devices (like hard drives, MMC/SD cards, USB flash drives, SSDs, etc).
UBIFS was designed to work on top of raw flash.

The usage is a little different than using FAT/ext.
Before you can access the UBIFS you need to mount it first:

=> ubi part rootfs
=> ubifsmount ubi0:rootfs

Now you can access the UBIFS with the regular commands above.
The <interface> in this case is 'ubi', <dev> can be anything (the value is ignored) and part is not necessary.
For example:

List files in directory /home/root on the mounted UBI file system:
=> ls ubi 0 /home/root

When finished accessing it, unmount the FS:

=> ubifsumount


USB sub-system

To use the USB as host (connect a USB Storage or Ethernet Device to the board), you need to use the usb command.
Usage:

usb start - start (scan) USB controller
usb reset - reset (rescan) USB controller
usb stop [f] - stop USB [f]=force stop
usb tree - show USB device tree
usb info [dev] - show available USB devices
usb test [dev] [port] [mode] - set USB 2.0 test mode
    (specify port 0 to indicate the device's upstream port)
    Available modes: J, K, S[E0_NAK], P[acket], F[orce_Enable]
usb storage - show details of USB storage devices
usb dev [dev] - show or set current USB storage device
usb part [dev] - print partition table of one or all USB storage    devices
usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'
    to memory address `addr'
usb write addr blk# cnt - write `cnt' blocks starting at block `blk#'
    from memory address `addr'

First, connect your device to a USB port on the board.
After the device is connected, start the USB controller:

=> usb start

If you connect/disconnect devices after that, before you can access them you need to rescan the USB controller:

=> usb reset


Known Issue:
USB Host mode on the OTG port sometimes doesn't work.
To fix this, you need to disable the D-Cache by adding the following definition to include/configs/mx6var_som.h in the U-Boot source code:
CONFIG_SYS_DCACHE_OFF

Using a USB Storage Device

Once you connected the device and stated the USB controller, you can now use the regular File System commands mentioned above with it.
The <interface> in this case is 'usb'.

Flashing NAND using U-Boot

Flashing U-Boot to NAND

Assuming you are reading the U-Boot image from our Recovery SD card:

=> mw.b 0x18100000 0xff 0x1e0000                                 # Write 0xFF to RAM in order to pad the image and align it to the NAND erase block size
=> load mmc 0:2 0x18100000 /opt/images/Yocto/u-boot.img          # Load the U-Boot image from the SD card to RAM
=> nand erase 0x200000 0x1e0000                                  # Erase the part of the NAND saved for the U-Boot image 
=> nand write 0x18100000 0x200000 0x1e0000                       # Write the U-Boot image from RAM to NAND


Flashing the Linux kernel to NAND

Assuming you are reading the kernel image from our Recovery SD card:

=> mw.b 0x18100000 0xff 0x800000                                 # Write 0xFF to RAM in order to pad the image and align it to the NAND erase block size
=> load mmc 0:2 0x18100000 /opt/images/Yocto/uImage              # Load the Linux kernel image from the SD card to RAM
=> nand erase.part kernel                                        # Erase the 'kernel' MTD partition
=> nand write 0x18100000 kernel 0x800000                         # Write the Linux kernel image from RAM to MTD partition 'kernel'


Flashing the Linux device tree to NAND

Assuming you are reading the .dtb file from our Recovery SD card:

=> mw.b 0x18100000 0xff 0x20000                                            # Write 0xFF to RAM in order to pad the image and align it to the NAND erase block size (128KiB)
=> load mmc 0:2 0x18100000 /opt/images/Yocto/imx6q-var-som-cap.dtb         # Load the dtb from the SD card to RAM - Change to the correct .dtb filename for your setup
=> nand erase 0x3e0000 0x20000                                             # Erase the part of the NAND saved for the device tree
=> nand write 0x18100000 0x3e0000 0x20000                                  # Write the device tree from RAM to NAND


Flashing UBIFS to NAND

The best way to flash a UBI image is by using ubiformat (which is a part of mtd-utils) under Linux, as it preserves erase counters (our Recovery SD card scripts are using ubiformat).
But if you flash the UBIFS for the first time, then it doesn't matter because there are no erase counters to preserve.

Assuming you are reading the UBI image from our Recovery SD card:

=> load mmc 0:2 0x18100000 /opt/images/Yocto/rootfs.ubi          # Load the UBI image from the SD card to RAM
=> nand erase.part rootfs                                        # Erase the 'rootfs' MTD partition
=> nand write.trimffs 0x18100000 rootfs $filesize                # Write the UBI image from RAM to MTD partition 'rootfs'


Note:
There is another method to do this using U-Boot, that preserves erase counters, using the higher level ubi command, but you need a UBIFS image for it (which Yocto also creates, but we do not put on our Recovery SD card by default):

=> load mmc 0:2 0x18100000 /opt/images/Yocto/rootfs.ubifs        # Load the UBIFS image from an SD card to RAM
=> ubi part rootfs                                               # Set current MTD partition to 'rootfs'
=> ubi remove rootfs                                             # Remove the 'rootfs' UBI volume (if already exists)
=> ubi create rootfs                                             # Create a new dynamic UBI volume (read/write) with max size, and name it 'rootfs'
=> ubi write 0x18100000 rootfs $filesize                         # Write the volume from RAM

SD card detect

By default, our U-Boot uses the card detect pin on the SD card connector of our evaluation boards.
If you don't use card detect in your design, apply the following U-Boot patch to disable it:

Subject: [PATCH] mx6var_som: Disable mmc card detect

---
 board/variscite/mx6var_som/mx6var_som.c | 40 +--------------------------------
 1 file changed, 1 insertion(+), 39 deletions(-)

diff --git a/board/variscite/mx6var_som/mx6var_som.c b/board/variscite/mx6var_som/mx6var_som.c
index 196a54d..cb9b775 100644
--- a/board/variscite/mx6var_som/mx6var_som.c
+++ b/board/variscite/mx6var_som/mx6var_som.c
@@ -467,17 +467,6 @@ static iomux_v3_cfg_t const usdhc2_pads[] = {
 	IOMUX_PADS(PAD_SD2_DAT3__SD2_DATA3	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
 };
 
-static iomux_v3_cfg_t const usdhc2_cd_pad[][1*2] = {
-	{
-		/* DART */
-		IOMUX_PADS(PAD_GPIO_6__GPIO1_IO06 | MUX_PAD_CTRL(NO_PAD_CTRL)),
-	},
-	{
-		/* Non-DART */
-		IOMUX_PADS(PAD_KEY_COL4__GPIO4_IO14 | MUX_PAD_CTRL(NO_PAD_CTRL)),
-	}
-};
-
 static iomux_v3_cfg_t const usdhc3_pads[] = {
 	IOMUX_PADS(PAD_SD3_CLK__SD3_CLK		| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
 	IOMUX_PADS(PAD_SD3_CMD__SD3_CMD		| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
@@ -536,30 +525,8 @@ static int mmc_map_to_kernel_blk(int dev_no)
 }
 #endif
 
-static int usdhc2_cd_gpio[] = {
-	/* DART */
-	IMX_GPIO_NR(1, 6),
-	/* Non-DART */
-	IMX_GPIO_NR(4, 14)
-};
-
 int board_mmc_getcd(struct mmc *mmc)
 {
-	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
-	int board = is_dart_board() ? 0 : 1;
-
-	/* SD card */
-	if (cfg->esdhc_base == USDHC2_BASE_ADDR) {
-		return !gpio_get_value(usdhc2_cd_gpio[board]);
-	}
-
-	/*
-	 * On DART SOMs eMMC is always present.
-	 *
-	 * On non DART SOMs eMMC can be present or not,
-	 * but we can't know until we try to init it
-	 * so return 1 here anyway
-	 */
 	return 1;
 }
 
@@ -581,7 +548,7 @@ static enum mmc_boot_device get_mmc_boot_device(void)
 int board_mmc_init(bd_t *bis)
 {
 #ifndef CONFIG_SPL_BUILD
-	int ret, i, board;
+	int ret, i;
 
 	/*
 	 * According to the board_mmc_init() the following map is done:
@@ -598,11 +565,6 @@ int board_mmc_init(bd_t *bis)
 		switch (i) {
 		case 0:
 			SETUP_IOMUX_PADS(usdhc2_pads);
-
-			board = is_dart_board() ? 0 : 1;
-			SETUP_IOMUX_PADS(usdhc2_cd_pad[board]);
-			gpio_direction_input(usdhc2_cd_gpio[board]);
-
 			usdhc_cfg[0].esdhc_base = USDHC2_BASE_ADDR;
 			usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
 			usdhc_cfg[0].max_bus_width = 4;