2009-10-04

Upgrading the factory SheevaPlug nand to a more efficient version

If you've had a look at openplug.org, as you should have, you've read that the default installed NAND kind of blows (slow MMC/NAND accesses, old U-Boot version that lacks versatility to install newer kernels, etc.), so you'll want to upgrade the default NAND (u-boot and Ubuntu) to something that's more up to date.

Well, the good guys at openplug.org heard you and made a readily available package for ya (see SheevaPlug Installer in the HowTo's section), so off you go an download the big tarball.
Only thing is, well, they've customized their packages for the masses (that still run a 32 bit OS), not the classes (x64), and they insist on using a PHP installer (eeeeew!!!).
Are we gonna trust a one size-fits-all installer to cover our needs? Of course not!

The purpose of this guide then is to show you how to manually install the SheevaPlug Installer v1.0 from a Linux x86_64 environment, since, if you followed the previous post, you should now have a working openocd there. Of course, this stuff will work on 32 bit Linux as well.

For the purpose of this exercise, we'll assume that you have extracted the tar in /usr/src, and thus you have a /usr/src/sheevaplug-installer-v1.0/ directory and that you have a FAT32 formatted USB stick mounted in /mnt/usb

First we need to populate the USB stick.
cd /usr/src/sheevaplug-installer-v1.0/installer/
cp * /mnt/usb
sync
That's really all there is to it for the USB part. Once syncing is done, just plug the USB stick on the sheevaplug.

Then, log on the sheeva with the serial console, and reboot it. When you see the prompt "Hit any key to stop autoboot:" press a key. Now that the plug is in idle state, we'll start by re-flashing the U-Boot using openocd, which is definitely something you want to know how to do in case of trouble. Please note that, as shown below, you MUST launch openocd from the directory where your uboot.bin image is located. Also note that the flashing itself takes about 2-3 minutes, during which NOTHING will happen in the openocd console, so be patient.
cd uboot
openocd -f /usr/local/share/openocd/scripts/board/sheevaplug.cfg
Then from another Linux terminal
# telnet localhost 4444
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> sheevaplug_init
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x000000d3 pc: 0xffff0000
MMU: disabled, D-Cache: disabled, I-Cache: disabled
0 0 1 0: 00052078
> sheevaplug_reflash_uboot
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x000000d3 pc: 0xffff0000
MMU: disabled, D-Cache: disabled, I-Cache: disabled
0 0 1 0: 00052078
NAND flash device 'NAND 512MiB 3,3V 8-bit' found
erased blocks 0 to 5 on NAND flash device #0 'NAND 512MiB 3,3V 8-bit'
[!!!! THE 2-3 MINUTES PAUSE HAPPENS HERE - BE PATIENT!!!!]
wrote file uboot.bin to NAND flash 0 up to offset 0x00074000 in 217.873932s
>
After that, the plug will reboot (into the new U-Boot), so make sure you have your serial console still running. The upgraded U-Boot should still let you boot the old factory installed Ubuntu Linux, so you might wanna check that everything's copacetic.

So far so good? Alright then, let's move to the next stage and flash that up to date Linux image.
This time we're not gonna use openocd but the flashing capabilities of the U-Boot, so you can "shutdown" (i.e. exit) openocd if not already done.

Once again, you need to reset the plug & interrupt the boot process to get to the Marvel>> prompt. There, we will install the new Ubuntu image by using the various commands from the U-Boot environment.
Three points that you need to know before starting this procedure:
  1. Please note that it is necessary to boot the RAM image at the end to setup the NAND filesystem. Failure to do so will result in an unbootable Linux image, but this can be rectified by reloading the USB images and issuing the last command listed.
  2. It is also a good idea, before you start this whole procedure, to spare a copy of your environment variables, which you'll get with the command 'printenv', as we're going to modify/create some of those. This way you should be able to revert back to your old environment if anything happens
  3. The initial setup of the Linux image requires access to the USB stick, so make sure you leave it plugged in.
Marvell>> usb start
(Re)start USB...
USB: scanning bus for devices... 2 USB Device(s) found
scanning bus for storage devices... 1 Storage Device(s) found
Marvell>> fatload usb 0 0x00800000 uImage
reading uImage
...............................................................................................................................................................................................................................................................

2620504 bytes read
Marvell>> fatload usb 0 0x01100000 initrd
reading initrd
.....................................................................................................................................................................................................................................................................................................................................

3331626 bytes read
Marvell>> nand erase clean 0x00100000 0x00400000;

NAND erase: device 0 offset 0x100000, size 0x400000
Erasing at 0x4e0000 -- 100% complete. Cleanmarker written at 0x4e0000.
OK
Marvell>> nand write.e 0x00800000 0x00100000 0x00400000

NAND write: device 0 offset 0x100000, size 0x400000

Writing data at 0x4ff800 -- 100% complete.
4194304 bytes written: OK
Marvell>> setenv mainlineLinux yes
Marvell>> setenv arcNumber 2097
Marvell>> setenv bootargs_root ubi.mtd=1 root=ubi0:rootfs rootfstype=ubifs
Marvell>> setenv mtdpartitions mtdparts=orion_nand:0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs)
Marvell>> setenv bootargs_console console=ttyS0,115200
Marvell>> setenv bootargs $(bootargs_console) $(mtdpartitions) $(bootargs_root)
Marvell>> saveenv
Saving Environment to NAND...
Erasing Nand...Writing to Nand... done
Marvell>> setenv bootargs $(bootargs_console) $(mtdpartitions) root=/dev/ram0 rw ramdisk=0x01100000,8M install_type=nand; bootm 0x00800000 0x01100000
Now, because of the "bootm" command after the semicolon, this last command will make the plug boot automatically into the Linux copy in RAM, which needs to be done at least once to setup your initial system on the NAND. If all is well, this one time Linux installer will run & setup your system, restart the plug, and you'll get the new Ubuntu 9.04 booting which you'll find is A LOT faster than the factory one!

Next, we'll see how to recompile and install a vanilla kernel to boot the new distro.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.