Installing Debian on a Sheevaplug into Flash

Ok, so you are looking for a comprehensive guide on how to install a modern Debian system into the Flash memory of your Sheeva Plug? Your googling has paid of – look no further!

What we will do in this guide:

  • Update the bootloader to a recent version which supports direct booting from ubifs partions. So you can just use the stock Debian kernel without any hassle or SD card.
  • Install Debian to a ubifs filesystem on the Sheevaplug flash.

Not everything needed in this guide is covered here. It’s assumed you have prepared:

  1. A terminal program of your choice which you can use to connect to the debug connection of your Sheeva Plug.
  2. You have a working TFTP server for providing the new firmware etc. to your Sheeva. You can probably adapt this guide to use USB or SD cards, though.

Please note that this guide is specific to the “normal” SheevaPlug, that is the original SheevaPlug, the eSATA SheevaPlug and the Ionics Nimbus 100. Especially the u-boot update procedure will be different and you can brick your non-normal Sheeva that way!

 Updating the bootloader

Let’s first update the bootloader to something useful i.e. a recent built of the vanilla u-boot bootloader. So connect to your Sheeva and stop the boot process by pressing the “any” key:

 

         __  __                      _ _
        |  \/  | __ _ _ ____   _____| | |
        | |\/| |/ _` | '__\ \ / / _ \ | |
        | |  | | (_| | |   \ V /  __/ | |
        |_|  |_|\__,_|_|    \_/ \___|_|_|
 _   _     ____              _
| | | |   | __ )  ___   ___ | |_ 
| | | |___|  _ \ / _ \ / _ \| __| 
| |_| |___| |_) | (_) | (_) | |_ 
 \___/    |____/ \___/ \___/ \__| 
 ** MARVELL BOARD: SHEEVA PLUG LE 

U-Boot 1.1.4 (Jul 14 2009 - 06:46:57) Marvell version: 3.4.16

U-Boot code: 00600000 -> 0067FFF0  BSS: -> 006CF120

Soc: MV88F6281 Rev 3 (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 256MB 
DRAM CS[1] base 0x10000000   size 256MB 
DRAM Total size 512MB  16bit width
Flash:  0 kB
Addresses 8M - 0M are saved for the U-Boot usage.
Mem malloc Initialization (8M - 7M): Done
NAND:512 MB

CPU : Marvell Feroceon (Rev 1)

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 
Marvell>>

Since all u-boot settings will be lost during the update  it’s a good idea to remember the MAC address of your Sheeva :

Marvell>> printenv ethaddr
ethaddr=F0:AD:4E:01:49:8F

Which is of cause differs for each Sheeva.

For u-boot we use a 2012.04.01-2 build which can be downloaded here. Copy it to your TFTP directory. Now let’s flash it:

setenv serverip 172.16.0.187 # IP of your TFTP server
setenv ipaddr 172.16.0.15    # IP address for the sheeva
tftpboot 0x0800000 u-boot.kwb
nand erase 0x0 0x60000
nand write 0x0800000 0x0 0x60000

After a reset you should be greeted by the new bootloader:

U-Boot 2012.04.01 (Jun 01 2012 - 02:27:06)
Marvell-Sheevaplug - eSATA - SD/MMC

SoC:   Kirkwood 88F6281_A1
DRAM:  512 MiB
WARNING: Caches not enabled
NAND:  512 MiB
NAND read from offset 60000 failed -74
*** Warning - readenv() failed, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   egiga0
88E1116 Initialized on egiga0
Hit any key to stop autoboot:  0 
Marvell>>

As you can see, your old settings are all scrambled. It’s a good idea to save back the  MAC address now:

setenv ethaddr F0:AD:4E:01:49:8F
saveenv
reset

Great! You got a great new and powerful bootloader installed which can also boot from ubifs partitions!

Installing Debian

Now it’s time to install Debian. Unfortunately we cannot directly install Debian to Flash because  it is not supported by the Debian installer. So we first install it to a USB stick and later move it to Flash.

Installing to USB stick

The installation to stick is basically a total standard installation as explained by  the well know HOW-TO at cyrius.com. This is the gist of it:

Download the uImage and uInitrd to your TFTP directory and boot it with:

setenv serverip 172.16.0.187 # IP of your TFTP server
setenv ipaddr 172.16.0.15    # IP address for the sheeva
tftpboot 0x00800000 uImage
tftpboot 0x01100000 uInitrd

setenv bootargs console=ttyS0,115200n8 base-installer/initramfs-tools/driver-policy=most
bootm 0x00800000 0x01100000

Continue the installation to stick and do not change the partition layout. The installation will take some time, go and grab a coffee.

Transferring image to flash

Boot from USB stick

Once the installation has finished and u-boot is booted again it’s time to boot from  USB  and copy the  image to flash.

setenv bootargs_console console=ttyS0,115200
setenv bootcmd_usb 'usb start; ext2load usb 0:1 0x00800000 /uImage; ext2load usb 0:1 0x01100000 /uInitrd'
setenv bootcmd 'setenv bootargs $(bootargs_console); run bootcmd_usb; bootm 0x00800000 0x01100000'
run bootcmd

This will straightly boot up your Debian installation, so log in with your username and password:

Debian GNU/Linux 6.0 sheevaplug ttyS0

sheevaplug login: user
Password: 
Linux sheevaplug 2.6.32-5-kirkwood #1 Sun May 6 16:57:51 UTC 2012 armv5tel

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
user@sheevaplug:~$

Now it’s time to copy your Debian to Flash. For this you have to become root, either by using su or sudo – depending on the method you choose during installation.

For the installation we still have to format the Flash so let’s install the required software (as superuser):

apt-get install mtd-utils

Now we are able to format the Flash as ubifs and mount it to /mnt/:

ubiformat /dev/mtd2 -s 512
ubiattach /dev/ubi_ctrl -m 2 
ubimkvol /dev/ubi0 -N rootfs -m
mkfs.ubifs --compr=zlib /dev/ubi0_0
mount -t ubifs ubi0:rootfs /mnt

What is left now is copying all the required data to the newly created ubifs partition:

mkdir /tmp/rootfs
mount -o bind / /tmp/rootfs/
cp -a /tmp/rootfs/* /mnt/
cp -a /boot /mnt/

What should also be adapted is the fstab of the Debian installation in Flash at /mnt/etc/fstab. It should look like this:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
ubi0:rootfs  /               ubifs   defaults,noatime,rw                    0 0
tmpfs      /var/run        tmpfs   size=1M,rw,nosuid,mode=0755              0 0
tmpfs      /var/lock       tmpfs   size=1M,rw,noexec,nosuid,nodev,mode=1777 0 0
tmpfs      /tmp            tmpfs   defaults,nosuid,nodev                    0 0

Setup u-boot to boot from ubi partition

Reboot your Sheeva and enter u-boot. Make u-boot know about your partition setup and set the boot sequence:

# Set uboot to boot from ubi
setenv mtdids nand0=orion_nand
setenv mtdparts mtdparts=orion_nand:0xa0000@0x0(u-boot),0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs)

setenv bootargs_ubi 'console=ttyS0,115200 ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs'
setenv bootcmd_ubi 'ubi part nand0,2; ubifsmount rootfs; ubifsload 0x1100000 /boot/uInitrd; ubifsload 0x800000 /boot/uImage'
setenv bootcmd 'setenv bootargs $(bootargs_ubi); run bootcmd_ubi; bootm 0x00800000 0x01100000'

saveenv

Congratulations! You’ve just successfully installed Debian to a modern ubifs partition on your SheevaPlug Flash!

9 thoughts on “Installing Debian on a Sheevaplug into Flash

  1. At last! You’ve basically saved my sanity.
    I’ve been wrestling with the u-boot for two days to figure out how to load uI* from the flash and I completely missed the ubi support in it.

    Many thanks!

    V.

    • Hi Valentin,

      I’m glad this helped you! I’ve also only discovered the ubi support by accident. Most guides I found stored the image directly (which requires some kind of flashing mechanism) or on a SD card.

      One thing I’ve learnt just yesterday is that uboot will fail to load files from an unclean ubifs file system. So if you are looking for stability you might move /boot to it’s own partition.

      Best,
      Matthias

      • Maybe another ubi partition for /boot (as it was originally done). However the current md layout should be changed to increase the space on md1.

        V.

  2. Thanks for the guide this helped me a lot. If you want some more space on the internal ubifs use as a mount option during creation and operations “compr=zlib” as explained on this page: http://www.linux-mtd.infradead.org/faq/ubifs.html It helped me save almost 50% of my storage space, also the guruplug is capable of speedy zlib, whereas nand is rather slow, so it speeds up the operations.

  3. I got a sheevaplug which is come with a debian 5. I tried to upgrade the u-boot that you mentioned, it is failed to boot up. I fixed it using esia to reload the u-boot into it. Do you know any version of u-boot that is compatible for the sheevaplug that come with debian 5?

  4. Thanks much Matthias for the tutorial. After reading about the different solutions to upgrade my SheevaPlug from its stock Ubuntu 9.04… and getting nowhere, I’m now a happy Debian 6.0 user :-)

  5. Pingback: Install Debian 7 Wheezy on NAND flash of Sheevaplug eSata | 2nd.homelinux.com

Leave a Reply

Your email address will not be published. Required fields are marked *


6 × = forty two

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>