Write Images to Flash
Flashing with Linux
We recommend using the Linux mtd utilities to write images to flash. This will require a bootable microSD card, which you can create by following the instructions posted here.
Now, copy the image files, and the script below, to the microSD card (for example to /home/root/images). You may need to modify the script to reflect the names of your image files. Make sure the script is marked as executable.
Unmount the microSD card from your development machine, insert in the Overo microSD slot and boot.
Login and run the script. Some users have reported that 'flash_erase /dev/mtdX 0' erases the partition where the syntax 'flash_erase /dev/mtdX 0 0' fails---this seems to occur on verion 1.4.1 of mtd_utils (check with 'opkg list_installed | grep mtd-utils').
uboot=u-boot-overo.bin
uimage=uImage-overo.bin
rootfs=omap3-desktop-nand-image-overo.ubi
if [ -e $uboot ]; then
echo "Erasing u-boot partition ..."
flash_erase /dev/mtd1 0 0
echo "Erasing u-boot environment partition ..."
flash_erase /dev/mtd2 0 0
echo "Writing u-boot to NAND ..."
nandwrite -p /dev/mtd1 $uboot
else
echo "ERROR: couldn't find u-boot binary"
fi
if [ -e $uimage ]; then
echo "Erasing kernel partition ..."
flash_erase /dev/mtd3 0 0
echo "Writing kernel to NAND ..."
nandwrite -p /dev/mtd3 $uimage
else
echo "ERROR: couldn't find kernel binary"
fi
if [ -e $rootfs ]; then
umount /dev/mtdblock4
echo "Writing rootfs to NAND ..."
ubiformat -y /dev/mtd4 -f $rootfs
else
echo "ERROR: couldn't find rootfs ubi"
fi
Replacing MLO
The Overo COM bootstrap loader MLO (x-load) requires hardware error checking which is available within the u-boot environment. The following commands issued at the u-boot prompt write four copies of an MLO (filename="MLO") from the FAT partition of a microSD card to Flash memory on the COM. Four copies are used for redundancy in case of corruption.
Overo # mmc rescan 0
Overo # fatload mmc 0 $loadaddr MLO
reading MLO
24220 bytes read
Overo # nandecc hw
HW ECC selected
Overo # nand erase 0 80000
NAND erase: device 0 offset 0x0, size 0x80000
Erasing at 0x60000 -- 100% complete.
OK
Overo # nand write $loadaddr 0 20000
NAND write: device 0 offset 0x0, size 0x20000
131072 bytes written: OK
Overo # nand write $loadaddr 20000 20000
...
Overo # nand write $loadaddr 40000 20000
...
Overo # nand write $loadaddr 60000 20000
...
Alternatively, you can write a u-boot script to flash MLO.
$ nano flash-MLO.cmd
fatload mmc 0 $loadaddr MLO nandecc hw nand erase 0 80000 nand write $loadaddr 0 20000 nand write $loadaddr 20000 20000 nand write $loadaddr 40000 20000 nand write $loadaddr 60000 20000
Make the script readable by u-boot.
$ mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "flash-MLO" -d flash-MLO.cmd flash-MLO.scr
Copy flash-MLO.scr to your boot partition, insert the microSD card in your COM and wait for u-boot to load from mmc. Interrupt the boot process when you see Hit any key to stop autoboot and enter these commands.
# mmc rescan 0; fatload mmc 0 ${loadaddr} flash-MLO.scr; source ${loadaddr}
Flashing with U-Boot
It is possible to completely reflash the COM (MLO, u-boot, kernel, root file system) from u-boot. First, you need to prepare an SD card with a large enough FAT partition to store the rootfs. To do so, follow the instructions posted here specifying a 512MB partition rather than 32MB. Now open a terminal window and copy the files you want to flash.
$ cd /media/boot $ wget http://cumulus.gumstix.org/images/angstrom/developer/current/MLO $ wget http://cumulus.gumstix.org/images/angstrom/developer/current/u-boot.bin $ wget http://cumulus.gumstix.org/images/angstrom/developer/current/uImage $ wget http://cumulus.gumstix.org/images/angstrom/developer/current/omap3-desktop-nand-image-overo.ubi -O rootfs.ubi
Now create a script to write the files to flash.
$ nano flash-all.cmd
nand erase.chip
# write MLO
fatload mmc 0 $loadaddr MLO
nandecc hw
nand write $loadaddr 0 20000
nand write $loadaddr 20000 20000
nand write $loadaddr 40000 20000
nand write $loadaddr 60000 20000
# write u-boot
fatload mmc 0 ${loadaddr} u-boot.bin
nandecc sw
nand write ${loadaddr} 80000 ${filesize}
nand erase 240000 20000
# write the kernel
fatload mmc 0 ${loadaddr} uImage
nand write ${loadaddr} 280000 ${filesize}
# write the filesystem
fatload mmc 0 ${loadaddr} rootfs.ubi
nand write ${loadaddr} 0x00680000 ${filesize}
To make the script readable by u-boot, use the following command.
$ mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "flash-all" -d flash-all.cmd flash-all.scr
Insert the microSD card in your COM and wait for u-boot to load from mmc. Interrupt the boot process when you see Hit any key to stop autoboot and enter these commands.
# mmc rescan 0; fatload mmc 0 ${loadaddr} flash-all.scr; source ${loadaddr}
Remove the SD card and restart your system. If all went well, your system should start normally. Note that this method is less reliable than flashing from Linux.