Hi Guys,
Here's how to build a MIPS32 system that will run in emulation on a PC (a
Debian/wheezy Linux install).
The root file system of the
BT Home Hub 3.0b is mounted by a Linux kernel built for the
MIPS Malta evaluation board. The Malta board is a $3000 development platform that is supported by
QEMU the open-source processor emulator. [1]
MIPS Malta ATX factor evaluation board
Firstly, install
QEMU - the processor emulator. See [2]
$ apt-get install qemu qemu-user-static
The 32MB NAND flash image for the BT Home Hub 3.0b (f/w revision
V100R001C01B031SP09 [2011-06-01] ) can be downloaded from here. [3]
First we extract the
jffs2 root file system image from that NAND image
$ dd if=hh3.0b.V100R001C01B031SP09_L_B_t2011-06-01_22_39.eccstripped.bin of=hh3.0b_jffs2_be skip=$((0x8000)) count=12173332 bs=1
Convert that bigendian
jffs2 image to little-endian bytesex for mounting on an x86 PC:
$ jffs2dump --bigendian hh3.0b_jffs2_be --endianconvert=hh3.0b_jffs2_le
Mount the HH3.0b
jffs2 root file system at
/mnt/hh3.0b_jffs2_le$ modprobe mtdblock
$ modprobe mtdram total_size=300000
$ dd if=./hh3.0b_jffs2_le of=/dev/mtdblock0
$ mkdir /mnt/hh3.0b_jffs2_le
$ mount -t jffs2 /dev/mtdblock0 /mnt/hh3.0b_jffs2_le
Create an empty 100MB file
$ dd if=/dev/zero of=hh3.0b.ext2 bs=512 count=$((0x30000))
Make the file into an
ext2 image and mount it under
/mnt/hh3.0b_ext2$ mke2fs -F hh3.0b.ext2
$ mkdir /mnt/hh3.0b_ext2
$ mount -t ext2 -o loop hh3.0b.ext2 /mnt/hh3.0b_ext2
Copy contents of (little-endian)
jffs2 filesystem into our mounted
ext2 file system
$ cp -ar /mnt/hh3.0b_jffs2_le/* /mnt/hh3.0b_ext2
This is what we've got:
$ ls -l /mnt/hh3.0b_ext2/
total 1392
dr-xr-xr-x 2 root 1101 2048 Jun 1 2011 bin
drwxrwxrwx 3 root root 1024 Jun 1 2011 BTAgent
-rw-r--r-- 1 root root 187416 Jun 1 2011 cferam.000
drwxrwx--- 2 root 1102 1024 Jun 1 2011 config
drwxr-xr-x 3 root root 1024 Jun 1 2011 dev
dr-xr-xr-- 8 root 1102 1024 May 31 2011 etc
drwxrwxrwx 5 root root 2048 Jun 1 2011 lib
lrwxrwxrwx 1 root 1101 11 Jun 1 2011 linuxrc -> bin/busybox
drwxr-xr-x 2 root root 1024 Jun 1 2011 mnt
drwxr-xr-x 2 root root 1024 Jun 1 2011 proc
dr-xr-xr-x 2 root 1101 1024 Jun 1 2011 sbin
drwxr-xr-x 2 root root 1024 Jun 1 2011 tmp
dr-xr-xr-x 3 root 1101 1024 Jun 1 2011 usr
drwxrwx--- 2 root 1102 1024 Jun 1 2011 var
-rw-r--r-- 1 root root 1202746 Jun 1 2011 vmlinux.lz
We can disable login authentication by modifying
/etc/inittab as follows (viz the
respawn line)
$ cat /mnt/hh3.0b_ext2/etc/inittab
::sysinit:/etc/init.d/rcS
::respawn:/bin/sh
# tty2::askfirst:-/bin/sh
#::ctrlaltdel:/bin/umount -a -r
Now unmount our
ext2 fs image and our
jffs2 image
$ umount /mnt/hh3.0b_ext2
$ umount /mnt/hh3.0b_jffs2_le
And that is the HH3.0b root file system sorted out, ready for the emulator
Now we can build a MIPS32 Linux kernel that will run in QEMU emulation on the PC
To do that, we will use the
buildroot cross-compiler toolchain (latest stable version). See [4]
$ wget http://buildroot.uclibc.org/downloads/buildroot-2012.05.tar.bz2
$ tar jxvf buildroot-2012.05.tar.bz2
$ cd buildroot-2012.05
We will use the default kernel config for the
MIPS Malta Development Board (MIPS 32r2|OABI32|BE)
This is just illustrative. We can tweak the kernel build and userspace options properly later:
$ cp configs/qemu_mips_malta_defconfig .config
$ make
# [verify and confirm config options]
$ make
(simmer for 20-50 minutes depending on core speed. Zzzz!)
Hopefully, we now have a Linux (3.3.7) kernel built for the Malta board and our root file system (
hh3.0b.ext2) for the BT Home Hub 3.0b.
Together, the kernel and the rootfs can be built into a complete MIPS32 system to run in emulation on the PC.
(Lots of tweaking needed - see all the errors about missing (Broadcom) kernel modules, flash partitions, network interfaces, etc.,etc.)
Start
QEMU with the following command line options:
$ qemu-system-mips -M malta -kernel output/images/vmlinux -nographic -hda hh3.0b.ext2 -append "root=/dev/hda"
And away she goes!:
Linux version 3.3.7 (asbo@home) (gcc version 4.5.3 (Buildroot 2012.05) ) #1 SMP Fri Aug 17 03:22:58 BST 2012
Config serial console: console=ttyS0,38400n8r
bootconsole [early0] enabled
CPU revision is: 00019300 (MIPS 24Kc)
FPU revision is: 00000000
Determined physical RAM map:
memory: 00001000 @ 00000000 (reserved)
memory: 000ef000 @ 00001000 (ROM data)
memory: 003dc000 @ 000f0000 (reserved)
memory: 07b33000 @ 004cc000 (usable)
Wasting 39296 bytes for tracking 1228 unused pages
Zone PFN ranges:
DMA 0x00000000 -> 0x00001000
Normal 0x00001000 -> 0x00007fff
Movable zone start PFN for each node
Early memory PFN ranges
0: 0x00000000 -> 0x00007fff
PERCPU: Embedded 7 pages/cpu @81103000 s4672 r8192 d15808 u32768
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32511
Kernel command line: root=/dev/hda console=ttyS0,38400n8r
PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Primary instruction cache 2kB, VIPT, 2-way, linesize 16 bytes.
Primary data cache 2kB, 2-way, VIPT, no aliases, linesize 16 bytes
Writing ErrCtl register=00000000
Readback ErrCtl register=00000000
Memory: 124988k/126156k available (2871k kernel code, 1168k reserved, 704k data, 196k init, 0k highmem)
Hierarchical RCU implementation.
NR_IRQS:256
CPU frequency 200.00 MHz
Console: colour dummy device 80x25
Calibrating delay loop... 847.05 BogoMIPS (lpj=4235264)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
Brought up 1 CPUs
NET: Registered protocol family 16
bio: create slab <bio-0> at 0
vgaarb: loaded
PCI host bridge to bus 0000:00
pci_bus 0000:00: root bus resource [mem 0x10000000-0x17ffffff]
pci_bus 0000:00: root bus resource [io 0x1000-0x1fffff]
pci 0000:00:0a.3: quirk: [io 0x1100-0x110f] claimed by PIIX4 SMB
vgaarb: device added: PCI:0000:00:12.0,decodes=io+mem,owns=none,locks=none
pci 0000:00:12.0: BAR 0: assigned [mem 0x10000000-0x11ffffff pref]
pci 0000:00:0b.0: BAR 6: assigned [mem 0x12000000-0x1200ffff pref]
pci 0000:00:12.0: BAR 6: assigned [mem 0x12010000-0x1201ffff pref]
pci 0000:00:12.0: BAR 1: assigned [mem 0x12020000-0x12020fff]
pci 0000:00:0a.2: BAR 4: assigned [io 0x1000-0x101f]
pci 0000:00:0b.0: BAR 0: assigned [io 0x1020-0x103f]
pci 0000:00:0b.0: BAR 1: assigned [mem 0x12021000-0x1202101f]
pci 0000:00:0a.1: BAR 4: assigned [io 0x1040-0x104f]
Switching to clocksource MIPS
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
UDP hash table entries: 128 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 128 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
PCI: Enabling device 0000:00:0a.2 (0000 -> 0001)
VFS: Disk quotas dquot_6.5.2
Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
msgmni has been set to 244
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
PCI: Enabling device 0000:00:12.0 (0000 -> 0002)
cirrusfb 0000:00:12.0: Cirrus Logic chipset on PCI bus, RAM (4096 kB) at 0x10000000
Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
serial8250.0: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
console [ttyS0] enabled, bootconsole disabled
console [ttyS0] enabled, bootconsole disabled
serial8250.0: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
Uniform Multi-Platform E-IDE driver
piix 0000:00:0a.1: IDE controller (0x8086:0x7111 rev 0x00)
PCI: Enabling device 0000:00:0a.1 (0000 -> 0001)
piix 0000:00:0a.1: not 100% native mode: will probe irqs later
ide0: BM-DMA at 0x1040-0x1047
ide1: BM-DMA at 0x1048-0x104f
hda: QEMU HARDDISK, ATA DISK drive
hda: UDMA/33 mode selected
hdc: QEMU DVD-ROM, ATAPI CD/DVD-ROM drive
hdc: UDMA/33 mode selected
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
ide1 at 0x170-0x177,0x376 on irq 15
ide_generic: please use "probe_mask=0x3f" module parameter for probing all legacy ISA IDE ports
ide-gd driver 1.18
hda: max request size: 512KiB
hda: 196608 sectors (100 MB) w/256KiB Cache, CHS=195/255/63
hda: cache flushes supported
hda: unknown partition table
ide-cd driver 5.00
ide-cd: hdc: ATAPI 4X DVD-ROM drive, 512kB Cache
cdrom: Uniform CD-ROM driver Revision: 3.20
pcnet32: pcnet32.c:v1.35 21.Apr.2008 tsbogend@alpha.franken.de
PCI: Enabling device 0000:00:0b.0 (0000 -> 0003)
pcnet32: PCnet/PCI II 79C970A at 0x1020, 52:54:00:12:34:56 assigned IRQ 10
pcnet32: eth0: registered as PCnet/PCI II 79C970A
pcnet32: 1 cards_found
mousedev: PS/2 mouse device common for all mice
TCP cubic registered
NET: Registered protocol family 17
VFS: Mounted root (ext2 filesystem) readonly on device 3:0.
Freeing prom memory: 956k freed
Freeing unused kernel memory: 196k freed
init started: BusyBox vv1.9.1 (2011-06-01 22:36:10 CST)
starting pid 741, tty '': '/etc/init.d/rcS'
/bin/startbsp: line 22: cannot create /dev/mtdblock2: No such device or address
/bin/startbsp: line 23: cannot create /dev/mtdblock3: No such device or address
/bin/startbsp: line 24: cannot create /dev/mtdblock4: No such device or address
mount: mounting /dev/mtdblock2 on /var/module failed: No such device
mount: mounting /dev/mtdblock3 on /config failed: No such device
mount: mounting /dev/mtdblock4 on /var/middleware failed: No such device
Loading drivers and kernel modules...
insmod: cannot insert '/lib/extra/pktflow.ko': Success
insmod: cannot insert '/lib/extra/bcmfap.ko': Success
insmod: cannot insert '/lib/extra/bcmxtmcfg.ko': Success
insmod: cannot insert '/lib/extra/adsldd.ko': Success
insmod: cannot insert '/lib/extra/bcm_enet.ko': Success
insmod: cannot insert '/lib/extra/wl.ko': Success
insmod: cannot insert '/lib/extra/p8021ag.ko': Success
insmod: cannot insert '/lib/extra/bcmvlan.ko': Success
insmod: cannot insert '/lib/extra/pwrmngtd.ko': Success
insmod: cannot insert '/lib/kernel/drivers/watchdog/bcmdog.ko': Success
insmod: cannot insert '/lib/kernel/drivers/usb/storage/usb-storage.ko': Success
RCS DONE
starting pid 936, tty '': '/bin/sh'
With our kernel booted, we arrive at the familiar (GPL'ed ;- )
BusyBox shell [5]
Version 1.9.1 of BusyBox, apparently:
BusyBox vv1.9.1 (2011-06-01 22:36:10 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.
# cat /proc/version
Linux version 3.3.7 (asbo@home) (gcc version 4.5.3 (Buildroot 2012.05) ) #1 SMP Fri Aug 17 03:22:58 BST 2012
# cat /proc/cpuinfo
system type : MIPS Malta
processor : 0
cpu model : MIPS 24Kc V0.0 FPU V0.0
BogoMIPS : 847.05
wait instruction : yes
microsecond timers : yes
tlb_entries : 16
extra interrupt vector : yes
hardware watchpoint : yes, count: 1, address/irw mask: [0x0ff8]
ASEs implemented : mips16
shadow register sets : 1
kscratch registers : 0
core : 0
VCED exceptions : not available
VCEI exceptions : not available
# ls -l
-rw-r--r-- 1 0 0 1202746 vmlinux.lz
drwxrwx--- 15 0 1102 340 var
dr-xr-xr-x 3 0 1101 1024 usr
drwxrwx--- 2 0 1103 40 tmp
dr-xr-xr-x 2 0 1101 1024 sbin
dr-xr-xr-x 29 0 0 0 proc
drwxrwx--- 2 0 1103 40 mnt
lrwxrwxrwx 1 0 1101 11 linuxrc -> bin/busybox
drwxrwxrwx 5 0 0 2048 lib
dr-xr-xr-- 8 0 1102 1024 etc
drwxrwxrwt 2 0 0 1820 dev
drwxrwx--- 2 0 1102 1024 config
-rw-r--r-- 1 0 0 187416 cferam.000
drwxrwxrwx 3 0 0 1024 BTAgent
dr-xr-xr-x 2 0 1101 2048 bin
And here's the Broadcom
xdslcmd tool, running in emulation on a PC:
# xdslcmd
Usage: xdslcmd start [--up] [--mod <a|d|l|t|2|p|e|m>] [--lpair <(i)nner|(o)uter>]
[--trellis <on|off>] [--snr <snrQ4>] [--bitswap <on|off>] [--sesdrop <on|off>]
[--sra <on|off>] [--CoMinMgn <on|off>] [--i24k <on|off>] [--phyReXmt <0xBitMap-UsDs>]
[--TpsTc <0xBitMap-AvPvAaPa>] [--monitorTone <on|off>]
[--forceJ43 <on|off>] [--toggleJ43B43 <on|off>]
xdslcmd stop
xdslcmd connection [--up] [--down] [--loopback] [--reverb]
[--medley] [--noretrain] [--L3] [--diagmode] [--L0]
[--tones] [--normal] [--freezeReverb] [--freezeMedley]
xdslcmd configure [--mod <a|d|l|t|2|p|e|m>] [--lpair <(i)nner|(o)uter>]
[--trellis <on|off>] [--snr <snrQ4>] [--bitswap <on|off>] [--sesdrop <on|off>]
[--sra <on|off>] [--CoMinMgn <on|off>] [--i24k <on|off>] [--phyReXmt <0xBitMap-UsDs>]
[--TpsTc <0xBitMap-AvPvAaPa>] [--monitorTone <on|off>]
[--forceJ43 <on|off>] [--toggleJ43B43 <on|off>]
xdslcmd bert [--start <#seconds>] [--stop] [--show]
xdslcmd afelb [--time <sec>] [--tones] [--signal <1/2/8>]
xdslcmd qlnmntr [--time <sec>] [--freq <msec>]
xdslcmd inm [--start <BB_THRESH 10*dB> <INMIATO> <INMIATS>] [--stop] [--show]
xdslcmd snrclamp [--shape <shapeId>] [--bpshape [bpIndex-bpLevel,]]
xdslcmd nlnm [--show ] [--setThld <Thld_Num_Tones>]
xdslcmd diag [--logstart <nBytes>] [--logpause] [--logstop] [--loguntilbufferfull <nBytes>]
[--loguntilretrain <nBytes>]
xdslcmd info [--state] [--show] [--stats] [--SNR] [--QLN] [--Hlog] [--Hlin] [--HlinS] [--Bits]
[--linediag] [--reset] [--vendor] [--cfg]
xdslcmd profile [--show] [--save] [--restore]
xdslcmd --version
xdslcmd --help
#
In summary: shown above, the file system of the BT Home Hub 3.0b is used as the rootfs for a MIPS32 Linux kernel running in emulation on a PC.
Any collaborators to get it running properly?!
cheers, a
[1]
http://www.mips.com/products/development-kits/malta/[2]
http://www.qemu.org/[3]
http://docs.google.com/open?id=0B6wW18mYskvBaDBuSzhqZk13N3M[4]
http://buildroot.uclibc.org/about.html[5]
http://www.busybox.net/