SEARCH
TOOLBOX
LANGUAGES
modified on 21 September 2011 at 23:46 ••• 108,227 views

Flashing filesystems larger than RAM

From Manuals

Revision as of 23:46, 21 September 2011 by Support (Talk | contribs)
Jump to: navigation, search

Contents

The Electrum User's Manual suggests using the U-Boot bootloader to flash the kernel and root filesystem to NAND. U-Boot performs this in two steps. First the file is copied from the original source (USB, TFTP, microSD) to RAM using fatload, tftp, etc. Then it is copied from RAM to NAND using "nand write". This procedure is simple but limits the filesystem to be flashed to available RAM. Files can be copied to the root filesystem after Linux boots but this makes the procedure more cumbersome.

For larger filesystems a better alternative is to flash from Linux. This requires booting the board using a medium other than NAND such as microSD, USB or NFS. This application note explains the procedure using a microSD card. It can be easily adapted to USB or NFS boots.

Setup mtd-utils

Prepare a microSD card for flashing NAND using mtd-utils. This is a one time setup.

1. First, prepare a bootable microSD card using the procedure in the Wiki.

2. Configure bootloader for microSD boot. Press space bar when bootloader loads to get an ">Electrum" command prompt.

setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p1 rw ip=192.168.1.102:192.168.1.253::255.255.255.0::eth0:none
setenv bootcmd mmcinfo\; ext2load mmc 0:1 0x22000000 uImage-2.6.33.5\; bootm
saveenv
reset

NOTE: Substitute 192.168.1.102, 192.168.1.253 and 255.255.255.0 for the corresponding board IP address, gateway address and netmask.

3. Boot from the microSD card. Login as root and verify that the root filesystem uses device mmcblk0p1.

# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mmcblk0p1         1889792    193096   1600700  11% /
tmpfs                    30652         0     30652   0% /lib/init/rw
tmpfs                    30652         0     30652   0% /dev/shm

If not edit /etc/fstab and reboot.

/dev/mmcblk0p1  /               ext2   defaults        0       0

4. Setup your network gateway & install mtd-utils from repository.

# route add default gw 192.168.1.253 eth0
# apt-setup
# apt-get install mtd-utils
# apt-purge

NOTE: Substitute 192.168.1.253 for the corresponding gateway address. You may need to change /etc/resolv.conf to use the name servers for your network.

5. Copy the desired kernel and filesystem to a directory in the microSD card, e.g. /home/electrum100 .

6. Create the NAND character devices. First, verify the NAND partition labels. The default is to use mtd5 for the Linux kernel and mtd6 for the root filesystem. The 512MB NAND uses a page size of 0x800 (2K) and an erase block size of 0x20000 (128K).

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00040000 00020000 "bootstrap"
mtd1: 00040000 00020000 "uboot"
mtd2: 00040000 00020000 "env1"
mtd3: 00040000 00020000 "env2"
mtd4: 00100000 00020000 "user"
mtd5: 00200000 00020000 "linux"
mtd6: 1fc00000 00020000 "root"
mtd7: 00042000 00000108 "spi0.1-AT45DB021B"

Then use mknod to create the device nodes

# mknod /dev/mtd0 c 90 0
# mknod /dev/mtd1 c 90 2
# mknod /dev/mtd2 c 90 4
# mknod /dev/mtd3 c 90 6
# mknod /dev/mtd4 c 90 8
# mknod /dev/mtd5 c 90 10
# mknod /dev/mtd6 c 90 12
# mknod /dev/mtd7 c 90 14