My father uses a WISP for his Internet access. His equipment malfunctioned recently and a technician came out to examine the antenna. He discovered that the circuitry inside it had failed; instead of throwing it away, he offered it to me.
Meet the MicroTik Routerboard 411.
The specs:
- 300MHZ AR7130 CPU
- 32MB RAM
- 4MB NAND Flash
- AR5413 802.11a/b/g MiniPCI wireless radio
- Serial port
- 1 Fast Ethernet port (supports PoE over non-data pairs, 10-28V)
- MicroTek RouterOS
- Professional low-gain adjustable wifi antenna (Oh, no, wait–that’s aftermarket!)*
The cause of the board’s failure is evident in the photos; four of the five capacitors on the board have vented. As a result, the board has trouble booting up with some power supplies and is very picky about voltages. However, I found one power brick that provides just the right voltage for it to boot up without errors. (I’m waiting on replacement capacitors to solder in.)
Once I got the router to boot, I tried logging in to the admin panel. However, the default RouterOS username/password combo didn’t work, and I’m not a huge fan of RouterOS anyhow, so I decided to put OpenWRT on the device for a test run. OpenWRT is a Linux-based router firmware distribution. The Routerboard is one of the many devices supported by OpenWRT.
I began by gaining access to the router’s bootloader, which behaves much like the BIOS in a computer. The bootloader is stored in a section of the router’s flash memory and is the first code that runs when the router is powered on. Most routers offer access to the bootloader via a serial cable, although very few have an actual serial port like the Routerboard–the other router I’m working on at the moment has a 4-pin serial header on the circuit board. More on that in another post. Since this router has a serial port, all I needed was a cable and a null-modem adapter, which swaps the transmit and receive lines.
My serial cable is a cheap USB->Serial adapter. When plugged in, Linux produces the device /dev/ttyUSB0. To talk to the router, I used GNU Screen, which is secretly a serial console. The command is as follows:
screen /dev/ttyUSB0 115200
115200 is the router’s baud rate. This is specific to certain manufacturers, although 115200 and 9600 are common. Firing it up and then plugging in the router, this appears:
Pressing a key brings up a menu with various settings:
…from here, I chose Ethernet as a boot device:
Now, instead of loading from the NAND flash memory, the router will try to load firmware from the network via TFTP, which means we need a TFTP server! Since my laptop had dnsmasq on it, I used that. I was too lazy to write a configuration file. Instead, I ran it from the command line:
dnsmasq --tftp-root=/tftpboot --enable-tftp --dhcp-boot=boot.bin --dhcp-range=192.168.100.25,192.168.100.60 -d
I don’t know if the dhcp-range is necessary; it may not be. It worked the first time I tried it, so I didn’t experiment with the dnsmasq command line. Note that by default the router appears to use BOOTP; if you’re using something other than dnsmasq, you may need to change this to DHCP in the “boot protocol” menu of the bootloader.
Note that you’ll need to either add a firewall exception for DHCP/TFTP or, if you’re impatient, just disable it entirely. In addition, you’ll need to give your network interface a static IP address on the appropriate netblock. I chose 192.168.100.1.
Now dnsmasq is running and is ready to serve up the file boot.bin from /tftpboot to any device that requests it on bootup. What is boot.bin? It’s OpenWRT itself.
I decided to build OpenWRT from source because 1) I was bored and 2) I wanted the experience. It turns out, it’s very easy. The OpenWRT wiki has several pages on building OpenWRT from source. Unfortunately, the documentation is split into multiple pages and some of them contradict each other. Here’s a good place to start. My workflow went something like this:
- Fetch the OpenWRT source and install prerequisites.
- Update the feeds
- Install only the feed I needed (luci)
- Run make menuconfig
- Use the convenient “Disable Unnecessary Packages” script here (scroll down) so you don’t build everything.
- Run make menuconfig again
- Build it
In detail:
1. Fetch source and prerequisites
Easy. Follow the directions. You’ll want Attitude Adjustment or trunk.
2. Update the feeds
Also easy. Follow the directions.
3. Install necessary feeds
What feeds are necessary? The only feed I found to be necessary was “luci”. This is the web GUI for OpenWRT. You probably won’t be very happy without it. Install it using the feeds scripts.
4. Run make menuconfig
And this is where we configure a billion options! Actually, just a few. Use the keyboard arrows to navigate, Enter to go into a submenu, Spacebar to toggle between selections, and Esc to go back. Entries with a —> are submenus. You’ll want to set the following:
- Target: Atheros AR7xxx/AR9xxx
- Subtarget: Devices with NAND flash (mostly Microtek)
- Target Profile: Atheros WiFi (ath5k)
Uncheck the following:
- Build the OpenWRT SDK
- Build the OpenWRT based toolchain
Under image configuration, select “ramdisk”. (At least, that’s what I did–I wanted to test OpenWRT BEFORE flashing it.)
Keep pressing escape until it asks you to save, and tell it to save the information. This puts the configuration into a file called .config.
5. Run the “disable unnecessary packages” script
Do you want to build a billion packages? Do you want to increase your carbon footprint unnecessarily? Neither do I! Take the script, (scroll down), put it in a file called disable.pl in the root directory of your openwrt source, and do the following:
perl disable.pl > newconfig mv newconfig .config
6. Run make menuconfig again!
Because repetition is fun. Repetition is fun! Repetition is fun, especially if you change something just a little bit each time so your audience doesn’t catch on to the fact that repetition is fun too soon. The second time you runĀ make menuconfig, go down to LuCI, then Collections, then checkĀ luci. Exit out and save your changes.
7. Build it
make V=s -j5
Adjust the number after the -j according to the formula (number of CPU cores + 1). Now walk away and go do something else for an hour or so. Read a book. Listen to music. If you see build errors, you’re likely missing prerequisites. Be aware that OpenWRT will download lots of stuff, so if you have a metered connection, this might be something worth doing at a friend’s house or, if you’re a college student, at campus.
In the end, your shiny new image should be in bin/ar71xx/. Copy the file openwrt-ar71xx-nand-vmlinux-initramfs.elf to /tftpboot/boot.bin and start DNSMasq (if you haven’t already).
Now the router is ready to rock! Reboot it. You should see the bootloader print information about loading the image from the network. A moment later, you should see the OpenWRT kernel start. After it’s booted up, change your IP address to 192.168.1.2 (or run dhclient so OpenWRT can give you an IP address on the appropriate netblock) and access 192.168.1.1 in your browser.
The next step is to put OpenWRT on the NAND flash memory itself, overwriting RouterOS. I’m holding off on this until I have replacement capacitors.
So what could this little router be used for? It has only one Ethernet port. This brings to mind some possible scenarios:
- Wireless access point
- Wireless bridge
- Wireless-only router
In addition, with a VLAN-capable switch attached to the router, it would be possible to use this device as a wired router as well. Most routers use some sort of VLAN-capable programmable switch internally to separate the WAN port from the LAN ports. I don’t have an external VLAN-capable switch so I haven’t tried this yet.
Stay tuned!
* The antenna was borrowed from another router and stuck into the bottom of a yogurt cup, a-la Michael Weston. C’mon, don’t look at me like I’m some kind of cannibal. it had two antennas! It only needs one!
If you are an employer you need to hire this guy!
PS My website is not up yet!