On most devices, the vendor provided boot loader is a partition separated from the actual firmware. In case of a failed flash process or in case of a misconfiguration, the device's boot loader usually is still untouched and fully working. It the boot loader has a built-in “TFTP recovery mode”, it enables to regain control of a device with a broken firmware partition, by allowing a recovery flash process (which will also reset your configuration to the device defaults).
For many routers the recovery works by starting a TFTP server on your computer. Then device with the broken firmware has to be started up in TFTP recovery mode. Some devices then will pull the network-provided firmware file over TFTP network protocol to the OpenWrt and hopefully recover with a successful emergency flash process.
Some devices do not have automatic pull function and they need manual TFTP copy commands in recovery mode to get firmware from TFTP and firmware install.
NOTE: Some other routers, e.g. many Netgear routers, have TFTP server on themselves, and the PC needs to act as TFTP client. The “TFTP recovery mode” can also mean that, so look carefully at info about your router to find out which method your router possibly supports.
The below article mainly advises on the “TFTP client at router” recovery.
TFTP recovery over Ethernet is not supported by every router model. TFTP recovery is based on a device- and vendor-specific boot loader that may or may not be present on your device. Check the OpenWrt device page for your precise model to find out, if your device has a boot loader supporting TFTP recovery. If your device supports it, then this recovery function will still be present in your device boot loader, after OpenWrt firmware has been flashed onto the device.
The following procedure only describes how to set up a TFTP server over Ethernet for the TFTP recovery/install preparation process, it does not describe the device-specific flash recovery/install process. For the actual flash process you have to consult the vendor provided documentation, the Internet, the OpenWrt Forum or the OpenWrt device pages.
macOS provides a native tftpd server that runs the command line. There are also GUI applications that are available for those that prefer them.
For recent versions of macOS, the system-supplied
tftpd is managed with
launchctl. Users should be comfortable with command-line usage and
sudo to take this approach. As confirmed on macOS Sierra 10.12.6 and macOS Mojave 10.14.2, the general steps involved are
$ sudo cp path/to/file/to/serve.bin /private/tftpboot/the_name_the_device_is_looking_for.bin $ sudo launchctl load -F /System/Library/LaunchDaemons/tftp.plist
tfptdis running by looking for the UDP listener on port 69
$ netstat -an | fgrep \*.69 udp4 0 0 *.69 *.*
tftpd, shut it down with
$ sudo launchctl unload -F /System/Library/LaunchDaemons/tftp.plist
As an example of a GUI-driven tftp server, TFTPServer.app from http://ww2.unime.it/flr/tftpserver/ provides a pleasant GUI wrapper around the native command that makes the process less error prone. This procedure was tested with TftpServer.app v 3.4.1 on OSX 10.10.5 in December 2016.
While there is a command line TFTP server/client feature in windows, it's easier to use a third party one that has a proper graphical interface.
A simple and free TFTP application is Tftpd32, available here (Tftpd64 is the 64-bit version and will be used in this example).
Download the portable version, and unzip it in a folder. You should see the manual, a license in a PDF file, a configuration file, and the application executable itself.
Place the file you want to send (the firmware file usually) in the same folder where you find the Tftpd64 program file. The folder exposed through TFTP can be changed by clicking on Browse button, but in most situations you don't need to do that.
Configure your ethernet port according to your device's own recovery method as detailed in Rescue from failed firmware upgrade, note that in most cases you can't use that port to connect to the internet until you reconfigure it back like it was before.
Double-click on the Tftpd64 program file and you should get a Windows Firewall popup asking you to grant access. Check both options, to allow Tftpd64 to communicate over both home/work and public networks. This is very important, if the Windows Firewall blocks your TFTP server you won't be able to access it from the device you want to recover.
Click on the drop-down menu called Server Interfaces and select your PC's ethernet port.
Now the tftp server is online and ready, and the file(s) in it can be accessed as normal.
Install atftpd from repository on Debian/Ubuntu/Mint
# apt install atftpd
Install atftpd from repository on RedHat/Fedora/Centos
# yum install atftpd
Create directory where you want to put the image file
# mkdir /srv/tftp
Put an image file into your directory - actual name will vary
# cp ~/tp_recovery.bin /srv/tftp
Change the ownership of the folder and the file in it
# chown nobody:nogroup -R /srv/tftp
Run TFTP server
# atftpd --daemon /srv/tftp
Check if your TFTP server is listening
# netstat -lunp|grep 69
If not set, you should try running TFTP server as superuser.
Check that you can in fact pull the file from your tftp server. Preferably from another computer call your tftp server IP: (or if not possible, in same server call IP 0.0.0.0)
# tftp 192.168.0.66 tftp> get tp_recovery.bin Received 8152633 bytes in 0.8 seconds tftp> quit
If you have received the file, congratulations, it's ready.
TFTP file transfer doesn't work from local computer
TFTP file transfer works from local computer, but not from another computer:
TFTP file transfer works from another computer, but not from router: