Playing with u-boot

Once you get the console link working, you can witness the very early stage of the ED Mini boot process. It looks like this:

__ __ _ _
| \/ | __ _ _ ____ _____| | |
| |\/| |/ _` | '__\ \ / / _ \ | |
| | | | (_| | | \ V / __/ | |
|_| |_|\__,_|_| \_/ \___|_|_|
_ _ ____ _
| | | | | __ ) ___ ___ | |_
| | | |___| _ \ / _ \ / _ \| __|
| |_| |___| |_) | (_) | (_) | |_
\___/ |____/ \___/ \___/ \__| ** LOADER **
** MARVELL BOARD: DB-88F5182-EDmini-V2 LE

U-Boot 1.1.1 (Aug 16 2006 - 10:46:18) Marvell version: 1.7.3 - LaCie version: 1.3.4

DRAM CS[0] base 0x00000000 size 64MB
DRAM Total size 64MB
Flash: flashStructGet manu 0xff id 0xff
[0kB@fff80000] ## Unknown FLASH at fff80000: Size = 0x00000000 = 0 MB
Flash: 0 kB
Addresses 20M - 0M are saved for the U-Boot usage.
Mem malloc Initialization (20M - 16M): Done
*** Warning - bad CRC, using default environment


Soc: MV88F5182 Rev 2
CPU: ARM926 (Rev 0) running @ 400Mhz
SysClock = 133Mhz , TClock = 166Mhz


USB 0: host mode
USB 1: device mode
PCI 0: PCI Express Root Complex Interface
PCI 1: Conventional PCI, speed = 33000000
Net: egiga0 [PRIME]
Power Button Released
Hit any key to stop autoboot: 3

Is that big enough to notice? The ED Mini uses u-boot as its bootloader. You can find more about u-boot there. U-boot is Open Source, and actually in the ED Mini tarball, LaCie provides a heavily modified u-boot version.

The good news is that we can stop the boot process and enter u-boot commands at the console, which allows us to change the Linux booting process: we could for instance load a Linux kernel from a TFTP server, and boot on a root filesystem over NFS. We simply need to set some environment variables at the u-boot prompt and enter the right boot command.

The bad news is that, as the prompt shows, this u-boot has trouble recognizing the board's FLASH part. This basically means we can't make permanent changes to environment variables, which should reside in FLASH. And this means that each time we want to boot over TFTP/NFS, we'd have to stop u-boot at the prompt, re-enter the environment variables again, and re-enter the right boot command.

But we've got the source, right? So we should be able to fix that FLASH issue.

Summary of the u-boot patches

Here are the patches I made against LaCie's u-boot source tarball. You can find a patch file (cd uboot-lacie; patch -p1 < patchfile) as an attachment below.

File Patch
board/mv88fxx81/Board/boardEnv/DB_88FXX81/mvBoardEnvSpec.h Change BOOT device bus width from 8 to 16
board/mv88fxx81/Board/flash/mvAmdFlash.c Add support for Macronix in unlock, erase and program functions
board/mv88fxx81/Board/flash/mvAmdFlash.h Add device ID for Macronix MX29LV400CBCT
board/mv88fxx81/Board/flash/mvFlash.c Add support for Macronix and MX29LV400CBCT in reset, erase and program functions
board/mv88fxx81/Board/flash/mvFlashCom.c Add support for Macronix and MX29LV400CBCT in console messages
board/mv88fxx81/USP/mv_main.c Changed wrong machine type from 526 to 1756 (ED Mini) and added a mach_type envirnoment variable to allow overriding during boot
examples/Makefile Fixed rules which break with make 3.81
include/configs/db88f5181.h Enabled "bdinfo" command
lib_arm/armlinux.c Added support to take mach_type's value into account if modified between power-up and bootm
Makefile Added removal of temp files created by examples/Makefile fix
AttachmentSize
uboot-lacie-aa-patch.patch11.89 KB

A fixed u-boot, with instructions

For those who want the result without wading through my rants, here it is.

Requirements:

  • An ED Mini V2 with a Macronix MX29LV400CBCT FLASH part;
  • A serial console hooked up on the ED Mini V2;
  • A machine to act as a TFTP server.

BEWARE!

Do not try this on anything else than an ED Mini V2 with a Macronix MX29LV400CBCT FLASH part.

Do not try this if you don't want to take the risk of rendering your ED Mini TOTALLY AND DEFINITIVELY UNUSABLE. Should the ED Mini become unuseable, you might be able to raise it from the dead by using JTAG equipment, but I cannot vouch for it, because I did not try JTAG.

Instructions:

  1. Download both u-boot-RAM.bin and u-boot-FLASH.bin.
  2. Power up the ED Mini V2 with the console attached, and press a key to get to the u-boot command prompt.
  3. Enter the following commands:
    • setenv serverip ip address of the TFTP server
    • setenv ipaddr ip address of the ED Mini V2
    • tftp 400000 u-boot-RAM.bin
    • go 410000
  4. The RAM-based u-boot starts. Press a key to stop it and get to its command line
  5. Enter the following commands:
    • setenv serverip ip address of the TFTP server
    • setenv ipaddr ip address of the ED Mini V2
    • tftp 500000 u-boot-FLASH.bin
  6. After the TFTP transfer is done, the length of the image is given, in decimal then between parentheses in hexadecimal. Note the hexadecimal length, you'll need it.
  7. Enter the following commands:
    • protect off all
    • erase all
    • cp.b 500000 fff80000 length
  8. Hold your breath, and enter the following command:
    • reset
  9. Relax and enjoy your newly flashed u-boot or weep.

2008-jun-13: inserted the 'erase all' command, which was missing previously; thanks to petris at nas-central.org for pointing it out!

AttachmentSize
u-boot-RAM.bin448.13 KB
u-boot-FLASH.bin448.13 KB