Booting the pandaboard over NFS

17 Aug

I strangled some days to get this working: I want to boot the filesystem of my embedded pandaboard over NFS, so that I can make quicker changes to it from my development machine. As always with this stuff, it sounds simple and – in the end – it is simple. But the timespan between is really annoying while you are googeling and trying this until four o’clock in the morning…

So to make things hopefully shorter for you, here a quick tutorial how to do all that stuff.

Kernel

First step is our kernel. I’m using the 3.0.2 final which is atm the newest stable release. The guys commited a lot for the omap branch there, especially OMAP4 which is used on Pandaboard. But I’m really not sure, why the kernelguys are not making more defconfigs for starters. Sure they must not be perfect, but simple things like networking should work out of the box…

So go to your development machine and get the 3.0.2 sources from kernel.org and untar them:

wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.0.2.tar.bz2
tar xzf linux-3.0.2.tar.bz2

Now make a OMAP-generic default config (defconfig) and edit it (I’m assuming, that you have downloaded/untared/exported the path of i.e. the CodeSourcery Cross Compiler Toolchain):

cd linux-3.0.2
make CROSS_COMPILE=arm-none-linux-gnueabi- ARCH=arm omap2plus_defconfig
make CROSS_COMPILE=arm-none-linux-gnueabi- ARCH=arm menuconfig

Because of the generic type of this defconfig, you have to do some manual changes to get everything working. This can easily done by selecting via the ncurse-based “menuconfig” command.
Make sure that the following point are selected ([*] in front of it):

Networking support
--> [*] TCP/IP networking
--> --> [*] IP: kernel level autoconfiguration
--> --> --> [*] IP: DHCP support
--> --> --> [*] IP: BOOTP support
--> --> --> [*] IP: RARP support
Device Drivers
--> [*] Network device support
--> --> USB Network Adapters
--> --> --> [*] SMSC LAN95XX based USB 2.0 10/100 ethernet devices
--> [*] USB support
--> --> [*] EHCI HCD (USB 2.0) support
File systems
--> [*] Network File Systems
--> --> NFS client support
--> --> --> [*] NFS client support for NFS version 3 --> [*] Root file system on NFS

Or do it via bash by checking the .config in the same dir for those variables enabled ( XXX=y ):

CONFIG_IP_PNP=y
CONFIG_IP_PNP_DHCP=y
CONFIG_IP_PNP_BOOTP=y
CONFIG_IP_PNP_RARP=y
CONFIG_USB_USBNET=y
CONFIG_USB_NET_SMSC95XX=y
CONFIG_USB=y
CONFIG_USB_SUPPORT=y
CONFIG_USB_ARCH_HAS_EHCI=y
CONFIG_NETWORK_FILESYSTEMS=y
CONFIG_NFS_FS=y
CONFIG_NFS_V3=y
CONFIG_NFS_V3_ACL=y
CONFIG_ROOT_NFS=y

Now build your kernel and (according to the number of CPU Cores in your system) change the number behind “j”:

make CROSS_COMPILE=arm-none-linux-gnueabi- ARCH=arm -j4 all
make CROSS_COMPILE=arm-none-linux-gnueabi- uImage

Now your kernel is ready to be used!
I’m assuming here, that you already have a clue how to setup the SD Card right and have U-boot and X-Loader correctly in place. I will make further tutorials on that, too – later!

NFS Server

To use NFS, your development system also needs the NFS server to be installed. On debian systems you can install it simply with

sudo apt-get install nfs-common nfs-kernel-server

The next step is to create the folder (here /panda/fs) for the filesystem and make it ready for “export”.
Edit the /etc/exports to match your config:
/panda/fs 192.168.1.0/24(rw,sync,no_root_squash,no_subtree_check)
I allow all adresses in this IP Range to access the NFS, due to multiple systems on the network. If you are changing the config and want to reload it, restart the nfs server with

/etc/init.d/nfs-kernel-server restart

My development System/NFS-Server is using 192.168.1.1 and pandaboard uses the 192.168.1.2 .

U-Boot

Now copy the kernel from arch/arm/boot/uImage over to your SD Card partition 1 and connect your board to a serial cable. Get into U-Boot and enter the following commands to make a network boot:

mmc rescan
fatload mmc 0:1 0x80000000 uImage
setenv bootargs vram=32M console=ttyO2,115200 mem=456M@0x80000000 mem=512M@0xA0000000 smsc95xx.macaddr=76:2F:97:85:4F:56 root=/dev/nfs rw nfsroot=192.168.1.1:/panda/fs,nolock,wsize=1024,rsize=1024 ip=192.168.1.2 rootdelay=2 init=/linuxrc
bootm 0x80000000

Change here the arguments to fit it to your system, i.e. change the MAC Address of your NIC, the IP Address of your server if necessary (nfsroot=X.X.X.X) and the folder (here /panda/fs).
The second IP beginning with “ip=” is the IP address your board will choose after kernel has started up. You can also assign DHCP as choice here (ip=DHCP) – No subnetmask is needed.

To make this executed every boot, you have to create a new textfile on your development system called “boot.script”. Copy your boot commands into it and save it. Then convert it to a file namend “boot.scr” with the command:

mkimage -A arm -T script -C none -n "Pandaboard boot script" -d boot.script boot.scr

and copy it over to your SD Cards first partition. It will then be executed as first action first by U-Boot on every boot.

Note: If mkimage is not found, install it with “sudo apt-get install uboot-mkimage”!

Et voila! Thanks to the guys over at Googleboard for the startup.