Create new virtual machine and install Ubuntu from step 2 to it. VirtualBox may use a ISO-image as drive in virtual machine.

If you plan to use Ubuntu with the GUI, you must dedicate at least 1.5Gb of RAM for the virtual machine. When you select a smaller size of RAM you may receive errors when you create the image of the firmware.

Start your virtual machine and open Terminal on it.

Install git:

sudo apt-get update
sudo apt-get install git

Go to directory /opt and run command for create the local copy of repository:

cd /opt
sudo git clone https://bitbucket.org/padavan/rt-n56u.git

This copies all the source code, creates a local git-repository. Directory /opt/rt-n56u will be the root of the git-repository.

Read the document /opt/rt-n56u/readme.eng.txt and install all the required packages that are listed in it:

The result will be collected the target of toolchain /opt/rt-n56u/toolchain-mipsel/toolchain-3.0.x

In the future, you will need these commands only if the toolchain will be updated.

Now go to directory with sources:

cd /opt/rt-n56u/trunk

and edit file /opt/rt-n56u/trunk/.config to fit your needs.

Edit path to toolchain (if you need it):

CONFIG_TOOLCHAIN_DIR=/opt/rt-n56u/toolchain-mipsel

To build the firmware, for example, for router RT-N65U uncomment (remove the simbol #) the line:

CONFIG_FIRMWARE_PRODUCT_ID="RT-N65U"

and comment the line:

#CONFIG_FIRMWARE_PRODUCT_ID="RT-N56U"

Save the file after edit.

Clear source tree (every time before a new build)

sudo ./clear_tree

Build the firmware:

sudo ./build_firmware

Created custom firmware file will be in the directory ./path_to_your_dir/rt-n56u/trunk/images. If you want to save the firmware that you created earlier - copy it to another location, because the command clear_tree overwrites the directory images.

When repository updated a local source tree must be updated with command:

sudo git pull

If you made ​​any changes to the local repository, when you upgrade tree some files could not be copied. In this case, you must give the command:

sudo git stash
sudo git pull

If toolchain sources (cross-compiler and tools for building) is changed you must re-build it: