Tweaking the LaCie ED Mini V2 (old book)

The LaCie ED Mini Gigabit (aka ED Mini V2) is an Ethernet + slave USB disk that I've bought in hopes that I could use USB for accessing the files from my multimedia box and Ethernet for managing these files, all at the same time. Alas, my box expects USB Mass Storage, and the EDMiniV2, unusually for USB disks, offers CDC Ethernet instead. But as the EDMiniV2 is Linux-based, it should be feasible to get it to support USB Mass Storage, right?

So here we go.

UPDATE: actually LaCie did more than provide the tarballs. It took some discussion but basically, they have provided a way to recompile the kernel (actually the config name, which is "db88f5182_EDMV2_config"), and acknowledged what I'd already suspected from looking into the SATA disk: the Linux kernel is on /dev/sda6, as a raw u-boot image.

Introduction

The ED Mini Gibabit is an external disk with Gigabit Ethernet (hence the name) and slave USB connectors.

I chose it because it has the slave USB, as I was looking for a USB Mass Storage device with an additional fast link.

Guess what: the ED Mini behaves as a USB Ethernet, not a USB Mass Storage, device.

Never mind I say as I discover this: it's GPL-based, let's just modify it.

The problem is, LaCie is not on par with Linksys as far as GPL compliance is.

Oh yes, I got the GPL source for the GPL binaries that are in the ED Mini; but I did not get the userland management code (that's fair: it is not required to be GPL), nor did I get the scripts needed to build and install the GPL sw (and GPLv2 says those scripts should be there).

So here I am, with a collection of tarballs.

Let's get to work, then.

Having a look at the ED Mini

TBD

Looking at the syslog

The ED Mini UI allows looking at the syslog, so let's see what's in there.

May 3 20:40:01 syslogd started: BusyBox v1.1.0 (2006.07.27-12:59+0000)
May 3 20:40:02 kernel: klogd started: BusyBox v1.1.0 (2006.07.27-12:59+0000)
May 3 20:40:02 kernel: Linux version 2.6.12.6-arm1-lacie5a (root@lacie) (gcc version 3.4.4 (release) (CodeSourcery ARM 2005q3-2)) #1 Tue Oct 31 11:26:21 CET 2006
May 3 20:40:02 kernel: CPU: ARM926EJ-Sid(wb) [41069260] revision 0 (ARMv5TEJ)
May 3 20:40:02 kernel: CPU0: D VIVT write-back cache
May 3 20:40:02 kernel: CPU0: I cache: 32768 bytes, associativity 1, 32 byte lines, 1024 sets
May 3 20:40:02 kernel: CPU0: D cache: 32768 bytes, associativity 1, 32 byte lines, 1024 sets
May 3 20:40:02 kernel: Machine: MV-88fxx81
May 3 20:40:02 kernel: Using UBoot passing parameters structure
May 3 20:40:02 kernel: Sys Clk = 133000000, Tclk = 166666667
May 3 20:40:02 kernel: Memory policy: ECC disabled, Data cache writeback
May 3 20:40:02 kernel: On node 0 totalpages: 16384
May 3 20:40:02 kernel: DMA zone: 16384 pages, LIFO batch:7
May 3 20:40:02 kernel: Normal zone: 0 pages, LIFO batch:1
May 3 20:40:02 kernel: HighMem zone: 0 pages, LIFO batch:1
May 3 20:40:02 kernel: Built 1 zonelists
May 3 20:40:02 kernel: Kernel command line: console=ttyS0,115200 root=/dev/sda7 ro
May 3 20:40:02 kernel: PID hash table entries: 512 (order: 9, 8192 bytes)
May 3 20:40:02 kernel: Console: colour dummy device 80x30
May 3 20:40:02 kernel: Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
May 3 20:40:02 kernel: Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
May 3 20:40:02 kernel: Memory: 64MB 0MB 0MB 0MB = 64MB total
May 3 20:40:02 kernel: Memory: 61440KB available (2817K code, 416K data, 96K init)
May 3 20:40:02 kernel: Calibrating delay loop... 266.24 BogoMIPS (lpj=1331200)
May 3 20:40:02 kernel: Mount-cache hash table entries: 512
May 3 20:40:02 kernel: CPU: Testing write buffer coherency: ok
May 3 20:40:02 kernel: NET: Registered protocol family 16
May 3 20:40:02 kernel: NET: Registered protocol family 16
May 3 20:40:02 kernel: CPU Interface
May 3 20:40:02 kernel: -------------
May 3 20:40:02 kernel: SDRAM_CS0 ....base 00000000, size 64MB
May 3 20:40:02 kernel: SDRAM_CS1 ....disable
May 3 20:40:02 kernel: SDRAM_CS2 ....disable
May 3 20:40:02 kernel: SDRAM_CS3 ....disable
May 3 20:40:02 kernel: PEX0_MEM ....base e0000000, size 128MB
May 3 20:40:02 kernel: PEX0_IO ....base f2000000, size 1MB
May 3 20:40:02 kernel: PCI0_MEM ....base e8000000, size 128MB
May 3 20:40:02 kernel: PCI0_IO ....base f2100000, size 1MB
May 3 20:40:02 kernel: INTER_REGS ....base f1000000, size 1MB
May 3 20:40:02 kernel: DEVICE_CS0 ....no such
May 3 20:40:02 kernel: DEVICE_CS1 ....base f4000000, size 16MB
May 3 20:40:02 kernel: DEVICE_CS2 ....no such
May 3 20:40:02 kernel: DEV_BOOCS ....base ff800000, size 8MB
May 3 20:40:02 kernel: CRYPTO ENG ....base f0000000, size 64KB
May 3 20:40:02 kernel: CRYPTO ENG ....base f0000000, size 64KB
May 3 20:40:02 kernel: LaCie EDmini V2 (MV LSP Version 1.10.3.patch2_DB_NAS)-- RD-88F5182-EDMV2 Soc: 88F5182 A2
May 3 20:40:02 kernel: LaCie EDmini V2 (MV LSP Version 1.10.3.patch2_DB_NAS)-- RD-88F5182-EDMV2 Soc: 88F5182 A2
May 3 20:40:02 kernel: Detected Tclk 166666667 and SysClk 133000000
May 3 20:40:02 kernel: Marvell USB EHCI Host controller #0: c3c11b00
May 3 20:40:02 kernel: Marvell USB EHCI Gadget controller #1: c3c11a40
May 3 20:40:02 kernel: pexBarOverlapDetect: winNum 2 overlap current 0
May 3 20:40:02 kernel: mvPexInit:Warning :Bar 2 size is illigal
May 3 20:40:02 kernel: it will be disabled
May 3 20:40:02 kernel: please check Pex and CPU windows configuration
May 3 20:40:02 kernel: PCI: bus0: Fast back to back transfers enabled
May 3 20:40:02 kernel: PCI: bus1: Fast back to back transfers enabled
May 3 20:40:02 kernel: SCSI subsystem initialized
May 3 20:40:02 kernel: usbcore: registered new driver usbfs
May 3 20:40:02 kernel: usbcore: registered new driver hub
May 3 20:40:02 kernel: Use the XOR engines (offloading) for enhancing the following functions:
May 3 20:40:02 kernel: o RAID 5 Xor calculation
May 3 20:40:02 kernel: o kernel memcpy
May 3 20:40:02 kernel: o kenrel memzero
May 3 20:40:02 kernel: o copy user to/from kernel buffers
May 3 20:40:02 kernel: Number of XOR engines to use: 2
May 3 20:40:02 kernel: Fast Floating Point Emulator V0.9 (c) Peter Teichmann.
May 3 20:40:02 kernel: inotify device minor=63
May 3 20:40:02 kernel: Registering unionfs 1.1.5
May 3 20:40:02 kernel: Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing disabled
May 3 20:40:02 kernel: ttyS0 at MMIO 0x0 (irq = 3) is a 16550A
May 3 20:40:02 kernel: io scheduler noop registered
May 3 20:40:02 kernel: io scheduler anticipatory registered
May 3 20:40:02 kernel: io scheduler deadline registered
May 3 20:40:02 kernel: io scheduler cfq registered
May 3 20:40:02 kernel: loop: loaded (max 8 devices)
May 3 20:40:02 kernel: Marvell Gigabit Ethernet Driver 'egiga':
May 3 20:40:02 kernel: o Ethernet descriptors in DRAM
May 3 20:40:02 kernel: o DRAM SW cache-coherency
May 3 20:40:02 kernel: o Checksum offload enabled
May 3 20:40:02 kernel: o Loading network interface 'egiga0'
May 3 20:40:02 kernel: Intergrated Sata device found
May 3 20:40:02 kernel: scsi0 : Marvell SCSI to SATA adapter
May 3 20:40:02 kernel: scsi1 : Marvell SCSI to SATA adapter
May 3 20:40:02 kernel: Vendor: Hitachi Model: HDT725050VLA360 Rev: V56O
May 3 20:40:02 kernel: Type: Direct-Access ANSI SCSI revision: 03
May 3 20:40:02 kernel: SCSI device sda: 976773168 512-byte hdwr sectors (500108 MB)
May 3 20:40:02 kernel: SCSI device sda: drive cache: write back
May 3 20:40:02 kernel: SCSI device sda: 976773168 512-byte hdwr sectors (500108 MB)
May 3 20:40:02 kernel: SCSI device sda: drive cache: write back
May 3 20:40:02 kernel: sda: sda1 < sda5 sda6 sda7 sda8 sda9 > sda2
May 3 20:40:02 kernel: Attached scsi disk sda at scsi1, channel 0, id 0, lun 0
May 3 20:40:02 kernel: Attached scsi generic sg0 at scsi1, channel 0, id 0, lun 0, type 0
May 3 20:40:02 kernel: physmap flash device: 80000 at ff800000
May 3 20:40:02 kernel: phys_mapped_flash: Found 1 x16 devices at 0x0 in 8-bit bank
May 3 20:40:02 kernel: Amd/Fujitsu Extended Query Table at 0x0040
May 3 20:40:02 kernel: I does not contain boot bank location. Assuming top.
May 3 20:40:02 kernel: number of CFI chips: 1
May 3 20:40:02 kernel: cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
May 3 20:40:02 kernel: cmdlinepart partition parsing not available
May 3 20:40:02 kernel: RedBoot partition parsing not available
May 3 20:40:02 kernel: ehci_platform ehci_platform.4523: EHCI Host Controller
May 3 20:40:02 kernel: ehci_platform ehci_platform.4523: new USB bus registered, assigned bus number 1
May 3 20:40:02 kernel: ehci_platform ehci_platform.4523: irq 17, io mem 0x00000000
May 3 20:40:02 kernel: ehci_platform ehci_platform.4523: park 0
May 3 20:40:02 kernel: ehci_platform ehci_platform.4523: USB 0.0 initialized, EHCI 1.00, driver 10 Dec 2004
May 3 20:40:02 kernel: hub 1-0:1.0: USB hub found
May 3 20:40:02 kernel: hub 1-0:1.0: 1 port detected
May 3 20:40:02 kernel: ohci_hcd: 2004 Nov 08 USB 1.1 'Open' Host Controller (OHCI) Driver (PCI)
May 3 20:40:02 kernel: usbcore: registered new driver usblp
May 3 20:40:02 kernel: drivers/usb/class/usblp.c: v0.13: USB Printer Device Class driver
May 3 20:40:02 kernel: Initializing USB Mass Storage driver...
May 3 20:40:02 kernel: usbcore: registered new driver usb-storage
May 3 20:40:02 kernel: USB Mass Storage support registered.
May 3 20:40:02 kernel: usbcore: registered new driver usbhid
May 3 20:40:02 kernel: drivers/usb/input/hid-core.c: v2.01:USB HID core driver
May 3 20:40:02 kernel: mice: PS/2 mouse device common for all mice
May 3 20:40:02 kernel: edmini_power 1.0 initialised
May 3 20:40:02 kernel: md: linear personality registered as nr 1
May 3 20:40:02 kernel: md: raid0 personality registered as nr 2
May 3 20:40:02 kernel: md: raid1 personality registered as nr 3
May 3 20:40:02 kernel: md: raid10 personality registered as nr 9
May 3 20:40:02 kernel: md: md driver 0.90.1 MAX_MD_DEVS=256, MD_SB_DISKS=27
May 3 20:40:02 kernel: device-mapper: 4.4.0-ioctl (2005-01-12) initialised: dm-devel@redhat.com
May 3 20:40:02 kernel: NET: Registered protocol family 2
May 3 20:40:02 kernel: IP: routing cache hash table of 512 buckets, 4Kbytes
May 3 20:40:02 kernel: TCP established hash table entries: 4096 (order: 3, 32768 bytes)
May 3 20:40:02 kernel: TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
May 3 20:40:02 kernel: TCP: Hash tables configured (established 4096 bind 4096)
May 3 20:40:02 kernel: NET: Registered protocol family 1
May 3 20:40:02 kernel: NET: Registered protocol family 17
May 3 20:40:02 kernel: NET: Registered protocol family 5
May 3 20:40:02 kernel: Loading I2C based RTC driver device interface.
May 3 20:40:02 kernel: Found TWSI adapter with id: 0
May 3 20:40:02 kernel: Found I2C RTC rs5c372 @ 0x32
May 3 20:40:02 kernel: md: Autodetecting RAID arrays.
May 3 20:40:02 kernel: md: autorun ...
May 3 20:40:02 kernel: md: ... autorun DONE.
May 3 20:40:02 kernel: EXT3-fs: mounted filesystem with ordered data mode.
May 3 20:40:02 kernel: VFS: Mounted root (ext3 filesystem) readonly.
May 3 20:40:02 kernel: Freeing init memory: 96K
May 3 20:40:02 kernel: kjournald starting. Commit interval 5 seconds
May 3 20:40:02 kernel: EXT3-fs warning: checktime reached, running e2fsck is recommended
May 3 20:40:02 kernel: kjournald starting. Commit interval 5 seconds
May 3 20:40:02 kernel: EXT3 FS on sda9, internal journal
May 3 20:40:02 kernel: EXT3-fs: mounted filesystem with ordered data mode.
May 3 20:40:02 kernel: kjournald starting. Commit interval 5 seconds
May 3 20:40:02 kernel: EXT3-fs: mounted filesystem with ordered data mode.
May 3 20:40:03 kernel: SGI XFS with no debug enabled
May 3 20:40:03 kernel: mv_gadget: version 05-July-2006 loaded
May 3 20:40:03 kernel: USB-1 Gadget driver probed
May 3 20:40:03 kernel: USB underrun WA: idma=1, streaming=1, threshold=64, SRAM: base=f0000000, size=8192, parts=2
May 3 20:40:03 kernel: USB init: CAP_REGS=0xf10a0100, DEV_REGS=0xf10a0140, MAX_EP=4
May 3 20:40:03 kernel: USB EP_QH: Base=f0000000 (0xf0000000), Aligned(2048)=f0000000, Size=512
May 3 20:40:03 kernel: USB dTD(48): Base=f0000200 (0xf0000200), Aligned(32)=f0000200, Size=1536, Scratch=c3420c00
May 3 20:40:03 kernel: USB WA_Queue: base=f0000800, size=6144, parts=2
May 3 20:40:03 kernel: USB Init: Wait for RESET completed
May 3 20:40:03 kernel: USB Init: RESET completed
May 3 20:40:03 kernel: device_init: pDev=0xc3d72800, pXD(32)=0xc3d72000, pSCRATCH(32)=0xc34fec00, pTempXD=0xc3b359e0
May 3 20:40:03 kernel: usb0: Ethernet Gadget, version: May Day 2005
May 3 20:40:03 kernel: usb0: using mv_gadget, OUT ep1out IN ep1in STATUS ep2in
May 3 20:40:03 kernel: usb0: MAC 76:c4:f2:eb:5b:bb
May 3 20:40:03 kernel: usb0: HOST MAC 00:d0:4b:62:81:29
May 3 20:40:03 kernel: usb0: RNDIS ready
May 3 20:40:03 kernel: registered Marvell USB-1 gadget driver ether
May 3 20:40:03 kernel: NTFS driver 2.1.22 [Flags: R/O MODULE].
May 3 20:40:04 kernel: Adding 128448k swap on /dev/sda5. Priority:-1 extents:1
May 3 20:40:05 kernel: VFS: Can't find ext3 filesystem on dev sda2.
May 3 20:40:05 kernel: VFS: Can't find an ext2 filesystem on dev sda2.
May 3 20:40:05 kernel: FAT: bogus number of FAT structure
May 3 20:40:05 kernel: VFS: Can't find a valid FAT filesystem on dev sda2.
May 3 20:40:05 kernel: Unable to identify CD-ROM format.
May 3 20:40:05 kernel: HFS+-fs: unable to find HFS+ superblock
May 3 20:40:05 kernel: VFS: Can't find a HFS filesystem on dev sda2.
May 3 20:40:05 kernel: UDF-fs: No VRS found
May 3 20:40:05 kernel: XFS mounting filesystem sda2
May 3 20:40:05 kernel: Ending clean XFS mount for filesystem: sda2
May 3 20:40:07 udhcpc[497]: udhcpc (v0.9.9-pre) started
May 3 20:40:07 kernel: egiga0: link down
May 3 20:40:10 kernel: egiga0: link up<5>, full duplex<5>, speed 1 Gbps<5>
May 3 20:40:11 udhcpc[497]: Lease of 192.168.128.10 obtained, lease time -1
May 3 20:40:16 udhcpc[621]: udhcpc (v0.9.9-pre) started
May 3 20:40:25 udhcpc[621]: No lease, forking to background.
May 3 20:40:26 ifplugd(egiga0)[670]: ifplugd 0.28 initializing.
May 3 20:40:26 ifplugd(egiga0)[670]: Using interface egiga0/00:D0:4B:81:29:62 with driver (version: )
May 3 20:40:26 ifplugd(egiga0)[670]: Using detection mode: SIOCETHTOOL
May 3 20:40:26 ifplugd(egiga0)[670]: Initialization complete, link beat detected.
May 3 20:40:26 ifplugd(egiga0)[670]: Executing '/etc/ifplugd/ifplugd.action egiga0 up'.
May 3 20:40:26 ifplugd(egiga0)[670]: client: route: SIOC[ADD|DEL]RT: No such process
May 3 20:40:27 ifplugd(egiga0)[670]: Program executed successfully.
May 3 20:40:27 ifplugd(usb0)[706]: ifplugd 0.28 initializing.
May 3 20:40:27 ifplugd(usb0)[706]: Using interface usb0/76:C4:F2:EB:5B:BB with driver (version: May Day 2005)
May 3 20:40:27 ifplugd(usb0)[706]: Using detection mode: SIOCETHTOOL
May 3 20:40:27 ifplugd(usb0)[706]: Initialization complete, link beat not detected.
May 3 20:40:27 ipconfd[725]: daemon started
May 3 20:40:35 proftpd[853]: localhost.localdomain - ProFTPD 1.3.0 (stable) (built Tue Aug 8 14:05:58 CEST 2006) standalone mode STARTUP
May 3 20:40:39 init: Starting pid 942, console /dev/ttyS0: '/sbin/getty'
May 3 20:42:26 httpd(pam_unix)[998]: bad username []
May 3 20:42:31 httpd(pam_unix)[999]: session opened for user admin by (uid=0)
May 3 20:42:31 httpd(pam_unix)[999]: session closed for user admin
May 3 20:42:36 httpd(pam_unix)[1032]: session opened for user admin by (uid=0)
May 3 20:42:36 httpd(pam_unix)[1032]: session closed for user admin
May 3 20:42:43 httpd(pam_unix)[1139]: session opened for user admin by (uid=0)
May 3 20:42:43 httpd(pam_unix)[1139]: session closed for user admin

So that's what you get. Now we can easily see that we're running Linux version 2.6.12, for ARM, modified by LaCie, on an ARM926EJ core in a MV-88fxx81 system (same as in the Kurobox and LinkStation), actually a 88F5182 A2, featuring 64 MB SDRAM at address 0, a 16550A serial port, a Marvell gigabit ethernet port (driver is 'egiga'), a Marvell SCSI to SATA adapter, 512KB Flash at address ff800000, a TWSI I2C adapter connected to an rs5c372 RTC, and a Marvell USB slave port.

Initial rootfs is /dev/sda7, disk is partitioned as sda1 < sda5 sda6 sda7 sda8 sda9 > sda2. Log says sda5 is swap, sda7 is the initrd, and sda2 is the home.

That's it for tonight, folks. Gotta sleep. Tomorrow we'll see what the ED Mini's disk can tell.

Looking into the ED Mini partitions

LaCie finally provided me with some info, and that concurred with my own findings regarding the SATA disk partitioning.

sda1 is a logical partion holding sda5 to sda9

sda5 is the swap
sda6 contains the kernel as a raw u-boot image (no filesystem)
sda7 looks like the initrd (initial root filesystem)
sda8 looks like the actual root file system.
sda9 is used for snapshots and patches.

sda2 is the actual storage for user data.

Initially you could think that sda7 is an initrd and sda8 is the actual root fs. But a quick look at sda8's /etc/fstab file shows sda7 as being '/', so I conclude that sda7 is the real root fs and pulls sda8 in using unionfs somehow. Now to make this sure we need to dive into sda7.

There are 224 files on sda7, of which 42 are directories, 23 are regular files, 12 are block devices, 4 are character devices, and 143 are symlinks.

Of the symlinks, 140 are commands in bin and sbin symlinked to busybox, and 3 are library symlinks (where an X.Y version points to the actual X.Y.Z version).

The 23 regular files on sda7 are:


/home/EDMINI/var/lib/misc/udhcpd.leases
/home/EDMINI/var/log/wtmp
/usr/bin/find
/bin/touch
/bin/chmod
/bin/busybox
/lib/libc.so.6
/lib/libgcc_s.so.1
/lib/libm-2.3.4.so
/lib/libdl-2.3.6.so
/lib/ld-linux.so.3
/lib/libpam.so.0.77
/lib/libcrypt.so.1
/etc/libunionfs
/etc/mtab
/etc/inittab
/sbin/unionctl
/sbin/unionimap
/sbin/snapmerge
/sbin/init
/sbin/mdadm
/sbin/uniondbg
/sbin/mkfs.xfs

I'm not going to dig too deep in the file system as such, though there's a lot to be said (anyone fancy a /sbin/init shell script the last line of which invokes /sbin/init?) but suffice it to say that sda7 deals with whatever snapshot and patch management is needed, then somehow we end up with the content of sda8 maped to '/'.

Now sda8 has 2300+ files in it, and it"s almost 11PM, and I've had enough for today. You'll have to wait for the rest.

Deep dive into the Lacie kernel source

Well, LaCie finally has put a GPL archive on their site, and inside it lies a 'linux-2.6.12-mv-1.10.3-lacie5b.tar.gz' file, and yes, it contains their kernel source tree. The trick is, it is based on an old Marvell set of patches, different from that which Marvell has officially contributed to the ARM kernel.

Now this code contains patches from both Marvell (so as to support their MV88F5182 SoC) and LaCie (to support the ED Mini that contains the Marvell SoC). As Marvell has, in the meantime, provided patches to the mainstream kernel, and I would like to use these, I want to apply the LaCie patches to these "Marvellized" kernels. Problem is, how do I tell the LaCie patches apart from the Marvell ones in LaCie's source kernel?

Luckily, the folks at the linux ARM mailing list (including at least two Marvell guys) have pointed me to a valuable site, that is, NAS-central. There I could find a kernel source tree for the Kurobox Pro, which is based on a Marvell LSP 1.10.3 patch 5, which is a patch 2.

So I fired off Kdiff3 on the Kurobox, Lacie and vanilla 2.6.12 kernels, and I now end up with a list of what I believe are patches from LaCie against the vanilla plus Marvell code.

There's 104 of them, so I felt I should classify them in groups as follows:

  • 15 "reject": trivial and unneeded
  • 28 "accept": trivial and needed
  • 17 "ignore": non-trivial and probably unneeded
  • 17 "port": non-trivial and probably needed
  • 27 "unclear": non-trivial and undecidable (that is, not without actually trying to merge them)

Next step is to merge those diffs into a recent kernel. :)

Let's start tinkering

TBD

Patch the kernel, man!

Long time no see again, you know by now I don't update often--I need real news to feel the need to add something to this site. And news I have, but still, I took my own time...

For some time already the Marvell folks have contributed support for their SoCs to the Linux kernel. And recently, kernel 2.6.28 was published, which contains a commit by Chris (and to a lesser extent, myself) to add support to the Marvell-based ED Mini!

The commit is there:

This means you can build a Linux kernel for the ED Mini, and it'll boot. :)

However it does not support everything yet, most notably USB slave is missing. I'm trying to find some time working on that right now.

Also, we have a kernel now but installing a complete linux distribution is no piece of cake at the moment. I personally went through most of Debian's install process, only to fail near the end for some reason.

But the point is: no need to re-use LaCie's code. I'll keep it around of course, if only as a reference or if you absolutely want to rebuild it because you can't wait for USB gadget to work on 2.6.28.

See you soon!

Hooking up the console

Recently, I came in contact with another edminiv2 owner, who goes by the nick rosbif, and who also likes to tinker. That gave me the impulse to proceed further, so I went and did what had to be done: hook up a terminal to the EDMini's serial console.

The serial is 3.3V, which is not standard RS232 but is, fortunately, common across many mobile phones. A web search will show that Nokia's DKU-5 USB cable is an ideal candidate to connect a modern PC to any 3.3V UART.

As rosbif pointed out, LaCie's been kind enough to populate the J2 UART+JTAG connector on their ED Mini, which made things easier yet.

Then there was a short phase of worry: if you connect the DKU-5 to the LaCie but not to the PC which will act as a console, then power up the LaCie, it will seem not to boot. Actually it does, but it stops at the bootloader prompt--and thus does not boot Linux nor LaCie's SW. If the DKU-5 is connected (whether or not you actually read the console from the PC) then the LaCie will boot without stopping at the u-boot prompt any more.

What do I learn from looking at the console?

First: the flash memory (a Macronix 29LV400CBCT in my case) isn't propery recognized. That means I can't reflash my unit from u-boot... yet.

Second: once the unit has completely booted, it prompts for a Linux login. I haven't tried much, but I can already tell that neither 'admin' nor the users added through the Web interface can log in. Maybe 'root' can, but I don't know root's password.

Third: with some care, we can boot from TFTP and NFS. To achieve this, one has to re-build the LaCie kernel, create a minimal rootfs (with /etc/console and /bin/busybox aliased as /bin/sh). I'll dive into more details later on.

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

DKU-5 versus ARM-USB-OCD (updated)

For some time I've been unable to access my ED Mini's console.

This was not a fault in the wiring or a failure of the DKU-5 cable. This is a fault of the Linux kernel on my host, development, machine: it freezes completely when opening the /dev/ttyUSB0 device which represents the DKU-5 cable; and when I say 'freeze', I mean it. Mouse pointer dead. Keyboard dead. Filesystems not synced. Only way out is reset or, as my computer does not have a reset button, forced power-off.

I don't like that at all.
<!--break--!>
Investigations showed that some Ubuntu and Redhat users experienced the same issue, with variants. It looks like recent kernels have the issue; I could downgrade my kernel... Or I could switch from the DKU-5 cable to the serial on my Olimex ARM-USB-OCD JTAG probe, which I knew was not causing trouble with Linux.

That meant unsoldering the end of the DKU-5 cable from the 8-pin header on the ED Mini, and re-soldering again... Which I was becoming tired of. So I decided I'd rather add a connector to the ED Mini once and for all.

I chose a DB-9 female connector for two reasons. First, it's the most common connector with close to 8 lines. Second, its ninth hole can easily be filled in to make sure no one will plug a normal male DB-9 in it by mistake.

First thing was to drill the casing...

... then adding the DB-9...

... then drilling the backplate and putting it back in place.

Now the next phase was to build a splitter which would connect to the ED Mini's female DB-9 and split out to a 20-pin JTAG connector on one side and a male DB-9 RS-232 plug on the other side. Of course, the splitter has to do the level conversion between the ED Mini's 3.3v serial console and the theoretical +12/-12 (actually +5/-5) RS-232.

[picture of the splitter coming up soon]

Actually the splitter is not 100% complete yet: it lacks two resistors that will provide a 3.3v reference voltage for the JTAG probe from the 5v source on the ED Mini. However, the serial part is complete, which allows me to go back to software development. :)

Rebuilding whole systems

TBD

A minimal TFTP/NFS system

TBD