
OpenWrt: Post Kernel System Initialization on the Fonera FON
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.
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
Fonera FON related posts at wolfpaulus.com
- La Fonera Hacking
Does the FON have all the attributes required to be added to the digital playground? - La Fonera (FON2100) Hardware Details
A detailed look at the La Fonera (FON 2100) hardware. - La Fonera 2.0 FON 2100a/b/c
RedBoot details and booting into OpenWrt 8.09.1 Kamikaze - La Fonera 2.0 (FON2202) Hardware Details
A detailed look at the La Fonera 2.0 hardware. - La Fonera 2.0 Preview
Putting the original (or newer) firmware back on a Fonera FON 2.0, and some 2.0 screen shots. - La Fonera 2.0 (FON2202) Hacking, Cleaning House
Preparing the FON 2202 for reflashing with OpenWrt or DD-WRT - OpenWrt, Post Kernel System Initialization
A closer look at what happens when OpenWrt boots on the Fonera FON Router. - PhoneME, a JavaVM for the Fonera FON Router
A closer look at how a JavaVM could be built, packaged, and deployed into an embedded system, running the OpenWrt firmware.
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 '' &
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