OpenWRT Build Guide: Get custom firmware in two easy steps.
OpenWRT Build Guide: Get custom firmware in two easy steps.
The following guide will show you the downloading, configuring, and compilation of OpenWRT. The guide makes no assumption about the reader’s previous experience with OpenWRT, or even building from source, so as long as you follow along you should be fine. That said, experience with compiling software and general troubleshooting skills would help make sure the process goes smoothly.
Lets begin.
1) First you will need a Linux running machine, I use an Ubuntu Server running on my virtual machine “Parallels Desktop”. After your Linux machine is up and running, you’ll need to prepare your system for building packages from source.
2) Install packages that you will need for getting, installing and compiling the openWRT image Builder.
sudo apt-get install subversion build-essential libncurses5-dev zlib1g-dev gawk flex quilt git-core
3) After the packages has been installed, prepare the working directory and download the source. We are recommending to NOT do those steps as a ROOT, and make your source dir somewhere in your /home directory, to avoid problems during your compilation.
mkdir ~/OpenWRT cd OpenWRT svn co svn://svn.openwrt.org/openwrt/trunk/ cd trunk
4) After you got OpenWRT downloaded on your system, you now have everything you need to build a minimal firmware image for your router. But depending on what you want to do, there might be additional software outside of the stock OpenWRT tree that you want to include in your final firmware image. OpenWRT includes a tool called “feeds” which helps find, update, and install these additional packages, which you should run before going any farther if you wish to include any of them. To start using the “feeds” tool, you first need to tell it which repositories you want to include. This is done through a file in the root of the OpenWRT source called “feeds.conf.default”. Opening it up in your text editor of choice should present you with the following:
src-svn packages svn://svn.openwrt.org/openwrt/packages src-svn xwrt http://x-wrt.googlecode.com/svn/trunk/package src-svn luci http://svn.luci.subsignal.org/luci/trunk/contrib/package #src-svn phone svn://svn.openwrt.org/openwrt/feeds/phone #src-svn efl svn://svn.openwrt.org/openwrt/feeds/efl #src-svn xorg svn://svn.openwrt.org/openwrt/feeds/xorg #src-svn desktop svn://svn.openwrt.org/openwrt/feeds/desktop #src-svn xfce svn://svn.openwrt.org/openwrt/feeds/xfce #src-svn lxde svn://svn.openwrt.org/openwrt/feeds/lxde #src-link custom /usr/src/openwrt/custom-feed
Here we can see that only the first three repositories are enabled, as everything else is commented out with the “#” character. For most tasks the first three repositories should be sufficient, but if you are looking to get into the more advanced territories, like installing X and using graphical tools on it, you’ll need to enable the appropriate repositories in this file by removing the “#” signs before each line.
5) Now that we’ve enabled the repositories we want to use, the next step is to download the list of available packages by running the following command from within the OpenWRT source tree:
scripts/feeds update -a
6) Install packages that you will use in the future, in my example i’m installing the package for L2TP support called “xl2tpd”, and luci for over web configuration “luci:
scripts/feeds install xl2tpd luci
7) With the OpenWRT source (and any additional packages) installed, you can move on to configuring the actual build so it is tailored to both your hardware and the tasks you want to perform. The menu system for configuring OpenWRT is identical to what is used to configure and compile the Linux kernel itself, so if you’ve ever built a custom kernel you should feel right at home here. To start the process, run the command:
make menuconfig
You should see the following screen:
This is the main screen for configuring OpenWRT, here you’ll see an overview of what hardware you’ll be building for and what software and libraries will be built into the image. The top of the window shows instructions on how to interact with the menu selections, and you can select “Help” to get more information about most menu selections.
The first part of configuring OpenWRT is to select what hardware you’ll be building with with the top two items:
Target System: The core architecture for your device, check OpenWRT Wiki if you don’t know what it is.
Target Profile: Specific router make/model. Not all models have specific build profiles, otherwise, the default generic profile will probably work.
Going down the list, the next couple options should be:
Build the OpenWRT Image Builder Build the OpenWRT SDK Build the OpenWRT based Toolchain
The next option that will be of interest to us is “Base system”, which will let you pick individual software packages you wish to include in your firmware:
After you’re done selecting which of the base packages you need, back out of that screen and select “Libraries” from the main menu. That will present you with the same type of menu as “Base system”, but this time you’ll be going through the system libraries.
With your libraries selected, you can go back up to the top menu and chose the next category on the list. Depending on what (if any) optional packages you included earlier, you may see different categories listed. The process with all of the categories is the same, go into them, select the packages you want to include or exclude from the final image, and then back out to the main menu to proceed down to the next selection.
When finished going through all the categories of software, you can back out of the menu system entirely. Make sure to confirm that you want to save your OpenWRT configuration when it asks you.
8) With all of your packages selected and your configuration saved, you’re ready to build your firmware. Type in the simple command: make and this will launch the compilation.
9) Hopefully the build process went well for you and didn’t take a ridiculous amount of time to complete. If you got to the end and there were no errors, then you should have firmware images for your hardware created under the /bin directory of the OpenWRT source. For example, when building for my TP-Link MR3220, I get the following files:
./bin/ar71xx/openwrt-ar71xx-tl-mr3220-v1-squashfs-factory.bin ./bin/ar71xx/openwrt-ar71xx-tl-mr3220-v1-squashfs-sysupgrade.bin
The first file, factory.bin, is for flashing over the original firmware your device came with. The second file, sysupgrade.bin, is for upgrading an existing OpenWRT installation. Don’t try to flash a sysupgrade.bin file over your stock firmware, as the results can be unpredictable.
Follow the device-specific instructions from the OpenWRT Wiki to find out the exact process required to replace your device’s stock firmware with this brand new image. Some devices allow you to install any image you like through their web configuration, other devices may require more exotic installation methods.
UPD for Vocore Users
Your steps will be a little bit different. First of all, in the make menuconfig menu you need to set options for vocore compilation: 1) Target System –> Ralink RT288x/RT3xxx 2) Subtarget –> RT3x5x/RT5350 based boards 3) Target Profile –> Vocore
4) make 5) After the compilation is done, you will find your firmware in ./bin/ramips/openwrt-rt305x-vocore-squashfs-factory.bin 6) Copy your new firmware to your vocore board in /tmp 7) I usually rename it to something like up.bin 8) Via terminal connected to your router, or you us SSH, or connected directly, type sysupgrade -v /tmp/up.bin 9) Enjoy!













