Installing Debian on the Marvell SheevaPlug and OpenRD
These instructions cover how to install Debian onto the NAND of the Marvell SheevaPlug and OpenRD (tested on the Client and Ultimate flavours) platforms; another approach is to use the Marvell Easy Plug EPIA tool.
Before you continue you must have a pre-built 'armel' based Debian rootfs to hand, using an approach such as the one I detail on my page titled Cross debootstrap Debian Root Filesystem with User Mode QEMU; these instructions continue from where that page leaves off. You will additionally need the following packages installed:
mtd-utils - do not use 20100907
- uboot-mkimage
- qemu-user-static
- binfmt-support
- tftpd-hpa
Well, we start off by adding the Linux kernel package to the root filesystem:
berk:/usr/src/kirkwood# cat /etc/resolv.conf > rootfs/etc/resolv.conf berk:/usr/src/kirkwood# cp /usr/bin/qemu-arm-static rootfs/usr/bin/ berk:/usr/src/kirkwood# chroot rootfs berk:/# apt-get update berk:/# aptitude install linux-image-2.6-kirkwood uboot-mkimage tftp-hpa mtd-utils [snipped] berk:/# apt-get clean berk:/# exit berk:/usr/src/kirkwood# rm rootfs/usr/bin/qemu-arm-static berk:/usr/src/kirkwood# : > rootfs/etc/resolv.conf
Now our root filesystem is ready to go, we need to create suitable snapshots that U-Boot can boot and also the final UBIFS image that we will burn to the NAND. To get this data to the platform, we run a TFTP server on the host workstation:
berk:/usr/src/kirkwood# cd rootfs berk:/usr/src/kirkwood/rootfs# find . | cpio -H newc -o | gzip -n > ../initrd.img.gz berk:/usr/src/kirkwood# cd .. berk:/usr/src/kirkwood# mkimage -A arm -O linux -T kernel -C none -n uImage -a 0x00008000 -e 0x00008000 -d rootfs/vmlinuz uImage berk:/usr/src/kirkwood# mkimage -A arm -O linux -T ramdisk -C none -n uInitrd -d initrd.img.gz uInitrd berk:/usr/src/kirkwood# cat <<EOF > ubi.cfg [ubifs] mode=ubi image=ubifs.img vol_id=0 vol_size=128MiB vol_type=dynamic vol_name=rootfs vol_flags=autoresize EOF berk:/usr/src/kirkwood# mkfs.ubifs -v -r rootfs -m 2048 -e 129024 -c 4096 -x zlib -o ubifs.img berk:/usr/src/kirkwood# ubinize -v -m 2048 -p 128KiB -s 512 ubi.cfg -o ubi.img berk:/usr/src/kirkwood# ip addr add 10.4.50.5/24 dev eth0 berk:/usr/src/kirkwood# in.tftpd --foreground --secure /usr/src/kirkwood
Now, over to the platform it's-self. You will need to hook up using the serial port over USB that it provides. Set up 'minicom' at 115200,8n1 or you could use 'screen' by running 'screen /dev/ttyUSB0 115200'.
N.B. bear in mind, the serial port/USB device only functions when powered up so strange things happen if you power cycle the platform whilst connected to it over USB...please try to avoid doing so otherwise you will quickly become irritated at having to repeatedly restart minicom/screen.
When you power up the device you will see the following rolling by, interrupt the process when prompted so you get to U-Boot's command line:
[snipped]
PCI 0: PCI Express Root Complex Interface
PEX interface detected Link X1
Net: egiga0 [PRIME], egiga1
Hit any key to stop autoboot: 0
Marvell>> resetenv
Marvell>> reset
[snipped]
PCI 0: PCI Express Root Complex Interface
PEX interface detected Link X1
Net: egiga0 [PRIME], egiga1
Hit any key to stop autoboot: 0
Marvell>> setenv run_diag no
Marvell>> setenv mainlineLinux yes
Marvell>> setenv arcNumber 2361 <--- openrd-client, consult http://www.arm.linux.org.uk/developer/machines/ (ie. 2097 for SheevaPlug)
Marvell>> setenv mtdids nand0=nand_mtd
Marvell>> setenv mtdparts mtdparts=nand_mtd:0x100000@0x000000(uboot),0x400000@0x100000(uImage),0x1fb00000@0x500000(root)
Marvell>> setenv x_bootcmd_kernel nand read 0x1000000 uImage
Marvell>> setenv x_bootargs console=ttyS0,115200 panic=10 ubi.mtd=root
Marvell>> setenv x_bootargs_root root=ubi0:rootfs rootfstype=ubifs rw
Marvell>> setenv bootcmd '${x_bootcmd_kernel}; setenv bootargs ${x_bootargs} ${x_bootargs_root}; bootm 0x1000000'
Marvell>> saveenv
Marvell>> reset
[snipped]
PCI 0: PCI Express Root Complex Interface
PEX interface detected Link X1
Net: egiga0 [PRIME], egiga1
Hit any key to stop autoboot: 0
Marvell>> tftp 0x1000000 uImage
Marvell>> nand erase uImage
Marvell>> nand write 0x1000000 uImage
Marvell>> tftp 0x2000000 uInitrd
Marvell>> setenv bootargs ${x_bootargs} root=/dev/ram0 rdinit=/sbin/init
Marvell>> bootm 0x1000000 0x2000000
[snipped Linux booting]
Debian GNU/Linux squeeze/sid (none) ttyS0
(none) login: root
Password:
Linux (none) 2.6.32-5-kirkwood #1 Thu Aug 26 03:31:56 UTC 2010 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.
root@(none):~# ip addr add 10.4.50.165/24 dev eth0
root@(none):~# ip link set dev eth0 up
root@(none):~# flash_eraseall /dev/mtd2
root@(none):~# mount /tmp/ -o remount,size=256M
root@(none):~# tftp -m binary 10.4.50.5 -c get ubi.img /tmp/ubi.img
root@(none):~# nandwrite -p /dev/mtd2 /tmp/ubi.img
root@(none):~# rebootYou should find your platform is up and running on it's own and you can use it like you would any x86/amd64 installed copy of Debian. All that remains is that you kill the TFTP server with a Ctrl-C and remove the temporary IP you gave your host:
berk:/usr/src/kirkwood# ip addr del 10.4.50.5/24 dev eth0
Second Serial Port (UART1)
The OpenRD lets you choose between enabling either the SDIO interface (SD card slot) or alternatively the UART1 port (the RS-232 or RS-485 external serial port). To pick what you want you pass the kernel parameter 'kw_openrd_init_uart1' on boot like so:
Marvell>> setenv x_bootargs console=ttyS0,115200 console=ttyS1,115200 panic=10 ubi.mtd=root kw_openrd_init_uart1=232 Marvell>> saveenv Marvell>> boot
The parameter takes two options, either '232' or '485' depending on whether you want the RS-232 port or the RS-485 port enabled; passing anything else (or not using the parameter) results in the default behaviour where SDIO interface left enabled.
N.B. unfortunately there does not seem to be any way to get the factory installed u-boot to use UART1 (RS232 or RS485 port) as the console instead of UART0 (USB port)
Updating the Kernel
When the kernel updates, you will need to manually burn the updated kernel image to the NAND with the following:
(none):/# mkimage -A arm -O linux -T kernel -C none -n uImage -a 0x00008000 -e 0x00008000 -d /vmlinuz /tmp/uImage (none):/# flash_eraseall /dev/mtd1 (none):/# nandwrite -p /dev/mtd1 /tmp/uImage
Once done, you can reboot whenever you wish.
Updating U-Boot
FIXME this is a works in progress but does work, however I do not personally feel there is much point in doing so
Gleamed from http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/79733, http://www.cyrius.com/debian/kirkwood/sheevaplug/uboot-upgrade.html and http://www.plugcomputer.org/plugwiki/index.php/Re-building_the_kernel_and_U-Boot#Building_U-Boot.
Download uboot-openrd.patch.
berk:/usr/src/kirkwood# git clone git://git.denx.de/u-boot-marvell.git berk:/usr/src/kirkwood# cd uboot-marvel berk:/usr/src/kirkwood/uboot-marvell# patch -p1 < ../uboot-openrd.patch berk:/usr/src/kirkwood/uboot-marvell# make mrproper berk:/usr/src/kirkwood/uboot-marvell# make openrd_client_config berk:/usr/src/kirkwood/uboot-marvell# make u-boot.kwb CROSS_COMPILE=arm-linux-gnueabi-
Marvell>> tftp 0x1000000 u-boot.kwb Marvell>> nand erase uboot Marvell>> nand write 0x1000000 uboot Marvell>> reset