OpenWRT for Raspberry PI


This site has served many, but it's time to go upstream again, and now I have created a patch that allows OpenWRT to use RPI-specific kernel
directly. Instructions for building a image, can be found from this site. I will still keep this site online for awhile, but am going to remove it
as deprecated. Another site doesn't have ready to install image, but a patch for OpenWRT sources directly, so you can build your own.


OpenWRT supports Raspberry PI now. Unfortunately there is still a lot of work. I wanted to run OpenWRT
on my Raspberry PI and noticed that it's not yet suitable for production environment. Here are some issues I spotted:
  • SD Card failures: suddenly something happens and root filesystem is in readonly mode. No way to recover, expect by a reboot. (mount -o remount, rw /dev/root did not work)
  • Non-working/missing kernel modules: many of us want to add a RTC clock to raspberry, well, currently OpenWRT's kernel and modules don't have proper support for i2c. Nor many other peripherals available for RasPI. Well, even with working i2c.. I would still be missing modules for rtc devices, such as rtc_ds1307 (which supports ds1338 that I have installed to my Raspberry PI)
  • Rebooting issue. Only way to reboot is this: kill -9 <pid of watchdog> - or killall -9 watchdog. Actually this is not entirely true, as there's a patch for this.. It just hasn't been included yet in images available at openwrt site's downloads section.
  • Boot issue: didn't boot out-of-the-box on my Raspberry Pi model B with bigger memory.. Had to get newer bootcode.bin and other files from git first and update configurations..
Patch that I am talking about is included in openwrt build tree available from here:
They might have more patches available as well, which might fix other problems as well, but I am not sure about them. Also at the moment, page doesn't have up-to-date image with patch enabled, one at openwrt's site is newer I think. 
To get up-to-date and patched imaged, you need to compile openwrt manually with their git tree.. I wasn't able to add luci and other add-on software feeds to their tree properly, or compile it anyhow, since I am using Mac and wasn't interested of setting up a virtual machine for a rather lengthy process that might fail at the moment.. So I was thinking about a shortcut to working system.. My first idea was to use another distribution and first I thought Gentoo as it is one of my all time favourite Linux distributions.. Well, I have plans for my Raspberry and I should be doing that instead of installing system - which after all might not be as good as I thought anyway for my needs. Something minimal.. And I found Moebius. It's minimalistic Raspbian, sounds good. Except, I never have felt like home in Debian/Ubuntu environment. This wasn't an exception. Something good anyway, I updated my Moebius to up-to-date, so vfat boot partition is up to the latest, and all the kernel modules as well.. Then it hit me.. Could I make OpenWRT system work.. With kernel and modules from another distribution? Oh yes I can.

Modules from Moebius didn't fit on partition by default openwrt.. So I used gparted to change partition sizes.. Not much.. But enough for my purposes.. After all, this is just test at the moment..

So I just copied contents of boot partition and modules, installed latest openwrt image again and copied modules there. Then I replaced the boot partition with Moebius's boot partition and crossed my fingers. Lots of errors. These were because OpenWRT's default init is /etc/preinit - and raspbian uses propably /sbin/init. Well, this can be fixed with a kernel command-line change - and voila. A working OpenWRT environment with kernel and modules compiled with Hard Float. And it works, feels stable, no more SD card problems and I have a lot of modules available. I2C support is there, and so is rtc support. I made i2c work by changing scripts in /etc/modules.d and added rtc there too. This isn't enough so I also added a /etc/init.d/hwclock script which enables and starts RTC support, sets up time from RTC on startup and saves it on exit. Perfect.

Add init=/etc/preinit to kernel's command line to make the magic work..

I also changed settings, so now when you install this image, Raspberry uses DHCP client to get IP address, instead of initial which is all-time favourite and default of OpenWRT usually.. Also I killed dnsmasq, as I have router running OpenWRT so, it's very un-likely that one is going to be using RasPI as dhcp server. Well, dnsmasq is still there, it's just initially disabled. Also I disabled firewall, one network shouldn't be having so many firewalls, except for a good reason.. Only thing that I forgot, I was supposed to disable my hwclock script as well, so if you don't have a RTC ds1307/ds1338, just enter /etc/init.d/hwclock disable. Of, I also installed nano. If you don't want it.. Do opkg remove nano.

Okay, it's not perfect-- It's a bloody hack. But pretty nicely performing hack :)

And it's not that small anymore.. ALL those modules take a lot of space.. With this guide you should be able re-produce my work.. 
But a binary image is available at downloads as well. It's bz2 packed and in packed format it takes 84mb and as unpacked it takes 228mb - small enough to fit to 256mb SD..
One could think of that my image is huge!!! Well it ain't. It has 64mb vfat partition 1 with bootfiles. All that 64mb hasn't been used. Root filesystem is ext4 formatted and contains modules and OpenWRT system, I have sized it to 160mb. Don't worry, all these hasn't used either.. I cannot remember now how much of space has been consumed- but it should be less than 100megabytes. OpenWRT does not come with gparted, so resizing partitions is a bit hard, so I gave some space for you to get started with. Also - you can free a lot of space - by removing every module you don't need. Also, there's cutdown version of kernel and modules, if you don't use those- remove 'em. Or if you use, remove normal versions. Just back them up somewhere so you don't need to re-write your SD from scratch if decide that you need something, after all.. So a 256mb SD card still has 28 unused megabytes, what is this for? You decide that..