Installing Linux Images to Flash Print


This note explains how to install a bootable Linux image to the NAND Flash on the VF6 System-On-Module (SOM). Having installed a Linux image to the Flash, you would be able to boot Linux on the target automatically on any power up or reset cycle. This is the mode of operation that is typically used for deployed production units.

It should be noted that all VF6 SOMs come with a default Linux image preloaded to the Flash. This is the same rootfs.uImage that is included in the Emcraft software distribution (refer to VF6 System-On-Module Release Materials). Clearly, as you proceed to develop your Linux applications against your specific requirements, you will need a way to install an updated Linux image to the target for deployment. This note explains how to do that.

The example below refers to rootfs.uImage. This image is included as a prebuilt binary in the software distribution so you can always use it to revert to the factory default software, should you need to do that at some point. As mentioned above though, the process below will work for any bootable Linux image you build using the Emcraft software distribution.

Before you proceed to install a Linux image to the NAND Flash, it probably makes sense to verify that what you have is indeed a bootable Linux image. You can do that by loading the image to the target from the network using the run netboot command (refer to Loading Linux Images via Ethernet and TFTP). It is important to understand that the same uImage that you load via TFTP can be loaded from the Flash as well. It doesn't make sense to install a Linux image to the Flash unless you have validated the image by loading it via Ethernet and TFTP.

The U-Boot command sequence required to install a Linux image to the NAND Flash is defined for you by the U-Boot environment variable called update. Here is how update is defined in U-Boot by default:

Vybrid U-Boot > print update
update=tftp ${image} && nand erase.spread ${uImage_offset} ${filesize} && nand write ${loadaddr} ${uImage_offset} ${filesize} && setenv flashsize ${filesize}  && saveenv
Vybrid U-Boot >

You will notice that the first command in update is a tftpboot command to download an image from the network via Ethernet and TFTP. Please refer to Loading Linux Images via Ethernet and TFTP for detailed information on how to set up your target and the development host for loading images from TFTP. Following tftpboot, there is a sequence of commands that erase those Flash sections where the Linux image will be installed to and then copy the image to the Flash.

Here is a snapshot showing how update is used to install rootfs.uImage to the Flash:

Vybrid U-Boot > setenv image vf6/rootfs.uImage
Vybrid U-Boot > saveenv
Saving Environment to NAND...
...
Vybrid U-Boot > run update
AUsing FEC0 device
TFTP from server 172.17.0.1; our IP address is 172.17.80.3
Filename 'psl/vy/lcdkit/vf6-2.2.1/rootfs.uImage'.
Load address: 0x80007fc0
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
########################
done
Bytes transferred = 7019816 (6b1d28 hex)

NAND erase.spread: device 0 offset 0x2c0000, size 0x6b1d28
Erasing at 0x960000 -- 100% complete.
OK

NAND write: device 0 offset 0x2c0000, size 0x6b1d28
7019816 bytes written: OK
Saving Environment to NAND...
Erasing redundant NAND...
Erasing at 0xe0000 -- 100% complete.
Writing to redundant NAND... done
Vybrid U-Boot >

Having installed an image to the Flash, just hit the Reset button on the baseboard to boot the newly installed image from Flash:

U-Boot 2011.12-vf6 (Dec 30 2016 - 10:12:09)

CPU:   Freescale VyBrid 600 family rev1.3 at 498 MHz
Board: VF6-SOM-LC Rev 3.a, www.emcraft.com
DDR controller is initialized
DRAM:  512 MiB
NAND:  512 MiB
MMC:   FSL_SDHC: 0
Bad block table found at page 261952, version 0x01
Bad block table found at page 261888, version 0x01
nand_read_bbt: Bad block at 0x00001ffc0000
nand_read_bbt: Bad block at 0x00001ffe0000
In:    serial
Out:   serial
Err:   serial
Net:   FEC0 [PRIME]
Hit any key to stop autoboot:  0

NAND read: device 0 offset 0x2c0000, size 0x6b1d28
7019816 bytes read: OK

NAND read: device 0 offset 0x2a0000, size 0x7000
28672 bytes read: OK
## Booting kernel from Legacy Image at 80007fc0 ...
Image Name:   Linux-4.5.0-vf6-2.2.1
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    7019752 Bytes = 6.7 MiB
Load Address: 80008000
Entry Point:  80008000
## Flattened Device Tree blob at 80000100
Booting using the fdt blob at 0x80000100
XIP Kernel Image ... OK
OK
Loading Device Tree to 9fdee000, end 9fdf79b8 ... OK

Starting kernel ...
...
init started: BusyBox v1.17.0 (2016-12-27 19:31:05 +0400)
~ #

On deployed units, you will probably want to optimize the boot time by setting the U-Boot bootdelay variable to 0. Please refer to Autobooting Linux from U-Boot for detailed information on how to do that.

The root filesystem UBI image, U-Boot LCD splash image and kernel Device Tree Blob (rootfs.dtb) are updated using the similar U-Boot macros - rootfsupdate, splashupdate and dtbupdate.