Contents |
This page describes howto make N900 boot a MeeGo root filesystem from your host (PC) using USB networking. If you choose to load kernel and initrd, then nothing needs to be changed in your N900. Two different approaches are described:
Initrd is the preferred method.
First, you have to get/make a MeeGo rootfs image. You can download a pre-built raw image (ARM/Meego_images_for_N900) or create your own (ARM/Creating ARM image using MeeGo Image Creator).
nokia-usb-networking script conflicts with nfsroot thus it must be removed.
rm /home/nfs/rootfs/etc/rc.d/rc3.d/S50nokia-usb-networking
This is already done in prebuilt image
Mount the unpacked raw image to temporary directory and copy the contents to suitable location on your host system. Here we use /home/nfs/rootfs.
NOTICE: the offset of the mount command depends on image. offset=512*start_sector. Check the start sector of your image by running command: (In our prebuilt image the start sector was 1)
file yourimage.raw
bunzip2 meego-n900-*.raw.bz2 mkdir temp mount -o loop,offset=512 meego-*.raw temp mkdir -p /home/nfs/rootfs cp -ax temp/* /home/nfs/rootfs/
Next, make sure you have NFS server installed on your host and export the rootfs.
apt-get install nfs-kernel-server ### Ubuntu yum install nfs-utils ### Fedora echo '/home/nfs 192.168.2.15(rw,no_root_squash,no_subtree_check)' >> /etc/exports exportfs -v -a
This method involves using busybox from MeeGo and does not require kernel recompilation. You can more easily keep in sync with the MeeGo kernel.
First, you have to create a directory for preparing initrd. We'll create that under the rootfs directory (but you could create it anywhere you like, of course).
mkdir /home/nfs/rootfs/initrd
You need some initial directories:
cd /home/nfs/rootfs/initrd mkdir bin mkdir sbin mkdir proc mkdir sys mkdir dev mkdir mnt mkdir -p lib/modules
Some device nodes are needed by the kernel (note, these must be run as root to preserve device node properties):
cp -a /dev/console dev/ cp -a /dev/null dev/ cp -a /dev/ram0 dev cp -a /dev/tty dev/ cp -a /dev/tty0 dev/ cp -a /dev/zero dev/
Copy kernel modules from your rootfs to the initrd (be sure to use correct kernel version):
cp -r /home/nfs/rootfs/lib/modules/2.6.* lib/modules/
As the next step, you need Busybox. If you have busybox installed in you rootfs, you can simply:
cp /home/nfs/rootfs/sbin/busybox bin/
If you don't, you can get the binary e.g. by fetching the busybox rpm package and extracting the binary from there
mkdir tmp cd tmp wget http://repo.meego.com/MeeGo/releases/1.0/core/repos/armv7l/packages/armv7l/busybox-1.16.0-3.1.armv7l.rpm rpm2cpio busybox-1.16.*.armv5tel.rpm | cpio -id cp sbin/busybox /home/nfs/rootfs/initrd/bin/ cd .. rm -rf tmp
Now, you have the busybox binary installed. Currently, MeeGo does not have a statically compiled version of Busybox. Thus, you need some libraries as well:
cp /home/nfs/rootfs/lib/ld-linux.so.3 lib/ cp /home/nfs/rootfs/lib/libc.so.6 lib/ cp /home/nfs/rootfs/lib/libm.so.6 lib/
Last, you need to set up some links to the busybox binary:
cd bin ln -s busybox sh ln -s busybox mount ln -s busybox modprobe ln -s busybox sleep ln -s busybox ifconfig ln -s busybox echo ln -s busybox umount ln -s busybox pivot_root ln -s busybox exec ln -s busybox cd ln -s busybox ls ln -s busybox chroot cd ..
Now, you're done with Busybox.
Next, make a script for doing the actual NFS-rooting and :
vim autonfsroot.sh # edit the script, an example is found below chmod a+x autonfsroot.sh rm sbin/init ln -s ../autonfsroot.sh sbin/init
Here's a simple example of autonfsroot.sh
#!/bin/sh echo "Doing mounts..." mount -t proc proc /proc mount -t sysfs sysfs /sys echo "Loading modules..." modprobe sunrpc modprobe auth_rpcgss modprobe rpcsec_gss_krb5 modprobe nfs modprobe phonet modprobe g_nokia sleep 2 echo "Configuring network interface..." ifconfig usb0 192.168.2.15 echo "Mounting NFS..." mount -t nfs -o nolock 192.168.2.14:/home/nfs/rootfs /mnt echo "Unmounting proc and sys..." umount /proc umount /sys echo "Switching to nfsroot..." # switch_root does not seem to be working with cramfs #exec switch_root /mnt /sbin/init cd /mnt pivot_root . mnt exec chroot . /sbin/init
Of course, you could do more elaborate scripting, e.g. add automatic kernel command line parsing/analysis, but that's not covered here.
N900 requires cramfs initrd images. This is a bootloader restriction. Go back to the directory containing the initrd dir and then:
cd .. mkfs.cramfs -b 4096 -n meego_initrd ./initrd/ initrd.img
Now you are ready to load your kernel + initrd with flasher and boot to nfs-root. Interface usb0 should be assigned an IP right after the loading.
NOTICE: Here we do not flash the kernel or initrd to the device, but only load them to the device memory during the boot. Original images are restored when the device is restarted.
sudo flasher -k /home/nfs/rootfs/boot/vmlinuz-VERSION_HERE -n initrd.img -l -b"root=/dev/ram0" ; \ sleep 5 ; sudo ifconfig usb0 192.168.2.14
As a pre-requisite, you have to have environment for cross-building ARM binaries.
Then, you have to recompile kernel for N900. You must enable (built inside kernel, thus select '*', not 'M'):
* USB Gadget support (Device drivers -> USB Support -> USB Gadget support)
* USB Gadget drivers (Device drivers -> USB Support -> USB Gadget support -> USB Gadget drivers)
* Ethernet gadget
* RNDIS Support (Device drivers -> USB support -> USB Gadget support -> RNDIS support)
* Ethernet Emulation Model (EEM) support (Device drivers -> USB support -> USB Gadget support -> EEM support)
* NFS support (File systems -> Network File systems -> NFS client support)
* NFS-Root support (File systems -> Network File systems -> NFS client support -> Root file system on NFS)
* IP kernel autoconf (Networking support -> Networking options -> IP: kernel level autoconfiguration)
* all sub-options
Compile and install modules
make make modules_install INSTALL_MOD_PATH=/home/nfs/rootfs
After compilation is finished you can boot the new kernel with (assuming 192.168.2.14 is your host)
NOTICE: Here we do not flash the kernel or initrd to the device, but only load them to the device memory during the boot. Original images are restored when the device is restarted.
flasher -k arch/arm/boot/zImage -l -b"init=/sbin/preinit ip=192.168.2.15::192.168.2.14 root=/dev/nfs \ nfsroot=192.168.2.14:/home/nfs/rootfs rootdelay=2 rw console=ttyMTD console=tty0"
You can also hard code the kernel command line options as default when recompiling the kernel (Boot options -> default kernel command string). Further, you can also flash the new kernel to the device by:
NOTICE: If you choose to flash the kernel, original image (e.g. Maemo 5) will not start and you need to flash the original kernel back before normal use.
sudo flasher-3.5 -f -k <kernel_image>
But still, you have to override the Nolo command line options on every startup with flasher:
flasher -b