Creating a Vagrant virtual machine for OpenWRT

Since my last post, there have been many great improvements to Micah’s Fadecandy project and the “fcserver” application I ported for Atheros-based OpenWRT devices. I didn’t really keep up with things and only just released builds with the newer versions. They’re at the same download URLs, just in release2. https://github.com/nemik/fadecandy-openwrt/releases/tag/release2

To keep this from happening again, it seems like a good idea to show people how to make their own OpenWRT builds with “fcserver” and other things they might want. The buildroot for OpenWRT is simple but can still be a challenge sometimes.
That’s why the Vagrant http://www.vagrantup.com/ virtual machine helper is so awesome. It makes using virtual machines very easy on just about every platform. Unfortunately the complete Vagrant box with OpenWRT buid-root is over 2.7GB and is too much for me to host here for download. If anyone wants to help with this, please get in touch.
But in the meantime, I’ll show you how to do the same thing yourself.

1. Download and install Vagrant for your OS from http://www.vagrantup.com/
2. Set up a Debian-Wheezy-based Vagrant box. Download “Debian Wheezy 7.2 amd64 (VirtualBox Guest Additions 4.3.0) (2013/10/19)” from http://www.vagrantbox.es/
3. Save this to some directory for this project, call it “openwrt_vagrant”
4. Run vagrant box add fadecandy-openwrt debian-7.2.0.box to add the box
5. Download my Vagrantfile from http://nemik.net/x/Vagrantfile into the directory. This is the config for it, it will make the virtual machine run on IP “192.168.44.10”
6. Run vagrant init fadecandy-openwrt to initialize the box
7. At this point it should be all set up, so let’s start the virtual machine with vagrant up
8. The box should come up successfully, and when it does, SSH into it with vagrant ssh. You can also do this by doing: ssh -i ~/.vangrant.d/insecure_private_key vagrant@192.168.44.10
9. Now we’re inside the Debian system! We should update it with sudo apt-get update and then sudo apt-get upgrade
10. The upgrades will require a restart of the box. Exit from it with Ctrl+d or the exit and then shut down the vagrant machine with vagrant halt. Then start it up again with vagrant up and SSH back in like in step 8
11. When SSH’d back into the box, let’s install the build dependencies needed for building OpenWRT. sudo apt-get install subversion build-essential git-core libncurses5-dev zlib1g-dev gawk
12. Now let’s get OpenWRT source with git clone git://git.openwrt.org/openwrt.git
13. Go into the new source directory with cd openwrt
14. Add my package to the feeds. Edit the “feeds.conf.default” file with vim or nano and add the line “src-git fadecandy git://github.com/nemik/fadecandy-openwrt.git” to the file
15. Update and install the packages from the feeds by running ./scripts/feeds update -a followed by ./scripts/feeds install -a
16. It’s now time to set up the OpenWRT build configuration. Run make menuconfig
17. In the menu, change your “Target Profile” to the device you’re targeting, like say a TP-Link TL-MR3040
18. Turn off the firewall too so we don’t have to open more ports. Go to “Base System” and press space until “firewall” isn’t selected anymore.
19. Go to “Utilities” and scroll down to “fcserver”. Press space on the option until it’s a star “*” and then exit from the menu and save it.
20. Download some static files to go into the OpenWRT OS from http://nemik.net/x/openwrt-fc-files.tar.gz. Run wget http://nemik.net/x/openwrt-fc-files.tar.gz and then tar xzvf openwrt-fc-files.tar.gz These file set up the default root password, wifi access point, and things like that.
21. Now to finally do the build. For this, just run make
22. That should be it! If this finished successfully, you’ll have a build in “bin/ar71xx/” with the name “openwrt-ar71xx-generic-tl-mr3040-v2-squashfs-sysupgrade.bin” just like the ones I’ve been releasing.