Here's a successful boot of OpenWrt, with a spinning hard drive, annotated with notes to explain what Random believes is going on.
This first section is CFE saying hello and booting the kernel, just like always:
CFE version 1.0.37 for BCM947XX (32bit,SP,LE)
Build Date: ?| 12?? 29 20:36:58 CST 2005 (root@localhost.localdomain)
Copyright (C) 2000,2001,2002,2003 Broadcom Corporation.
Initializing Arena
Initializing Devices.
et0: Broadcom BCM47xx 10/100 Mbps Ethernet Controller 3.90.23.0
rndis0: Broadcom USB RNDIS Network Adapter (P-t-P)
CPU type 0x29006: 264MHz
Total memory: 67108864 KBytes
Total memory used by CFE: 0x80800000 - 0x8089BA00 (637440)
Initialized Data: 0x80831B70 - 0x80834250 (9952)
BSS Area: 0x80834250 - 0x80835A00 (6064)
Local Heap: 0x80835A00 - 0x80899A00 (409600)
Stack Area: 0x80899A00 - 0x8089BA00 (8192)
Text (code) segment: 0x80800000 - 0x80831B70 (203632)
Boot area (physical): 0x0089C000 - 0x008DC000
Relocation Factor: I:00000000 - D:00000000
Device eth0: hwaddr 00-17-31-2A-90-0B, ipaddr 192.168.1.1, mask 255.255.255.0
gateway not set, nameserver not set
Null Rescue Flag.
Null Restore Flag.
set pivot_wait = 0
Loader:raw Filesys:raw Dev:flash0.os File: Options:(null)
Loading: .. 3740 bytes read
Entry at 0x80001000
Closing network.
Starting program at 0x80001000
Every message subsequent to CFE's "Starting program at" announcement is coming from Linux.
Linux version 2.6.21.5 (eric@xyzzy) (gcc version 4.1.2) #1 Sun Jun 17 18:52:39 7
That's a little surprising! I have been using a cross-toolchain based around GCC 3.4.6, because my previous experiments using GCC 4.x were abject failures. Huh. update: toolchain success!
CPU revision is: 00029006 ssb: Sonics Silicon Backplane found on address 0x18000000 ssb: BUG: Assertion failed (bus->board_vendor && bus->board_type) at: drivers/s) ssb: Core 0 found: ChipCommon (cc 0x800, rev 0x03, vendor 0x4243) ssb: Core 1 found: Fast Ethernet (cc 0x806, rev 0x06, vendor 0x4243) ssb: Core 2 found: Fast Ethernet (cc 0x806, rev 0x06, vendor 0x4243) ssb: Core 3 found: USB 1.1 Hostdev (cc 0x808, rev 0x02, vendor 0x4243) ssb: Core 4 found: PCI (cc 0x804, rev 0x08, vendor 0x4243) ssb: Core 5 found: MIPS 3302 (cc 0x816, rev 0x00, vendor 0x4243) ssb: Core 6 found: V90 (cc 0x807, rev 0x02, vendor 0x4243) ssb: Core 7 found: IPSEC (cc 0x80B, rev 0x00, vendor 0x4243) ssb: Core 8 found: MEMC SDRAM (cc 0x80F, rev 0x00, vendor 0x4243) ssb: Initializing MIPS core... ssb: set_irq: core 0x0806, irq 2 => 2 ssb: set_irq: core 0x0806, irq 3 => 3 ssb: set_irq: core 0x0804, irq 0 => 4
Sonics Silicon Backplane is the architecture for the WL-700gE. Driver details to follow.
Determined physical RAM map: memory: 04000000 @ 00000000 (usable) Initrd not found or empty - disabling initrd Built 1 zonelists. Total pages: 16256 Kernel command line: root=/dev/mtdblock2 rootfstype=squashfs,jffs2 init=/etc/pr0 Primary instruction cache 16kB, physically tagged, 2-way, linesize 16 bytes. Primary data cache 16kB, 2-way, linesize 16 bytes. Synthesized TLB refill handler (19 instructions). Synthesized TLB load handler fastpath (31 instructions). Synthesized TLB store handler fastpath (31 instructions). Synthesized TLB modify handler fastpath (30 instructions). PID hash table entries: 256 (order: 8, 1024 bytes) Using 132.000 MHz high precision timer. Dentry cache hash table entries: 8192 (order: 3, 32768 bytes) Inode-cache hash table entries: 4096 (order: 2, 16384 bytes) Memory: 62340k/65536k available (2005k kernel code, 3136k reserved, 286k data, ) Mount-cache hash table entries: 512 NET: Registered protocol family 16 ssb: PCIcore in host mode found registering PCI controller with io_map_base unset PCI: fixing up bridge PCI: Fixing up device 0000:00:00.0 Time: MIPS clocksource has been installed. NET: Registered protocol family 2 IP route cache hash table entries: 1024 (order: 0, 4096 bytes) TCP established hash table entries: 2048 (order: 2, 16384 bytes) TCP bind hash table entries: 2048 (order: 1, 8192 bytes) TCP: Hash tables configured (established 2048 bind 2048) TCP reno registered
All that stuff is pretty standard.
squashfs: version 3.0 (2006/03/15) Phillip Lougher Registering mini_fo version $Id$ JFFS2 version 2.2. (NAND) (C) 2001-2006 Red Hat, Inc.
Squashfs is the filesystem type used by openwrt as a default. It's a highly-compressed filesystem that, if memory serves, is read-only. "mini_fo" is kind of like unionfs -- it's a "fanout" filesystem, meaning that you can mount multiple filesystems at the same point, with one of them writeable. So from this I infer that OpenWRT mounts the main filesystem as a read-only squashfs, and then adds an additional writeable JFFS2 filesystem backed by a different part of the flash area.
io scheduler noop registered io scheduler deadline registered (default) Serial: 8250/16550 driver $Revision: 1.90 $ 2 ports, IRQ sharing enabled serial8250: ttyS0 at MMIO 0x0 (irq = 3) is a 16550A serial8250: ttyS1 at MMIO 0x0 (irq = 3) is a 16550A
Not really surprising that a serial device is detected, since that's where these messages are being printed.
b44.c:v1.01 (Jun 16, 2006) eth0: Broadcom 10/100BaseT Ethernet 00:17:31:2a:90:0b eth1: Broadcom 10/100BaseT Ethernet 40:10:18:00:00:2c
The wired ethernet ports use the b44 driver. There are two ethernet ports, probably eth0 is WAN and eth1 is the four-port LAN hub. It might be the other way around.
flash init: 0x1c000000 0x02000000 Physically mapped flash: Found 1 x16 devices at 0x0 in 16-bit bank Amd/Fujitsu Extended Query Table at 0x0040 Physically mapped flash: CFI does not contain boot bank location. Assuming top. number of CFI chips: 1 cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness. Flash device: 0x200000 at 0x1fc00000 bootloader size: 262144 Updating TRX offsets and length: old trx = [0x0000001c, 0x000008f0, 0x000b5000], len=0x00161000 crc32=0x734c4af1 new trx = [0x0000001c, 0x000008f0, 0x000b5000], len=0x000b5000 crc32=0x3b6a6f96 Done Creating 4 MTD partitions on "Physically mapped flash": 0x00000000-0x00040000 : "cfe" 0x00040000-0x001f0000 : "linux" 0x000f5000-0x001f0000 : "rootfs" mtd: partition "rootfs" doesn't start on an erase block boundary -- force read-y 0x00190000-0x001f0000 : "rootfs_data" 0x001f0000-0x00200000 : "nvram"
Details on how the flash chip is used. CFE is the boot loader, of course. The Linux region -- that came from the TRX image -- goes up to the final 64kb NVRAM region, and is divided into the kernel image, the "rootfs" (which is a squashfs), and "rootfs_data", which is presumably the writeable filesystem mentioned earlier. Note that the ending addresses for those chunks are bogus, you can determine the correct ending address by looking at the starting address of the next partition.
It seems odd that it says it's creating 4 MTD partitions, and then actually creates five. But ... ah well.
Note that the warning message actually says "force read-only" but Eric's minicom truncated the message to 80 columns.
nf_conntrack version 0.5.0 (512 buckets, 4096 max) ip_tables: (C) 2000-2006 Netfilter Core Team TCP vegas registered NET: Registered protocol family 1 NET: Registered protocol family 17 802.1Q VLAN Support v1.8 Ben Greear <greearb@candelatech.com> All bugs added by David S. Miller <davem@redhat.com>
Blah blah blah network stuff.
VFS: Mounted root (squashfs filesystem) readonly. Freeing unused kernel memory: 116k freed Warning: unable to open an initial console. Algorithmics/MIPS FPU Emulator v1.5
That warning message seems odd, I don't understand it. But here we see that the filesystem is mounted successfully, hooray. Now, under normal circumstances, the next thing that happens is that the kernel runs the "init" process. Check out what happens in OpenWRT:
- preinit - diag: Detected 'ASUS WL-700gE' diag: Spinning up HDD and enabling leds b44: eth0: Link is up at 100 Mbps, full duplex. b44: eth0: Flow control is off for TX and off for RX. jffs2 not ready yet; using ramdisk mini_fo: using base directory: / mini_fo: using storage directory: /tmp/root
This is the preinit script, which you can find in package/base-files/files. The really interesting thing that preinit does is run preinit.arch. I betcha the preinit.arch that winds up in the OpenWRT trx image starts by loading the diag kernel module, the source for which is in package/broadcom-diag. That module figures out the device is a WL-700gE, and sets up the GPIO pins appropriately. Most importantly, it sets pin 3, which causes power to be delivered to the hard disk and LEDs.
I'm surprised it doesn't also set pin 6, which is done by the ASUS firmware. Maybe things will work better if it does that?
Since this is the first boot of OpenWRT, the JFFS2 filesystem hasn't been created yet, so openwrt uses a ramdisk instead. I'd kind of like to use a ramdisk all the time, so perhaps we should amend the init scripts to do that? The place to do that would be in the /etc/init.d/done script, which does the switch to JFFS.
- init - init started: BusyBox v1.4.2 (2007-06-17 18:39:35 CEST) multi-call binary Please press Enter to activate this console. b44: eth0: Link is up at 100 Mbps,. b44: eth0: Flow control is off for TX and off for RX. PPP generic driver version 2.4.2 jffs2_scan_eraseblock(): End of filesystem marker found at 0x0 jffs2_build_filesystem(): unlocking the mtd device... done. jffs2_build_filesystem(): erasing all blocks after the end marker... <7>eth0.0:e eth0.0: dev_set_promiscuity(master, 1) device eth0 entered promiscuous mode device eth0.0 entered promiscuous mode eth0.1: Setting MAC address to 00 17 31 2a 90 0c. br-lan: port 1(eth0.0) entering learning state br-lan: topology change detected, propagating br-lan: port 1(eth0.0) entering forwarding state done. mini_fo: using base directory: / mini_fo: using storage directory: /jffs
Now we are in the init program, which is exec'ed by preinit as its last operation. It runs init.d/rcS S boot, which is the source of all that activity -- setting the network stuff, building the actual jffs2 filesystem and adding it to the fanout, and it looks like setting up an ethernet bridge.
BusyBox v1.4.2 (2007-06-17 18:39:35 CEST) Built-in shell (ash) Enter 'help' for a list of built-in commands. _______ ________ __ | |.-----.-----.-----.| | | |.----.| |_ | - || _ | -__| || | | || _|| _| |_______|| __|_____|__|__||________||__| |____| |__| W I R E L E S S F R E E D O M KAMIKAZE (bleeding edge, r7646) ------------------- * 10 oz Vodka Shake well with ice and strain * 10 oz Triple sec mixture into 10 shot glasses. * 10 oz lime juice Salute! --------------------------------------------------- root@OpenWrt:/#