I recently came across a MikroTik RouterBoard 493AH at work. We’d acquired the device among numerous other pieces of equipment from a now defunct wireless ISP.
The 493AH features 9 ethernet ports, can accept POE on its WAN interface, has 64M NAND, 128M RAM, and can support 3 mini-PCI cards. Configuration can be performed via a serial interface and there is an external power connector available if POE isn’t used.
The device itself wouldn’t boot, only hang at the RouterBoot bootloader. Attempts to boot the NAND image failed, but the bootloader gives an easy option for downloading an image to it via TFTP.
Looking around, it appears the 493AH is an Atheros AR7161 .. an architecture readily supported under OpenWRT. Sure, I could just re-install RouterOS… but let’s do that later.
To install OpenWRT to the 493AH, first format the NAND. This can easily be done via the bootloader (option e):
Next, use subversion to check out the Backfire version of OpenWRT:
mkdir ~/svn/
cd ~/svn/
svn co svn://svn.openwrt.org/openwrt/branches/backfire backfire
Building the image is fairly easy, all configuration is done via a “make menuconfig“. First, we’ll build a small initramfs. This will give us a tiny environment to boot into the device and later install our kernel with.
Ensure that you’ve selected the AR71xx target architecture…
Next, I opt for the default profile (to give me all the modules I should need)
And finally, select the build of a ramdisk image:
After you’ve made your selections, exit saving your changes, and run make. The build itself will take some time, but when you’re finished you’ll have the first key ingredient – a basic root filesystem embedded into the kernel. This image is essentially a “Live CD” that we’ll use to install our real kernel.
As with all of the images you create, you’ll find them under ~/svn/backfire/bin/ar71xx/ Our newly created image is openwrt-ar71xx-vmlinux-initramfs.elf
Next, we’ll want to build our actual system. To do this, re-run make menuconfig and select the packages that you wish to compile and include in your firmware image. After you’ve made all of your selections, change your Target Image to squashfs and exit saving your changes.
A quick make later, and we now have a working rootfs and kernel – in addition to our initramfs to install the system with:
openwrt-ar71xx-vmlinux-initramfs.elf (Our temporary kernel)
openwrt-ar71xx-vmlinux.elf (The kernel)
openwrt-ar71xx-root.squashfs (Our Root Filesystem)
We now have almost everything we need.
To install our kernel, we need a few additional tools. First off, we need to configure a DHCP server (I’m using ISC’s). Here’s an example from my dhcpd.conf file:
authoritative;
ddns-update-style interim;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.20 192.168.1.40;
option subnet-mask 255.255.255.0;
option routers 192.168.1.1;
}host routerboard
{
hardware ethernet 00:0c:xx:xx:xx:xx;
fixed-address 192.168.1.17;
}
Next, we’ll need a TFTP server. I prefer atftpd. No configuration is necessary, simply create a directory to serve files from and start the server:
mkdir /tftpboot/
chmod 777 /tftpboot/
atftpd ––daemon /tftpboot/
The only file that has to be loaded via TFTP is the initramfs kernel. Copy it to /tftpboot with the filename vmlinux and we’re ready to start.
cp ~/svn/backfire/bin/ar71xx/openwrt-ar71xx-vmlinux-initramfs.elf /tftpboot/vmlinux
Power up the RouterBoard and quickly press the space bar. Select “boot over Ethernet” and it will download and boot the linux kernel.
Next ,we need to install the kernel and root filesystem. Here’s where I ran into my first problem – the kernel has no init variable specified so it panics. Thankfully it clearly states this: “Kernel panic – not syncing: No init found. Try passing init= option to kernel.”
Unfortunately the boot loader doesn’t appear to allow one to specify command line options for the kernel and I was unable to find a way to set this when configuring the kernel. (I vaguely recall seeing it when compiling for x86, but may be mistaken). Either way, the solution is simple:
Add your kernel parameters to a file (kernel-params in my instance) and use objcopy to insert it into the ELF file:
The options I used are:
root=/dev/mtdblock2 rootfstype=squashfs,yaffs,jffs2 noinitrd console=ttyS0,115200 init=/etc/preinit
The toolchain supplied with OpenWRT contains a MIPs compatible version of objcopy that will allow you to add a kernel parameters section to the ELF file:
cd ~/svn/bin/ar71xx/
~/svn/backfire/build_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/binutils-2.19.1/binutils/objcopy ––add-section kernparm=kernel-params openwrt-ar71xx-vmlinux.elf
To install the kernel, configure an IP on your ethernet (or bridge) interface, mount /dev/mtdblock1 and use scp to copy your kernel to the device (as “kernel”).
ifconfig br-lan 192.168.1.10
mkdir /mnt/boot
mount /dev/mtdblock1 /mnt/boot
cd /mnt/boot/
scp 192.168.1.1:~/svn/backfire/bin/ar71xx/openwrt-ar71xx-vmlinux.elf kernel
Next, install your squashfs root filesystem to /dev/mtdblock2. Unlike the kernel, This shouldn’t be mounted when installed.
cd /tmp/
scp 192.168.1.1:~/svn/backfire/bin/ar71xx/openwrt-ar71xx-root.squashfs .
cat openwrt-ar71xx-root.squashfs > /dev/mtdblock2
After the root filesystem is installed, reboot the device and welcome to OpenWRT on the RouterBoard 493AH
I’m not quite sure what I’ll end up doing with the 493AH just yet. The neighborhood wireless system now consists of 2 Engenius EOC2610 units running firmware images based off OpenWRT… so there may be the potential to add it to the fray. The 9 ethernet ports would make it ideal for a Quagga router (although I already have one). Installing the MikroTik RouterOS and working with MPLS is another options. Right now it sits on my desk at work as a “pretty cool paperweight with a lot of potential”.
If you have any suggestions – please let me know.
Hello,
thank you for a nice cook-book on getting OpenWRT on the RB493AH. I am about to get a RB493G and I am wondering if this procedure would also work on this one. Would you expect any differences?
Best regards
Michal
Thanks Michal,
I can’t guarantee it (since I’ve not tried), but the important thing to look for is what type of CPU is in use. The 493G appears to be the same as the 493AH (both are running an AR7161 according to http://routerboard.com/pdf/291/rb493G.pdf and http://routerboard.com/pdf/84/rb493AH.pdf ), so I think you’ll find that you can follow the cook-book without any changes at all.
Let me know if you pick one up and have any questions, I’ll see what I can help out with.
There’s no timestamps on the above comments so I’ve no idea how long ago they were posted.
For others who may stumble across this page in the future, however, the RB493G works okay w/ OpenWRT “Attitude Adjustment” v12.09. There’s an issue w/ the USB port (due, apparently, to crappy Mikrotik engineering) and the SD card reader doesn’t work on the kernel version I have installed but support has been added since then.
Refer to the RB493G page on the OpenWRT wiki for more information:
http://wiki.openwrt.org/toh/mikrotik/rb493g
Hi Michael,
I’m trying to get the latest version of OpenWRT to run on my RB493G but I can’t get past the “Kernel panic – not syncing: No init found” error message.
After seeing Jeremy’s post I was hoping that compiling the image was no longer required. Perhaps I used the wrong image ? I’ve been trying with this : openwrt-ar71xx-nand-vmlinux.elf
Any ideas ?
Thanks,
John
PS: we have the same surname, yay 🙂
Meant Matthew, not Michal…
I’m not sure offhand John as I never bothered with the distributed images, only compiled the system by hand. It almost sounds as though you’ll need to use objcopy from the toolchain and insert the kernel parameters into openwrt-ar71xx-nand-vmlinux.elf (similarly to what I did in this article). That would be the first thing that I would try if I were you.
I’ve successfully flashed the latest version of OpenWRT AA 12.09 (r36088) using the official build. The SD card reader works after installing the kmod-mmc-spi package. My routerboard R52Hn wifi card also works but my config still needs some tweaking 🙂
Have you tested the throughput you get between the wan port and the other interfaces ? When I hook up my laptop to one of the ports on switch1 I can only push about 30mbps whereas I max out my internet link (200mbps) when using a port on switch0. I’m also getting bad performance when going over wifi.
Any ideas ?
Really interesting and informative.
Thanks a lot.