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.

Dear fellow members,

I really need some help. I am a total noob and need some help. I was looking for a device which could convert my hard disk into a NAS (Network acess storage) device, something I could add as a network device on my PC and access. If not, atleast a device which can provide FTP access to my hard disk using Filezilla. Dlink DIR 505 was something the retailer promised could do (he just said it will help me share media across phones and PC using HDD). Given NAS devices are not easily available in stores nearby, I got the DLink DIR 505 for myself.

While this thing does partially what the retailer says, it is not exactly what I hoped for.

1) HDD, even after providing extra power using dual usb port, does not seem to be shown as a storage in shareport
2) USB device, though detected, can be accessed only by using the shareport web link (191.168.0.1:8181). Pointing filezilla for ftp does not work and I even cannot use the hard disk as a wifi drive.

I spent some time surfing openwrt and stumbled across this forum. My question is would the steps suggested by masamunecyrus here https://forum.openwrt.org/viewtopic.php … 61#p230861 , help me get the ftp or NAS protocol running??? If not, is there  any alternative to make it work or I would need a different NAS device altogether? Hoping for an early response and apologies if I sound like a noob.

Thank you,

Yes, if you install OpenWRT you can use this device as a NAS with various protocols.

The easiest file-serving protocol is just ssh with various client tools (scp, or sftp-like clients).  Learn how to use ssh, if you don't already know it.  You may be able to install OpenWRT without it, but it is very useful for troubleshooting.

If you use Windows, I would take a look at Putty.  It may also have the ftp-like client that you need to access the files from your PC.

OpenWRT comes with an ssh server, so you don't need to install it.  You do need to install some software in order to use the USB disk, as described here:
http://wiki.openwrt.org/doc/howto/usb.storage

I have done this and used it with a FAT32 flash drive, an ext2 flash drive, and an NTFS hard disk (read-only).

I installed OpenWRT by installing the OpenWRT firmware from the standard web ui of the device:
openwrt-ar71xx-generic-dir-505-a1-squashfs-factory.bin
I did not use the "emergency restore mode".

You can then follow the "firstlogin" instructions to setup a password, and use the OpenWRT web interface (Luci) to upload a second firmware file:
openwrt-ar71xx-generic-dir-505-a1-squashfs-sysupgrade.bin
I'm not sure what you gain by installing the sysupgrade file.  OpenWRT also works without it.

Ah thanks. Would try this later in the day.

Would the USB storage then appear as a drive on my pc (network location) or I would need to use FTP program like filezilla to transfer files?

new clean installation ...is this a normal space left??


  _______                     ________        __
|       |.-----.-----.-----.|  |  |  |.----.|  |_
|   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
|_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
-----------------------------------------------------
CHAOS CALMER (Bleeding Edge, r45915)
-----------------------------------------------------
  * 1 1/2 oz Gin            Shake with a glassful
  * 1/4 oz Triple Sec       of broken ice and pour
  * 3/4 oz Lime Juice       unstrained into a goblet.
  * 1 1/2 oz Orange Juice
  * 1 tsp. Grenadine Syrup
-----------------------------------------------------
root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                    4.4M    276.0K      4.2M   6% /
/dev/root                 2.0M      2.0M         0 100% /rom
tmpfs                    29.8M     56.0K     29.7M   0% /tmp
/dev/mtdblock8            4.4M    276.0K      4.2M   6% /overlay
overlayfs:/overlay        4.4M    276.0K      4.2M   6% /
tmpfs                   512.0K         0    512.0K   0% /dev
root@OpenWrt:~#

ROOTFS size is 4.4 MB instead of 8MB ... m i wrong?

(Last edited by drbios on 8 Jun 2015, 18:11)

You would need an ftp-like program, preferably a program that can use ssh instead of ftp.

It is possible for the USB storage to appear as a drive on your pc, but you would need to install and configure more packages on the device.  I haven't done it.

Are you sure the device does not do this as is?  Maybe you just need to configure it.  I don't have an original device to try it (nor do I have a Windows machine to try it with), but I saved some of the screens when I first bought it.  I see that in the REPEATER mode, it has a MEDIA SERVER screen that configures a DLNS Media Server and a STORAGE screen (I don't know what a DLNS Media Server is, but it seems relevant to what you want to do).

You should install OpenWRT only if you are willing to learn some Linux and OpenWRT adminstration.  OpenWRT does not implement a media server out of the box.

votsalo wrote:

Yes, if you install OpenWRT you can use this device as a NAS with various protocols.

The easiest file-serving protocol is just ssh with various client tools (scp, or sftp-like clients).  Learn how to use ssh, if you don't already know it.  You may be able to install OpenWRT without it, but it is very useful for troubleshooting.

If you use Windows, I would take a look at Putty.  It may also have the ftp-like client that you need to access the files from your PC.

OpenWRT comes with an ssh server, so you don't need to install it.  You do need to install some software in order to use the USB disk, as described here:
http://wiki.openwrt.org/doc/howto/usb.storage

I have done this and used it with a FAT32 flash drive, an ext2 flash drive, and an NTFS hard disk (read-only).

I installed OpenWRT by installing the OpenWRT firmware from the standard web ui of the device:
openwrt-ar71xx-generic-dir-505-a1-squashfs-factory.bin
I did not use the "emergency restore mode".

You can then follow the "firstlogin" instructions to setup a password, and use the OpenWRT web interface (Luci) to upload a second firmware file:
openwrt-ar71xx-generic-dir-505-a1-squashfs-sysupgrade.bin
I'm not sure what you gain by installing the sysupgrade file.  OpenWRT also works without it.


i tried using the standard webUI. The device restarts on uploading the firmware but I get the old UI on reconnecting. I guess it is not accepting the firmware. I have a A1 model.

Will try doing it using emergency flash  when I get time.

votsalo wrote:

You would need an ftp-like program, preferably a program that can use ssh instead of ftp.

It is possible for the USB storage to appear as a drive on your pc, but you would need to install and configure more packages on the device.  I haven't done it.

Are you sure the device does not do this as is?  Maybe you just need to configure it.  I don't have an original device to try it (nor do I have a Windows machine to try it with), but I saved some of the screens when I first bought it.  I see that in the REPEATER mode, it has a MEDIA SERVER screen that configures a DLNS Media Server and a STORAGE screen (I don't know what a DLNS Media Server is, but it seems relevant to what you want to do).

You should install OpenWRT only if you are willing to learn some Linux and OpenWRT adminstration.  OpenWRT does not implement a media server out of the box.

DLNS media server only uses DLNA protocol (if I am right with the name). This is a streaming protocol used by the web UI or the shareport app on mobile. Curiously, shareport app on my mobile detects the usb drive, the app on my pc does not. I need to use the web ui for streaming, which is a pain, if I want to transfer a bulk of data to the drive (including non media files like zip, exe etc.)

donutsncreme wrote:

The device restarts on uploading the firmware but I get the old UI on reconnecting.

Even after reboot?

votsalo wrote:
donutsncreme wrote:

The device restarts on uploading the firmware but I get the old UI on reconnecting.

Even after reboot?

Yes

Ok. So I uploaded the firmware using the method here:

https://forum.openwrt.org/viewtopic.php … 61#p230861

I then telneted into the system and set a password.

I then sshed and ran all the commands as mentioned in the post.

I then took off the power connected my Dlink 505 router to my main router lan via ethernet cable. I switched the Dlink 505 on and was able to connect to Openwrt wifi network. I was also able to ssh into it over wifi.

However, the Dlink 505 is unable to connect to internet via the main router ethernet cable. I check the same cable on my PC and my pc was able to connect to internet.  Even directly connecting the main ethernet cable (which goes into my main wifi router from my fiber optic modem) directly to Dlink 505 but still no internet.

I went to my friends house who has a broadband modem and tried using it there but still the Dlink 505 did not receive any internet. Am I doing something wrong? I am unable to install Luci because of this.

Hi,

So I was able to connect to internet. Issue was my master router and Dlink were using same IP address.

Now, I am trying to mount my HDD with 3 partitions. I tried http://wiki.openwrt.org/doc/howto/usb.storage however while I was able to get my HDD detected once (just 2 of 3 partitions), they are not appearing anymore. I guess auto mount is not working. Can someone help?

Thank you

Trying to flash openwrt, i have two dir-505 from the same seller, one installed fine a few days ago and now the second is giving me some trouble. 

When i upload a firmware firefox gives a timeout responce.
After rebooting the original chinees D-link firmware still lives there

Tried the same procedure also with supwerwrt
https://superwrt.ro/firmware/
Also no joy...  and Ni-hao, D-Link fw still owns the box

I have the model with the EU plug
Both models are A1 with firmware 1.03

I'm sure i downloaded the firmware for the other router direct form the openwrt repo, but it seems to be a different file. I very much doubt that the hardware is different...

donutsncreme wrote:

Hi,
however while I was able to get my HDD detected once (just 2 of 3 partitions), they are not appearing anymore.

what type of partitions are on the HDD?  fat only or also ntfs, ext3 or ext4?   and if so, are the corresponding packages installed to support that filesystem?

Just when i wanted to give up:

I updated the D-Link v1.03 firmware to 1.07 (the last stable firmware from D-Link)
http://support.dlink.com/ProductInfo.aspx?m=DIR-505
for those who also have the Chinese version the link to D-Link DIR-505's firmware page is
http://192.168.0.1/Firmware.htm

After I did this I finally could update to OpenWRT
I think it's just extremely odd that i had to go this route, since the other 505 that i have was no problem at all.
But just in case anyone has a similair issue, then please give it a try.

Hello everybody,
I was trying to put the slider/switch to use (DIR-505L A2). It was easy to enable the GPIOs 19 and 20 as input. I can get their value (eg via cat) manually but I couldn’t find a way to get them working automatically via /etc/rc.button (I even googled for that problem). I tried "gpio" and "sysfs" as name but I doesn't seem to be working Now my question is: what is the proper name for the rc.button-file or rather what is the correct way to use them.

root@OpenWrt:/etc/rc.button# cat /sys/kernel/debug/gpio 
GPIOs 0-29, ath79:
....   
 gpio-19  (sysfs               ) in  lo    
 gpio-20  (sysfs               ) in  hi    
...

(Modified reboot script(quick and dirty))

#!/bin/sh

. /lib/functions.sh

if [ $(cat /sys/class/gpio19/value) -eq 0 ]
then
    if [ $(cat /sys/class/gpio20/value) -eq 1]
    then
        echo "REBOOT" > /dev/console
        sync
        reboot
    fi
fi

return 0

Slider button based network (/etc/config) profiles
Small script to have network profiles based on the slider switch,
puts this code in /etc/rc.d/S11config_modes file (you have to create this file)

#!/bin/sh /etc/rc.common
                                
START=11
boot() {
         
        # enable gpio pins
        echo 19 > /sys/class/gpio/export
        echo 20 > /sys/class/gpio/export
                                        
        k19=`cat /sys/class/gpio/gpio19/value`
        k20=`cat /sys/class/gpio/gpio20/value`
                                              
        mkdir -p /etc/config_modes
        c_dir=/etc/config_modes/$k19$k20
                                        
        # copy the current config to current mode if booting first time in this mode
        # wanted it to be default config but don't know from where to get           
        if [ ! -d "$c_dir" ]; then                                       
                cp -r /etc/config/ $c_dir
        fi                               
          
        # remove /etc/config
        if [ -d /etc/config ]; then
          if [ -L /etc/config ]; then
            rm /etc/config           
          else            
            rm -rf /etc/config
          fi                  
        fi  
          
        ln -snv $c_dir /etc/config
}
chmod 777 /etc/rc.d/S11config_modes
reboot
  • On the first boot in particular switch mode its going to copy the existing config for the current switch mode.

  • after changing the switch position you have to reboot to load the corresponding config, this is same behavior as stock firmware.

To have the backup of all the modes as well on default openwrt backup run this

echo "/etc/config_modes" >> /etc/sysupgrade.conf

today only i wrote this script, tested only a few times, also please share your improvements.

@manishgkasera
Your script is awesome! big_smile It's small, simple and effective - perfect for the small router.
And while testing it I didn't encounter any flaws. You did a great job.

It's been a while since I've looked at OpenWrt on DIR-505, so I'd appreciate if anyone could address a few questions:
1. There's just one three-position switch, is it represented by two binary GPIOs (19 & 20)?
2. Is the only ethernet port configured as a LAN port or WAN port in default CC config?

stangri wrote:

1. There's just one three-position switch, is it represented by two binary GPIOs (19 & 20)?

https://wiki.openwrt.org/toh/d-link/dir-505#mode-switch

2. Is the only ethernet port configured as a LAN port or WAN port in default CC config?

Just like with all other single-port devices, it is configured as LAN. You need to configure the device and you can't do that through WAN with default firewall settings, eh?

(Last edited by metai on 20 Mar 2016, 22:30)

Thanks for your prompt reply. I'm ashamed I've asked something which was already in the wiki. wink

@luke.skywalk3r -- did you figure out how to detect the slider/switch changes on the fly? In combination with @manishgkasera's script above we could get pretty close to stock functionality then.

stangri wrote:

I'm ashamed I've asked something which was already in the wiki. wink

Eh, happens, don't worry about it.

@luke.skywalk3r -- did you figure out how to detect the slider/switch changes on the fly? In combination with @manishgkasera's script above we could get pretty close to stock functionality then.

(Heavily edited.)

I'm not entirely sure if that's the best way to go about it. If you reacted to the switch instantaneously, it would become hard to reach the extreme positions without reacting to the middle position in the process. You'd have to "debounce" the switch in some way, and at that point you can use another delayed method as well.

Short of recompiling OpenWrt for the router and including the GPIOs (or at least one of them) in the hotplug configuration you will not get an instant reaction to the switch anyway. But there are other ways to go about it. You could have a cronjob check the switches every minute, or an infinitely looping shell script with an even shorter delay. You can check the GPIOs on system boot like the above script does.

Personally, I wired up a hotplug script to react to the WPS button on the side. It in turn checks the GPIOs for the switch and reacts accordingly. "Set switch, confirm with button" in a way.

As usual, there are half a dozen ways to go about it.

(Last edited by metai on 21 Mar 2016, 12:27)

metai wrote:
stangri wrote:

@luke.skywalk3r -- did you figure out how to detect the slider/switch changes on the fly? In combination with @manishgkasera's script above we could get pretty close to stock functionality then.

I'm not entirely sure if that's the best way to go about it. Pointing out a minor flaw: The script reboots the router, if you combine this with an immediate reaction, you'd have to reboot the router twice to get from one side of the switch to the other. (A simple reload of network would solve this, there really is not much of a point in rebooting the router just to change the network setting.)

No, the script doesn't reboot the router, it just manages config folders.

metai wrote:

Short of recompiling OpenWrt for the router and including the GPIOs (or at least one of them) in the hotplug configuration you will not get an instant reaction to the switch. But there are other ways to go about it. You could have a cronjob check the switches every minute, or an infinitely looping shell script with an even shorter delay. Personally, I wire up a hotplug script to react to the WPS button on the side. It in turn checks the GPIOs for the switch and reacts accordingly. "Set switch, confirm with button" in a way.

I thought about that, but I was hoping for an elegant way, detecting the slider. cronjob is a bit trickier as you'd have to store previous state, but if the recompile is required to enable hotplug for gpio, I'll probably go for the WPS-button script.

metai wrote:

Or you could check the GPIOs at system start, in an init.d script starting before network does (probably position 18 or 19). You'd set the switch, unplug and replug, to change the configuration.

That's what the script above does and it works very well.

stangri wrote:

No, the script doesn't reboot the router, it just manages config folders. (...) That's what the script above does and it works very well.

I do stand corrected, it was a wee bit late last night. You are of course right, I edited my post accordingly.

(Last edited by metai on 21 Mar 2016, 12:26)

Maybe if I read the first 9 pages of this thread I wouldn't have ran into this, but...

I've learnt a hard lesson that it's better to not use reghack with this model. WiFi was very flakey (to a point where it would not start after flash at all) and at first I thought I messed up my uci-defaults script or something.

I ended up using the script above, the hotplug wps button script which simply reboots the device (which is only marginally slower than network restart) and a small uci-defaults script which:
* Sets up WiFi AP
* Sets up WAN/WAN6 interfaces and detaches eth1 from LAN
* Creates clone of the default config into /etc/config_modes/01, -10, -11
* Manipulates the /etc/config softlink to properly set Hotspot and Repeater modes

I've tried to see if I could use uci cli to make changes to folders other than /etc/config and couldn't find any info on that. There's some info on how to do that with Lua, but I couldn't make it work. If someone here has a working knowledge of Lua, I'll post my script.

I'm trying to perfect my custom image to disable STA if it can't connect to it in repeater mode, so that I could connect to the router over WiFi.

With so many options available (and iw warning "Do NOT screenscrape this tool, we don't consider its output stable.") -- what's the best and most reliable way to determine if the STA connection is up/down?