Installing OpenWrt on the Seagate DockStarInstalling OpenWrt on the Seagate DockStar

Eric Cooper <ecc@cmu.edu>

July 2010

Introduction

This document describes how to install an OpenWrt kernel and rootfs on the internal NAND flash of the Seagate DockStar so that it will boot into OpenWrt at power-on, with no USB storage device required.

The main method presented here does not require opening the case or attaching a serial cable, just using the Linux command line on the DockStar. But I also describe a method that does use a serial cable to interact with the u-boot bootloader. This was the approach I initially used to get OpenWrt working on the DockStar, but it should only be necessary now if the first approach fails for some reason.

Important: if possible, do not connect your DockStar to the outside Internet prior to re-flashing. Otherwise the factory firmware will automatically “phone home” and modify itself, making it more difficult to connect via ssh.

Building the OpenWrt kernel and root filesystem images

You need to build your own OpenWrt kernel and root filesystem image, because OpenWrt’s Marvell Kirkwood target currently supports only the Sheevaplug, which has a different NAND flash layout.

  1. Use make menuconfig to configure the build system for a kirkwood target. Add squashfs in the target images section. Also select built-in luci and ntpclient packages.

    Use make kernel_menuconfig to add built-in SCSI disk, USB EHCI, USB storage, and ext2 filesystem support. (This step isn’t required, but I recommend it. It will allow you to boot from a USB flash drive if the root filesystem on internal flash is corrupted.)

    Do an initial build.

  2. Change to build_dir/linux-kirkwood/linux-2.6.30.10 and apply the following patches, based on work done by Alexander Holler <holler@ahsoftware.de>.

    Support the DockStar flash layout and the OpenWrt naming scheme:

    --- a/arch/arm/mach-kirkwood/sheevaplug-setup.c
    +++ b/arch/arm/mach-kirkwood/sheevaplug-setup.c
    @@ -33,7 +33,11 @@ static struct mtd_partition sheevaplug_nand_parts[] = {
     		.offset = MTDPART_OFS_NXTBLK,
     		.size = SZ_4M
     	}, {
    -		.name = "root",
    +		.name = "rootfs",
    +		.offset = MTDPART_OFS_NXTBLK,
    +		.size = SZ_32M
    +	}, {
    +		.name = "rootfs_data",
     		.offset = MTDPART_OFS_NXTBLK,
     		.size = MTDPART_SIZ_FULL
     	},
    

    Support the DockStar LEDs:

    diff --git a/arch/arm/mach-kirkwood/sheevaplug-setup.c b/arch/arm/mach-kirkwood/sheevaplug-setup.c
    index 555f7c3..648c741 100644
    --- a/arch/arm/mach-kirkwood/sheevaplug-setup.c
    +++ b/arch/arm/mach-kirkwood/sheevaplug-setup.c
    @@ -62,9 +62,15 @@ static struct mvsdio_platform_data sheeva_esata_mvsdio_data = {
     
     static struct gpio_led sheevaplug_led_pins[] = {
     	{
    -		.name			= "plug:green:health",
    +		.name			= "dockstar:green:health",
     		.default_trigger	= "default-on",
    -		.gpio			= 49,
    +		.gpio			= 46, /* green */
    +		.active_low		= 1,
    +	},
    +	{
    +		.name			= "dockstar:orange:misc",
    +		.default_trigger	= "none",
    +		.gpio			= 47, /* orange */
     		.active_low		= 1,
     	},
     };
    @@ -84,7 +90,8 @@ static struct platform_device sheevaplug_leds = {
     
     static unsigned int sheevaplug_mpp_config[] __initdata = {
     	MPP29_GPIO,	/* USB Power Enable */
    -	MPP49_GPIO,	/* LED */
    +	MPP46_GPIO,	/* LED green */
    +	MPP47_GPIO,	/* LED orange */
     	0
     };
     
    

    Rebuild the kernel with “make” at the top level. The kernel image will be in bin/kirkwood/openwrt-kirkwood-uImage.

  3. Pad the kernel image to a multiple of 128K bytes:
    # dd if=openwrt-kirkwood-uImage of=uImage bs=128k conv=sync
    # mv uImage openwrt-kirkwood-uImage
    
  4. Prepare the rootfs image. Do not use the squashfs file in bin/kirkwood. (It is a combined image with both the kernel and the root filesystem.) Instead, cd to build_dir/linux-kirkwood and run the command
    dd if=root.squashfs of=openwrt-kirkwood-rootfs.squashfs bs=128k conv=sync
    

    to pad the (rootfs-only) squashfs file to a 128K multiple.

Installing the images

  1. Prepare the kernel and rootfs images as described above. Copy them to a USB flash drive.
  2. Download the blparam program from Cloud Engines and copy it to the USB drive.
  3. Follow Alexander Holler’s instructions to connect to your DockStar via ssh. If you previously connected the DockStar to the Internet, you might have to follow these instructions instead.

    The following instructions should be executed on the DockStar.

  4. Kill off some unneeded processes:
    # killall -9 hbwd
    # killall -9 hbplug
    
  5. Insert the USB drive in the DockStar, mount it somewhere, and change to that directory:
    # mount /dev/sda1 /mnt
    # cd /mnt
    
  6. Make a backup of the factory firmware onto the USB drive if you think you might want to restore it some day.
  7. Set the magic u-boot parameters. These are case-sensitive, so make sure you type them correctly.
    # ./blparam arcNumber=2097
    # ./blparam mainlineLinux=yes
    
  8. Flash the kernel and rootfs images:
    # flash_eraseall /dev/mtd1
    # nandwrite /dev/mtd1 openwrt-kirkwood-uImage
    # flash_eraseall /dev/mtd2
    # nandwrite /dev/mtd2 openwrt-kirkwood-rootfs.squashfs
    
  9. Erase the rootfs_data partition so that OpenWrt will create a jffs2 overlay filesystem there when it boots. It’s OK if this step fails with a “read-only filesystem” error.
    # flash_eraseall /dev/mtd3
    
  10. That’s all there is to it. Unmount and remove the USB drive and power-cycle the DockStar. It should reboot into OpenWrt with the usual 192.168.1.1 IP address.

Installation using a serial cable

As mentioned above, this approach should normally not be necessary. But if your DockStar fails to boot with the previous method, this approach may work. See also the “Troubleshooting” section below.

  1. Prepare the kernel and rootfs images as described above. Copy them to a TFTP server on your network.
  2. Open the case and install a serial cable. See Alexander Holler’s page for the serial pinout (and how to open the case) and this page for a picture of where to find the connector.
  3. Connect your DockStar to your network and use a terminal program like minicom to connect to it (speed 115200, no flow control). Power-on the DockStar. You should see the u-boot output as it boots. Type any character to interrupt the boot sequence:
    U-Boot 1.1.4 (Jul 16 2009 - 21:02:16) Cloud Engines (3.4.16)
    
    U-Boot code: 00600000 -> 0067FFF0  BSS: -> 00690D60
    
    Soc: 88F6281 A0 (DDR2)
    CPU running @ 1200Mhz L2 running @ 400Mhz
    SysClock = 400Mhz , TClock = 200Mhz
    
    DRAM CAS Latency = 5 tRP = 5 tRAS = 18 tRCD=6
    DRAM CS[0] base 0x00000000   size 128MB
    DRAM Total size 128MB  16bit width
    Flash:  0 kB
    Addresses 8M - 0M are saved for the U-Boot usage.
    Mem malloc Initialization (8M - 7M): Done
    NAND:256 MB
    
    CPU : Marvell Feroceon (Rev 1)
    CLOUD ENGINES BOARD: REDSTONE:1.0
    
    Streaming disabled
    Write allocate disabled
    
    
    USB 0: host mode
    PEX 0: interface detected no Link.
    Net:   egiga0 [PRIME], egiga1
    Hit any key to stop autoboot:  0
    CE>>
    

    Use the setenv command in u-boot to set the ipaddr and netmask variables for the DockStar’s IP address, and the serverip variable to the IP address of your TFTP server. Check that you have connectivity by doing

    CE>> ping $(serverip)
    
  4. Now you’re ready to flash the kernel and rootfs images onto your DockStar. WARNING: double-check everything you type before hitting return. If you overwrite the u-boot partition by mistake, you will brick your DockStar.
    CE>> mw 0x1000000 0 0x100000
    CE>> tftpboot 0x1000000 openwrt-kirkwood-uImage
    # take note of the "bytes transferred" in hex and make sure that it's less than 0x100000
    # if not, redo the "mw" command above with a larger size, and use that size in the commands below
    
    # CAREFULLY erase the uImage partition and flash it with the new kernel
    CE>> nand erase 0x100000 0x400000
    CE>> nand write.e 0x1000000 0x100000 0x100000  # or larger size if needed
    
    CE>> mw 0x1000000 0 0x200000
    CE>> tftpboot 0x1000000 openwrt-kirkwood-rootfs.squashfs
    # as above, make sure 0x200000 is larger than the rootfs image size, or adjust accordingly
    
    # CAREFULLY erase the rootfs partition and flash it with new squashfs image
    CE>> nand erase 0x500000 0x2000000
    CE>> nand write.e 0x1000000 0x500000 0x200000  # or larger size if needed
    
    # CAREFULLY erase the rootfs_data partition so openwrt will create a jffs2 overlay filesystem
    CE>> nand erase 0x2500000 0xdb00000
    
  5. Set some magic u-boot parameters and save them:
    CE>> setenv arcNumber 2097
    CE>> setenv mainlineLinux yes
    CE>> saveenv
    
  6. Type reset, or just power-cycle the DockStar. It should boot into OpenWrt.

Troubleshooting

While getting this to work, I occasionally observed incorrect writes to the rootfs partition. If your kernel boots but fails to find the root filesystem due to errors in the squashfs root partition, that might be the problem. (But that symptom can also be caused by flashing a squashfs image that is not 128K-aligned, so check that also.) The following steps may allow you to recover.

  1. If you didn’t do the “recommended” part of configuring your kernel (enabling support for USB storage and ext2), do it now, then rebuild the kernel and re-flash it.
  2. Format a USB drive with one partition containing an ext2 filesystem. As root, un-tar the contents of bin/kirkwood/openwrt-kirkwood-rootfs.tar.gz onto the USB drive, and also copy the openwrt-kirkwood-rootfs.squashfs image onto the drive (as a regular file).
  3. In u-boot, do
    CE>> setenv bootargs_root root=/dev/sda1 rootdelay=10 rootfstype=ext2
    CE>> boot
    

    Your DockStar should boot with the USB drive as its root filesystem.

  4. Configure OpenWrt so that it can network to the outside world. Then do:
    # opkg update
    # opkg install mtd-utils
    

    (Alternatively, you can copy the mtd-utils package, or its commands, onto the USB drive before booting the DockStar.)

  5. Use the mtd-utils commands to flash the /dev/mtd2 partition:
    # flash_eraseall /dev/mtd2
    # nandwrite /dev/mtd2 /openwrt-kirkwood-rootfs.squashfs
    
  6. Type reboot and hope that your rootfs partition is now correct.

Restoring the factory firmware

It should be possible to restore the factory firmware by following the instructions in this thread.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Turn on pictures to see the captcha *