NAND Boot for Vybrid Tower U-Boot 2011

Writing u-boot to NAND Flash Boot for Vybrid Tower

Generating the NAND U-boot Image

The u-boot binary generated by your LinuxLink the build (u-boot.imx) needs to be padded before using the u-boot utility to write it is written to NAND flash. The u-boot image must be prepended/padded by 1024 bytes, since this is where the ROM expects to find the IVT. This process is outlined below.

# dd if=/dev/zero of=u-boot-pad bs=1024 count=1
# cat u-boot-pad /path/to/u-boot.imx u-boot.imx > u-boot.nand u-boot.timesys

Writing a u-boot image to NAND

Initially, you will need to use the u-boot running from the SD card to write u-boot to NAND using the “nb_update” utility. Make sure to update u-boot on your SD card with u-boot.imx as generated from your latest LinuxLink build. This is because the nb_update utility has been updated on the new u-boot image. Please see step 5 in the following document with instructions for updating u-boot on your SD card:

https://linuxlink.timesys.com/docs/gsg/twr_vf600#SECTION00041000000000000000

You can put the NAND u-boot image (u-boot.nand) in a partition or pull it over the network to get it into ram. For this example the NAND u-boot image is put into a partition on the SD card and read into ram from there. Remember to erase the NAND chip before writing the image. Booting from NAND requires that the "Boot Config" jumpers 1-2 should be bridged, and also 9-10 should be bridged. Below is the example u-boot commands used to put an image in NAND.

U-Boot 2011.12-dirty (Jun 12 2013 - 15:41:26)

CPU: Freescale VyBrid 600 family rev1.1 at 0 MHz
Reset cause: <NULL>
Board: Vybrid
DRAM: 128 MiB
WARNING: Caches not enabled
NAND: 256 MiB
MMC: FSL_SDHC: 0
In: serial
Out: serial
Err: serial
Net: Link UP timeout
FEC0, FEC1
Hit any key to stop autoboot: 0

Vybrid U-Boot > nand erase.chip

NAND erase.chip: device 0 whole chip
Bad block table found at page 131008, version 0x01
Bad block table found at page 130944, version 0x01
Skipping bad block at 0x0ff80000
Skipping bad block at 0x0ffa0000
Skipping bad block at 0x0ffc0000
Skipping bad block at 0x0ffe0000

OK
Vybrid U-Boot > fatload mmc 0:1 0x80400000 u-boot.nand u-boot.timesys
reading u-boot.nand u-boot.timesys

204772 bytes read
Vybrid U-Boot > nb_update 0x80400000 204772 0x80000
Flashing image to 0x80000
Vybrid U-Boot >

Booting Kernel/RFS from NAND Flash

Prerequisites

In order to write the RFS image to NAND Flash, you must have the following package in your existing RFS for Vybrid:

mtd-utils

Define NAND Partitions

If you require booting the kernel and/or RFS via NAND, you will need to specify NAND partitioning to do so. This can be done via a kernel commandline argument, like such:

mtdparts=NAND:0xc0000(U-boot),0x500000(Kernel),-(RFS)

This would provide a first partition of size 0xc0000 bytes for u-boot, a second partition with size 0x500000 bytes for the kernel, and the remaining size of the NAND chip for an RFS partition.

Append this kernel commandline argument to the 'bootargs' u-boot environment variable, like such:

Vybrid U-boot > setenv bootargs ${bootargs} mtdparts=NAND:0xc0000(U-boot),0x500000(Kernel),-(RFS)

Writing Kernel to NAND Flash

You can run the following commands in u-boot to write a kernel image to NAND Flash. The kernel image is loaded to RAM over the networking interface in this example, but you can also read an image to RAM via the SD card interface if networking is unavailable.

Vybrid U-Boot > bootp
BOOTP broadcast 1
DHCP client bound to address 10.0.0.10
Using FEC0 device
TFTP from server 10.0.0.1; our IP address is 10.0.0.10
Filename 'uImage-3.0-ts-armv7l'.
Load address: 0x80010000
Loading: #################################################################
#################################################################
#################################################
done
Bytes transferred = 2615492 (27e8c4 hex)

Vybrid U-Boot > nand write 0x80010000 0xc0000 0x27e8c4
Bad block table found at page 131008, version 0x01
Bad block table found at page 130944, version 0x01
nand_read_bbt: Bad block at 0x000000000000
nand_read_bbt: Bad block at 0x000000020000
2615492 bytes written: OK

Vybrid U-Boot >

Writing RFS to NAND Flash

You will need to have mtd-utils available in your NFS or SD card based RFS in order to write the RFS image to NAND. Please be sure to have already defined your NAND partitioning as outlined in the "Define NAND Partitions" section. In Linux on your Vybrid, run the following command:

# nandwrite /dev/mtd2 rootfs.jffs2
Writing data to block 0 at offset 0x0
Writing data to block 1 at offset 0x20000
Writing data to block 2 at offset 0x40000
...
Writing data to block 41 at offset 0x80000
#

Booting the kernel and RFS via NAND Flash

First, you will need to use the following kernel commandline arguments to boot the RFS from NAND Flash. Update your 'bootargs' u-boot environment variable with the following (make sure you replace any existing 'root=' argument):

rootfstype=jffs2 root=/dev/mtdblock2

The following boot command in u-boot can be used to load the kernel from NAND to RAM:

Vybrid U-Boot > setenv bootcmd 'nand read 0x80010000 0xc0000 0x27e8c4; bootm 0x80010000'
Vybrid U-boot > boot