Quality Guru's – Home of QA/QE SW Testing Workshops

May 9, 2010

Enlil Network Emulator: Fist Touch – Netboot of Microtik RB450G with stock OpenWRT Backfire 10.03 image

Filed under: Enlil Network Emulator — natiku @ 4:20 pm

This entry is part of Enlil Handy Network Emulator

I will boot my RB450G with stock OpenWRT Backfire 10.03 image, as part of this First Touch, I will configure all needed stuff for RB450G netboot on Ubuntu 10.03.
Booting a stock OpenWRT Backfire 10.03 image with netboot is know to be relatively safe and don’t harm device or pre-installed Microtik RouterOS.

Process of netboot – booting of combined kernel image + root disk in elf format – is used later as a first step in RB450G kernel + rootfs transferring,
so I will also include some debugging tips here. New RouterBOOT versions are capable to boot with new method of DHCP + TFTP, no need to setting up old bootp service.

Getting MAC Address from RB450G unit labels

On new unit you have 2 identical stickers with 5 MAC addresses and Serial Number – one stick is on board, one is to stick on unit case.


00:0C:42:52:E4:92
...
00:0C:42:52:E4:96
---------------------------
1234567FBC12/123

Check then you have Serial port activated in build machine on boot

Note: In my Atom based build machine I use a build in regular serial port, when you will use an USB – Serial dongle output can be different.

dmesg | egrep -e “ttyS|serial”
[ 0.719631] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[ 0.720114] 00:01: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

Installing needed tools into Ubnutu

Installing serial terminal minicom

sudo apt-get install minicom

Attach null modem serial cable and check connection

Start minicom and configure port as /dev/ttyS0 and connection as 115200, 8N1 with no Hardware and Software handshaking
I also start a logging screen output, so I don’t need to make screen shots , I can simply copy content of file later.

minicom -D /dev/ttyS0 --noinit --capturefile=/tmp/rb450g.log
Press Ctrl-A-Z and O for configuration 
Safe config as default

Now power-on Rb450G unit and check if you see boot up process

Note: Unit has no power switch, you need to pug/unplug device power device instead.

RouterBOOT booter 2.23

RouterBoard 450G

CPU frequency: 680 MHz
Memory size: 256 MB

Press any key within 2 seconds to enter setup..
loading kernel from nand…. OK
setting up elf image… OK
jumping to kernel code
Starting…
Starting services…
MikroTik 3.31
MikroTik Login:

Check if you run a latest RB450G RouterBOOT firmware and backup it

I see line on boot RouterBOOT booter 2.23 and on RB450G product page latest Firmware is 2.23 (April/2010).
So I backup ar7100-2.23.fwf file, if you don’t run latest RouterBOOT firmware I suggest to update to it first before any OpenWRT experiments.
Updating to latest and create a backup of firmware you use will allow you to restore a original RouterOS later in case then you need apply for a WARRANTY.
If you already apply for L5 RouterOS License file don’t forget to backup it too.

Reboot unit again and enter setup

Press space to enter setup when you see this promt:

Press any key within 2 seconds to enter setup.

RouterBOOT booter 2.23

RouterBoard 450G

CPU frequency: 680 MHz
Memory size: 256 MB

Press any key within 2 seconds to enter setup.

RouterBOOT-2.23
What do you want to configure?
d – boot delay
k – boot key
s – serial console
o – boot device
u – cpu mode
f – cpu frequency
r – reset booter configuration
e – format nand
g – upgrade firmware
i – board info
p – boot protocol
b – booter options
t – do memory testing
x – exit setup

Alternative: Getting MAC addresses from RouterBOOT

While in root on setup mode type i .

RouterBOOT booter 2.23

RouterBoard 450G

CPU frequency: 680 MHz
Memory size: 256 MB

Press any key within 2 seconds to enter setup.

RouterBOOT-2.23
What do you want to configure?
d – boot delay
k – boot key
s – serial console
o – boot device
u – cpu mode
f – cpu frequency
r – reset booter configuration
e – format nand
g – upgrade firmware
i – board info
p – boot protocol
b – booter options
t – do memory testing
x – exit setup

your choice: i – board info

Board Info:

Board type: 450G
Serial number: 12345678FBC12
Firmware version: 2.23
CPU frequency: 680 MHz
Memory size: 256 MB
eth1 MAC address: 00:0C:42:52:E4:92
eth2 MAC address: 00:0C:42:52:E4:93
eth3 MAC address: 00:0C:42:52:E4:94
eth4 MAC address: 00:0C:42:52:E4:95
eth5 MAC address: 00:0C:42:52:E4:96

press any key to continue…

Reconfiguring boot prompt delay to 5s

Default 2s delay (display time to access setup prompt) can be easily missed, reconfiguring it to boot prompt delay to 5s

While in root on setup mode type d and 5.

RouterBOOT-2.23
What do you want to configure?
d – boot delay
k – boot key
s – serial console
o – boot device
u – cpu mode
f – cpu frequency
r – reset booter configuration
e – format nand
g – upgrade firmware
i – board info
p – boot protocol
b – booter options
t – do memory testing
x – exit setup
your choice: d – boot delay

Select boot delay:
1 – 1s
* 2 – 2s
3 – 3s
4 – 4s
5 – 5s
6 – 6s
7 – 7s
8 – 8s
9 – 9s
your choice: 5 – 5s

Reconfigure boot parameters to boot from Ethernet and DHCP

While in root on setup mode type p and 2
While in root on setup mode then type o and e

RouterBOOT-2.23
What do you want to configure?
d – boot delay
k – boot key
s – serial console
o – boot device
u – cpu mode
f – cpu frequency
r – reset booter configuration
e – format nand
g – upgrade firmware
i – board info
p – boot protocol
b – booter options
t – do memory testing
x – exit setup
your choice: p – boot protocol

Choose which boot protocol to use:
* 1 – bootp protocol
2 – dhcp protocol
your choice: 2 – dhcp protocol

RouterBOOT-2.23
What do you want to configure?
d – boot delay
k – boot key
s – serial console
o – boot device
u – cpu mode
f – cpu frequency
r – reset booter configuration
e – format nand
g – upgrade firmware
i – board info
p – boot protocol
b – booter options
t – do memory testing
x – exit setup
your choice: o – boot device

Select boot device:
e – boot over Ethernet
* n – boot from NAND, if fail then Ethernet
1 – boot Ethernet once, then NAND
o – boot from NAND only
b – boot chosen device
your choice: e – boot over Ethernet

Exit so save changes automatically to flash memory

While in root on setup mode type x to safe configuration

RouterBOOT-2.23
What do you want to configure?
d – boot delay
k – boot key
s – serial console
o – boot device
u – cpu mode
f – cpu frequency
r – reset booter configuration
e – format nand
g – upgrade firmware
i – board info
p – boot protocol
b – booter options
t – do memory testing
x – exit setup
your choice: x – exit setup

writing settings to flash… OK

Now netboot process will start automatically in loop

RouterBOOT booter 2.23

RouterBoard 450G

CPU frequency: 680 MHz
Memory size: 256 MB

Press any key within 5 seconds to enter setup…..
Please, check ethernet cable…

Connecting Ethernet Cable to RB450H and build machine

I will connect Rb450G to my second connection on Intel Corporation 82574L Gigabit Network with regular 1GBit Ethernet cable using most left port (near serial) Net1 which is configured with direct connection to CPU.
This Intel card as most other new Gigabit Enternet cards support automatic crossover with normal cable as is specifies as optional feature for 1000Bit Ethernet Auto MDIX
Plus brochure for RB450G said then device use Auto MDI/X configuration, so you will probably don’t need an Gigabit Ethernet crossover cable even with other network cards.

Important: I use for netbooting a high quality factory made CAT6a 20cm long cable, I have bad experience with cheap CAT5e cables.

RB450G now see a Network Link and start DHCP process

Now I see on screen in minicom terminal (if Ethernet cable connection is OK)

Trying dhcp protocol……. failed
kernel loading failed

And device reboot in this loop

Debugging: Getting MAC address on most left Ethernet port by sniffing DHCP with tcpdump

dhcp uses as transport protocol old bootp, so we need to sniff data on ports bootpc (68) and bootps (67)

sudo apt-get install tcpdump
sudo tcpdump -i eth1 -vvv -s 1500 ‘((port 67 or port 68))’

You will see lines like this:

Client-Ethernet-Address 00:0c:42:52:e4:92

Selecting private IP network range and configure etrh1

On Nvidia network card eth0 I have connected my DSL line on 10.0.0.0/24 network.

So I will temorarly enable IP4 routing so I can get to OpenWRT repositories in public Internet.

sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

I will also get DHCP servers configuration of my ADSL connection, so I can past them to DHCP configuration later

cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 193.85.1.100
nameserver 193.85.2.100

For OpenWRT WAN port configuration I will select a network from private range 192.168.x.x 192.168.11.0/24

Setup interface eht1 in Intel network card with static IP address in /etc/network/interfaces, which will disable it (eth1 – device not managed) in Gnome network manager

auto eth1
iface eth1 inet static
   address 192.168.11.254
   network 192.168.11.0/24
   netmask 255.255.255.0
   broadcast 192.168.11.255

And restart network to get eth1 configured

sudo /etc/init.d/networking restart

ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:1b:21:56:55:e0  
          inet addr:192.168.11.254  Bcast:192.168.11.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Memory:faee0000-faf00000 

Installing on build machine needed DHCP and TFTPF services for netboot

I will install on Atom based build machine running Ubuntu 10.03 tftp and dhcp servers

sudo apt-get install tftpd-hpa dhcp3-server

Start tftd server as daemon

cat /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa

TFTP_USERNAME=”tftp”
TFTP_DIRECTORY=”/var/lib/tftpboot”
TFTP_ADDRESS=”0.0.0.0:69″
TFTP_OPTIONS=”–secure”

ls -l /var/lib/ | grep tftp
drwxr-xr-x 2 root nogroup 4096 2010-05-09 19:01 tftpboot

sudo start tftpd-hpa
tftpd-hpa start/running, process 2636

netstat -lu | grep tftp
udp 0 0 *:tftp *:*

Configuring and starting DHCP server

In /etc/default/dhcp3-server allow only interface eth1

INTERFACES=”eth1″

In /etc/dhcp3/dhcpd.conf configure network and host information

authoritative;

max-lease-time 604800;
default-lease-time 3100;

ddns-update-style none;
ddns-ttl 7200;

allow booting;
allow bootp;
one-lease-per-client true;

subnet 192.168.11.0 netmask 255.255.255.0 {
	option routers 192.168.11.254;
	option subnet-mask 255.255.255.0;
	option broadcast-address 192.168.11.255;
        option domain-name-servers 193.85.1.100,193.85.2.100;
        option domain-name "practicaltester.com";
	ignore client-updates;
}

group {
	host rb450g1 {
		hardware ethernet 00:0c:42:52:e4:92;
		next-server 192.168.11.254;
		fixed-address 192.168.11.11;
		filename "rb450gbackfire1003stock";
	}

}

Start DHCP server

sudo /etc/init.d/dhcp3-server start

tail /var/log/syslog

ps -ef| grep dhcp

Now we see on minicom attempts to load kernel, we see MAC and IP of build host interface.

trying dhcp protocol… OK
resolved mac address 00:1B:21:56:55:E0
Gateway: 192.168.11.254
transfer started udp error 1
kernel loading failed

Debugging: Looking in detail over DHCP and TFTP with Tshark

dhcp uses as transport protocol old bootp, so we need to decode data on post bootpc (68) and bootps (67) plus tftpd uses port (69)

tshark is command line tool from wireshark (formely ehtereal) package

sudo apt-get install wireshark tshark

sudo tshark -i eth1 -t a -f “(port bootpc or port bootps or port tftp) and (ether host 00:0c:42:52:e4:92)”

17:36:49.755614 0.0.0.0 -> 255.255.255.255 DHCP DHCP Discover – Transaction ID 0x3615c020
17:36:49.755942 192.168.11.254 -> 192.168.11.11 DHCP DHCP Offer – Transaction ID 0x3615c020
17:36:49.756097 0.0.0.0 -> 255.255.255.255 DHCP DHCP Request – Transaction ID 0xc1d8db9e
17:36:49.756490 192.168.11.254 -> 192.168.11.11 DHCP DHCP ACK – Transaction ID 0xc1d8db9e
17:36:49.762865 192.168.11.11 -> 192.168.11.254 TFTP Read Request, File: rb450gbackfire1003stock00, Transfer type: octet00
17:37:46.769426 0.0.0.0 -> 255.255.255.255 DHCP DHCP Release – Transaction ID 0xd3dcbee0

Hint: If you want to see full decoded content of this communication add -V before -i eth1

Compile stock OpenWRT backfire image with ramdisk option

Install needed tools chain into Ubutnu 10.03

sudo apt-get install subversion g++ ncurses-term zlib1g-dev gawk flex patch openssh-server minicom tftp tftpd gettext libncurses5 libncurses5-dev

cd ~
mkdir openwrt
cd openwrt
svn co svn://svn.openwrt.org/openwrt/branches/backfire
cd ~/openwrt/backfire

Apply patch to extend kernel partition from 4MB to 8MB (I edit file manually)
This patch is not needed for netboot experiments, but is needed for flashing device later.

--- ./drivers/mtd/nand/rb4xx_nand.c.org    2010-05-05 07:09:26.000000000 -0500
+++ ./drivers/mtd/nand/rb4xx_nand.c    2010-05-05 18:52:16.000000000 -0500
@@ -92,5 +92,5 @@
    {
        .name    = "kernel",
        .offset    = (256 * 1024),
-       .size    = (4 * 1024 * 1024) - (256 * 1024),
+      .size    = (8 * 1024 * 1024) - (256 * 1024),
    },

make clean

make menuconfig

 Target System (Atheros AR71xx/AR7240/AR913x)  
 Target Profile (Default Profile (no WiFi)) 
 Target Images
    [*] ramdisk  --->
    --- Root filesystem archives
    [ ] cpio.gz
    [*] tar.gz
    --- Root filesystem images                   
    --- Image Options 

Take a cap of tee or coffee

Now copy stock OpenWRT backfire image to tftpd server location

Now is time to switch RB450G unit off and get OpenWRT image:

ls -l ~/openwrt/backfire/bin/ar71xx/openwrt-ar71xx-vmlinux-initramfs.elf
-rwxr-xr-x 1 xxx xxx 3589528 2010-05-03 17:21 ~/openwrt/backfire/bin/ar71xx/openwrt-ar71xx-vmlinux-initramfs.elf

sudo cp ~/openwrt/backfire/bin/ar71xx/openwrt-ar71xx-vmlinux-initramfs.elf /var/lib/tftpboot/rb450gbackfire1003stock

Pre-compiled version can be found here openwrt-backfire-1003-stock-ar71xx-vmlinux-initramfs.elf

Finally booing RB450G with stock OpenWRT Backfire 10.03 image

Now is time to power RB450G unit on

RouterBOOT booter 2.23

RouterBoard 450G

CPU frequency: 680 MHz
Memory size: 256 MB

Press any key within 5 seconds to enter setup…..
trying dhcp protocol… OK
resolved mac address 00:1B:21:56:55:E0
Gateway: 192.168.11.254
transfer started ……………………… transfer ok, time=0.93s
setting up elf image… OK
jumping to kernel code
Linux version 2.6.32.10 (ruda@ruda-atom) (gcc version 4.3.3 (GCC) ) #1 Mon May 3 17:21:21 CEST 2010
bootconsole [early0] enabled
CPU revision is: 00019374 (MIPS 24Kc)
Atheros AR7161 rev 2, CPU:680.000 MHz, AHB:170.000 MHz, DDR:340.000 MHz
Determined physical RAM map:
memory: 10000000 @ 00000000 (usable)
User-defined physical RAM map:
memory: 10000000 @ 00000000 (usable)
Initrd not found or empty – disabling initrd
Zone PFN ranges:
Normal 0×00000000 -> 0×00010000
Movable zone start PFN for each node
early_node_map[1] active PFN ranges
0: 0×00000000 -> 0×00010000
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 65024
Kernel command line: rootfstype=squashfs,yaffs,jffs2 noinitrd console=ttyS0,115200 console=ttyS0,115200 gpio=1983 HZ=340000000 mem=256M kma2
PID hash table entries: 1024 (order: 0, 4096 bytes)
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
Writing ErrCtl register=00010000
Readback ErrCtl register=00010000
Memory: 255684k/262144k available (2003k kernel code, 6188k reserved, 388k data, 1052k init, 0k highmem)
SLUB: Genslabs=7, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Hierarchical RCU implementation.
NR_IRQS:56
Calibrating delay loop… 452.19 BogoMIPS (lpj=2260992)
Mount-cache hash table entries: 512
NET: Registered protocol family 16
MIPS: machine is MikroTik RouterBOARD 450G
bio: create slab at 0
Switching to clocksource MIPS
NET: Registered protocol family 2
IP route cache hash table entries: 2048 (order: 1, 8192 bytes)
TCP established hash table entries: 8192 (order: 4, 65536 bytes)
TCP bind hash table entries: 8192 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 8192 bind 8192)
TCP reno registered
NET: Registered protocol family 1
squashfs: version 4.0 (2009/01/31) Phillip Lougher
Registering mini_fo version $Id$
JFFS2 version 2.2. (NAND) (SUMMARY) �© 2001-2006 Red Hat, Inc.
yaffs May 3 2010 17:09:47 Installing.
msgmni has been set to 499
io scheduler noop registered
io scheduler deadline registered (default)
Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
serial8250.0: ttyS0 at MMIO 0×18020000 (irq = 11) is a 16550A
console [ttyS0] enabled, bootconsole disabled
console [ttyS0] enabled, bootconsole disabled
NAND flash driver for RouterBoard 4xx series version 0.1.10
NAND SPI clock 28333 kHz (AHB 170000 kHz / 6)
FLASH SPI clock 28333 kHz (AHB 170000 kHz / 6)
NAND device: Manufacturer ID: 0xad, Chip ID: 0xdc (Hynix NAND 512MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 1 at 0×000000040000
Bad eraseblock 2 at 0×000000080000
Bad eraseblock 3 at 0x0000000c0000
…………. About 200 similar entries ……….
Bad eraseblock 387 at 0x0000060c0000

Creating 3 MTD partitions on “NAND 512MiB 3,3V 8-bit”:
0×000000000000-0×000000040000 : “booter”
0×000000040000-0×000000600000 : “kernel”
0×000000600000-0×000020000000 : “rootfs”
mtd: partition “rootfs” set to be root filesystem
split_squashfs: error occured while reading from “NAND 512MiB 3,3V 8-bit”
Atheros AR71xx SPI Controller driver version 0.2.4
ag71xx_mdio: probed
eth0: Atheros AG71xx at 0xba000000, irq 5
eth1: Atheros AG71xx at 0xb9000000, irq 4
eth1: AR8316 switch driver attached.
Atheros AR71xx hardware watchdog driver version 0.1.0
TCP westwood registered
NET: Registered protocol family 17
802.1Q VLAN Support v1.8 Ben Greear
All bugs added by David S. Miller
Freeing unused kernel memory: 1052k freed
gpio-buttons driver version 0.1.2
input: gpio-buttons as /devices/platform/gpio-buttons/input/input0
Button Hotplug driver version 0.3.1
- preinit -
Registered led device: rb4xx:yellow:user
Press the [f] key and hit [enter] to enter failsafe mode
- regular preinit -
- init -

Please press Enter to activate this console. device eth1 entered promiscuous mode
eth0: link up (1000Mbps/Full duplex)
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
PPP generic driver version 2.4.2
ip_tables: (C) 2000-2006 Netfilter Core Team
NET: Registered protocol family 24
ehci_hcd: USB 2.0 ‘Enhanced’ Host Controller (EHCI) Driver
nf_conntrack version 0.5.0 (4015 buckets, 16060 max)
ohci_hcd: USB 1.1 ‘Open’ Host Controller (OHCI) Driver
eth1: link up (1000Mbps/Full duplex)
br-lan: port 1(eth1) entering forwarding state

BusyBox v1.15.3 (2010-05-03 16:36:28 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
Backfire (10.03, r21342) ————————–
* 1/3 shot Kahlua In a shot glass, layer Kahlua
* 1/3 shot Bailey’s on the bottom, then Bailey’s,
* 1/3 shot Vodka then Vodka.
—————————————————
root@OpenWrt:/#

About these ads

Leave a Comment »

No comments yet.

RSS feed for comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Shocking Blue Green Theme Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: