Introduction
The Mikrotik Routerboards are cheap and versatile embedded platforms that can be used for routers, WiFi APs and the like. In a rather wide range of products, I happen to have access to the RB411 and the RB750 two devices of very different properties. While the RB750 is effectively a 5 port 10/100 Mbit Ethernet switch with an Atheros AR71xx CPU on it, the RB411 has the same CPU with one Ethernet port and a Mini PCI slot as well as a serial port (and a beeper

Although I do not have other Mikrotik products, I assume that the OpenWRT flash procedure is similar for products using RouterBOOT as bootloader and the Atheros AR71xx CPU. However, this guide comes without warranty, everything you do is at your full risk. Although I was unable to do so, there is a certain risk of permanently bricking your device.
The process of flashing the Routerboard has 5 major steps:
- Prepare an OpenWRT Ramdisk Image
- Prepare the OpenWRT target Image
- Configure the TFTP and DHCP Server
- Boot the Routerboard using the Ramdisk Image
- Flash the Target Image
Preparation Procedure
Prepare an OpenWRT Ramdisk Image
Compiling OpenWRT from the SVN is actually more straight forward than you might imagine. Take your favorite Linux Distribution (Ubuntu in my case), check our the SVN, configure it and hit make. There you go.- Get the source code
Check out the latest and greatest version of OpenWRT:1 - Configure OpenWRT according to your needs
12
cd
trunk
make
menuconfig
123Target System: Atheros AR71xx
Subtarget: Devices with NAND flash (mostly Mikrotik)
Target Images: ramdisk
- Build it
The build process of OpenWRT takes a long time, but is very simple:1make
Prepare the OpenWRT target Image
- Configure OpenWRT according to your needs
12
cd
trunk
make
menuconfig
123Target System: Atheros AR71xx
Subtarget: Devices with NAND flash (mostly Mikrotik)
Target Images: tar.gz
- Build it
1
make
- Kernel Image: openwrt-ar71xx-nand-vmlinux.elf
- Root File System: openwrt-ar71xx-nand-rootfs.tar.gz
Configure the TFTP and DHCP Server
- Configure your network Interface
The network interface to which the Routerboard is connected must have a unique IP with a DHCP running on it. To make debugging easier, it is usually a good idea to directly connect the Routerboard to your NIC without other devices involved.
Configure the Interface within the subnet 192.168.1.0/24 (OpenWRTs default subnet) but try to avoid 192.168.1.1 (OpenWRTs default IP). I have used 192.168.1.2. - Install DHCP and TFTP Servers
You will need a DHCP Server to assign an IP address to the Routerboard for the flash process. Also, the DHCP server tells the board which file to use as image. Frankly, the tftp Server is responsible to provide the image file to the RB.
On Ubuntu Linux, I have used these packages:1apt-get
install
dhcp3-server atftpd
- Configure the DHCP Server
The DHCP Server does not need much configuration. I use the following as /etc/dhcp3/dhcpd.conf:12345678910111213allow booting;
allow bootp;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.10 192.168.1.200;
}
host routerboard {
hardware ethernet 00:0c:42:XX:YY:ZZ;
fixed-address 192.168.1.100;
next-server 192.168.1.2;
filename "openwrt-ar71xx-nand-vmlinux-initramfs.elf";
}
- Configure the TFTP Server
Edit /etc/default/atftps to avoid running the daemon over inetd. My file looks like this:12USE_INETD=false
OPTIONS="--tftpd-timeout 300 --retry-timeout 5 --mcast-port 1758 --mcast-addr 239.239.239.0-255 --mcast-ttl 1 --maxthread 100 --verbose=5 /tftpboot"
1cp
bin
/ar71xx/openwrt-ar71xx-nand-vmlinux-initramfs
.elf
/tftpboot
- Apply the changed configuration
12
/etc/init
.d
/dhcp3-server
reload
/etc/init
.d
/atftpd
reload
Flash process for Routerboard 750
Booting the Ramdisk Image
The purpose of this step is to have a ramdisk version of OpenWRT running on the routerboard. This is a good basis for our flashing process and can also be used to test images without flashing them. This involves the following steps:- Connecting the Routerboard
Connect port 1 of the Routerboard with the Ethernet port that your DHCP and TFTP server listens on. - Boot the Routerboard
Now press and hold the “RES” button of the router board and connect power. Both LEDs (PWR and ACT) will be constantly on, keep pressing the button. After some seconds the “ACT” LED starts flashing, keep pressing. After some more seconds, the “ACT” LED turns off, now you can stop pressing the button. The board will now try to obtain an IP address via DHCP/BOOTP and then download and boot the Ramdisk image. You can see this activity by looking at the appropriate log files:1tail
-f
/var/log/daemon
.log
/var/log/messages
123May 27 13:21:26 tk dhcpd: BOOTREQUEST from 00:0c:42:XX:YY:ZZ via eth1
May 27 13:21:26 tk dhcpd: BOOTREPLY for 192.168.1.101 to routerboard (00:0c:42:XX:YY:ZZ) via eth1
May 27 13:21:26 tk atftpd[26400]: Serving openwrt-ar71xx-nand-vmlinux-initramfs.elf to 192.168.1.101:33321
1telnet 192.168.1.1
- Erase the flash memory
You can look at the existing flash partitions by looking at /proc/mtd.12345root@OpenWrt:~# cat /proc/mtd
dev: size erasesize name
mtd0: 00040000 00004000 "booter"
mtd1: 003c0000 00004000 "kernel"
mtd2: 03c00000 00004000 "rootfs"
12mtd erase kernel
mtd erase rootfs
- Create new file systems
After erasing the content of the flash, we now need to create new yaffs2 partitions. In principle, we could also make the rootfs ext2/3/4, but I have not tried this. The kernel partition has to be yaffs2 as far as I know to be compatible with the bootloader.123mkdir
/mnt/kernel
/mnt/rootfs
mount
-t yaffs2
/dev/mtdblock1
/mnt/kernel
mount
-t yaffs2
/dev/mtdblock2
/mnt/rootfs
- Copy the images onto the Routerboard
Copying the images onto the routerboard can be done in multiple ways, I have used secure file copy (scp). First, we have to create a password for the root user. On the routerboard, execute1passwd
1scp
bin
/ar71xx/openwrt-ar71xx-nand-rootfs
.
tar
.gz bin
/ar71xx/openwrt-ar71xx-nand-vmlinux
.elf root@192.168.1.1:
/tmp
- Flash the images onto the Routerboard
Flashing the images is simple, once you have them on the Routerboard. First, the kernel:123mv
/tmp/openwrt-ar71xx-nand-vmlinux
.elf
/mnt/kernel/kernel
chmod
+x
/mnt/kernel/kernel
umount
/mnt/kernel
1234cd
/mnt/rootfs
tar
-xvzf
/tmp/openwrt-ar71xx-nand-rootfs
.
tar
.gz
cd
/
umount
/mnt/rootfs
- That’s it, you are done
Finally, reboot the routerboard.1reboot
Flash the target Image
What if the Routerboard does not boot?
Do not panic. If the board is not reachable at 192.168.1.1 after some minutes, something must have gone wrong. You can always recover the boards using Mikrotiks Netinstall. Also, you can start again at the point where the ramdisk image should have booted. Unfortunately, the RB750 does not have a serial port, debugging problems with the linux boot process is probably *very* annoying.Flash process for Routerboard 411
The flash process for the Routerboard 411 is almost similar to the process for the RB750 – only the flash layout is a bit different and hence the number of the target partitions have to be changed. Apart from that, you can use the exact same procedure. However, since the RB411 offers a serial port, debugging is much more convenient.Booting the Ramdisk Image
The purpose of this step is to have a ramdisk version of OpenWRT running on the routerboard. This is a good basis for our flashing process and can also be used to test images without flashing them. This involves the following steps:- Connecting the Routerboard
Connect the Ethernet port of the Routerboard with the Ethernet port that your DHCP and TFTP server listens on. - Configure the Bootloader
Connect a serial cable to the serial port of the routerboard using the settings 115200 8n1. The boot process should look similar to this:12345678RouterBOOT booter 2.27
RouterBoard 411
CPU frequency: 300 MHz
Memory size: 32 MB
Press any key within 2 seconds to enter setup
123456789101112131415161718RouterBOOT-2.27
What do you want to configure?
d - boot delay
k - boot key
s - serial console
n - silent boot
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:
- Boot the Routerboard
While looking at the serial terminal, you should see something like:123456789101112RouterBOOT booter 2.27
RouterBoard 411
CPU frequency: 300 MHz
Memory size: 32 MB
Press any key within 2 seconds to enter setup..
trying bootp protocol... OK
Got IP address: 192.168.1.100
resolved mac address 00:E0:4C:XX:YY:ZZ
transfer started ..........................
- Erase the flash memory
You can look at the existing flash partitions by looking at /proc/mtd.12345678910root@OpenWrt:~# cat /proc/mtd
root@OpenWrt:/# cat /proc/mtd
dev: size erasesize name
mtd0: 0000b000 00001000 "routerboot"
mtd1: 00001000 00001000 "hard_config"
mtd2: 00002000 00001000 "bios"
mtd3: 00001000 00001000 "soft_config"
mtd4: 00040000 00004000 "booter"
mtd5: 005c0000 00004000 "kernel"
mtd6: 03a00000 00004000 "rootfs"
12mtd erase kernel
mtd erase rootfs
- Create new file systems
After erasing the content of the flash, we now need to create new yaffs2 partitions. In principle, we could also make the rootfs ext2/3/4, but I have not tried this. The kernel partition has to be yaffs2 as far as I know to be compatible with the bootloader.123mkdir
/mnt/kernel
/mnt/rootfs
mount
-t yaffs2
/dev/mtdblock5
/mnt/kernel
mount
-t yaffs2
/dev/mtdblock6
/mnt/rootfs
- Copy the images onto the Routerboard
Copying the images onto the routerboard can be done in multiple ways, I have used secure file copy (scp). First, we have to create a password for the root user. On the routerboard, execute1passwd
1scp
bin
/ar71xx/openwrt-ar71xx-nand-rootfs
.
tar
.gz bin
/ar71xx/openwrt-ar71xx-nand-vmlinux
.elf root@192.168.1.1:
/tmp
- Flash the images onto the Routerboard
Flashing the images is simple, once you have them on the Routerboard. First, the kernel:123mv
/tmp/openwrt-ar71xx-nand-vmlinux
.elf
/mnt/kernel/kernel
chmod
+x
/mnt/kernel/kernel
umount
/mnt/kernel
1234cd
/mnt/rootfs
tar
-xvzf
/tmp/openwrt-ar71xx-nand-rootfs
.
tar
.gz
cd
/
umount
/mnt/rootfs
- Reconfigure the Bootloader
Reboot the board and enter the bootloader. Now change the boot device (o) to “boot from NAND, if fail then Ethernet” (n). Save settings with x. - That’s it, you are done
After some while, you should be able to ping the board at 192.168.1.1.
We have made a tutorial to make RouterBoard 750GL Openflow enabled.
ReplyDeleteWhat this tutorial contain:
-Installation procedure of OpenWRT on RouterBoard GL750
-Installation procedure of Openflow v1.0 on RouterBoard GL750
-Installation of NOX/POX/Floodlight Controller
-Testing of OpenFlow enabled Network
This tutorial can be downloaded from the following link:
http://andash.seecs.nust.edu.pk/andash_publications/SDN.pdf