Sheeva Plug & cross compiled kernel

I am the happy owner of this this little cutie. I however recently discovered that it doesn’t play nice with the USB2 module (ehci-hcd) and since this is compiled directly in the kernel, you cannot just unload the module…

Fortunately, there is a solution. I could compile it on this ARM device but I have the feeling this would probably take a few years. Since I have done cross compiles in the past (specifically on NetBSD), the idea appealed to me. So, the reference page I used is located here.

First off, git grab the last kernel, for this i used (on my Debian VM):

cd /usr/src/
git clone git://git.marvell.com/orion.git
Cloning into orion…
remote: Counting objects: 1626626, done.
remote: Compressing objects: 100% (278343/278343), done.
remote: Total 1626626 (delta 1359976), reused 1600949 (delta 1334736)
Receiving objects: 100% (1626626/1626626), 422.11 MiB | 623 KiB/s, done.
Resolving deltas: 100% (1359976/1359976), done.

You then need to grab the cross compiler, the easiest is to go to this page and grab the IA32 one. You also need to install mkimage for your plug:

# if not already installed, get all the good tools
apt-get install build-essential
cd /usr/src
wget ftp://ftp.denx.de/pub/u-boot/u-boot-latest.tar.bz2
tar -xjvf u-boot-latest.tar.bz2
cd u-boot-2010.09
make tools
install tools/mkimage /usr/local/bin

Once installed (if you don’t go for the tarball, you’ll need a graphical interface or SSH forwarding), you can start dealing with your kernel:

make ARCH=arm kirkwood_defconfig
# You will need curses for the menu
apt-get install libncurses5-dev
make ARCH=arm menuconfig
# change path according to where you installed it obviously
make -j2 ARCH=arm CROSS_COMPILE=/usr/local/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi- uImage

All going well after the coffee break, it should finish with:

Image Name: Linux-2.6.35-rc1-09018-g67a3e12-
Created: Sun Nov 14 21:27:37 2010
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2156168 Bytes = 2105.63 kB = 2.06 MB
Load Address: 00008000
Entry Point: 00008000
Image arch/arm/boot/uImage is ready
file arch/arm/boot/uImage
arch/arm/boot/uImage: u-boot legacy uImage, Linux-2.6.35-rc1-09018-g67a3e12, Linux/ARM, OS Kernel Image (Not compressed), 2156168 bytes, Sun Nov 14 21:27:37 2010, Load Address: 0x00008000, Entry Point: 0x00008000, Header CRC: 0x5F387405, Data CRC: 0xF11545CA

Well, looks like you just cross-compiled your first ARM kernel 🙂 Let’s copy that over to a directory we will rsync over to the plug:

mkdir /usr/src/arm
cp arch/arm/boot/uImage /usr/src/arm/
make -j2 ARCH=arm CROSS_COMPILE=/usr/local/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi- modules
make -j2 ARCH=arm CROSS_COMPILE=/usr/local/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi- INSTALL_MOD_PATH=../arm/ modules_install
cd /usr/src
# replace by box IP of course…
rsync -avP arm sheeva:/usr/src/

We are now at a point where I STRONGLY suggest you read this before doing anything else: Writing to NAND. I will summarize but suggest you read it nonetheless.

First check for the existence of an NAND partition:

root@debian:~# cat /proc/mtd
dev: size erasesize name
mtd0: 00100000 00020000 “u-boot”
mtd1: 00400000 00020000 “uImage”
mtd2: 1fb00000 00020000 “root”

That is looking good, since we rsync’d over, just a matter of over-writing. First make sure you have proper serial over USB loaded:

modprobe usbserial vendor=0x9e88 product=0x9e8f
modprobe ftdi_sio vendor=0x9e88 product=0x9e8f
# all going well, kernel will then greet you with:
ftdi_sio 7-5.4:1.1: FTDI USB Serial Device converter detected
Detected FT2232C
FTDI USB Serial Device converter now attached to ttyUSB1

This is all I have time for tonight, but I will make another entry hopefully tomorrow on how to copy this over SAFELY to your sheeva plug.