Table of contents

Introduction To make our embedded linux work as virtual development platform we need some environment after booting. There is many approaches to get working root file system but I will use the easiest one as an exercise. I don’t want to create full embedded distribution (this is good plan for future works). Right now I will be happy with simple initramfs based on

BusyBox. For all interested in creating own root filesystem there are few places where you can find informations: * Embedded Linux: Small Root Filesystems * ramfs-rootfs-initramfs * Creating a Root File System for Linux on OMAP35x

Get and build BusyBox Clone git repository:

Fast and simple Of course make sure to use correct toolchain. I made few notes about Ubuntu/Linaro toolchain in

previous post make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig Mark

Busybox Settings -> Build Options -> Build BusyBox as a static binary (no shared libs) option. Exit and save. make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- install cd _install/

Setting up kernel through NFS

Previously we prepared U-Boot kenernel image with DHCP and rootfs which we want to expose over NFS. First lets start with NFS configuration: sudo apt-get install nfs-kernel-server I use simple

/etc/exports configuration: /srv/homes 192.168.1.0/255.255.255.0(rw,sync,no_subtree_check,no_root_squash) Make sure that

/srv/homes exist, if no than create it. After editing nfs configuration file we have to restart NFS server: sudo service nfs-kernel-server restart

Verify configuration I assume that you go through all previous articles in this series. To verify configuration we have to copy whole BusyBox

_install directory to known nfs location: mkdir /srv/homes/rootfs sudo chmod 777 /srv/homes/rootfs cd /srv/homes/rootfs cp -R /path/to/busybox/_install/* . Now we can try our Virtual Development Board:

192.168.1.24 should be replaced with correct address of TFTP server. VersatilePB # tftp SMC91111: PHY auto-negotiate timed out SMC91111: MAC 52:54:00:12:34:56 Using SMC91111-0 device TFTP from server 192.168.1.20; our IP address is 192.168.1.13 Filename ‘uImage’. Load address: 0x7fc0 Loading: ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################## 252 KiB/s done Bytes transferred = 1917944 (1d43f8 hex) Right now we will set boot arguments for our kernel:

  • root=/dev/nfs – following kernel.org: {% blockquote %} This is necessary to enable the pseudo-NFS-device. Note that it’s not a real device but just a synonym to tell the kernel to use NFS instead of a real device. {% endblockquote %}
  • mem=128M ip=dhcp – self-explaining
  • netdev=25,0,0xf1010000,0xf1010010,eth0 – network device configuration (Format: <irq>,<io>,<mem_start>,<mem_end>,<name>), this was provided by default U-Boot bootargs
  • nfsroot=192.168.1.20:/srv/homes/rootfs – NFS server ip and path to rootfs
  • console=ttyAMA0 – very importanat if you want to see anything in -nographic mode After setting bootargs we can boot our Virtual Development Board:

    bootm As you can see that’s not all, our current configuration end with:

    (…) Sending DHCP requests .input: AT Raw Set 2 keyboard as /devices/fpga:06/serio0/input/input0 , OK IP-Config: Got DHCP answer from 192.168.1.1, my address is 192.168.1.13 IP-Config: Complete: device=eth0, hwaddr=52:54:00:12:34:56, ipaddr=192.168.1.13, mask=255.255.255.0, gw=192.168.1.1 host=192.168.1.13, domain=, nis-domain=(none) bootserver=0.0.0.0, rootserver=192.168.1.20, rootpath= nameserver0=192.168.1.1 input: ImExPS/2 Generic Explorer Mouse as /devices/fpga:07/serio1/input/input1 VFS: Mounted root (nfs filesystem) on device 0:9. Freeing unused kernel memory: 112K (c034e000 – c036a000) nfs: server 192.168.1.20 not responding, still trying nfs: server 192.168.1.20 OK can’t run ‘/etc/init.d/rcS’: No such file or directory can’t open /dev/tty2: No such file or directory can’t open /dev/tty3: No such file or directory

    can’t open /dev/tty4: No such file or directory can’t open /dev/tty2: No such file or directory can’t open /dev/tty3: No such file or directory can’t open /dev/tty4: No such file or directory can’t open /dev/tty2: No such file or directory can’t open /dev/tty3: No such file or directory try to open ttys loop. This is because of default behavior of

BusyBox when inittab was not found.

Embedded filesystem tuning To override above behavior we have to create

/etc/inittab file: cd /srv/homes/rootfs mkdir etc vim etc/inittab Our

inittab is very simple: ::sysinit:/etc/init.d/rcS ::askfirst:/bin/ash ::ctrlaltdel:/sbin/reboot ::shutdown:/sbin/swapoff -a ::shutdown:/bin/umount -a -r ::restart:/sbin/init If you want to learn more about inittab –

man inittab .We need improve out filesystem with few directories: mkdir sys proc etc/init.d In

/etc/init.d/rcS we will mount sysfs and procfs:

Give executable permission to

rcS script: chmod +x etc/init.d/rcS We also have to create

dev directory with ttyAMA0 block device: mkdir dev sudo mknod dev/ttyAMA0 c 204 64 sudo mknod dev/null c 1 3 sudo mknod dev/console c 5 1 Right now we should be able to boot our Virtual Development Board. Let’s try again: {% raw %}

Summary This setup need few minor tweaks like adding U-Boot environment variables storage to not enter it every time or removing annoying message

can't access tty(...). I’m done for now, its time to take care about other challenges. I hope that I will back to this issues in near future. If you like this series please share it, if somethings wrong please comment I will try to help if can. How to set up a NFS root filesystem for embedded Linux development