Building WL500GP firmware from scratch

From Crashcourse Wiki

Jump to: navigation, search

WARNING: There appears to be a serious issue with building images from the git or Subversion source repositories. See the relevant section at the bottom of the page.

Contents

Overview

This page describes how to build a new flashable .trx image for your WL500GP, starting from the source, and how to re-flash your router with the end result.

NOTE: While this page was written specifically for the WL500GP, the general recipe should be applicable to pretty much any OpenWrt-compatible router. Or so the theory goes.

Setting up your development environment

All of the following is meant to be done on your favourite distribution of Linux, provided you've already installed the standard development environment. That would include things like make, gcc and a number of related packages.

It's difficult to say exactly what packages you'll need depending on your distro, but the following initial output from your first invocation of make menuconfig should give you a good idea of what the configuration and build process will be looking for:

$ make menuconfig
Checking 'working-make'... ok.
Checking 'case-sensitive-fs'... ok.
Checking 'working-gcc'... ok.
Checking 'working-g++'... ok.
Checking 'ncurses'... ok.
Checking 'zlib'... ok.
Checking 'gawk'... ok.
Checking 'bison'... ok.
Checking 'flex'... ok.
Checking 'unzip'... ok.
Checking 'bzip2'... ok.
Checking 'patch'... ok.
Checking 'perl'... ok.
Checking 'wget'... ok.
Checking 'gnutar'... ok.
Checking 'svn'... ok.
Checking 'autoconf'... ok.
Checking 'gnu-find'... ok.
...

As one example, one of your authors needed to do the following on his Ubuntu system:

# apt-get install libncurses5-dev zlib1g-dev gawk autoconf bison flex

How you deal with satisfying the development requirements for the build is up to you and might require a little experimentation, but it shouldn't be hard.

Getting the source

You have two choices for the source. On the one hand, you can use the stock Kamikaze 7.09 tarball [here], which represents precisely the same source that was used to build the earlier downloadable image that you're probably running now.

On the other hand, if you want to live dangerously, you can work with the very latest source base, which you can check out in one of two ways depending on which version control system you prefer (as explained [here]).

For Subversion:

$ svn co https://svn.openwrt.org/openwrt/trunk/
$ cd trunk
$ ... configure and build new images ...
$ svn update          [when you want to update the source]

For git:

$ git clone git://nbd.name/openwrt.git
$ cd openwrt
$ ... configure and build new images ...
$ git pull            [when you want to update the source]

For our experiment, we'll use the contents of the git repository, but that's purely a matter of personal preference.

Creating an external "download" directory

Before you get started, it's worth understanding why you should build a tarball "downloads" directory outside of your Kamikaze source directory.

Part of the image build process is building the appropriate cross-compiler toolchain (in this case, a MIPS little-endian toolchain), a step which requires downloading a number of source tarballs for packages such as gcc, binutils and so on. If you don't specify otherwise, those downloaded tarballs will be saved in a directory named dl/ at the top level of your source tree, which is an unfortunate choice since that entire directory is removed if you run make distclean, whereupon the next build will require them to be downloaded all over again.

As an alternative, if you plan on doing a number of builds and cleans, create a downloads directory elsewhere for all of those tarballs. You'll be able to use that external directory as part of your build process, and it won't be cleaned every time you run make distclean, saving you piles of downloading. And how do you take advantage of it? That depends.

With the newest, version-controlled content under svn or git, simply set the config option:

[*] Buildsystem settings -> Download folder

With the older, stock 7.09 source, there is no such setting, so this will require you to manually configure that directory before each build. The easiest solution is to simply recreate a symlink dl/ from the top of the source tree to your external downloads directory after each invocation of make distclean.

P.S. Furthermore, if you already have some of the tarball packages you know you'll need for your build, you can pre-load that external downloads directory before your first build and that will save you even more downloading time.

Configuring and building

To keep things simple, make your first configuration and build as basic as possible, just to verify that you can build and reflash your unit. Once you verify that, then you can get more ambitious.

To configure:

$ make menuconfig

As an example of a really basic build, here is the total set of configuration changes I made with respect to the default:

  • Target System: Broadcom 2.6
  • Target Profile: No WiFi
  • Buildsystem settings --> Download Folder: /home/rpjday/dl

And that's it. (Again, note that that last option for download folder is available only with the latest version-controlled source, not with stock 7.09.)

Note that I didn't even configure wireless since that's still a bit problematic under this kernel so we can always come back to that. Remember, the goal here is just to get a flashable image to prove you can do it.

And finally, do the build:

$ make

If the build succeeds, the end result should be under the new bin/ directory:

$ ls bin/
openwrt-brcm47xx-2.6-squashfs.trx     [the image name under 7.09]
openwrt-brcm47xx-squashfs.trx         [the newer image name]
...

Flashing your new image

Assuming your router is already running OpenWrt, you can reflash it in two easy steps:

  • Copy the new image to the router, perhaps using scp
  • Flash the image with:
# mtd -r write openwrt-brcm47xx-squashfs.trx linux

The -r option to mtd means that your router will automatically reboot once the flash is complete, at which point, you'll have to start over again with what is effectively a new router, beginning with the initial telnet to set a new root password and so on.

Piece of cake.

And now what?

Once you verify that all of the above works, you can re-configure your source any way you want and build new images to your heart's content.

Adding extra package feeds

By default, the build process gives you a choice of less than 100 packages to choose from to build your images. But you can augment that list by running make menuconfig and selecting the choice:

[*] Select all packages by default

Save your configuration, exit, then run:

$ make package/symlinks

When you return to the configuration process, you should see far more packages to choose from to build your new image.

This and that: Some miscellaneous observations

Building offline

It's worth knowing that if your downloads directory is fully populated with respect to your desired configuration, you can do your build offline with no need for Internet access.

And if you want to populate that directory, simply do a configuration, then run:

$ make download

which will check your current configuration and download only the relevant packages, then stop, at which point you can disconnect from the Net and do the build at your leisure offline.

*** NEW: Build problems with the git or Subversion repos ***

I've just noticed a rather serious issue with images you build from the git or Subversion repositories. The build works fine, and flashing works fine as well, but trying to install or update your software is going to fail miserably as the feed information that will be built into that image is simply wrong.

The problem is that the configuration file /etc/ipkg.conf that will be built into the image will have the content:

src snapshots http://downloads.openwrt.org/snapshots/$S/packages
dest root /
dest ram /tmp

That's not going to work since the URL associated with "snapshots" simply doesn't exist. In short, the image will have an ipkg configuration file that's just wrong. And it's not clear where you should get packages that are appropriate for the git or Subversion source trees.

Until this issue is resolved, building your own images will have serious limitations.

P.S. There is no such issue with images built from the stock 7.09 version of Kamikaze, as that source tree has a different /etc/ipkg.conf that's actually correct.


Return to OpenWrt on the ASUS WL-500g Premium.

Personal tools