Flashing the Fonera Router with a default distribution of
OpenWrt requires two files, the kernel image
(openwrt-atheros-vmlinux.lzma 704 KB) and the root file system
(openwrt-atheros-root.squashfs 1.2 MB).
Like
previously mentioned, using a
TFTP Server on a host machine and standard RedBoot commands on the Fonera might be the easiest way to write the root file system and the kernel into nonvolatile storage (flash memory).
After successfully booting the Fonera and accessing the console via
telnet or
ssh, displaying the system message buffer by entering the
dmesg command, allows the reconstruction of the boot process.
Boot Log
When the kernel boots, it detects the presence of the root file system image (openwrt-atheros-root.squashfs) and mounts it as the root file system. The boot log also reveals that
initrd, the initial Ram Disk that a Linux distribution typically mounts during the boot process, is missing. Instead, the kernel command line parameter specifies
/etc/preinit as the the first process to gain control at the completion of the kernel's boot process. It also specifies a single console on device
ttyS0 at 9600 baud, and the root file system's type as
squashfs.
Boot Log (abridged)
Linux version 2.6.26.8 (wolf@wpbook.local) (gcc version 4.1.2) #5 Sun Dec 21 14:47:58 PST 2008
..
Initrd not found or empty - disabling initrd
..
Kernel command line: console=ttyS0,9600 rootfstype=squashfs,jffs2 init=/etc/preinit
preinit
/etc/preinit contains instructions like:
mount proc /proc -t proc
mount sysfs /sys -t sysfs
mount tmpfs /tmp -t tmpfs -o size=$size,nosuid,nodev,mode=1777
mount devpts /dev/pts -t devpts
and therefore, is responsible for mounting /proc (special-purpose filesystem), /sys, /dev (devices nodes, e.g. console), and /tmp (temporary files)
/etc/preinit also triggers the execution of
/etc/preinit.arch, if present. On the FON 2100 this means that support for the reset button on AR5315+ boards is being established.
As the last statement,
/etc/preinit call
exec /sbin/init, which in fact is a soft link to
/bin/busybox
BusyBox now performs an initialization differently from a standard
System V init and launches its default initialization script (/etc/init.d/rcS), i.e. BusyBox's version of
init still reads the system configuration file
/etc/inittab but there is no notion of runlevels.
inittab
::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K stop
tts/0::askfirst:/bin/ash --login
ttyS0::askfirst:/bin/ash --login
tty1::askfirst:/bin/ash --login
/etc/init.d/rcS is a short script that is executing all the startup (beginning with
S) or shutdown scripts (beginning with
K) that are stored in the
/etc/rc.ddirectory. All the scripts names end in a two-digit number and will be launched in order.
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
{
for i in /etc/rc.d/$1*; do
[ -x $i ] && $i $2 2>&1
done
} | logger -s -p 6 -t '' &
All the scripts in the
/etc/rc.d directory are actually symbolic links. Here are all the deployed startup scripts in a default OpenWrt distribution built for the Atheros AR231x / (MIPS 4KEc):
Launch Scripts stored in /etc/rc.d/
/etc/rc.d/S10boot -> ../init.d/boot
/etc/rc.d/S20fstab -> ../init.d/fstab
/etc/rc.d/S39usb -> ../init.d/usb
/etc/rc.d/S40network -> ../init.d/network
/etc/rc.d/S45firewall -> ../init.d/firewall
/etc/rc.d/S50cron -> ../init.d/cron
/etc/rc.d/S50dropbear -> ../init.d/dropbear
/etc/rc.d/S50httpd -> ../init.d/httpd
/etc/rc.d/S50telnet -> ../init.d/telnet
/etc/rc.d/S60dnsmasq -> ../init.d/dnsmasq
/etc/rc.d/S60led -> ../init.d/led
/etc/rc.d/S95done -> ../init.d/done
/etc/rc.d/S97watchdog -> ../init.d/watchdog
/etc/rc.d/S99sysctl -> ../init.d/sysctl
Summary
A default OpenWrt deployed on a La Fonera FON router does not use
initrd, an initial Ram Disk that a Linux distribution typically mounts during the boot process, nor a standard
System V init. Instead, a kernel command line
console=ttyS0,9600 rootfstype=squashfs,jffs2 init=/etc/preinit is used to define
/etc/preinit as the the first process to gain control at the completion of the kernel's boot process. BusyBox is launched and
/etc/init.d/rcS via
/etc/inittab executes all the launch scripts stored in /etc/rc.d/.
/etc/inittab also launches the login shell.