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 Linux image that is included in the Emcraft software distribution (refer to the VF6 SOM Software 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 networking.uImage. This image corresponds to the projects/networking project included in the Emcraft software distribution. As mentioned above though, the process documented below will work for any uImage you build using the Emcraft software distribution.

Before you proceed to install an uImage 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 an uImage to the Flash unless you have validated the image on the target by loading it via Ethernet and TFTP.

The U-Boot command sequence required to install a uImage 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 120000 ${filesize} && nand write ${loadaddr} 120000 ${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 networking.uImage to the Flash:

VF6 U-Boot > setenv image vlad/networking.uImage
VF6 U-Boot > saveenv
...
Vybrid U-Boot > run update
Using FEC0 device
TFTP from server 172.17.0.1; our IP address is 172.17.44.46
Filename 'vlad/networking.uImage'.
Load address: 0x80007fc0
Loading: ################################################################# ################################################################# ################################################################# ########################
done
Bytes transferred = 3206508 (30ed6c hex)

NAND erase.spread: device 0 offset 0x120000, size 0x30ed6c
Erasing at 0x420000 -- 100% complete.
OK

NAND write: device 0 offset 0x120000, size 0x30ed6c
3206508 bytes written: OK
Saving Environment to NAND...
Erasing NAND...
Erasing at 0xa0000 -- 100% complete.
Writing to 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-1.14.0 (Apr 28 2015 - 20:54:55)

CPU: Freescale VyBrid 600 family rev1.3 at 498 MHz
...
## Booting kernel from Legacy Image at 80007fc0 ...
Image Name: Linux-3.0.15-vf6-1.14.0
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 3206444 Bytes = 3.1 MiB
Load Address: 80008000
Entry Point: 80008000
XIP Kernel Image ... OK
OK

Starting kernel ...

Linux version 3.0.15-vf6-1.14.0 (vlad@ocean.emcraft.com) (gcc version 4.7.2 (GCC)) #26 Sat May 2 13:06:56 +0400 2015
...
init started: BusyBox v1.17.0 (2015-05-02 13:06:01 +0400)
eth0: Freescale FEC PHY driver [Micrel KS8081] (mii_bus:phy_addr=1:01, irq=-1)
Loading /cmsis_example.bin to 0x3f400000 ...
Loaded 65872 bytes. Booting at 0x3f404119... done
~ # PHY: 1:01 - Link is Up - 100/Full
~ # ls
app                etc       mqxboot    start-mqx.sh
bin                httpd     proc       sys
cmsis-demo         init      root       usr
cmsis_example.bin  lib       sample.ko  var
dev                mnt       sbin
~ #

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