Is my D-Link DIR-2640 defective, or am I doing something wrong?

I purchased a D-Link DIR-2640, because it seems to be the last WiFi router on the ToH for a reasonable price on Amazon. I downloaded the Factory Image from here https://openwrt.org/toh/d-link/dir-2640_a1. Then entered recovery mode and connected as described here: https://openwrt.org/docs/guide-user/installation/installation_methods/d-link_recovery_gui. However, the recovery firmware only seems to ever respond to one request. If you try to load the recovery page twice it will simply hang, failing to so much as open the TCP connection.

You are able to make the request to flash the file from the terminal:

$ curl -v -i -F firmware=@Downloads/openwrt-23.05.4-ramips-mt7621-dlink_dir-2640-a1-squashfs-factory.bin 192.168.0.1
*   Trying 192.168.0.1:80...
* Connected to 192.168.0.1 (192.168.0.1) port 80
> POST / HTTP/1.1
> Host: 192.168.0.1
> User-Agent: curl/8.7.1
> Accept: */*
> Content-Length: 9568532
> Content-Type: multipart/form-data; boundary=------------------------LpsCd7YDWIm01T0i62GWpT
> Expect: 100-continue
> 
* Done waiting for 100-continue
* upload completely sent off: 9568532 bytes
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
HTTP/1.0 200 OK
< Content-type: text/html
Content-type: text/html
< 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><style type='text/css'>.warning{margin:50px 0;color:red;font-size:22px}</style></head><script type="text/javascript">var percent=1;var Timer;function uiOnload(){Timer=setTimeout("upStatus()",2200);}window.onload = uiOnload;function upStatus(){percent++;if(percent > 100){clearTimeout(Timer);document.getElementById('wait').style.display = 'none';document.getElementById('result').style.display = '';return;       }document.getElementById('time').innerHTML = 'Device is upgrading the firmware...' + percent + '%';     Timer = setTimeout('upStatus()',2200);}window.onload = uiOnload;</script><body><center><div><center style='margin:50px 0;color:blue;font-size:24px'>D-Link Router Recovery Mode</center></div><div id=wait><center style='margin:50px 0;font-size:15px'><span id=time>Device is upgrading the firmware... 1%</span></center></div><div id=result style=disp* Closing connection
lay:none><center class=warning><span>Upgrade successfully!</span></center></div><hr/><div><center class=warning>WARNING!!</center></div></center><ul><li style='margin:50px 0 10px;font-size:14px'>Do not interrupt the update process,as it may demage the device</li></ul><hr/></body></html>

This looks like it goes smoothly, but it never reboots (even after some hours), and again, never responds to another query, just like if I try to make 2 subsequent get requests to the recovery firmware:

Should I return it for another one or am I doing something wrong?

Initial commit describes this exact behaviour and how to get around it.
https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=de768829a5c6cd1c7889ba25c50db07827cfc96c

Maybe I'm just unfamiliar with the interface and looking in the wrong place, but I don't see anywhere in the link you sent me which describes the problem I described. Also, the only alternate suggested technique I see there is to use cURL instead of a web browser, which I described doing in the OP

curl does one single tcp connection before reboot.

Sorry, that doesn't really make sense.

The D-Link recovery mode is partly botched in that and around 2 dozen other D Link routers of that decade.
reason: "http 100 continue" is not properly implemented in the recovery mode. For some reasons any modern browser on a modern Linux TCP stack will stall on that after the first request.
If curl does not work, you can try any Windows client (but not in a VM on Linux) for the installation via recovery mode. I think, a really ancient Linux kernel/browser combo was also said to work.

1 Like

Installing from windows worked. Hopefully I can figure out another solution, eventually, as I don't always have access to a Windows machine

You can write expect chatscript to implement broken-http it needs...

1 Like

sorry, what does "you can write expect chatscript" mean?

Expect is a very old scripting language that harks back to the old AT command set modem days.

It basically is a chat script - it "expects" a string (prompt, or similar) and then "sends" a command in reply.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.