OpenWRT on the D-Link DSL-502T (Gen 1)

NOTE: Much of this isn’t necessary now, because OpenWRT 8.09 now supports AR7. You can just grab the openwrt-ar7-squashfs.bin image to use from

I’ve had this old D-Link DSL-502T sitting around, basically working. When I moved place just recently, I took the opportunity to look into getting OpenWRT installed on this thing, basically because I wanted something I could do DNS/DHCP serving on, while giving me some shell access. The D-Link firmware is kinda dodgy, and I always enjoy installing Linux onto something new.

Chris Pascoe’s page is quite dated now, but was a good place to start. Much development has gone into OpenWRT and the AR7 platform, so much of his information is now incorrect. The best place for info is the OpenWRT wiki page for the DSL-502T. It’s much more comprehensive and many of the patches and hacks that Chris Pascoe needed to do have be rolled into the OpenWRT trunk.

Much of this information has been copied and pasted from the above sites. Credits to both of them.

Start by grabbing the SVN trunk of OpenWRT.

$ svn co

Once this is done, you can grab any packages you’re interested in. Note that you can install these later using the opkg command once your firmware is running. I grabbed ntpclient, tcpdump, openvpn and the ddns-scripts.

cd openwrt/trunk/package
svn co
svn co
svn co
svn co
svn co

Select firmware components
Enter into the folder and run make menuconfig. Select at least:

  • Target System -> TI AR7 [2.6]
  • Target Profile -> No Wifi
  • Target Images -> SquashFS
  • Image configuration -> LAN IP Address (not required, but makes it easier if you’re already running a network)
  • Base system -> br2684ctl (only needed by PPPoE)
  • Network -> ppp -> ppp-mod-pppoa and/or ppp-mod-pppoe, depending on your ADSL type
  • Kernel Modules -> Network Devices -> select Annex A (which is ADSL over POTS. B is for ADSL over ISDN)

Make sure that you enable your packages from above in the config. E.g. Network -> Time Synchronization -> ntpclient

Quit and save the config.

Get the build dependencies.

For Ubuntu, you’ll need:
sudo apt-get install flex bison autoconf zlib1g-dev libncurses5-dev automake g++ patch gawk

Build your image by doing
make -j3 (for a dual-core system)

The final firmware produced by the build is located in bin/openwrt-ar7-squashfs.bin.

Uploading the initial OpenWRT firmware.

To upload the initial OpenWRT image, there is a tool called adam2flash. It can be found in the OpenWRT trunk, under the scripts directory. To use it, you need to execute the script in the first second or so of the machine being turned on. It’s recommended that you don’t connect the modem directly to your computer, but use a switch in between. This is in case it takes too long for the ethernet cards to negotiate.

One thing I had trouble with was finding out what the initial IP address of the device was. Before you overwrite your firmware, you can find this out by using telnet. Enable the telnet remote management from the D-Link interface and then check out the ADAM2 environment variables. They should be stored in /proc/ticfg (from memory).

If you’re lucky, you might see an entry starting with my_ipaddress. Mine was, but many others have mentioned On my DSL-502T (Gen II), it haven’t found it’s IP yet. It wasn’t set in the file.

Lots more info about the ADAM2 bootloader can be found at the Seattle Wireless site.

Here’s the steps:

  • Download a copy of the standard D-Link firmware so you can revert to it if things go wrong! You need the “web upgrade” .BIN version of the firmware, not the .EXE version. D-Link firmware can be downloaded from (for example)
  • Configure your PC for a static IP address on the same subnet as your modem’s default IP address.
  • Choose an IP address for your modem. The OpenWrt firmware will use after rebooting (unless you set it in the menuconfig), so that’s a sensible choice.
  • Turn off the modem.
  • Run, providing the modem IP address you chose and the new firmware to upload. If you are changing between D-Link and OpenWrt firmware, you will also need to specify -setmtd1 (if you forget this, the script will tell you that you need it and exit)
  • Turn on the modem.
  • Wait for the upload to complete. Here’s a sample session:

$ scripts/ -setmtd1 bin/openwrt-ar7-squashfs.bin
Looking for device: ..... found!
ADAM2 version 0.22.2 at (
Firmware type: OpenWRT (little-endian)
logging into ADAM2 bootloader.. ok.
checking hardware.. AR7RD / DSL-502T.
checking MTD settings.. ok.
Firmware size: 0x00280004
Available flash space: 0x003e0000
Preparing to flash.. ok.
Erasing flash and establishing data connection (this may take a while): ok.
Writing firmware: ............. lots of dots ......... done.
Rebooting device.

If you have trouble with this (as I did) you might need to hack the adam2flash-502T script a little. I commented out the whole section about doing the UDP probe part, and just passed the IP address right into the $box variable.

Getting the LEDs to work
Grab a copy of the ledsetup script found in the scripts directory of your SVN checkout. Install it into /etc/init.d and it should run on start-up. This will give you the ethernet light, and also map the USB light to ppp0. Very handy.

DSL Sync
When I finally got my ADSL connected in the new place, I couldn’t get DSL sync. It seemed to be because I had the wrong modulation set.

When you boot the device, you should see something like this in your dmesg.

Registered device TI Avalanche SAR
Sangam detected
requesting firmware image "ar0700xx.bin"
avsar firmware released
tn7dsl_set_modulation : Setting mode to 0xffff
Creating new root folder avalanche in the proc for the driver stats
Texas Instruments ATM driver: version:[]
DSL in Sync

The line about setting the mode to 0xffff is important. For me, my initial mode was being set to 0x7f (which wasn’t for ADSL2+). The 0xffff mode means to negotiate the best speed (ADSL 1 or 2, 2+). This is set in the ADAM2 environment so if this needs to be changed, you’ll have to reboot your modem and use the onboard FTP server’s commands SETENV, UNSETENV, GETENV (all caps matter), by doing telnet to your modem’s default IP address on port 21.

$ telnet 21
220 ADAM2 FTP Server ready.
530 Please login with USER and PASS.
USER adam2
331 Password required for adam2.
PASS adam2
230 User adam2 successfully logged in.
GETENV my_ipaddress
200 GETENV command successful
GETENV modulation
200 GETENV command successful
modulation 127
SETENV modulation,65535
200 SETENV command successful

You can also set/reset your modem’s default IP address here with the variable my_ipaddress.

Backing up and restoring your configuration changes
OpenWRT saves your filesystem (effectively, configuration) changes in a JFFS filesystem mounted at /jffs. As this filesystem is dynamically sized based upon the size of your kernel and SquashFS, uploading a new firmware image may cause your configuration to be lost.

You can back your changes up to a file on your local machine via ssh:
ssh root@ tar cf - /etc/ > dsl502t-backup.tar

To restore a saved configuration, we reverse the direction of the transfer. The following command checks the configuration copied properly before deleting the old configuration:
ssh root@ 'cat > /tmp/.r.$$ && tar tf /tmp/.r.$$ && cd / && rm -rf etc/* && tar xf /tmp/.r.$$' < dsl502t-backup.tar

Updating your OpenWRT install
SCP over the new image
desktop# scp bin/openwrt-ar7-squashfs.bin root@

Log into the OpenWRT device, and use the mtd command to write the new image:
openwrt# mtd -r write /tmp/newimg linux

This should then go through a write/verify process, and once completed it will reboot into the new image.

Posted in Personal by Andy Botting at October 10th, 2008.

19 Responses to “OpenWRT on the D-Link DSL-502T (Gen 1)”

  1. Agent24 says:

    I got through most of this up to the point where you compile the firmware image… and it just seems to stop at this line:

    make[3] -C toolchain/kernel-headers prepare

    Waited about 20 minutes and nothing happened, with what seemed no CPU or HDD activity

    Can anyone help?

  2. Agent24 says:

    Nevermind my previous comment:

    Turns out it was just downloading a LOT of stuff during the process. The entire thing took a couple of hours for me!

    Anyway, I’ve now got my DSL-502T running openWRT, thanks to your instructions and the other info at:


  3. Andy Botting says:

    Nice work. I found it made my internet connection far more stable.

  4. Chris Samuel says:

    Hey Andy – the URL for checking the code out has changed – it’s now here:

    svn co svn://

  5. steven job says:

    Vey nice, thanks for your tutorial.

  6. Andy Botting says:

    It seems that using the ImageBuilder system is the way to go, because everything is supported in the kernel.

    Have a look at:

    and use something like:

    make image PROFILE=”Annex-A” PACKAGES=”openvpn ppp -ppp-mod-pppoe”

  7. Brian May says:

    Unfortunately a lot of information I can find seems out-of-date – as far as I can tell there is no need to build from source anymore.

    I have used the image builder from:

    I flashed the resultant image to my DSL-502T, rebooted. Everything seems find. The Status light flashes twice then pauses, exactly what I expect.

    Unfortunately, the network doesn’t appear to be configured though. I get no response when I ping Without the network I cannot do anything.

    Did I miss something?

  8. Andy Botting says:

    Hey Brian

    You are correct – all the good stuff has now been included in the latest release, so there is usually no reason to need trunk.

    Have you tried the generic pre-built AR7 image? I’ve had situations before with OpenWRT if you miss a critical package.

    For example, on another router, I missed a package which is required for setting up the in-built switch.


  9. Brian May says:

    Hello Andy,
    Will try again just to be sure; however my memory tells me that I already tried the pre-built image :-(.
    I also tried the older 8.09 release, that works fine.

  10. Brian May says:

    Hello again,
    Yes I can confirm that the prebuilt image, downloaded here:
    Has exactly the same problem.
    If only I could see the kernel console output :-(.

  11. Andy Botting says:

    Maybe it’s time to build a serial cable 🙂

  12. Brian May says:

    Unfortunately the JTAG cable, apparently required for the 203t, plugs into the parallel port. Or requires a JTAG/USB adaptor – the cheapest seem to AU$110.

    However, I noticed OpenWRT 10.03.1-rc1 available – this seems to work fine. Or at least I can log in now.

    Just noticed dmesg is full of “eth0: tx dma ring full” messages. Whoops. That doesn’t look so good…

  13. Brian May says:

    Oh, never mind those messages. Just realized that eth1 is my main interface. Don’t know what this eth0 is.

  14. AprilHare says:

    Am I correct that this basically means I could use this on my D-Link DSL-502T Gen II and have working OpenWRT?
    Why hasn’t the support list been updated then?

  15. AprilHare says:

    Okay, I tried installing openwrt – kamikaze, not backfire, sourced from here – on my D-Link.
    I got the following back when I tried:

    $ ./ -setmtd1 ~/Downloads/openwrt-ar7-squashfs.bin
    Looking for device: ……… found!
    ADAM2 version 0.22.2 at (
    Firmware type: OpenWRT (little-endian)
    logging into ADAM2 bootloader.. ok.
    checking hardware.. AR7RD / DSL-502T.
    checking MTD settings.. MTD4 was not as expected (should be ‘0x90010000,0x903f0000’, was ‘0x90020000,0x903e0000’). Cowardly refusing to do anything about it! at ./ line 270.

    Furthermore, it behaves strangely afterwards, requiring power to be cycled from the power point.
    What’s going on, and how do I get it going?

  16. Andy Botting says:

    You should definitely be using backfire. There is no good reason for using Kamikaze on an AR7 device.

    With the update script.. i think if your MTD4 isn’t exactly the same, its probably ok. It’s best to check which MTD is for which part. You have to be very careful not to mess with the adam2 bootloader part.

  17. I would totally agree, use 10.3.1-rc5 or so, no need for old backfire version.

    I’m surprised about the adam2, it could indeed bo putting the environment on the end of the flash hence the unusual mtd4.

    I prefer to replace adam2 with an appropriate pspboot but changing that sort of thing is not for the faint-of-heart. I use JTAG to sort it out, etc…

  18. frakazoid says:

    could i use this method to flash openwrt to linksys wag200g with adam2 bootloader it has 4mb flash and 16mb ram

    thanks in advance

  19. Rsoo says:

    Can anyone dump their dsl 502t adam2 from mtd2 and post it here? I am unable to find it anywhere online. Thanks and regards

Leave a Reply

7 − one =