The Ultimate DIY OpenWrt Build

My (for myself) ulitmate OpenWrt build

My build did not proceed in exactly linear fashion, but iterated several times, so this writeup may suffer some continuity issues. It is intended as notes and details on implementation, not a full HOWTO. Where possible, I'll try to remember to link to official documentation.

Be patient, and expect that this process will take a couple weeks. It took me the better part of a few months.

My stated goals:

  • Cheap

    I chose a Pogoplug E02. I got it cheap off of feeBay. It's well supported. It has better specs than you'll find in most routers. It has a decent number of USB ports.

    Only major drawback: Fiddling with the boot loader. If the person you buy it from hasn't unregistered it from Pogo, you can't enable shell access via the account. It's simply easier to have a USB-serial converter and pop the case open to do direct access.

  • Real Time Clock

    A RTC is a nicety, but mandatory for anything that needs the proper time at boot. The Pogo doesn't have one, so I'm adding one.

    Unfortunately, nobody just makes a USB-RTC, at least not inexpensively, so I have to make one from parts. Also, there seems to be little call for a pluggable RTC which can be used at boot, so I have to do some extra work.

  • Data usage tracking

    Since I'm using 3G/4G for my data, over-usage has implications -- namely, exceedingly high overage charges, but also possibly losing my account. So, usage tracking should be:

    • As accurate as possible. To the byte, preferably.
    • Reset with the billing cycle.
    • Have a visible and preferably physical display of usage.
    • Possibly cut off all traffic when maximum limit is hit.
    • Should not 'leak' - there should be no traffic unnacounted for.
    • Robust. State should survive reboots and network connections.
  • Battery-backed-up

    To handle power outages, the router should have an UPS. Not to operate, but so it can properly shut down during an outage.

  • A Good USB 3G/4G modem

    Currently, the Sprint network in my area suffered some storm damage, and they seem to have no plans to repair it until they do some upgrading sometime late in 2014. I have some Virgin Mobile modems which I had been using, but they have been becoming increasingly unusable. Even before that, the data rate was abysmal.

    The next iteration of my last-mile solution will be to take advantage of Millenicom's latest 'Jetpack 4620L' offering, and swap the 3FF SIM over to a Pantech UML290.

Step One: The Pogoplug

When I buy hardware, particularly gadgets, I intend to own it until it dies. This allows me the freedom to void its warranty.

See the Arch Linux ARM site for the Pogoplug Pink/Gray for the specs and other information, and the Doozan debian project about using Debian on a pogoplug.

I've done it once, but now I don't bother with the 'nice' way of altering a Pogo. I go directly to serial access.

  • I remove the clear outside, and then pop the shell open.
  • I use an FTDI usb-serial converter from Sparkfun, and a modified cable that may have been a Wake-On-LAN or CDROM audio cable
  • Using a serial terminal program (cutecom) on the desktop, I connect to the FTDI module, and then power up Pogo.
  • At this point, you can start to follow the instructions given on (IIRC) Doozan's pages about updating uBoot.

Step Two: OpenWrt build

See the OpenWrt Wiki. Read the wiki. Understand the wiki. Read about building OpenWrt.

Details to use:

  • Create configuration files for your build and place them in ${BUILDROOT}/files/, so they can be 'baked in' to the filesystem image. This allows you the luxury of editing them in your favorite editor, rather than through a shell with a barebones OpenWrt environment.

  • If you want to patch the kernel (and we will, in a moment), then you can put a patch for the kernel down in ${BUILDROOT}/target/linux/generic/patches-X.XX, where X.XX is whichever kernel version your build will be using (3.10 at the time of this writing).

Step Three: The RTC

Read "How to build a USB real-time clock".

I'm using stuff from Sparkfun: the AVRstick and Real-Time Clock Module (linked in above link).

His instructions are good. You can make the firmware, and flash the AVR. I ended up doing this over on my desktop which still has a parallel port, using a basic programmer. My avrdude command was:

avrdude -p t85 -c dapa -P /dev/parport0 -U lfuse:w:0xe1:m -U flash:w:firmware.hex -U hfuse:w:0xd7:m -U efuse:w:0xff:m

His patch for the linux kernel is also good - as is his advice for dealing with kernel programmers who are assholes because they have to deal with other assholes. His patch for i2c-tiny-usb is such an excellent idea, the OpenWrt devs ought consider adding it as a patch. As it is, it's easy enough for to add it to the OpenWrt build: Just rename it something like 999-i2c-tiny-usb_add_boot_device_parameters.patch and drop it in that directory, and it will be applied after everything else.

This means two things need to be done: the i2c-tiny-usb module needs to be included (set to '*' in the kernel_menuconfig), and the relevant boot arguments need to be added to the uBoot kernel boot arguments on the Pogo itself.

Step Four: The modem

Millenicom makes it a condition of subscription to buy the Jetpack. Fine, whatever.

The Jetpack is very nice, but there is something that rubs me the wrong way about having yet another 'black box' in the chain of technology between me and the internet.

  • While you can tether the Jetpack, you can't shut off the wifi. I don't feel like running a separate Pogoplug with wifi just for intrusion detection.
  • Google "mifi data fraud". There seems to be a problem with either how Verizon accounts for usage, how secure the device is (botnet backdoor in firmware, anyone?), or how corrupt Verizon is. Possibly all three.
  • While Verizon might give a (albeit questionable) report on data usage, you're not supposed to use Verizon tools to do so, due to Millenicom's contract with Verizon. Millenicom has their own tools for reporting data usage, but they only update every other weekday, and are still subject to questionable accuracy.
  • I've had my Millenicom Jetpack 4620L for a couple weeks now, and I can already tell it is unsuitable for long term use. It locks up, or goes dormant, or something else PFM that can't be worked around except by cycling the power or pulling the battery.
  • I want to keep an accurate account of data usage. This means a router, one that I control.
  • I don't just want to account for usage, I want a hard limit to usage. Again, this means a router that I control.

I chose to step down the tech ladder for a 'dumber' device: The Pantech UML290. There were noises on the internet that it could be used instantly simply by moving the SIM over, and there was linux support for it.

Unfortunately, the Pantech takes a 2FF SIM, which meant getting a 3FF-2FF SIM adapter. I bought two kinds: the first used a sticker to hold the SIM in place, and the second had a 'bottom' molded as part of the hole. Of the two, I'd say I prefer the molded one. The sticker idea is OK, but you have to trim the edges of the sticker very carefully, and the sticker doesn't sit perfectly because is has such a narrow side to stick to. There is also the problem that the sticker could possibly jam.

One detail online and one missing: You can find talk on evdo.info about Tip #72, using a Windows-only utility to lock the Pantech to either 4G or 3G. Based on my experimentation, this may be mandatory to use the Pantech with linux or OpenWrt, as I was not able to connect until I put the Pantech into either mode. I tried dialing the different numbers ( #99* vs #777 ) and different init strings, but to no avail. So, pick a mode and lock it.

I left it in 3G, primarily because I currently have a Wilson 3G amplifier with which it was going to be used, and secondly because I don't need to burn through my data allotment quite so quickly. Maybe I'll try 4G in the future, when I can afford to have 2 or more such modems, with 20GB Millenicom accounts each to burn through.

Supposedly, there might be a way to switch 3G/4G without the utility. Cradlepoint is supposed to have this ability in their 3G/4G routers, but this feature does not currently exist in OpenWrt.

Step Five: Custom configuration

Putting all this shit together now.

So, I've got my plug computer with 3 of 4 USB slots filled: thumb drive to boot off of, the AVRstick with clock, and a short USB extension cable to the Pantech modem.

Once the basic configuration is done for 3G, now I want to account for usage. I've elected to do this with iptables.

I've broken this part out into it's own page HERE.