(Instructions fixed and somewhat restructured) |
|||
| Line 1: | Line 1: | ||
| + | This page describes howto make N900 boot a MeeGo root filesystem from your host (PC) using USB networking. Two different approaches are described: | ||
| + | * using initrd (no compilation of any sw components required) | ||
| + | * using customized kernel (requires kernel recompilation) | ||
| + | Initrd is the preferred method. | ||
| + | |||
== Requirements == | == Requirements == | ||
| - | |||
* USB networking | * USB networking | ||
| + | * a MeeGo rootfs image extracted | ||
| - | == | + | == Preparing the root filesystem == |
First, you have to get/make a MeeGo rootfs image. You can download a pre-built image ([[ARM/Meego_images_for_N900]]) or create your own ([[ARM/Creating ARM image using MeeGo Image Creator]]). Then you must make the (unpacked) rootfs available in a suitable location on your host system (e.g. /home/nfs/rootfs). | First, you have to get/make a MeeGo rootfs image. You can download a pre-built image ([[ARM/Meego_images_for_N900]]) or create your own ([[ARM/Creating ARM image using MeeGo Image Creator]]). Then you must make the (unpacked) rootfs available in a suitable location on your host system (e.g. /home/nfs/rootfs). | ||
| + | |||
| + | If you're creating your own rootfs image, you might want to install busybox there. So that you can easily get busybox for your initrd. | ||
Next, make sure you have NFS server installed on your host and export the rootfs. In Ubuntu: | Next, make sure you have NFS server installed on your host and export the rootfs. In Ubuntu: | ||
| Line 12: | Line 19: | ||
exportfs -v -a | exportfs -v -a | ||
| + | Currently, one hack for the (readymade) N900 rootfs image is needed. The nokia-usb-networking (provided by nokia-n900-configs package) messes up the networking when trying to use nfsroot. Simply remove it from the current default runlevel of the MeeGo rootfs: | ||
| + | rm /home/nfs/rootfs/etc/rc.d/rc3.d/S50nokia-usb-networking | ||
| - | + | == Method 1: NFS-Root with initrd == | |
| - | + | This method involves using busybox from MeeGo and does not require kernel recompilation. You can more easily keep in sync with the MeeGo kernel. | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | This method involves using busybox and does not require kernel recompilation. You can more easily keep in sync with the MeeGo kernel. | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | === Preparing initrd directory === | |
| + | 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 | |
| - | cd initrd | + | mkdir sbin |
mkdir proc | mkdir proc | ||
mkdir sys | mkdir sys | ||
| Line 80: | Line 46: | ||
cp -a /dev/tty0 dev/ | cp -a /dev/tty0 dev/ | ||
cp -a /dev/zero dev/ | cp -a /dev/zero dev/ | ||
| - | |||
Copy kernel modules from your rootfs to the initrd (be sure to use correct kernel version): | 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.28-19.1-n900/ lib/modules/ | cp -r /home/nfs/rootfs/lib/modules/2.6.28-19.1-n900/ lib/modules/ | ||
| + | === Installing Busybox === | ||
| + | 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/devel/trunk/repo/arm/os/armv5tel/busybox-1.16.0-2.5.armv5tel.rpm | ||
| + | rpm2cpio busybox-1.16.0-2.5.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. | ||
| + | === Making initrd to boot automatically === | ||
Next, make a script for doing the actual NFS-rooting and : | Next, make a script for doing the actual NFS-rooting and : | ||
vim autonfsroot.sh | vim autonfsroot.sh | ||
| Line 93: | Line 93: | ||
ln -s ../autonfsroot.sh sbin/init | ln -s ../autonfsroot.sh sbin/init | ||
| - | + | Here's a simple example of autonfsroot.sh | |
| - | Here's | + | |
#!/bin/sh | #!/bin/sh | ||
echo "Doing mounts..." | echo "Doing mounts..." | ||
| Line 121: | Line 120: | ||
echo "Switching to nfsroot..." | echo "Switching to nfsroot..." | ||
| - | # | + | # switch_root does not seem to be working with cramfs |
#exec switch_root /mnt /sbin/init | #exec switch_root /mnt /sbin/init | ||
cd /mnt | cd /mnt | ||
| Line 127: | Line 126: | ||
exec chroot . /sbin/init | 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. | ||
| - | === Making initrd and booting === | + | === Making initrd image and booting === |
N900 requires cramfs initrd images. This is a bootloader restriction. Go back to the directory containing the initrd dir and then: | N900 requires cramfs initrd images. This is a bootloader restriction. Go back to the directory containing the initrd dir and then: | ||
cd .. | cd .. | ||
| Line 137: | Line 137: | ||
Voilá, you should see MeeGo booting. | Voilá, you should see MeeGo booting. | ||
| + | |||
| + | |||
| + | |||
| + | == Method 2: NFS-Root with custom kernel == | ||
| + | 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) | ||
| + | * 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) | ||
| + | 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). And further, you can of course flash the new kernel to the device. But still, you have to override the Nolo command line options with flasher | ||
| + | |||
| + | flasher -b | ||
This page describes howto make N900 boot a MeeGo root filesystem from your host (PC) using USB networking. Two different approaches are described:
Initrd is the preferred method.
Contents |
First, you have to get/make a MeeGo rootfs image. You can download a pre-built image (ARM/Meego_images_for_N900) or create your own (ARM/Creating ARM image using MeeGo Image Creator). Then you must make the (unpacked) rootfs available in a suitable location on your host system (e.g. /home/nfs/rootfs).
If you're creating your own rootfs image, you might want to install busybox there. So that you can easily get busybox for your initrd.
Next, make sure you have NFS server installed on your host and export the rootfs. In Ubuntu:
apt-get install nfs-kernel-server echo '/home/nfs 192.168.*(rw,no_root_squash,no_subtree_check)' >> /etc/exports exportfs -v -a
Currently, one hack for the (readymade) N900 rootfs image is needed. The nokia-usb-networking (provided by nokia-n900-configs package) messes up the networking when trying to use nfsroot. Simply remove it from the current default runlevel of the MeeGo rootfs:
rm /home/nfs/rootfs/etc/rc.d/rc3.d/S50nokia-usb-networking
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.28-19.1-n900/ 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/devel/trunk/repo/arm/os/armv5tel/busybox-1.16.0-2.5.armv5tel.rpm rpm2cpio busybox-1.16.0-2.5.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 can load your initrd with flasher and boot to nfs-root:
flasher -n initrd.img -l -b"root=/dev/ram0"
Voilá, you should see MeeGo booting.
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)
* 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)
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). And further, you can of course flash the new kernel to the device. But still, you have to override the Nolo command line options with flasher
flasher -b