OpenWrt Forum Archive

Topic: D-link DIR-505 support?

The content of this topic has been archived between 2 Apr 2018 and 5 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Yes, you can use the mode switch for pretty much anything you want -- however, keep in mind that the "charge" position turns the router off and is pretty easy to accidentally switch to.

the switch and the pushbutton are not used by openwrt?

I'm not entirely sure about the wps button. My 505 is still happily buzzing along on r37855, and it's not used there, but that may have changed in the meantime. At any rate, how the button is used can be redefined, even if it comes with a default behaviour.

The switch is just a set of GPIOs which OpenWrt by default doesn't even know about. I believe they have to be exported to be queried.

I would linke to use the WPS button for reboot or shutdown. When preesing the real reset button, the Router makes a factory reset, all data and settings are lost. How could I realise this? The button should work on gpio11.  The Router works with mpd as webradio, controlled by mpdroid.

Have a look at /etc/rc.button/, in there are the scripts that handle button presses, they are quite straightforward. I don't think you have to go through GPIOs for the wps button, it should be recognized out of the box as "wps", and should just work in a script named "wps". (Didn't try it yet myself though.)

thank you, I added a script "wps":

#!/bin/sh

[ "${ACTION}" = "released" ] || exit 0

. /lib/functions.sh

logger "$BUTTON pressed for $SEEN seconds"

if [ "$SEEN" -lt 1 ]
then
        echo "REBOOT" > /dev/console
        sync
        reboot
elif [ "$SEEN" -gt 3 ]
then
        echo "SHUTDOWN" > /dev/console
        sync
        poweroff
fi

it works for reboot and shutdown.
Now I need to autostart mpc, set in the rc.local doesn´t work.
I ´ve added "mpc load playlist" and "mpc start", but the mpc doesn´t start.
When I start the rc.local with ". /etc/rc.local" it works. Why don´t the rc.local not run?
The same on my WR-703n works.

edit: now it works! I added a "sleep 10" in the file.(must be more then 7sec!)

(Last edited by micha-uhl on 29 Sep 2014, 15:12)

Hello guys,

My project is a i2c temperature sensor. Now i have a DIR505A1 working fine and logger my bedroom temp.

http://imgur.com/a/tjuTF
https://thingspeak.com/channels/16282/

But i trying of recover another bricked DIR505A1, i cant make it work.

I try with all type of firmware: AA with patch, BB, D-Link original and none works

Dlink firmware recovery not work, i can load recover web page but none firmware work after restart.

This is my console:

U-Boot 1.1.4 (Feb  9 2012 - 20:12:45)

AP121 (ar9331) U-boot

DRAM:  64 MB
Top of RAM usable for U-Boot at: 84000000
Reserving 161k for U-Boot at: 83fd4000
Reserving 192k for malloc() at: 83fa4000
Reserving 44 Bytes for Board Info at: 83fa3fd4
Reserving 36 Bytes for Global Data at: 83fa3fb0
Reserving 128k for boot params() at: 83f83fb0
Stack Pointer at: 83f83f98
Now running in RAM - U-Boot at: 83fd4000
============================================ 
Date:Feb  9 2012  Time:20:12:45
Cameo Version: v1.00 Build:03
Module Name: D-Link DIR-505A1
============================================ 
id read 0x100000ff
flash size 8388608, sector count = 128
Flash:  8 MB
Using default environment

In:    serial
Out:   serial
Err:   serial
Net:   ag7240_enet_initialize...
: cfg1 0x5 cfg2 0x7114
eth0: 90:94:e4:d3:96:5c
eth0 up
: cfg1 0xf cfg2 0x7214
eth1: 00:03:7f:ff:ff:fe
athrs26_reg_init_lan
ATHRS26: resetting s26
ATHRS26: s26 reset done
eth1 up
eth0, eth1
Hit any key to stop autoboot:  0 
## Booting image at 9f080000 ...
Bad Magic Number
ar7240> 
ar7240> 
ar7240> 
ar7240> 
ar7240> printenv
bootargs=console=ttyS0,115200 root=31:06 rootfstype=squashfs init=/sbin/init mtdparts=ar7240-nor0:64k(u-boot),64k(ART),64k(mac),64k(nvram),256k(language),1024k(uImage),6656k(rootfs)
bootcmd=bootm 0x9f080000
bootdelay=2
baudrate=115200
ethaddr=0x00:0xaa:0xbb:0xcc:0xdd:0xee
stdin=serial
stdout=serial
stderr=serial
ethact=eth0
filesize=780054
fileaddr=81000000
ipaddr=192.168.0.1
serverip=192.168.0.20

Environment size: 401/65532 bytes

ar7240> tftpboot 0x81000000 openwrt-ar71xx-generic-dir-505-a1-squashfs-factory.bin
Using eth0 device
TFTP from server 192.168.0.20; our IP address is 192.168.0.1
Filename 'openwrt-ar71xx-generic-dir-505-a1-squashfs-factory.bin'.
Load address: 0x81000000
Loading: #################################################################
         #################################################################
         #################################################################
done
Bytes transferred = 7864404 (780054 hex)
ar7240> bootm 0x81000000
## Booting image at 81000000 ...
Bad Magic Number
ar7240> 

Any suggestion?

Another of my projects:
riotNAS - Similar to pirate box but using samba.
[Google Translate link]
http://bit.ly/1rBtX9I

Sorry my bad english, i am work in my language too.

Thanks in advance.

Hello again,

I resolve my problem with this method.

1.- Get a image of firmware partition in my working device:

root@lis001:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00010000 00010000 "u-boot"
mtd1: 00010000 00010000 "art"
mtd2: 00010000 00010000 "mac"
mtd3: 00010000 00010000 "nvram"
mtd4: 00040000 00010000 "language"
mtd5: 00100000 00010000 "kernel"
mtd6: 00680000 00010000 "rootfs"
mtd7: 004a0000 00010000 "rootfs_data"
mtd8: 00780000 00010000 "firmware"
root@lis001:~# dd if=/dev/mtd8 of=/tmp/firmware.backup
15360+0 records in
15360+0 records out
root@lis001:~# ls -la /tmp/firmware.backup 
-rw-r--r--    1 root     root       7864320 Oct  3 15:39 /tmp/firmware.backup
root@lis001:~# 

2.- Put this image in my bricked DIR-505

ar7240> tftpboot 0x81000000 firmware.backup
Using eth0 device
TFTP from server 192.168.0.20; our IP address is 192.168.0.1
Filename 'firmware.backup'.
Load address: 0x81000000
Loading: #################################################################
         #################################################################
         #################################################################
done
Bytes transferred = 7864320 (780000 hex) 

ar7240> erase 0x9f080000 +0x780000
Erase Flash from 0x9f080000 to 0xffffffff in Bank # 1 
First 0x8 last 0x7f sector size 0x10000                                                                                127
Erased 120 sectors

ar7240> cp.b 0x81000000 0x9f080000 0x780000
Copy to Flash... write addr: 9f080000
done

And restart y voila! working again! but what about with the image of openwrt in repository?? I look this:

OpenWRT repository image:
Bytes 7864404 (780054 hex)
Data in firmware partition extracted
Bytes 7864320 (780000 hex)

Ok, then test this:

dd skip=84 if=openwrt-ar71xx-generic-dir-505-a1-squashfs-factory.bin of=firstcut.bin bs=1

And after use this:

mtd -r write firstcut.bin firmware

And this work too. Why this initial 84 bytes? I dont know but i am happy with my debricked router smile

Please, any can get me a explain about this?

Thanks and happy hacking!

Hi ach,

I am also planning to create a kind of "room sensor" out of the DIR-505.

Could you please share your setup of the i2c sensor you connected? Which cable connection corresponds to which GPIO line (maybe a numbered PCB picture)? What software/configuration do you use to read the sensor?

Maybe this would be something to add to the OpenWrt Wiki, too. Or we create a small howto in the forum out of that.

Thanks in advance

Andreas

Hi ach,

Pretty much like Andreas, I'm also wondering, how you built your temperature sensor (mostly because I'm planning to do the same).

My guess, from your pictures, would be that your repurposed the switch and used its GPIO to connect the sensor. Is that right?

Regards,
Shad

Hi everybody with a DIR-505!

I was a little silly and did something stupid (well, that's the point of flashing OpenWRT isn't it? big_smile) I overwrote some mtd partitions that I had no backups... I'm pretty sure that the ART partition (mtd1) shouldn't be full of 0xFF and that the MAC partition (mtd2) should'nt contain the first 64 bytes of a firmware big_smile

If somebody would be kind enough to upload a dump of all its mtd partitions, it would be most appreciated. Otherwise my DIR-505 is going to the garbage bin...

If you don't know how to do it it's pretty simple. On a running instance of OpenWRT :

# dd if=/dev/mtd0 of=/tmp/mtd0

On your Linux machine :

scp root@192.168.1.1:/tmp/mtd0 .

I think that I only need mtd1 and mtd2, but if you would be kind enough to upload all mtds (0 to 8) I would be sure to have everything I need.

By advance, thank you very much !

Tito1337 wrote:

If somebody would be kind enough to upload a dump of all its mtd partitions,

http://www.filedropper.com/dir505mtd0mtd4 contains mtd0 to mtd4 and should be enough to get you up and running again, at least to the Emergency Flash facility. mtd2 has the NIC part of the MAC address replaced with 00:00:00/00:00:01, so make up a new one for yourself. And for obvious reasons I won't give you mtd5 (which would include mtd6 and mtd7) of a device in use. HTH, HAND

Based in UK, just got hold of a DIR-505 (P/N EIR505BEU....A1E) but yet to open up to access serial.  Been tearing apart the stock firmware and interestingly the tftpd seems to allow the download of anything on the filesystem.  It's therefore possible to backup all the mtd partitions by doing a get on /dev/mtdblock[0-6]   (but writing appears to be blocked)
интериорни врати

(Last edited by grisina on 4 Mar 2015, 14:48)

metai wrote:

http://www.filedropper.com/dir505mtd0mtd4 contains mtd0 to mtd4 and should be enough to get you up and running again

Thank you very much! I suppose I will also have to correct the checksum but I understand that you don't include the Mac wink

EDIT1 : Also, it's normal that mtd1 is full of 0xFF?

EDIT2 : WiFi works again! Thanks again!

(Last edited by Tito1337 on 25 Feb 2015, 16:33)

Tito1337 wrote:

Thank you very much! I suppose I will also have to correct the checksum but I understand that you don't include the Mac wink

Ah, sorry, I wasn't aware that there was a checksum, but you seem to know your way around anyway. Also, including the MAC isn't so much a "security issue" I am worried about (that would be mtd5 to mtd7 that contains sensible data) rather than something that is supposed to be unique. Can't have people run around the interwebs with my router's MAC. smile

EDIT1 : Also, it's normal that mtd1 is full of 0xFF?

It isn't, have a look at offset 0x1000.

metai wrote:

Ah, sorry, I wasn't aware that there was a checksum

I read somewhere that the ART partition was storing the wireless MAC address with a checksum.

But I didn't run into any issues and the WiFi went right back up with your images (and my original Mac addresses in it) without any checksum trick. Maybe D-Link didn't bother storing the MAC in the ART partition.

metai wrote:

have a look at offset 0x1000.

Good catch. At that offset there is something that looks like a default MAC address ".0:11:22:33:44:55", maybe that's why I didn't have to modify the checksum.

(Last edited by Tito1337 on 25 Feb 2015, 18:00)

Ok now that my router is up & running again I will try to share some of the acquired knowledge for future reference and hopefully help others.

My DIR-505 was bricked : no firmware was booting and the U-Boot environment was waiting for instructions. This expressed in a solid red LED. The D-Link emergency flash webpage was still showing up but didn't flash the firmware correctly.

I hooked up serial like indicated on the DIR-505 wiki page. The 3.3V isn't necessary. I powered it with mains power but I think you can hookup 5V directly like described on the wiki. The U-Boot environment can access all of memory :
* 0x00000000 to 0x84000000 : 64MB RAM (with some U-Boot code in the upper addresses)
* 0x9f000000 to 0x9f800000 : 8MB FLASH

Here is the partition table of the FLASH :

MTD  |  Name       | Flash range                   | U-Boot address | Notes
------------------------------------------------------------------------------------------
mtd0 | u-boot      | 0x000000000000-0x000000010000 | 0x9f000000     | Bootloader /!\
mtd1 | ART         | 0x000000010000-0x000000020000 | 0x9f010000     | Atheros Radio Test
mdt2 | mac         | 0x000000020000-0x000000030000 | 0x9f020000     | MAC addresses
mtd3 | nvram       | 0x000000030000-0x000000040000 | 0x9f030000     | 
mtd4 | language    | 0x000000040000-0x000000080000 | 0x9f040000     |
mtd5 | firmware    | 0x000000080000-0x000000800000 | 0x9f080000     | Flash firmware here
mtd6 | kernel      | 0x000000080000-0x00000018e4dd | 0x9f080000     | First part of mtd5
mtd7 | rootfs      | 0x00000018e4dd-0x000000800000 | 0x9f18e4dd     | Second part of mtd5
mtd8 | rootfs_data | 0x0000003b0000-0x000000800000 | 0x9f3b0000     | Third part of mtd5

From U-Boot you can flash any of these partition. You need to connect your computer by ethernet and give it IP address 192.168.0.100. Configure a TFTP server with image.bin in the root. I can safely recommend using the 0x81000000 RAM address :

tftpboot 0x81000000 image.bin          # charge from TFTP to RAM
erase 0x9f080000 +0x780000             # erase firmware FLASH
cp.b 0x81000000 0x9f080000 0x780000    # copy from RAM to FLASH

You will notice that this requires an image.bin of 0x780000 (hexa) = 7864320 (decimal) bytes. OpenWRT or D-Link images are 7864404 bytes, so 84 bytes too large. This is because there is a header for the flashing software. You can safely remove these 84 bytes :

dd skip=84 if=original.bin of=image.bin bs=1

Or you could maybe try to flash an unmodified image by offsetting the cp.b (84 decimal = 54 hexa) but I didn't try this:

cp.b 0x81000054 0x9f080000 0x780000

I hope this will help someone. Don't forget to backup the entire flash before you begin hacking!

(Last edited by Tito1337 on 25 Feb 2015, 18:51)

I cannot connect to my OpenWRT DIR-505 device through an ethernet switch.
I have setup my eth interface to have a static ip address with the DHCP server enabled.
If I plug a cable directly from the DIR-505 to my PC, my PC gets an IP address through DHCP.  I can ping the device, ssh to it, etc.
But if I put an ethernet switch between the PC and the DIR-505, I cannot do any of the above.  Even if I set the ip address of my PC to be in the same network as the DIR-505, I cannot ping it.
I have tested the ethernet switch between my PC and another router, so I know it works.

What could be causing this?
The switch is NETGEAR FS605v3

I also tried connecting the DIR-505 with my PC through another router's switch, and it worked, even though the DIR-505 and the other router had different network addresses.  I just had to force the ip address on my PC to be in the same network as the DIR-505. (e.g. 192.168.5.x/24 vs 192.168.2.x/24)

Post your /etc/config/network.

config interface 'loopback'
    option ifname 'lo'
    option proto 'static'
    option ipaddr '127.0.0.1'
    option netmask '255.0.0.0'

config globals 'globals'
    option ula_prefix 'fd02:0e08:a54d::/48'

config interface 'lan'
    option proto 'static'
    option ipaddr '192.168.5.1'
    option netmask '255.255.255.0'
    option _orig_ifname 'eth0'
    option _orig_bridge 'false'
    option ifname 'eth1'

config interface 'wwan'
    option proto 'dhcp'
    option hostname 'OpenWrt'

The switch uses the store-and-forward method, which means it examines each packet for errors and drops the ones that have CRC errors (checksum) or perhaps other errors (too short or too long).

More on the 505-switch communication issue:

I believe the problem is called by a hardware bug or by incomplete implementation of auto-mid/midx.  The problem could be on either the DIR-505 or the FS605v3.  The switch is not that old (circa 2010) but it is a discontinued model with specifications that state it supports "Auto Uplink TM (Auto MDI-X)".  The fact that they use a trademarked name for the feature makes me suspicious.  On the other end, the 505 specs state that it supports IEE 802.3u, but it does not explicitly state Auto MDI-X.

I suspect that if I buy a new switch, it would work with the 505.

The 505 can communicate with my PC with either kind of cable (straight-through or crossover).

I would also like to point out that the 505 is picky about RJ-45 connector sizes.  My crossover cable barely fits in the 505.  I made the cable myself with commercial connectors.  I cannot see any difference in connector sizes when I put my cable side-by-side with other cables.

My brother ended up heating up the iron too hot and took the pad off the RX UART line. Does anyone know any other leads on the board I can use for the RX line?

thanks

Has the price of this device gone up?  In my country (Greece), it went from 29 euros to 39 euros in several stores that I have checked.
I was able to buy it for ~ 25 euros ~ two months ago.
People have mentioned that they've bought it for $22 or $25 in this topic.  Is it still available at these prices?

votsalo wrote:

Has the price of this device gone up?  In my country (Greece), it went from 29 euros to 39 euros in several stores that I have checked.
I was able to buy it for ~ 25 euros ~ two months ago.
People have mentioned that they've bought it for $22 or $25 in this topic.  Is it still available at these prices?

Looking at Ebay, they are going for that range $22-$25 for new units. Most are the newer "L" units but they work just fine with OpenWrt

(Last edited by bashywash on 4 Jun 2015, 01:44)