TFTP flash

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 09:53, 1 March 2009 (edit)
Alvin (Talk | contribs)
m (Compiled all TFTP steps for all WL-500 series routers, into ONE step-by-step list)
← Previous diff
Current revision (19:44, 14 December 2023) (edit) (undo)
Jeremywh7 (Talk | contribs)
m (General - section for Netgear NMRP)
 
(63 intermediate revisions not shown.)
Line 1: Line 1:
 +{{Languages|TFTP_flash}}
__TOC__ __TOC__
==General== ==General==
 +This article describes how to do an initial flash '''or''' a TFTP recovery flash for your device.
 +#Unplug the router, get a [[#TFTP Tools|TFTP client]] for the PC, and connect it via network cable to a router LAN port
 +#Set a [[Static IP|fixed IP address]] on the PC with the same network as your router, e.g. Router: 192.168.1.1, PC: 192.168.1.2
 +#Get a known good [http://www.dd-wrt.com/dd-wrtv2/downloads.php DD-WRT release]. Use the [[Supported_Devices]], the device wiki, or the forum for recommended files.
 +#*For recovering a bad flash, the OEM firmware might be required
 +#*Use a ''mini'' build for 4+ MB flash devices (when possible) or ''micro'' build for 2 MB flash devices
 +#Setup the TFTP client, then start a continuous ping (''-t'' switch is needed for this in Windows) to the router
 +#Plug in the router and start the TFTP client '''as soon as''' there is a TTL=100 ping response. The client should show transfer.
 +#*TTL=64 means application code has been reached. If the router isn't responding, it is soft-bricked (use OEM firmware)
 +#*Read about '''timing problems''' below: [[TFTP flash#Special for Vista, Win7 and Win 2008]]
-'''This article describes how to do a initial flash '''or''' a TFTP recovery flash for your device.'''+====Special Asus TFTP Flashing Procedures====
 +Some routers like the Asus WL-500xx series (WL-500G, WL-500G Premium, WL-500W, WL-500G Deluxe), need additional steps to perform a complete and proper initial flash. See this wiki page: [[Asus TFTP Flash]]
-* make sure you have a TFTP client installed (linux package, e.g. from [http://www.sf.net sf.net] or [http://www.dd-wrt.com/dd-wrtv2/downloads/others/tornado/Windows-TFTP/tftp2.exe Windows GUI TFTP Utility])+====Special Netgear NMRP Flashing Procedures====
-* connect your PC to one of the router's LAN ports using ethernet cable+Netgear router may require [[TFTP_flash#If_Something_Goes_Wrong|NMRP]] instead of TFTP.
-** tip: a hub or switch in-between your PC and router may be helpful, but it's optional+
-* make sure that your PC has a fixed IP address in the same network as your router, eg. Router: 192.168.1.1, PC: 192.168.1.2 ([[Installation#TFTP_Flashing_Buffalo_Routers_under_Windows|example w/picture]])+
-* get the latest dd-wrt release [http://www.dd-wrt.com/dd-wrtv2/downloads.php here] (plz use the mini version for devices with 4mb flash & the micro version for 2mb flash devices)+
-==Windows==+====Special for Vista, Win7 and Win 2008====
-The following example is for a belkin f5d130uk after a bricked update...+In order to catch the narrow window for TFTP flash, you should use platforms with simple TCP/IP implementations that don't have CTCP implemented: Windows XP or Linux are reported to work, but some have reported significant problems with Vista, Windows 7 or Windows 2008.'''
-NOTE: they already have a bootloader built in, no need for redboot...+* For more information see this [http://www.dd-wrt.com/phpBB2/viewtopic.php?p=319574#319574 posting]
 +Edit: While some may have reported problems, CTCP is definitely not the issue, because it is disabled by default in Windows Vista and Windows 7. So unless people are specifically turning it on, it isn't running. I personally just used TFTP on my router with no difficulties, although mine is a Netgear WNDR3700 that was waiting for a TFTP flash and didn't have this race condition at boot as some of these routers seem to. But again, even if you have an issue it's not CTCP. Check out the wikipedia article on CTCP for information on how to check if it is running and how to disable it (both are simple command line entries).
-===Command Line===+If having issues, try connecting a separate network switch between the PC and router, so the PC network port sees a connection before the router port is up. This should allow for a faster ping reply. Then follow the instructions as normal.
 +====Special for Linksys WRT54GL Users====
 +If the router seems to be bricked so that the power light is constantly blinking and pinging the router results in TLL=100 continuously, then there is still a great chance that tftp can help.
 +Firstly you must flash the router with the original firmware available at Linksys homepage www.linksys.com, since flashing it with DD-WRT probably won't give any result at all. Then do a 30/30/30 and after that you can flash with DD-WRT Mini. The initial flashing can be done with only the mini version, perhaps later you can move on to bigger versions of it.
-==== Asus WL-500 series example ====+==TFTP Tools==
-These steps are the same for :+With TFTP, all of the information about the transfer is specified during the initial command/setup; there is very little client/server interaction compared with standard FTP.
-* WL-500g Deluxe +
-* WL-500g Premium v1 & v2 +
-* WL-500W+
 +====Windows====
 +* Windows XP command line TFTP client is by default enabled
 +* Vista and Win7 command line TFTP needs enabled:
 +**''Control Panel'' -> ''Programs and Features'' -> ''Windows Features'' -> then check mark '''TFTP Client'''
 +* Windows GUI TFTP utilities:
 +:*Simple TFTP Utility [https://www.3iii.dk/linux/dd-wrt/tftp2.exe tftp2.exe]
 +::- The server/IP address is that of the router being flashed.
 +::- Leave the password blank.
 +::- Navigate and select the firmware you wish to flash.
 +::- Set retries to a number between 10 and 99.
 +:*Philippe Journin's [https://pjo2.github.io/tftpd64/ tftpd64] ''TFTP client'' (plus various servers: TFTP, DHCP, Syslog, and Log viewer)
 +::-Set the ''Server interface'', ''Host'' IP, ''Local File'', then click '''Put''' right after starting the router's TFTP server
 +::-[https://bitbucket.org/phjounin/tftpd64/downloads/ Download page] also provides tftp32
 +:*DrayTek Router Tools: This program will run all those pesky TFTP commands with a push of a button.
 +::ftp://ftp.draytek.com/Utility/Firmware%20Upgrade/ or https://www.draytek.com/products/utility/
 +:*Linksys Firmware Auto-Upgrade utility https://www.linksys.com/us/support-article?articleNum=137928
-'''Requirements:'''+====Linux====
-* conneting PC and Router through wired connection!+* '''tftp (official)'''
-* TFTP program+**Arch Linux: install as root with ''pacman -S tftp-hpa''
-* file [http://wl500g.dyndns.org/wl500g-clear-nvram.trx wl500g-clear-nvram.trx]+**Ubuntu: install as root with ''apt-get install tftp''
-* file [http://wl500g.dyndns.org/wl500g-recover.trx wl500g-recover.trx]+* '''atftp''': See [[TFTP flash#Using atftp on Linux|Using atftp on Linux]] for details including usage, description, and examples
-* file dd-wrt-v24_mini_asus.'''trx''' (or file as shown on [http://www.dd-wrt.com/dd-wrtv3/dd-wrt/hardware.html Supported Hardware] - type ''wl5'' to get the list)+*'''curl''' can also be used for tftp transfer: ''curl -T {file} tftp://192.168.1.1''
-* file dd-wrt-v24_xxxx.'''bin''' (or file as shown on [http://www.dd-wrt.com/dd-wrtv3/dd-wrt/hardware.html Supported Hardware] - type ''wl5'' to get the list)+
 +====Mac OS X====
 +* OS X ships with a command-line TFTP client.
 +connect 192.168.1.1
 + binary
 + rexmt 1
 + timeout 60
 + put dd-wrt.vXX_XXX.XXX
-'''Principle steps:'''+==Windows==
-:a) set PC to static IP: 192.168.1.2+
-:b) set router in recover-mode and load ''wl500g-clear-nvram.trx''+
-:c) set router in recover-mode and load ''wl500g-recover.trx''+
-:d) set router in recover-mode and load ''dd-wrt-v24_mini_asus.'''trx''''' file +
-:e) from with-in dd-wrt-mini web-GUI load any suitable ''dd-wrt-v24_xxxx.'''bin''''' file shown on [http://www.dd-wrt.com/dd-wrtv3/dd-wrt/hardware.html Supported Hardware] list+
- +
- +
-'''Detailed step-by-step guide:'''+
- +
-Preparations+
-* '''Step 1:''' Copy the four files mentioned above to a folder on your pc. Could be c:\dd-wrt +
-* '''Step 2:''' Make sure you have a TFTP client available on you pc.+
-* '''Step 3:''' Connect your computer via Ethernet cable to a LAN port on the router +
-* '''Step 4:''' Set your PC to static IP 192.168.1.2+
-* '''Step 5:''' Turn off the firewall on your PC - you need the TFTP program to be able to connect out through the firewall area to the router.+
- +
-* '''Step 6:''' Open a command prompt window, and goto the folder with the four files. Command could be ''cd \dd-wrt''+
- +
- +
-Set router in recover-mode and load ''wl500g-clear-nvram.trx''+
-* '''Step 7:''' Unplug the power cord from the router+
-* '''Step 8:''' Wait 20 seconds+
-* '''Step 9:''' Press and hold the reset button on the back of the router - Note that the reset button is recessed and you need a pen or paper clip to press it in. The button protruding from the back is the EZ Setup, which is not what you want to press.+
-* '''Step 10:''' While holding the reset button, plug the power cord into the router. ''Continue to hold the reset button until the power light starts flashing''. Let go of the reset button+
- +
-* '''Step 11:''' Use tftp to transfer ''wl500g-clear-nvram.trx'' to the router. The commands are as follows: +
-:in Windows: +
- tftp -i 192.168.1.1 put wl500g-clear-nvram.trx +
- +
-:on a Linux box:+
- user@box:$ tftp 192.168.1.1+
- > mode binary+
- > put wl500g-clear-nvram.trx+
- +
-* '''Step 12:''' Tftp should report a successful file transfer in 7-15 seconds. This means the file is transfered to RAM.+
-* '''Step 13:''' Wait 5 minutes for the file to be stored to FlashRAM. Then unplug the power from the router.+
- +
- +
-Set router in recover-mode and load ''wl500g-recover.trx''+
-* '''Step 14:''' Unplug the router, wait 20 seconds. Hold the reset button and plug the power cord into the router, ''continuing to hold the reset button until the power light flashes''. Release the reset button.+
- +
-* '''Step 15:''' Use tftp to transfer ''wl500g-recover.trx'' to the router. Same method as above, just change the file name.+
- +
- tftp -i 192.168.1.1 put wl500g-recover.trx +
- +
-* '''Step 16:''' Wait 5 minutes after tftp reports a successful file transfer before unplugging the router.+
- +
- +
-Set router in recover-mode and load ''dd-wrt-v24_mini_asus.'''trx''''' file +
-* '''Step 17:''' Unplug the router, wait 20 seconds. Hold the reset button and plug the power cord into the router, ''continuing to hold the reset button until the power light flashes''. Release the reset button.+
- +
-* '''Step 18:''' Use tftp to transfer the DD-WRT firmware .trx file to the router. MAKE SURE YOU USE THE CORRECT FILE. It should be be called something like dd-wrt.v**_asus.trx - ''Do not upload a .bin file yet''.+
- +
- tftp -i 192.168.1.1 put dd-wrt-v24_mini_asus.trx +
- +
-* '''Step 19:''' Wait 5 minutes after tftp reports a successful file transfer before unplugging the router. Unplug the power cord from the router, wait 20 seconds, and plug the power cord back into the router. +
- +
- +
-Load any suitable dd-wrt-v24_xxxx.bin file +
-* '''Step 20:''' From with-in dd-wrt-mini web-GUI load the ''dd-wrt-v24_xxxx.'''bin''''' file +
-: - Open a web browser to 192.168.1.1 (set your preferred root user name and password)+
-: - Click tab Administration -> Firmware Upgrade +
-: - at "After flashing, reset to" select "Reset to Default settings"+
-: - at "Please select a file to upgrade" point to the ''dd-wrt-v24_xxxx.'''bin''''' file+
-: - Click Upgrade+
-: - Wait until the router reboots on it own. Recommended: DO NOT TOUCH YOUR COMPUTER UNTIL ROUTER HAS REBOOTED. And under NO circumstances move the web browser away from the upgrade process, or you could brick your router. This whole process takes some five minutes, so go get some coffe - or go kiss your girlfriend/wife - I'm quite sure she will be happy to get this kind of indicator that you are now flashing your router. Who knows, maybe she'll start asking you to go flash your router more often - to get those kisses - one can always hope :-) +
- +
-==== Belkin f5d130uk example ====+====Command Line====
-The following example is for a belkin f5d130uk after a bricked update... NOTE: they already have a bootloader built in, no need for redboot... +This example is after a bricked update, using a Belkin f5d130uk (which has a bootloader built in, no need for redboot)
* ping the router permanently, by running in Start > Run: * ping the router permanently, by running in Start > Run:
Line 123: Line 88:
64 bytes from 192.168.2.1: icmp_seq=5 ttl=128 time=0.90 ms 64 bytes from 192.168.2.1: icmp_seq=5 ttl=128 time=0.90 ms
-... you will have to start the tftp upload in '''binary mode''' immediately after the first pings responses. the ttl of the boot tftp server will be 100 or 128. It usually does 5 pings responsed, after that it will boot the firmware in flash, this is the right time to flash (the ttl of ddwrt is only 64). if the upload doesn't work the first time, then you have to try the first steps again. you have to be very fast! ;-) maybe you will have to reset the device via reset button a few times to get the tftp-boot working (siemens, belkin and similar hw).<br>+... you will have to start the tftp upload in '''binary mode''' immediately after the first pings responses. The TTL of the boot tftp server will be 100 or 128. It usually does 5 pings responses, after that it will boot the firmware in flash, this is the right time to flash (the TTL of DD-WRT is only 64). If the upload doesn't work the first time, then you have to try the first steps again. you have to be very fast! ;-) Maybe you will have to reset the device via reset button a few times to get the tftp boot working (Siemens, Belkin and similar hardware).<br>
tftp -i 192.168.2.1 put dd-wrt.vXX_XXX.XXX tftp -i 192.168.2.1 put dd-wrt.vXX_XXX.XXX
-* wait a few seconds (be patient! dont reset the router! keep waiting!) when the upload is successful, change your computer IP to 192.168.1.10, and the router will start responding at 192.168.1.1 with dd-wrt <br>+* wait a few seconds (be patient! don't reset the router! keep waiting!) when the upload is successful, change your computer's IP address to 192.168.1.10, and the router will start responding at 192.168.1.1 with DD-WRT
-* username: '''root''' / pw: '''admin''' <br>+* user name: ''root'', password: ''admin''
-* always do a hardware factory reset after the successful flashing! <br>+* always do a hardware factory reset after the successful flashing!
-===Linksys TFTP GUI===+====Linksys TFTP GUI====
-Linksys has a GUI flash utility which may be tftp.exe on ftp://ftp.linksys.com/pub/network and can set the number of retries. It works with many other brands of routers too, not just Linksys.+Linksys has a GUI flash utility
 +: '''Special for Vista, Win7 and Win 2008'''
 +:In order to catch the narrow window for TFTP flash, you should use platforms with simple TCP/IP implementations that don't have CTCP implemented: Windows XP or Linux are reported to work, but some have reported significant problems with Vista, Win7 or W2K8.'''
 +:* For more information see this [http://www.dd-wrt.com/phpBB2/viewtopic.php?p=319574#319574 posting]
Here are the setup and use instructions for the TFTP utility. Here are the setup and use instructions for the TFTP utility.
-An updated copy can be found here [http://www.dd-wrt.com/dd-wrtv2/down.php?path=downloads%2Fothers%2Ftornado%2FWindows-TFTP/ TFTP2]+Both the Linksys original and a Linksys updated copy can be found here [https://dd-wrt.com/support/other-downloads/?path=others%2Ftornado%2FWindows-TFTP%2F TFTP]
-# Set your computer hardware adapter to a Static IP address within the same subnet as the router's original firmware (ex...set a static of 192.168.11.10 if your router's default IP is 192.168.11.1). Set the Mask to 255.255.255.0.+# Set your computer hardware adapter to a static IP address within the same subnet as the router's original firmware (ex...set a static of 192.168.11.10 if your router's default IP address is 192.168.11.1). Set the net mask to 255.255.255.0.
# Start the TFTP utility. # Start the TFTP utility.
#* The Server/IP address is that of the router being flashed. #* The Server/IP address is that of the router being flashed.
-#* Leave the Password blank.+#* Leave the password blank.
#* Navigate and select the firmware you wish to flash. #* Navigate and select the firmware you wish to flash.
#* Set retries to 10. #* Set retries to 10.
-# Now plug the Ethernet Cable from your computer into a LAN port of the router.+# Now plug the ethernet cable from your computer into a LAN port of the router.
-# Unplug the router....plug it back in...immediately hit the Upgrade button on the TFTP utility.+# Unplug the router, plug it back in, and immediately hit the Upgrade button on the TFTP utility.
-#* If the router does not flash immediately....stop the attempts and vary the timing from when you plug the unit in...to the time you hit the start button. I have had good luck flashing within the first 1/2 second of reapplying powering the device.+#* If the router does not flash immediately stop the attempts and vary the timing from when you plug the unit in to the time you hit the start button. I have had good luck flashing within the first 1/2 second of reapplying powering the device.
-#* Tip: Ping the router continuously. Start > Run > ''ping -t 192.168.x.x -w 10'' Power cycle the router (or tap the reset button) then press Upgrade as soon as you get the first ping reply.+#* Tip: ping the router continuously. Start > Run > ''ping -t 192.168.x.x -w 10''. Power cycle the router (or tap the reset button) then press Upgrade as soon as you get the first ping reply.
-# Once it flashes and you receive the Success message....wait for a full 2 minutes while the new firmware flash configures itself...<font color=red>'''DO NOT depower the router!'''</font>+# Once it flashes and you receive the Success message. Wait for a full 2 minutes while the new firmware flash configures itself. <font color=red>'''DO NOT power down the router!'''</font>
-# After the 2 minutes are up....do a [[Hard reset or 30/30/30]] on the router...then configure at 192.168.1.1 (dd-wrt's default IP address). The default dd-wrt Username/Password is root/admin.+# After the 2 minutes do a [[Hard reset or 30/30/30]] on the router, then configure at 192.168.1.1 (DD-WRT's default IP address). The default DD-WRT username/password is root/admin.
-==Linux and Mac OS X==+==Mac OS X==
 +OS X ships with a command-line TFTP client.<br>
-OS X ships with a command-line TFTP client. <br>+First, download the firmware file and put it in your user folder (/Users/yourusername/).<br>
 + 
 +Then connect your computer directly to your router via ethernet. Go to System Preferences > Network. Click on "Ethernet" in the left panel and change "Configure IPv4" to "Manually". Then change "IP address" to 192.168.1.x (where x is any number between 2 & 255).<br>
 + 
 +Then copy & paste the following text into a text editor:
 + connect 192.168.1.1
 + binary
 + rexmt 1
 + timeout 60
 + put dd-wrt.vXX_XXX.XXX
 + 
 +Change the last line to the filename of the firmware file, which you just moved to your user folder. Copy the whole thing, including the line break after the last line.<br>
 + 
 +Now open Applications > Utilities > Terminal. Enter:
 + tftp
 + 
 +A "tftp>" command prompt will appear. Now press the reset button on your router. On the tftp command line in Terminal, paste (Cmd+v) the text you copied. Since you copied the line break at the end, tftp will execute the command at the moment you paste it. Depending on your router, you may have to paste it multiple times to get the timing right.<br>
 + 
 +If it works, you'll see something like this:
 + tftp> connect 192.168.1.1
 + tftp> binary
 + tftp> rexmt 1
 + tftp> timeout 60
 + tftp> put dd-wrt.vXX_XXX.XXX
 + Sent 1769472 bytes in 9.0 seconds
 + 
 +==Linux==
In Linux, tftp can generally be installed with whatever package manager your distribution uses. <br> In Linux, tftp can generally be installed with whatever package manager your distribution uses. <br>
on suse: on suse:
Line 180: Line 175:
If it worked, it will say something like "Sent 1769472 bytes in 9.0 seconds" If it worked, it will say something like "Sent 1769472 bytes in 9.0 seconds"
-If it didn't work, it will say "Transfer timed out." This is often because it cannot connect to the IP. Make sure you have manually set your computer's IP to one in the router's subnet. +If it didn't work, it will say "Transfer timed out." This is often because it cannot connect to the IP address. Make sure you have manually set your computer's IP address to one in the router's subnet.
You can quit tftp with the 'quit' command or hitting ctrl+D. You can quit tftp with the 'quit' command or hitting ctrl+D.
Line 187: Line 182:
(you will need to unpack the tarball and compile the program) (you will need to unpack the tarball and compile the program)
-Another way of doing this is using '''atftp'''. You can search it in your package manager. +====Using atftp on Linux====
 +Another way of doing this is using ''atftp''. You can install aftp by search it in your package manager.
 + 
On Ubuntu: On Ubuntu:
sudo aptitude install atftp sudo aptitude install atftp
Line 207: Line 204:
Disconnect all your network cables from your router, only leaving one from the computer to the router. Then open another terminal and ping to 192.168.1.1 Disconnect all your network cables from your router, only leaving one from the computer to the router. Then open another terminal and ping to 192.168.1.1
ping 192.168.1.1 ping 192.168.1.1
-Then unplug and plug back the energy supply and when you see the first ping response from the router you must hit enter in the atftp terminal. Good luck! If everything is allright, you should see a lot of output, from all the transference. At the end you should see the orange/yellow light up. Then you should wait a couple more minutes (you never know what's happening there :D) and then try the [http://www.dd-wrt.com/wiki/index.php/Hard_reset_or_30/30/30 Hard reset aka 30/30/30]+Then unplug and plug back the energy supply and when you see the first ping response from the router you must hit enter in the atftp terminal. Good luck! If everything is alright, you should see a lot of output, from all the transference. At the end you should see the orange/yellow light up. Then you should wait a couple more minutes (you never know what's happening there :D) and then try the [http://www.dd-wrt.com/wiki/index.php/Hard_reset_or_30/30/30 Hard reset aka 30/30/30]
-About the atftp command: we are putting (-p) a local file (-l) called code.bin to the IP 192.168.1.1 asking for fully information (verbose) and showing all packages (trace), also that it must be trying for one minute (timeout 60) and in octet mode. Remember, if you get "code pattern error", try with the official Linksys firmware. More information: +About the atftp command: we are putting (-p) a local file (-l) called code.bin to the IP address 192.168.1.1 asking for fully information (verbose) and showing all packages (trace), also that it must be trying for one minute (timeout 60) and in octet mode. Remember, if you get "code pattern error", try with the official Linksys firmware. More information:
man atftp man atftp
atftp --help atftp --help
-'''Important''': you should allways try atftp with the official firmware and then flashing to dd-wrt with the HTTP webpage on Administration, "Upgrade Firmware"; specially if you get '''"code pattern error"'''.+'''Important''': you should always try atftp with the official firmware and then flashing to DD-WRT with the HTTP webpage on Administration, "Upgrade Firmware"; specially if you get '''"code pattern error"'''.
-'''Note''': if you use Gnome or KDE you can get problems while trying to put your static IP. Most of the times, applications like NetworkManager (aka nm-applet) or knetworkmanager will try to get a dynamic IP, so you should first kill them. For example:+'''Note''': if you use Gnome or KDE you can get problems while trying to put your static IP address. Most of the times, applications like NetworkManager (aka nm-applet) or knetworkmanager will try to get a dynamic IP address, so you should first kill them. For example:
sudo killall NetworkManager sudo killall NetworkManager
Line 221: Line 218:
sudo killall nm-applet sudo killall nm-applet
-==Related Links==+==If Something Goes Wrong==
 +*If the router fails to reboot (power light doesn't stop flashing, no web interface, etc.), see [[Recover from a bad flash]].
 +*Netgear routers may require NMRP (Netgear Management Remote Protocol) instead of TFTP.
 +**[https://github.com/jclehner/nmrpflash nmrpflash] is available for Windows ([https://npcap.com/#download NpCap] also required), Linux, and MacOS
 +**Set a static IP as per TFTP, then run: ''nmrpflash -L'' to get the LAN connection for NMRP e.g. for ''net0''
 +**Type '''but do not yet run''': ''nmrpflash -vi net0 -f {firmware}
 +**Power off the router, wait 10s, then power up and run the above command
 +**This should show a message like: Advertising NMRP server on eth0 … /
 +**The first run may give an error: ''Timeout while waiting for TFTP_UL_REQ''
 +***Immediately 'up arrow' to bring back the command and re-run it again
 +**'''The transfer could take up to 15min.''' Reboot after seeing: ''Remote finished. Closing connection. Reboot''...
 +**Retry if not working, and run ''ping''' to monitor power-up timing: ''TTL=100'' is for TFTP/NMRP
 +==Related Links==
[[Recover from a Bad Flash]] [[Recover from a Bad Flash]]
Line 229: Line 238:
[[TFTP Flashing a Belkin F5D7230]] - more detailed notes on flashing the F5D7230 (v1000, specifically) [[TFTP Flashing a Belkin F5D7230]] - more detailed notes on flashing the F5D7230 (v1000, specifically)
-[[Installation#How_to_Install_DD-WRT_onto_an_Asus_WL-500W_using_Ubuntu_Linux|Using Ubuntu and tftp to flash an Asus WL-500W]]+[[Asus TFTP Flash]] - special steps for WL-500gP, WL-500W and WL-500g Deluxe
 + 
 +[[Asus TFTP Flash#How to Install DD-WRT onto an Asus WL-500W Using Ubuntu Linux|Using Ubuntu and tftp to flash an Asus WL-500W]]
-[[Category:English documentation]]+[[Category:Flashing networking hardware]]
 +[[Category:Installation]]
 +[[Category:Recovery]]

Current revision

Contents


[edit] General

This article describes how to do an initial flash or a TFTP recovery flash for your device.

  1. Unplug the router, get a TFTP client for the PC, and connect it via network cable to a router LAN port
  2. Set a fixed IP address on the PC with the same network as your router, e.g. Router: 192.168.1.1, PC: 192.168.1.2
  3. Get a known good DD-WRT release. Use the Supported_Devices, the device wiki, or the forum for recommended files.
    • For recovering a bad flash, the OEM firmware might be required
    • Use a mini build for 4+ MB flash devices (when possible) or micro build for 2 MB flash devices
  4. Setup the TFTP client, then start a continuous ping (-t switch is needed for this in Windows) to the router
  5. Plug in the router and start the TFTP client as soon as there is a TTL=100 ping response. The client should show transfer.

[edit] Special Asus TFTP Flashing Procedures

Some routers like the Asus WL-500xx series (WL-500G, WL-500G Premium, WL-500W, WL-500G Deluxe), need additional steps to perform a complete and proper initial flash. See this wiki page: Asus TFTP Flash

[edit] Special Netgear NMRP Flashing Procedures

Netgear router may require NMRP instead of TFTP.

[edit] Special for Vista, Win7 and Win 2008

In order to catch the narrow window for TFTP flash, you should use platforms with simple TCP/IP implementations that don't have CTCP implemented: Windows XP or Linux are reported to work, but some have reported significant problems with Vista, Windows 7 or Windows 2008.

  • For more information see this posting

Edit: While some may have reported problems, CTCP is definitely not the issue, because it is disabled by default in Windows Vista and Windows 7. So unless people are specifically turning it on, it isn't running. I personally just used TFTP on my router with no difficulties, although mine is a Netgear WNDR3700 that was waiting for a TFTP flash and didn't have this race condition at boot as some of these routers seem to. But again, even if you have an issue it's not CTCP. Check out the wikipedia article on CTCP for information on how to check if it is running and how to disable it (both are simple command line entries).

If having issues, try connecting a separate network switch between the PC and router, so the PC network port sees a connection before the router port is up. This should allow for a faster ping reply. Then follow the instructions as normal.

[edit] Special for Linksys WRT54GL Users

If the router seems to be bricked so that the power light is constantly blinking and pinging the router results in TLL=100 continuously, then there is still a great chance that tftp can help. Firstly you must flash the router with the original firmware available at Linksys homepage www.linksys.com, since flashing it with DD-WRT probably won't give any result at all. Then do a 30/30/30 and after that you can flash with DD-WRT Mini. The initial flashing can be done with only the mini version, perhaps later you can move on to bigger versions of it.

[edit] TFTP Tools

With TFTP, all of the information about the transfer is specified during the initial command/setup; there is very little client/server interaction compared with standard FTP.

[edit] Windows

  • Windows XP command line TFTP client is by default enabled
  • Vista and Win7 command line TFTP needs enabled:
    • Control Panel -> Programs and Features -> Windows Features -> then check mark TFTP Client
  • Windows GUI TFTP utilities:
- The server/IP address is that of the router being flashed.
- Leave the password blank.
- Navigate and select the firmware you wish to flash.
- Set retries to a number between 10 and 99.
  • Philippe Journin's tftpd64 TFTP client (plus various servers: TFTP, DHCP, Syslog, and Log viewer)
-Set the Server interface, Host IP, Local File, then click Put right after starting the router's TFTP server
-Download page also provides tftp32
  • DrayTek Router Tools: This program will run all those pesky TFTP commands with a push of a button.
ftp://ftp.draytek.com/Utility/Firmware%20Upgrade/ or https://www.draytek.com/products/utility/

[edit] Linux

  • tftp (official)
    • Arch Linux: install as root with pacman -S tftp-hpa
    • Ubuntu: install as root with apt-get install tftp
  • atftp: See Using atftp on Linux for details including usage, description, and examples
  • curl can also be used for tftp transfer: curl -T {file} tftp://192.168.1.1

[edit] Mac OS X

  • OS X ships with a command-line TFTP client.

connect 192.168.1.1

binary
rexmt 1
timeout 60
put dd-wrt.vXX_XXX.XXX

[edit] Windows

[edit] Command Line

This example is after a bricked update, using a Belkin f5d130uk (which has a bootloader built in, no need for redboot)

  • ping the router permanently, by running in Start > Run:
 ping -t 192.168.2.1 -t

and see if it is responding, e.g. like this

 64 bytes from 192.168.2.1: icmp_seq=1 ttl=64 time=2.90 ms
 64 bytes from 192.168.2.1: icmp_seq=2 ttl=64 time=0.264 ms
 64 bytes from 192.168.2.1: icmp_seq=3 ttl=64 time=1.44 ms
  • reboot the router via web-if or powercycle (the ping response will stop)
  • if you see the the first ping response again ...
 From 192.168.2.1 icmp_seq=1 Destination Host Unreachable
 From 192.168.2.1 icmp_seq=2 Destination Host Unreachable
 64 bytes from 192.168.2.1: icmp_seq=3 ttl=128 time=2.90 ms
 64 bytes from 192.168.2.1: icmp_seq=4 ttl=128 time=3.50 ms
 64 bytes from 192.168.2.1: icmp_seq=5 ttl=128 time=0.90 ms

... you will have to start the tftp upload in binary mode immediately after the first pings responses. The TTL of the boot tftp server will be 100 or 128. It usually does 5 pings responses, after that it will boot the firmware in flash, this is the right time to flash (the TTL of DD-WRT is only 64). If the upload doesn't work the first time, then you have to try the first steps again. you have to be very fast! ;-) Maybe you will have to reset the device via reset button a few times to get the tftp boot working (Siemens, Belkin and similar hardware).

 tftp -i 192.168.2.1 put dd-wrt.vXX_XXX.XXX
  • wait a few seconds (be patient! don't reset the router! keep waiting!) when the upload is successful, change your computer's IP address to 192.168.1.10, and the router will start responding at 192.168.1.1 with DD-WRT
  • user name: root, password: admin
  • always do a hardware factory reset after the successful flashing!

[edit] Linksys TFTP GUI

Linksys has a GUI flash utility

Special for Vista, Win7 and Win 2008
In order to catch the narrow window for TFTP flash, you should use platforms with simple TCP/IP implementations that don't have CTCP implemented: Windows XP or Linux are reported to work, but some have reported significant problems with Vista, Win7 or W2K8.
  • For more information see this posting

Here are the setup and use instructions for the TFTP utility. Both the Linksys original and a Linksys updated copy can be found here TFTP

  1. Set your computer hardware adapter to a static IP address within the same subnet as the router's original firmware (ex...set a static of 192.168.11.10 if your router's default IP address is 192.168.11.1). Set the net mask to 255.255.255.0.
  2. Start the TFTP utility.
    • The Server/IP address is that of the router being flashed.
    • Leave the password blank.
    • Navigate and select the firmware you wish to flash.
    • Set retries to 10.
  3. Now plug the ethernet cable from your computer into a LAN port of the router.
  4. Unplug the router, plug it back in, and immediately hit the Upgrade button on the TFTP utility.
    • If the router does not flash immediately stop the attempts and vary the timing from when you plug the unit in to the time you hit the start button. I have had good luck flashing within the first 1/2 second of reapplying powering the device.
    • Tip: ping the router continuously. Start > Run > ping -t 192.168.x.x -w 10. Power cycle the router (or tap the reset button) then press Upgrade as soon as you get the first ping reply.
  5. Once it flashes and you receive the Success message. Wait for a full 2 minutes while the new firmware flash configures itself. DO NOT power down the router!
  6. After the 2 minutes do a Hard reset or 30/30/30 on the router, then configure at 192.168.1.1 (DD-WRT's default IP address). The default DD-WRT username/password is root/admin.

[edit] Mac OS X

OS X ships with a command-line TFTP client.

First, download the firmware file and put it in your user folder (/Users/yourusername/).

Then connect your computer directly to your router via ethernet. Go to System Preferences > Network. Click on "Ethernet" in the left panel and change "Configure IPv4" to "Manually". Then change "IP address" to 192.168.1.x (where x is any number between 2 & 255).

Then copy & paste the following text into a text editor:

 connect 192.168.1.1
 binary
 rexmt 1
 timeout 60
 put dd-wrt.vXX_XXX.XXX

Change the last line to the filename of the firmware file, which you just moved to your user folder. Copy the whole thing, including the line break after the last line.

Now open Applications > Utilities > Terminal. Enter:

 tftp

A "tftp>" command prompt will appear. Now press the reset button on your router. On the tftp command line in Terminal, paste (Cmd+v) the text you copied. Since you copied the line break at the end, tftp will execute the command at the moment you paste it. Depending on your router, you may have to paste it multiple times to get the timing right.

If it works, you'll see something like this:

 tftp> connect 192.168.1.1
 tftp> binary
 tftp> rexmt 1
 tftp> timeout 60
 tftp> put dd-wrt.vXX_XXX.XXX
 Sent 1769472 bytes in 9.0 seconds

[edit] Linux

In Linux, tftp can generally be installed with whatever package manager your distribution uses.
on suse:

 smart install tftp

on fedora:

 yum install tftp

on ubuntu

 sudo apt-get install tftp

etc.
The tftp client for Linux and OS X is very similar. When invoked, it gives the user a prompt and takes commands from the standard input.
Binary mode can be set with command-line flags - in OS X, the "-e" flag sets binary mode (among other things which are less important), and in Linux "-m binary". Binary can be set from the prompt in either (this is done below for consistency).

Typical usage looks like:

 tftp 192.168.x.x
 > binary
 > put dd-wrt.vXX_XXX.XXX

Because the transfer must be initiated in a narrow time window during the router's bootup, tftp's retransmit option is useful. In the following sequence of commands, tftp will retry to send the file every second for one minute. This can be issued just before the router is booted, so that it will retry to send every second while the router boots.

 tftp 192.168.x.x
 > binary
 > rexmt 1
 > timeout 60
 > put dd-wrt.vXX_XXX.XXX

If it worked, it will say something like "Sent 1769472 bytes in 9.0 seconds"

If it didn't work, it will say "Transfer timed out." This is often because it cannot connect to the IP address. Make sure you have manually set your computer's IP address to one in the router's subnet.

You can quit tftp with the 'quit' command or hitting ctrl+D.

Many Linksys routers require a special version of tftp that has a simple form of authentication. You can download and compile a special version of tftp that works on these routers from: http://redsand.net/projects/linksys-tftp/linksys-tftp.php (you will need to unpack the tarball and compile the program)

[edit] Using atftp on Linux

Another way of doing this is using atftp. You can install aftp by search it in your package manager.

On Ubuntu:

sudo aptitude install atftp

On Debian (as root):

aptitude install atftp

On Fedora (as root):

yum install atftp

On Suse (as root):

smart install atftp 

Then you go to the folder where you downloaded the official Linksys firmware, for instance if you downloaded it in your desktop:

cd ~Desktop

Unrar the file, for instance if the file is WRT54GL_v4.30.11_012_ETSI_EN_code.rar

unrar x WRT54GL_v4.30.11_012_ETSI_EN_code.rar

Rename the firmware to code.bin.

cp WRT54GL_v4.30.11_012_ETSI_EN_code.bin code.bin

Then you prepare this command (do not press enter yet):

atftp --option "mode octet" --option "timeout  60" --verbose --trace -p -l code.bin 192.168.1.1

Disconnect all your network cables from your router, only leaving one from the computer to the router. Then open another terminal and ping to 192.168.1.1

ping 192.168.1.1

Then unplug and plug back the energy supply and when you see the first ping response from the router you must hit enter in the atftp terminal. Good luck! If everything is alright, you should see a lot of output, from all the transference. At the end you should see the orange/yellow light up. Then you should wait a couple more minutes (you never know what's happening there :D) and then try the Hard reset aka 30/30/30

About the atftp command: we are putting (-p) a local file (-l) called code.bin to the IP address 192.168.1.1 asking for fully information (verbose) and showing all packages (trace), also that it must be trying for one minute (timeout 60) and in octet mode. Remember, if you get "code pattern error", try with the official Linksys firmware. More information:

man atftp 
atftp --help

Important: you should always try atftp with the official firmware and then flashing to DD-WRT with the HTTP webpage on Administration, "Upgrade Firmware"; specially if you get "code pattern error".

Note: if you use Gnome or KDE you can get problems while trying to put your static IP address. Most of the times, applications like NetworkManager (aka nm-applet) or knetworkmanager will try to get a dynamic IP address, so you should first kill them. For example:

sudo killall NetworkManager

or

sudo killall nm-applet

[edit] If Something Goes Wrong

  • If the router fails to reboot (power light doesn't stop flashing, no web interface, etc.), see Recover from a bad flash.
  • Netgear routers may require NMRP (Netgear Management Remote Protocol) instead of TFTP.
    • nmrpflash is available for Windows (NpCap also required), Linux, and MacOS
    • Set a static IP as per TFTP, then run: nmrpflash -L to get the LAN connection for NMRP e.g. for net0
    • Type but do not yet run: nmrpflash -vi net0 -f {firmware}
    • Power off the router, wait 10s, then power up and run the above command
    • This should show a message like: Advertising NMRP server on eth0 … /
    • The first run may give an error: Timeout while waiting for TFTP_UL_REQ
      • Immediately 'up arrow' to bring back the command and re-run it again
    • The transfer could take up to 15min. Reboot after seeing: Remote finished. Closing connection. Reboot...
    • Retry if not working, and run ping' to monitor power-up timing: TTL=100 is for TFTP/NMRP

[edit] Related Links

Recover from a Bad Flash

Flash Your Siemens SE505

TFTP Flashing a Belkin F5D7230 - more detailed notes on flashing the F5D7230 (v1000, specifically)

Asus TFTP Flash - special steps for WL-500gP, WL-500W and WL-500g Deluxe

Using Ubuntu and tftp to flash an Asus WL-500W