User Tools

Site Tools


Beginners guide to building your own firmware

The goal of this guide is to let you build your own flashable firmware in as few simple steps as possible. It is intended for Windows users and users who already have a Debian or Ubuntu server. You are required to have a 64 bit version of Windows and at least 8 GB free disk space. Setting up for building on a Mac will be very similar (Virtualbox is available), but I don't have one so I can't test it.

The main advantage of building your own firmware is that it compresses the files, so that you will have room for much more stuff. It is particularly noticeable on routers with 16 MB flash RAM or less. It also lets you change some options that can only be changed at build time, for instance the features included in BusyBox and the block size of SquashFS. Larger block size will give better compression, but may also slow down the loading of files.

Alternative guides to achieving the same goal: Quick Image Building Guide, Using the Image Builder.

1 - Getting a Linux server (for Windows user)

You will need access to a Linux build environment. ONE of the following approaches is possible.

  1. Run Linux.
    • If you already have a Debian/Ubuntu server you can skip to part 2.
  2. Windows 10 users can install Debian/Ubuntu from Microsoft Store (using Windows Subsystem For Linux) and skip to part 2.
    • To avoid issues, ensure you read this article: Windows Subsystem for Linux (WSL). WSL 2 is recommended but WSL 1 also works (but is slower).
    • Disabling the virus scanner will speed up the compilation. (But Virtualbox i.e. option 3 is still faster.)
    • After installing WSL, make sure to run these commands after installation:
      • sudo apt-get update
      • sudo apt-get upgrade
  3. Install Virtualbox, and then install a Linux distribution, and then set this up as a build environment.
    • Instructions for this follow below:

1.1 Get Virtualbox

This program will let you run a virtual Linux server on you Windows based computer. Download the newest version from and install using default settings.

1.2 Get a Debian image

Download the newest VirtualBox (VDI) 64bit Debian image (currently 9.3) from and unpack it using 7zip. 7zip can be downloaded from

1.3 Install the virtual server

  1. Start Oracle VM Virtualbox
  2. Click New
  3. Name: OpenWrtDev
  4. Type: Linux
  5. Version: Debian (64-bit). See here if 64-bit is not available.
  6. Hard Disk: Select “Use an existing virtual hard disk file” and choose the Debian .vdi file you just unpacked.
  7. Click Create
  8. Right click on the OpenWrtDev image and click Settings
  9. Select General, Advanced, Shared Clipboard: Bidirectional
  10. Select Shared Folders
  11. Right click Machine Folders and select Add Shared Folder
  12. Folder path: Click the down arrow, select Other and then the folder you want to share with the virtual Debian server (for transferring the firmware).
  13. Folder Name: Shared
  14. Select Auto-mount

1.4 Initial Debian setup

  1. Select the OpenWrtDev image and click Start
  2. Wait for it to finish booting and click
  3. Password:
  4. Click Activities, type term in the search field and click terminal

The interface for changing the keyboard is a bit weird, but you can find the correct place like this:

  1. Click Activites, type reg, click Region & Language
  2. Click + under Input Sources and then the vertical dots
  3. Click Other, select the language and click Add. You can now delete English.

From now on, whenever you should be in the terminal to type a command the syntax will look like this:

ls -l

meaning you should type ls -l and press enter (try it). Follow up questions with obvious answers like typing the passsword ( og confirming with y will not be included specifically in this guide. Cut and paste will unfortunately not work at this moment.

su -
nano /etc/apt/sources.list

You are now editing the list of servers to get updates from.

  • Delete the lines containing “deb cdrom”. Lines can be deleted with ctrl-k.
  • From the last two lines, remove the leading # and space, and the -updates after stretch. They should now look like this:
deb stretch main contrib
deb-src stretch main contrib
  • Type ctrl-x and then y and then enter to save and exit.
apt update
apt dist-upgrade

Log in and open the terminal again when it has rebooted.

su -
apt install linux-headers-amd64 make sudo

Click Devices (top line), select the last option (Install Guest Additions). The automatic install does not seem to work, so it doesn't matter if you select cancel or run.

sh /media/cdrom/

After this you will need to start the server again. Now you can change to a higher resolution so you get a larger window if you like:

  1. Click Activities, type disp in the search field.
  2. Click Displays, VBX
  3. Select a different resolution

And lastly (hopefully you can cut and paste now). Note that cut and paste only works for text without any kind of formatting. You may need to copy the text to notepad and then copy it from there to clean it up.

su -
adduser osboxes sudo
echo ' osboxes ALL=(ALL)   ALL' >> /etc/sudoers

Your virtual Debian server should now be set up correctly for following the rest of the guide. Congratulations. As a bonus, you now have a fully functional Linux computer that you can use for anything, and with the added safety of running it as a virtual machine. If you let the resolution match your monitor and select View/Full-screen mode there is almost no difference from a standalone Linux computer.

2 - Compiling OpenWrt

2.1 Initial check out of the code

Use the Quick Image Building Guide for the initial checkout, but to get the stable version you need to do this after you run “cd openwrt”:

git tag
git branch

This will give you a list of tag names for releases and development branches. Check out the one you want like this:

git checkout <tag or branch name>

Then continue following the Quick Image Building Guide

2.2 General tips on using the config system

You select a package using space one or more times. When you select something, always make sure it has a * and not an M in the selected field. * means it will be included in the image, while M means that it will only create a package for it, which kind of defeats the point of following this guide.

Except for choosing the target I suggest that you don't mess with the options above Base system. Also, in general, don't uncheck anything that is selected by default unless you really know what you're doing. If something is selected with “-*-” (so you can't uncheck it) it is because something else depends on it.

Instructions on how to include config files in the image (for instance from the backup you can download from the router): Custom files

2.3 Determining Target (Selecting the router model)

  1. Do a web search for <your router model> wikidevi. For instance, if you have an Asus RT-N56U then search for RT-N56U wikidevi. This would give as the first response on most search engines. Find CPU on the page. In the case of RT-N56U it says Ralink RT3662F. If you type / in the builder you can search for RT-N56U. This will give a bunch of hits, which among other things says Symbol: TARGET_DEVICE_PACKAGES_ramips_rt3883_DEVICE_rt-n56u. Notice the ramips part. Now select Target System. In the list you will find “Mediatek Ralink ARM” and “Mediatek Ralink MIPS”. Given the information we have you can probably guess that the correct choice is “Mediatek Ralink MIPS”.
  2. Select Subtarget. From the wikidevi page you know that it is a Ralink RT3662F, and the best fit in the list is “RT3662/RT3883 based boards”.
  3. Select Target Profile. Asus RT-N56U is now listed here, so you know you chose the correct target and subtarget.

2.4 Tips on what to include to get a functional image

  • Don't remove any of the default packages unless you know what you are doing. Some of them are crucial. See Saving firmware space
  • You'll probably want the LuCi web admin interface, so choose LuCi/Collections/luci. If LuCI is not available then you have not successfully checked out the feeds, or they have been removed. This can also happen if you for instance run make clean.
  • The selectable software is in the submenues from “Base system” and downwards. Start by going to LuCI / Applications, as this section lists the LuCI packages for the most commonly used software. Selecting them will also include the required dependencies.
  • When you build your own firmware you can't use the downloadable kernel packages (packages named kmod-<something>), so try to make sure you select everything you need. If you need more kernel modules later you will have to build a new firmware. It is also possible to select all the kernel modules using m and copy them to the router later if needed. Packages are placed in bin/targets/*/*/packages/.

2.5 Building the image



when you have selected what you want. This will take a very long the first time. Don't use the -j option mention in the Quick image building guide, it is asking for trouble.

If it completes without errors you should now have images. If not then try running

make -j1 V=s

to get more details about the error. A common mistake is to include packages that are mutually exclusive. After a successful build you can list the generated files using this command:

ls -l bin/targets/*/*/

Copy the image files to your shared Windows path:

sudo cp bin/targets/*/*/* /media/sf_Shared

Important: Make sure the image is at least about 500 KB less than the total amount of flash ROM, as some space is needed for configuration and other data. The absolute limit will vary depending on router model and how much configuration data you want to store. You can get an indication by being on the safe side the first time, and then check how much free space there is when you have installed it.

2.6 Starting over

To erase just the config:

rm ~/openwrt/.config

To check out a different version:

rm -rf ~/openwrt/

the follow part 2 of the guide from the start, except you can skip the sudo apt-get commands.

2.7 Further reading

For users:

Mostly for developers:

Don't hesitate to ask in this forum thread if anything in this guide is unclear.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
docs/guide-user/additional-software/beginners-build-guide.txt · Last modified: 2020/06/08 23:42 by ja