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:
Make sure that /srv/homes exist, if no than create it. After editing nfs
configuration file we have to restart NFS server:
1
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:
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:
1
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:
1
2
3
cd /srv/homes/rootfs
mkdir etc
vim etc/inittab
Our inittab is very simple:
1
2
3
4
5
6
::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:
1
mkdir sys proc etc/init.d
In /etc/init.d/rcS we will mount sysfs and procfs:
1
2
3
#! /bin/sh
mount -t proc proc /proc
mount -t sysfs sysfs /sys
Give executable permission to rcS script:
1
chmod +x etc/init.d/rcS
We also have to create dev directory with ttyAMA0 block device:
1
2
3
4
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 %}
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.
Founder and Embedded Systems Consultant at 3mdeb as well as freelance CTO of Vitro Technology and CEO of LPN Plant. Passionate about building firmware that enables advanced hardware features in modern products. Dedicated to customers that treat embedded software security and upgradeability as forethought. Open source firmware evangelist interested in platform security and trusted computing. In favor of fixed price projects with a clear definition of success.