D-Link DIR-300 Rev.A1 (Airlink AR335W/AR430W)

:!: Note: For D-Link DIR-300 Rev.B1 (other hardware (HW), please see D-Link DIR-300 Rev.B.

Supported Versions

Version/Model S/N OpenWrt Version Supported Model Specific Notes
A1 - Kamikaze 8.09 -
B1 - other hardware see DIR-300 Rev.B

:!: NOTE: Because of Ticket 6807 OpenWrt 10.03 'Backfire' wasn't working. In r20733 (2010-04-07) this issue has been fixed. So avoid OpenWrt 10.03 and use OpenWrt 8.09 'Kamikaze', a trunk version newer then r20733 or the newest OpenWrt 10.03.1 'Backfire'. Enjoy.

Hardware Highlights

CPU Ram Flash Network USB Serial JTag
Atheros AR2317@182MHz 16MB 4MB 4x1 No Yes Yes

First Time Installation...

Flash Layout

First let's have a quick view at the Flash Layout with the stock firmware and once OpenWrt has been installed onto the device. When you later want to understand, what mtd/sysupgrade do, have another look here:

D-Link DIR-300 Rev.A1 Flash Layout
Layer0 xxxxxx spi0.0: xxxxxx 4096KiB
Layer1 mtd0
RedBoot
192KiB
mtd1
vmlinux-bin.17
832KiB
mtd2 rootfs 2944KiB mtd4
FIS recovery
60KiB
mtd5
RedBoot config
4KiB
mtd6
boardconfig
64KiB
mountpoints /
filesystem mini_fo
Layer2 mtd0 mtd1 mtd3 rootfs_data 1600KiB mtd4 mtd5 mtd6
Size in KiB 192KiB 832KiB 1344KiB 1600KiB 60KiB 4KiB 64KiB
mountpoints none none /rom /overlay none none none
filesystem none none SquashFS JFFS2 none none none

:!: Note: As opposed to other devices, here we do not have a firmware partition, so you cannot address it with mtd -r write xxx.bin firmware. This is because every time you write to flash, you have to adjust the FIS (file information system). mtd cannot do that, so we cannot use it to do updates. You have to use RedBoot for updates.

:!: Some users have reported that using the jffs version of openwrt can remove the board config area of the flash. if at any point you need to restore to the original firmware or to the emergency redboot web flash page, you can find instructions here

... with manual step by step guide:

Note My DIR-300 takes ridiculously long to boot. I measured about 70 seconds after power connection has been established until I can connect to the bootloader and about 160 seconds until I can telnet/ssh to the OpenWrt! Maybe this is normal, maybe I miss-configured the replacement bootloader at the first time installation. FYI.

In order to replace the original firmware with OpenWrt, you will need to replace the BootLoader as well. RedBoot is OpenSource software and we are going to replace the original one with a modified one here or from the DD-Wrt-Project. For the first time installation of OpenWrt on the D-Link DIR-300 (Rev.A1) or on the Airlink AR335W/AR430W you need to obtain 4 files from the Internet and have a tfpd (i.e. daemon, not client) running.

First you should install a tfpt-daemon and change into its root directory. After installation it will be automatically started. In Ubuntu do:

sudo aptitude install tftpd-hpa
cd /var/lib/tftpboot

Now download the four files directly into this directory. You only need sudo, because as a normal user you cannot write in here:

sudo wget http://www.dd-wrt.com/dd-wrtv2/downloads/v24/Atheros%20WiSoc/Airlink%20101%20AR430W/ap61.ram
sudo wget http://www.dd-wrt.com/dd-wrtv2/downloads/v24/Atheros%20WiSoc/Airlink%20101%20AR430W/ap61.rom

sudo wget http://downloads.openwrt.org/snapshots/trunk/atheros/openwrt-atheros-vmlinux.lzma
sudo wget http://downloads.openwrt.org/snapshots/trunk/atheros/openwrt-atheros-root.squashfs

Let's assume, you have only one NIC in you PC, while keeping you browser with this page open so you can read on, you will need to give yourself the IP 192.168.20.80. Now before you proceed, due to compatibility issues, you need to create the ~/.telnetrc. It has to contain the following:

192.168.20.81
        mode line

Connect your NIC to the WAN-Port of the DIR-300 and then restart the Router. While it reboots, after about 5 sec, there is a window of about 1 sec, during which you should be able to login to the original BootLoader of the DIR-300. Simply repeat this, until success:

telnet 192.168.20.81 9000

This is not a big deal, and you should be successful at first try. You will be presented with the original RedBoot prompt eagerly awaiting your input:

Redboot>

Now we will get and execute the modified (and temporary) RedBoot from the DD-Wrt-Project:

Redboot> load ap61.ram go

or split over two commands (if you get an error with the above)

Redboot> load ap61.ram
Redboot> go

You will get no feedback and nothing has been written onto the flash yet, but the new temporary BootLoader should be running. To communicate with it, you need to change your own IP from 192.168.20.80 to 192.168.1.2 and reconnect the ethernet cable to one of the LAN-Ports of the Router. Then telnet to it:

telnet 192.168.1.1 9000

The modified (and temporary) BootLoader awaits you.

DD-WRT>

Now you need to make things permanent. For this we will use the other file, the ap61.rom:

DD-WRT>fis init
About to initialize [format] FLASH image system - continue (y/n)? y
*** Initialize FLASH Image System
... Erase from 0xbffe0000-0xbfff0000: .
... Program from 0x807f0000-0x80800000 at 0xbffe0000: .

DD-WRT>ip_address -h 192.168.1.2
IP: 192.168.1.1/255.255.255.0, Gateway: 0.0.0.0
Default server: 192.168.1.2

DD-WRT>load -r -b %{FREEMEMLO} ap61.rom
Using default protocol (TFTP)
Raw file loaded 0x80080000-0x800a8717, assumed entry at 0x80080000

DD-WRT>fis create -l 0x30000 -e 0xbfc00000 RedBoot
An image named 'RedBoot' exists - continue (y/n)? y
... Erase from 0xbfc00000-0xbfc30000: ...
... Program from 0x80080000-0x800a8718 at 0xbfc00000: ...
... Erase from 0xbffe0000-0xbfff0000: .
... Program from 0x807f0000-0x80800000 at 0xbffe0000: .

DD-WRT>fconfig bootp false
bootp: Setting to false
Update RedBoot non-volatile configuration - continue (y/n)? y
... Erase from 0xbffe0000-0xbfff0000: .
... Program from 0x80ff0000-0x81000000 at 0xbffe0000: . 
DD-WRT>reset

The Router will reboot, it should take about a minute. You login again to the modified (but this time persistent) BootLoader, load and fis the OpenWrt-Images onto the flash and configure the BootLoader:

DD-WRT>fis init
About to initialize [format] FLASH image system - continue (y/n)? y
*** Initialize FLASH Image System
... Erase from 0xbffe0000-0xbfff0000: .
... Program from 0x807f0000-0x80800000 at 0xbffe0000: .

DD-WRT>ip_address -h 192.168.1.2
IP: 192.168.1.1/255.255.255.0, Gateway: 0.0.0.0
Default server: 192.168.1.2

DD-WRT>load -r -b %{FREEMEMLO} openwrt-atheros-vmlinux.lzma
Using default protocol (TFTP)
Raw file loaded 0x80040800-0x801007ff, assumed entry at 0x80040800

DD-WRT>fis create -e 0x80041000 -r 0x80041000 vmlinux.bin.l7
... Erase from 0xbfc30000-0xbfcf0000: ............
... Program from 0x80040800-0x80100800 at 0xbfc30000: ............
... Erase from 0xbffe0000-0xbfff0000: .
... Program from 0x80ff0000-0x81000000 at 0xbffe0000: .

DD-WRT>load -r -b %{FREEMEMLO} openwrt-atheros-root.squashfs
Using default protocol (TFTP)
Raw file loaded 0x80040800-0x802207ff, assumed entry at 0x80040800''

DD-WRT>fis create rootfs
... Erase from 0xbfcf0000-0xbffe0000: ...............................................
... Program from 0x80040800-0x80220800 at 0xbfcf0000: ..............................
... Erase from 0xbffe0000-0xbfff0000: .
... Program from 0x80ff0000-0x81000000 at 0xbffe0000: .

DD-WRT>fconfig boot_script_timeout 5

DD-WRT>fconfig boot_script true
Run script at boot: true 

DD-WRT>fconfig
Run script at boot: true
Boot script:
Enter script, terminate with empty line
>> fis load -l vmlinux.bin.l7
>> exec
>>
Boot script timeout (1000ms resolution): 5
Use BOOTP for network configuration: false
Gateway IP address: 192.168.1.1
Local IP address: 192.168.1.10
Local IP address mask: 255.255.255.0
Default server IP address: 192.168.1.228
Console baud rate: 9600
GDB connection port: 9000
Force console for special debug messages: false
Network debug at boot time: false
Update RedBoot non-volatile configuration - continue (y/n)? y
... Erase from 0xbffe0000-0xbfff0000: .
... Program from 0x80ff0000-0x81000000 at 0xbffe0000: .''

DD-WRT>reset

And we are done. This time the reboot could take up to 4-5 minutes, so be patient.

... with dir300-flash.sh shell script

:!: If you don't trust the script below (it loads some binary from some blog, use the step by step guideline above ;-)

For linux there is shell script called dir300-flash; it wraps the manual steps for replacing the original bootloader and/or flashing firmware images into a single command line. The script requires a tftp-daemon to be already running. See –help for further details. Usage:

$ sudo ./dir300-flash.sh eth0 openwrt-atheros-vmlinux.lzma openwrt-atheros-root.squashfs Please connect now the WAN port of the DIR-300 wireless router directly to the interface "eth0" and then power the wireless router on. Waiting for the wireless router….. done Testing for the factory bootloader… yes Uploading the temporary bootloader RAM image… done Starting the temporary bootloader… done Waiting for the temporary bootloader to come up…. done Uploading the new bootloader ROM image… done Warning: Do not power off or disconnect as this may break the wireless router! Setting up bootloader configuration… done Flashing the new bootloader… done Resetting the wireless router… done Waiting for the new bootloader…………. done Uploading the new kernel image… done Flashing the new kernel image… done Uploading the new root filesystem… done Flashing the new root filesystem… done Resetting the wireless router… done

Reflash

via Bootloader

For reflashing via the bootloader do:

fis init
ip_address -h 192.168.1.2
load -r -b %{FREEMEMLO} openwrt-atheros-vmlinux.lzma
fis create -e 0x80041000 -r 0x80041000 vmlinux.bin.l7
load -r -b %{FREEMEMLO} openwrt-atheros-root.squashfs
fis create rootfs
If your router have already had DD-WRT installed, there will be a chance that the existing bootloader is MicroRedboot. In that case, the router boots rather fast, you cannot telnet to 192.168.1.1 9000 at start up. You will have to use Reset button to access Redboot. See http://www.dd-wrt.com/wiki/index.php/Micro_Redboot for more detail.

via OpenWrt

Use the openwrt-atheros-combined.squashfs.img to upgrade OpenWrt. The file can be found here. http://downloads.openwrt.org/backfire/10.03.1-rc5/atheros/ (this is the latest version at the time of wiki edit. There may be newer versions, so look around)

LUCI

  1. Go to System > Flash firmware
  2. Point to openwrt-atheros-combined.squashfs.img that you have downloaded
  3. Upload image
  4. Flash it

Terminal

  1. download the combined firmware from OpenWrt to your router:
    cd /tmp
    wget http://downloads.openwrt.org/snapshots/trunk/atheros/openwrt-atheros-combined.squashfs.img
    wget http://downloads.openwrt.org/snapshots/trunk/atheros/md5sums
    
  2. utilize sysupgrade:
    sysupgrade /tmp/openwrt-atheros-combined.squashfs.img

Basic configuration

Since this part is identical for all devices, see Basic configuration.

Redboot access script for Windows

download putty.exe to c:\ create a file on c:\ called redboot.txt, with the following content:

^C

create a file on c:\ called redboot.bat with the following content:

rem echo off :start rem ———————————————— ping 192.168.20.81 -n 1 -w 1 >NUL IF ERRORLEVEL 1 goto start rem putty rem ———————————————— break putty.exe telnet://192.168.20.81:9000 -m redboot.txt exit

start the bat file and power on the router…..here comes redboot

Hardware

Info

Architecture: MIPS
Vendor: Atheros
Bootloader: RedBoot
System-On-Chip: AR2317 (MIPS 4KEc V6.4)
CPU Speed: 182 Mhz
Flash-Chip: ???
Flash size: 4 MiB
RAM: 16 MiB
Wireless: Integrated Atheros 802.11b/g
Ethernet: IC Plus 175c
USB: No
Serial: Yes
JTAG: Yes

Serial Port (JP1)

|Power| |Wan| |Ethernet x4 ports| |Ant| |TXD| |GND| |VCC| | . | |RXD|

speed 9600,n,8.

If you just see non-printable characters in the console, you may want to change baudrate. In some case, where MicroRedboot is install, the speed is 115200.

JTAG (J6)

The router follows the MIPS 2.6 EJTAG Specification and has the same PIN information. But on the board the PINS are laid out as

1 - nTRST 2 - GND 3 - TDI 4 - GND 5 - TDO 6 - GND 7 - TMS
14 - VCC 13 - N/C 12 - N/C 11 - nSRST 10 - GND 9 - TCK 8 - GND

Specific configuration

Interfaces

The default network configuration is:

Interface Name Description Default configuration
br-lan LAN & WiFi 192.168.1.1/24
eth0.1 LAN ports (1 to 4) None
eth0.2 WAN port DHCP
ath0 WiFi Disabled

WiFi

To enable WiFi, you need to install packages xxx and xxx.

Switch Ports (for VLANs)

Numbers 0-3 are Ports 1-4 as labeled on the unit, number 4 is the Internet (WAN) on the unit, 5 is the internal connection to the router itself. Don't be fooled: Port 1 on the unit is number 3 when configuring VLANs. vlan0 = eth0.0, vlan1 = eth0.1 and so on.

Port Internet (WAN) LAN 1 LAN 2 LAN 3 LAN 4
Switch port 4 3 2 1 0

Failsafe mode

generic.failsafe

  • Unplug the router's power cord
  • Connect any router LAN port directly to your PC
  • Configure your PC with a static IP address: 192.168.1.2
  • Plug the power on to the router
  • Wait until the "SYS" LED starts flashing repeatedly
  • Press the button (on the side of the router) – the "SYS" LED will now start flashing at a faster rate
  • Login to the router by using telnet to connect to the IP address 192.168.1.1 – there will be an immediate unauthenticated login to a root shell

Commands:

  • mount_root - will mount the normal root filesystem
  • firstboot - all settings will be reset

Mods

CPU Overclock from 183 to 200 MHz

Assuming OpenWrt is already installed, log on the the device via SSH, then do:

cat /dev/mtdblock0 > /tmp/RedBoot.bin

Copy the file (with scp, for example) to your local computer and generate a MD5-checksum for it.

md5sum RedBoot.bin

if it equals with B9D638E537D01D3ED651FAB2AF63FC22 it is probalby safe to go on. Load the file into a hex editor and

- change offset 0x17 from 0x03 to 0x01 - change offset 0x23 from 0x5c to 0x28

MD5 checksums: DIR-300 183MHz: B9D638E537D01D3ED651FAB2AF63FC22 DIR-300 200MHz: 713806dbb99cb0e633a385eb1a8b5440

Copy the modded RedBoot.bin back to the /tmp folder of your router and flash it back:

mtd -f write /tmp/RedBoot.bin RedBoot

Reboot, then check CPU frequency:

cat /proc/cpuinfo

SD-card slot mod

There is a working mod to add a SD-card slot to your DIR-300. Follow the instructions here.

Back to top

toh/d-link/dir-300.txt · Last modified: 2013/06/15 19:51 by lorema