Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

Compile Firmware from source using Ubuntu

Oliver Schneider edited this page Jan 31, 2015 · 49 revisions

WARNING DESPITE THE FACT THAT IT IS POSSIBLE TO COMPILE YOUR OWN FIRMWARE, I DO NOT ADVISE YOU TO DO SO THIS GUIDE IS NOT WRITTEN BY A PROFESSIONAL BUT BY AN AMATEUR<>NOVICE THERE ARE A LOT OF THINGS THAT COULD GO WRONG DURING THE PROCESS THE AUTHOR OF THIS GUIDE NOR THE SOURCE PROVIDER CAN BE HELD RESPONSIBLE FOR ANY DAMAGE THAT MAY OCCUR BY FLASHING YOUR SELF COMPILED FIRMWARE ON YOUR ROUTER IF YOU REALLY WANT TO LEARN THIS TYPE OF COMPUTING AND CODING I SUGGEST YOU FIRST GET FAMILIAR WITH LINUX

But on the other hand your router is VERY hard to brick!

For the reference we are going to use Ubuntu 12.04 in VMware Player. You can download Ubuntu Here And VMware Player Here

When you have both install VMware Player.

Follow these steps :

  • Create a New Virtual Machine

Create

  • Select Installer disc image file (iso) ( VMware Player will tell you something about easy install, that's okay )

![Select Iso] (http://members.home.nl/frits.pruymboom/Howto%20Compile%20From%20Source/installer%20disc%20iso.png)

  • When installing Ubuntu it asks for a username it's best if you just name it ''router'' without the quotes because then you can just copy and paste from this guide no need to make everything complicated.

Name

  • Give it about 20 GB afterwards you can delete your virtual Ubuntu anyway.

20gb

  • Crank up some specs give it some more ram and procesing power, It doesn't sound as a heavy work load but making your .trx image for the router actually takes a long time on a slow processor

customize

crank

When the Ubuntu installer has finished you can fire up terminal

  • Fire up terminal CTRL+ALT+T

We are going to make the root account active because if we don't do that it will give us a lot of errors during compilation.

Paste in the following lines in terminal

sudo passwd root 

  • It will now ask you for your new ROOT password ( confirm this twice and be sure to remember it we need it ! )

Paste in

su

As you can see you are now running the terminal in root!

root

  • We are going to download some packages ( I am sure there are some you don't need, but this is how I got it working and you can delete Ubuntu afterward so who cares right ? )

Paste in

sudo apt-get install autoconf automake bash bison bzip2 diffutils file flex m4 \
g++ gawk groff-base libncurses-dev libtool libslang2 make patch perl pkg-config \
shtool subversion tar texinfo zlib1g zlib1g-dev git-core gettext libexpat1-dev \
libssl-dev cvs gperf unzip python libxml-parser-perl gcc-multilib gconf-editor \
libxml2-dev g++-4.4 g++-multilib gitk libncurses5 mtd-utils libncurses5-dev \
libstdc++6-4.4-dev libvorbis-dev g++-4.4-multilib git autopoint autogen sed \
build-essential intltool libelf1:i386 libglib2.0-dev automake-1.11

If you have Ubuntu x64 edition then you need lib32z1-dev and lib32stdc++6

sudo apt-get install lib32z1-dev lib32stdc++6

If you are ready installing all these packages take a coffee or a beer.

We are going to download merlins hard work with again some terminal commands. It appears as if scripts published in support forums all assume the clone is done off of root, so first we change to the root directory.

cd /root
git clone https://github.com/RMerl/asuswrt-merlin.git

Be patient it takes some time

With these command you will build your environment which you will need to work with.

sudo ln -s ~/asuswrt-merlin/tools/brcm /opt/brcm
sudo ln -s ~/asuswrt-merlin/release/src-rt-6.x.4708/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3 /opt/brcm-arm
export PATH=$PATH:/opt/brcm/hndtools-mipsel-linux/bin:/opt/brcm/hndtools-mipsel-uclibc/bin:/opt/brcm-arm/bin
sudo mkdir -p /media/ASUSWRT/
sudo ln -s ~/asuswrt-merlin /media/ASUSWRT/asuswrt-merlin

We are now ready to build a image

  • For RT-N16
cd ~/asuswrt-merlin/release/src-rt
make clean
make rt-n16
  • For RT-N66U
cd ~/asuswrt-merlin/release/src-rt-6.x
make clean
make rt-n66u
  • For RT-AC66U
cd ~/asuswrt-merlin/release/src-rt-6.x
make clean
make rt-ac66u
  • For RT-AC56U
cd ~/asuswrt-merlin/release/src-rt-6.x.4708
make clean
make rt-ac56u
  • For RT-AC68U
cd ~/asuswrt-merlin/release/src-rt-6.x.4708
make clean
make rt-ac68u

Notes for Ubuntu 13.10:

If you want to build in Ubuntu 13.10, before you make clean / make [router], you might need to perform these steps due to the different version of autoconf.

This works to build 3.0.0.4_374.38_1.

sudo apt-get install libproxy-dev
# fix neon missing proxy.h
cp /usr/include/proxy.h ~/asuswrt-merlin/release/src/router/neon/
# fix broken configure script for libdaemon
cd ~/asuswrt-merlin/release/src/router/libdaemon
aclocal
# fix broken configure script for libxml2
cd ~/asuswrt-merlin/release/src/router/libxml2
sed -i s/AM_C_PROTOTYPES/#AM_C_PROTOTYPES/g ~/asuswrt-merlin/release/src/router/libxml2/configure.in
aclocal

All in one script

Last tested on master as of 2015-01-25. The script takes care of the steps mentioned above for Ubuntu 13.10 and newer. In addition it does fixups to the source tree which ensure that it can run without superuser rights as long as the user makes sure all the packages are installed. It will also check for the packages being installed and bail out with a meaningful error message if not.

It can be run in two modes: with or without sudo involved. With sudo it will use the symbolic link method inside /opt, whereas without it will modify the files in the source tree to adjust hardcoded paths.

If you are running inside a tmux pane, this will also pipe the output into a log file.

Syntax

  • Unprivileged: ./ubuntu-build-image <router-model> [path-to-asuswrt-merlin]
  • With sudo: USE_SUDO=1 ./ubuntu-build-image <router-model> [path-to-asuswrt-merlin]

You can leave out the path-to-asuswrt-merlin argument and the script will check the folder it resides in for a marker file (README-merlin.txt) to see whether this is the expected source tree.

Any non-empty value for USE_SUDO can be used and you can of course also export it up front, instead of prepending it to the command line.

The script

The latest version can always be found at assarbad/build-asuswrt-merlin. Please report issues there as well.

Clone this wiki locally