What's new

MerlinWRT - compile instructions?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Well guys, if the guru's are having trouble, just think about us folks who aren't linux guru's.

Hmm... if one can't install a cross compile toolchain under linux and get it to work - then one shouldn't go there in the first place.

I'm not saying this in a mean way, but there are dragons... comments earlier in the thread made me realize that I should stop where I was at.
 
I successfully built an RT-AC86U firmware with these script.

Code:
### Install fresh Ubuntu 18.04 LTS (Bionic Beaver)
ubuntu-18.04.2-desktop-amd64.iso


### Apply OS updates and make bash the default shell (reboot required)
sudo apt-get update && sudo apt-get -y dist-upgrade && sudo rm -f /bin/sh && sudo ln -sf bash /bin/sh && sudo reboot


### Install Linux kernel headers and essential development tools
sudo apt-get update && sudo apt-get -y install git build-essential linux-headers-$(uname -r)


### Install dependencies for AsusWRT
sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get -y install libtool-bin cmake libproxy-dev uuid-dev liblzo2-dev autoconf automake bash bison bzip2 diffutils file flex m4 g++ gawk groff-base libncurses5-dev libtool libslang2 make patch perl pkg-config shtool subversion tar texinfo zlib1g zlib1g-dev git gettext libexpat1-dev libssl-dev cvs gperf unzip python libxml-parser-perl gcc-multilib gconf-editor libxml2-dev g++-multilib gitk libncurses5 mtd-utils libncurses5-dev libvorbis-dev git autopoint autogen sed build-essential intltool libelf1 libglib2.0-dev xutils-dev lib32z1-dev lib32stdc++6 xsltproc gtk-doc-tools libelf-dev:i386 libelf1:i386 libltdl-dev


### Install other programs
sudo apt-get -y install lzip patchelf


### Clone the toolchains
cd
if [ ! -d am-toolchains ]; then
  git clone https://github.com/RMerl/am-toolchains
fi


### Fix the toolchain symlinks
sudo mkdir -p /opt ; sudo rm -rf /opt/toolchains ; sudo ln -s ~/am-toolchains/brcm-arm-hnd /opt/toolchains ; sudo rm -f /opt/brcm-arm ; sudo ln -s ~/am-toolchains/brcm-arm-sdk/hndtools-arm-linux-2.6.36-uclibc-4.5.3 /opt/brcm-arm ; sudo rm -f /opt/brcm ; sudo ln -s ~/am-toolchains/brcm-mips-sdk/tools/brcm /opt/brcm


### Clone the repo
cd
if [ ! -d asuswrt-merlin.ng ]; then
  git clone https://github.com/RMerl/asuswrt-merlin.ng
  cd asuswrt-merlin.ng
#  git checkout master
  git checkout mainline
else
  cd asuswrt-merlin.ng
#  git checkout master
  git checkout mainline
  git pull
fi


### Create a build tree from the repo and fix the symlinks
cd
rm -rf asuswrt-merlin.ng-build
#rsync -aq asuswrt-merlin.ng/ asuswrt-merlin.ng-build --exclude .git
cp -a asuswrt-merlin.ng/ asuswrt-merlin.ng-build

# fix symlinks for HND toolchain
rm -rf ~/asuswrt-merlin.ng-build/release/src-rt-5.02hnd/bcmdrivers/broadcom/net/wl/impl51/main/src/toolchains
ln -s ~/am-toolchains/brcm-arm-hnd ~/asuswrt-merlin.ng-build/release/src-rt-5.02hnd/bcmdrivers/broadcom/net/wl/impl51/main/src/toolchains

# fix symlinks for ARM toolchain
rm -rf ~/asuswrt-merlin.ng-build/release/src-rt-6.x.4708/toolchains
ln -s ~/am-toolchains/brcm-arm-sdk ~/asuswrt-merlin.ng-build/release/src-rt-6.x.4708/toolchains


### Build RT-AC86U firmware (HND)
export LD_LIBRARY_PATH=/opt/toolchains/crosstools-arm-gcc-5.3-linux-4.1-glibc-2.22-binutils-2.25/usr/lib
export TOOLCHAIN_BASE=/opt/toolchains
echo $PATH | grep -qF /opt/toolchains/crosstools-arm-gcc-5.3-linux-4.1-glibc-2.22-binutils-2.25/usr/bin || export PATH=$PATH:/opt/toolchains/crosstools-arm-gcc-5.3-linux-4.1-glibc-2.22-binutils-2.25/usr/bin
echo $PATH | grep -qF /opt/toolchains/crosstools-aarch64-gcc-5.3-linux-4.1-glibc-2.22-binutils-2.25/usr/bin || export PATH=$PATH:/opt/toolchains/crosstools-aarch64-gcc-5.3-linux-4.1-glibc-2.22-binutils-2.25/usr/bin
cd ~/asuswrt-merlin.ng-build/release/src-rt-5.02hnd
make rt-ac86u


### Build RT-AC56U firmware (ARM)
export LD_LIBRARY_PATH=
export TOOLCHAIN_BASE=
echo $PATH | grep -qF /opt/brcm-arm/bin || export PATH=$PATH:/opt/brcm-arm/bin
echo $PATH | grep -qF /opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin || export PATH=$PATH:/opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin
cd ~/asuswrt-merlin.ng-build/release/src-rt-6.x.4708
make rt-ac56u


### Build RT-AC68U firmware (ARM)
export LD_LIBRARY_PATH=
export TOOLCHAIN_BASE=
echo $PATH | grep -qF /opt/brcm-arm/bin || export PATH=$PATH:/opt/brcm-arm/bin
echo $PATH | grep -qF /opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin || export PATH=$PATH:/opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin
cd ~/asuswrt-merlin.ng-build/release/src-rt-6.x.4708
make rt-ac68u


### Build RT-AC87U firmware (ARM)
export LD_LIBRARY_PATH=
export TOOLCHAIN_BASE=
echo $PATH | grep -qF /opt/brcm-arm/bin || export PATH=$PATH:/opt/brcm-arm/bin
echo $PATH | grep -qF /opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin || export PATH=$PATH:/opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin
cd ~/asuswrt-merlin.ng-build/release/src-rt-6.x.4708
make rt-ac87u


### Build RT-AC88U firmware (ARM)
export LD_LIBRARY_PATH=
export TOOLCHAIN_BASE=
echo $PATH | grep -qF /opt/brcm-arm/bin || export PATH=$PATH:/opt/brcm-arm/bin
echo $PATH | grep -qF /opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin || export PATH=$PATH:/opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin
cd ~/asuswrt-merlin.ng-build/release/src-rt-7.14.114.x/src
make rt-ac88u


### Build RT-AC3100 firmware (ARM)
export LD_LIBRARY_PATH=
export TOOLCHAIN_BASE=
echo $PATH | grep -qF /opt/brcm-arm/bin || export PATH=$PATH:/opt/brcm-arm/bin
echo $PATH | grep -qF /opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin || export PATH=$PATH:/opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin
cd ~/asuswrt-merlin.ng-build/release/src-rt-7.14.114.x/src
make rt-ac3100


### Build RT-AC5300 firmware (ARM)
export LD_LIBRARY_PATH=
export TOOLCHAIN_BASE=
echo $PATH | grep -qF /opt/brcm-arm/bin || export PATH=$PATH:/opt/brcm-arm/bin
echo $PATH | grep -qF /opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin || export PATH=$PATH:/opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin
cd ~/asuswrt-merlin.ng-build/release/src-rt-7.14.114.x/src
make rt-ac5300


### Build RT-AC3200 firmware (ARM)
export LD_LIBRARY_PATH=
export TOOLCHAIN_BASE=
echo $PATH | grep -qF /opt/brcm-arm/bin || export PATH=$PATH:/opt/brcm-arm/bin
echo $PATH | grep -qF /opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin || export PATH=$PATH:/opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin
cd ~/asuswrt-merlin.ng-build/release/src-rt-7.x.main/src
make rt-ac3200
 
Last edited:
I would like to thank every contributor on this thread..
A lot of ideas were exchanged and I appreciate it.
Especially Fitz Mutch - for the first time I could also compile the firmware without a glitch.
Your script is excellent.

I would like to start a new thread regarding a total new modular firmware design from scratch.... any votes for it?
 
I would like to start a new thread regarding a total new modular firmware design from scratch.... any votes for it?
I don't think that's practical (IMHO). If you want to go down that route look at (and use) OpenWRT. Consider how long and how much effort it took to get it to where it is today.
 
I would like to start a new thread regarding a total new modular firmware design from scratch.... any votes for it?
Several drivers are only available in binary format, so starting from scratch might be really hard...

Why do you want to vote? And who do you expect to act on the result?
 
I would like to start a new thread regarding a total new modular firmware design from scratch.... any votes for it?

It's called OpenWRT - the ARM based AC56U/AC68U/AC87U have some support - the MIPS devices of interest for most of the SNB community, e.g. RT-N66U is also supported.

You might miss out on some of the closed source sweetness - e.g. FA/CTF...

But I guarantee you it's an easier build.

Netgear's Orbi platform is built on a fork of OpenWRT, FWIW...
 
Morning fun :) Fitz Mutch script, thanks!


Code:
Creating ASUS RT-AC68U firmware to image/RT-AC68U_384.7_alpha1.trxit
TRX Image:
 Total Size .... : 37310464 (36436.0 KB) (35.6 MB)
 CRC-32 ........ : C3BA92F3

Ubuntu 18.10 dev
 
I would like to start a new thread regarding a total new modular firmware design from scratch.... any votes for it?
I like it!

If there is any way you can leave the feature AiMesh that works in the router and install the scripts like OpenWRT, that there are for Asuswrt-Merlin and that you're always up to date with the official firmware updates like Asuswrt-Merlin. I would use it.
 
Last edited:
How much space do you need?

I started with a 10 GB VirtualBox image on macOS, but it got completely full when cloning the repo...
 
I successfully built an RT-AC86U firmware with these script.

Code:
### Install fresh Ubuntu 18.04 LTS (Bionic Beaver)
ubuntu-18.04.1-desktop-amd64.iso


### Apply OS updates and make bash the default shell (reboot required)
sudo apt-get update && sudo apt-get -y dist-upgrade && sudo rm -f /bin/sh && sudo ln -sf bash /bin/sh && sudo reboot


### Install Linux kernel headers and essential development tools
sudo apt-get update && sudo apt-get -y install git build-essential linux-headers-$(uname -r)


### Install dependencies for AsusWRT
sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get -y install libtool-bin cmake libproxy-dev uuid-dev liblzo2-dev autoconf automake bash bison bzip2 diffutils file flex m4 g++ gawk groff-base libncurses5-dev libtool libslang2 make patch perl pkg-config shtool subversion tar texinfo zlib1g zlib1g-dev git gettext libexpat1-dev libssl-dev cvs gperf unzip python libxml-parser-perl gcc-multilib gconf-editor libxml2-dev g++-multilib gitk libncurses5 mtd-utils libncurses5-dev libvorbis-dev git autopoint autogen sed build-essential intltool libelf1 libglib2.0-dev xutils-dev lib32z1-dev lib32stdc++6 xsltproc gtk-doc-tools libelf-dev:i386 libelf1:i386 libltdl-dev


### Clone the toolchains
cd
if [ ! -d am-toolchains ]; then
  git clone https://github.com/RMerl/am-toolchains
fi


### Fix the toolchain symlinks
sudo mkdir -p /opt ; sudo rm -rf /opt/toolchains ; sudo ln -s ~/am-toolchains/brcm-arm-hnd /opt/toolchains ; sudo rm -f /opt/brcm-arm ; sudo ln -s ~/am-toolchains/brcm-arm-sdk/hndtools-arm-linux-2.6.36-uclibc-4.5.3 /opt/brcm-arm ; sudo rm -f /opt/brcm ; sudo ln -s ~/am-toolchains/brcm-mips-sdk/tools/brcm /opt/brcm


### Clone the repo
cd
if [ ! -d asuswrt-merlin.ng ]; then
  git clone https://github.com/RMerl/asuswrt-merlin.ng
  cd asuswrt-merlin.ng
  git checkout master
else
  cd asuswrt-merlin.ng
  git checkout master
  git pull
fi


### Create a build tree from the repo and fix the symlinks
cd
rm -rf asuswrt-merlin.ng-build
rsync -aq asuswrt-merlin.ng/ asuswrt-merlin.ng-build --exclude .git

# fix symlinks for HND toolchain
rm -rf ~/asuswrt-merlin.ng-build/release/src-rt-5.02hnd/bcmdrivers/broadcom/net/wl/impl51/main/src/toolchains
ln -s ~/am-toolchains/brcm-arm-hnd ~/asuswrt-merlin.ng-build/release/src-rt-5.02hnd/bcmdrivers/broadcom/net/wl/impl51/main/src/toolchains

# fix symlinks for ARM toolchain
rm -rf ~/asuswrt-merlin.ng-build/release/src-rt-6.x.4708/toolchains
ln -s ~/am-toolchains/brcm-arm-sdk ~/asuswrt-merlin.ng-build/release/src-rt-6.x.4708/toolchains


### Build RT-AC86U firmware (HND)
export LD_LIBRARY_PATH=/opt/toolchains/crosstools-arm-gcc-5.3-linux-4.1-glibc-2.22-binutils-2.25/usr/lib
export TOOLCHAIN_BASE=/opt/toolchains
echo $PATH | grep -qF /opt/toolchains/crosstools-arm-gcc-5.3-linux-4.1-glibc-2.22-binutils-2.25/usr/bin || export PATH=$PATH:/opt/toolchains/crosstools-arm-gcc-5.3-linux-4.1-glibc-2.22-binutils-2.25/usr/bin
echo $PATH | grep -qF /opt/toolchains/crosstools-aarch64-gcc-5.3-linux-4.1-glibc-2.22-binutils-2.25/usr/bin || export PATH=$PATH:/opt/toolchains/crosstools-aarch64-gcc-5.3-linux-4.1-glibc-2.22-binutils-2.25/usr/bin
cd ~/asuswrt-merlin.ng-build/release/src-rt-5.02hnd
make rt-ac86u


### Build RT-AC68U firmware (ARM)
export LD_LIBRARY_PATH=
export TOOLCHAIN_BASE=
echo $PATH | grep -qF /opt/brcm-arm/bin || export PATH=$PATH:/opt/brcm-arm/bin
echo $PATH | grep -qF /opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin || export PATH=$PATH:/opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin
cd ~/asuswrt-merlin.ng-build/release/src-rt-6.x.4708
make rt-ac68u


### Build RT-AC88U firmware (ARM)
export LD_LIBRARY_PATH=
export TOOLCHAIN_BASE=
echo $PATH | grep -qF /opt/brcm-arm/bin || export PATH=$PATH:/opt/brcm-arm/bin
echo $PATH | grep -qF /opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin || export PATH=$PATH:/opt/brcm-arm/arm-brcm-linux-uclibcgnueabi/bin
cd ~/asuswrt-merlin.ng-build/release/src-rt-7.14.114.x/src
make rt-ac88u

I see your script removes ng, is it possible to edit the script for legacy devices like N66?
 
Hm. Lots of fatal errors on first attempt to build AC86U firmware...

Code:
fatal: not a git repository (or any of the parent directories): .git


(after increasing the size to 20 GB and cloning again)
 
Last edited:
Hm. Lots of fatal errors on first attempt to build AC86U firmware...

Code:
fatal: not a git repository (or any of the parent directories): .git


(after increasing the size to 20 GB and cloning again)
My VM is 100GB size with 23% virtual disk space used after successfully compiling RT-AC86U firmware.
 
My VM is 100GB size with 23% virtual disk space used after successfully compiling RT-AC86U firmware.
Hm. Tried again with a 30 GB virtual disk (64% used), but build failed again... (after several hours of compiling)
 
Hm. Tried again with a 30 GB virtual disk (64% used), but build failed again... (after several hours of compiling)
I don't know why it's different for you. Try keeping the .git directory when copying from the repo to the build tree.

I make this change to my script.
Code:
#rsync -aq asuswrt-merlin.ng/ asuswrt-merlin.ng-build --exclude .git
cp -a asuswrt-merlin.ng/ asuswrt-merlin.ng-build
 
I make this change to my script.
Code:
#rsync -aq asuswrt-merlin.ng/ asuswrt-merlin.ng-build --exclude .git
cp -a asuswrt-merlin.ng/ asuswrt-merlin.ng-build
This again failed for me, but this time not on filesystem issues. The 1 GB I assigned to the VM was not enough...

When I increased the VM memory to 4 GB I finally had a successful build (after several more hours)!

("successful" meaning a file called RT-AC86U_384.7_alpha1_ubi.w being created; I don't know how to verify it)
 
... When I increased the VM memory to 4 GB I finally had a successful build (after several more hours)! ...
Very good point. For the HND toolchain (routers RT-AC86U, AC2900, GT-AC5300), I wouldn't try it with anything less than 4GB memory, otherwise it will crash the Linux OS. Here's my VM details.
Memory: 4GB
Processors: 2
 
make a checksum and compare it with others, isnt this the way how to do, or will everyone get different firmwares?

Everyone is different, due to different paths, datestamps, etc...
 
My VM is 100GB size with 23% virtual disk space used after successfully compiling RT-AC86U firmware.

On your VM - rather than use swap (which will absolutely kill speed), allocate enough RAM (for HND, 2GB is plenty), and then install the zram-config package for the guest OS - makes a big difference...
 

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top