Serial Port Access and Firmware Recovery for TL WR842ND
Author: Terry Gillett
The following describes how to get access to the serial port on the WR842ND V1 router and how to recover the firmware on the device in the event that the device is not accessible by normal means.
The process requires a PC running a serial port, a level shifter adapter or USB serial adapter, a serial terminal program, and a tftp server program.
Accessing Router Serial Port
The WR842ND V1 router has serial port connections available on the PCB that are easily accessible with normal soldering tools.
To open the router, remove the two small rubber feet at the back of the router and remove the screws underneath. Then carefully lift the top cover from the back. There are snap connectors along the sides and front of the case that need to be popped open.
The serial connections are located on the board behind Reset button, next to ferrite coil glued to pcb. (see photos)
Pin 1 - Tx (marked with bar - towards centre of pcb)
Pin 2 - Rx
Pin 3 - Gnd
Pin 4 - +ve
Connect a 10k Ohm resistor from Tx pin to +ve pin to get correct levels.
The serial connections may conveniently be brought out of the case using a "stereo" 3.5mm socket with tip, ring and sleeve connections. Use the sleeve for ground. I used the tip for TX and ring for RX. See photos for mounting in case.
The serial port signals from the router are at logic voltage levels, and so a 'level shifter' is required to change the voltages to the RS232 levels required for a serial port on the PC.
Alternatively, a USB serial adapter can be used (eg the Sparkfun.com CP2103 USB Serial Breakout board) in order to utilse a USB port on the PC instead of a serial port (particularly as serial are ommitted from many new PC/Laptops)
Connect router Tx, Rx, Gnd to the Adapter:
Make sure that the output from the router is connected to the input of the adapter, and vice versa. e.g. using the CP2103 USB serial adapter, connect Tx (router) to Rx (adapter), and Rx (router) to Tx (adapter)
The correct settings for accessing the WR842ND serial console are as follows:
Bits per second: 115200
Data bits: 8
Stop bits: 1
Flow control: None
(For info: Console access - Password to get prompt is "tpl". Not required for this firmware recovery process)
Set up the TFTP Server
This section describes the installation and configuration of the tftpd-hpa software on a Ubuntu (typically 14.04) workstation.
(For a Windows workstation see e.g. http://tftpd32.jounin.net/)
A. Install tftpd-hpa
$ sudo apt-get install tftpd-hpa
B. Configure tftpd-hpa for Daemon Operation
Configure the newly installed TFTP to run as a daemon by editing the /etc/default/tftpd-hpa file:
$ sudo gedit /etc/default/tftpd-hpa
$sudo vi /etc/default/tftpd-hpa
Add the lines:
TFTP_OPTIONS="--secure -c" RUN_DAEMON="yes"
TFTP_USERNAME="tftp" TFTP_DIRECTORY="/srv/tftp" TFTP_ADDRESS="0.0.0.0:69" TFTP_OPTIONS="--secure -c" RUN_DAEMON="yes"
Note: TFTP Options " -c " is for writable tftp directory, otherwise when you test you will get "Error code 2: Only absolute filenames allowed"
C. Setup the TFTP root directory
This config file also defines where your TFTP server is serving by default i.e. from the tftp root directory.
The default location is /srv/tftp (or /var/lib/tftpboot) but may be changed in this config file if desired.
The firmware bin file to be transmitted to the router should be copied into this directory before the tftp service is started.
D. Restart, Start or Stop the TFTP service
Start (or stop) the newly configured TFTP service as follows:
For Ubuntu 10.04 and later, use: $ sudo service tftpd-hpa restart (or start or stop)
For earlier versions of Ubuntu use: $ sudo /etc/init.d/tftpd-hpa restart (or start or stop)
E. Test the TFTP server
Save a suitable small file 'myfile' in the TFTP Server root directory.
Change to a working directory.
Use the 'tftp' command in a terminal session to copy the file to the working directory:
$ tftp tftp> ? (for a list of commands) tftp> connect localhost OR connect <IP_address_of_PC> tftp> get myfile
This will get the file from the default tftp directory as specified in the config file. You should see the file received with details of size and time.
If you get an error about requiring absolute path names, check config file as above for options, and directory permissions for RWX.
You can also specify an absolute path to the file in any location.
Set Up Serial Terminal Program
To use the serial interface on the router, a Serial Terminal program is required on your PC.
Install a suitable serial terminal program, e.g. GtkTerm for a Ubuntu PC.
Set the configuration to be:
- 115kbps - no parity - 8 bits - 1 stop bit - no Flow Control
The serial port setting will typically be /dev/ttyS0 for the first serial port on the PC, or /dev/ttyUSB0 for a USB serial adapter.
Firmware recovery uses the integrated tftp capability of the WR842ND router to load up the original TP Link OEM firmware, allowing new OpenWrt firmware to be flashed from the Firmware Upgrade screen.
Enter Failsafe mode
Remove the power plug from the router.
Press and hold the WPS/RESET button (next to USB port)
Insert the power plug without releasing the RESET button, wait a moment for the USB LED (second from end near power connector) to light, then release the RESET button
No LEDs other than the one for USB (and any attached Ethernet ports) should be lit.
The boot up sequence will be displayed on the serial terminal, ending in the tftp waiting state.
The device now uses the IP 192.168.1.86. It repeatedly tries to download a file named "wr842ndv1_tp_recovery.bin" from a tftpd server with the IP 192.168.1.66.
The following steps will install a replacement TP-Link firmware image to the device.
Get TP-Link Firmware
Download an appropriate firmware file from TP-LINK site.
Unpack the .zip file to get the binary file.
Copy and rename the binary file, so it matches the name required by the router: wr842ndv1_tp_recovery.bin
Copy the file into the tftp server root directory (see above).
Set up PC
Configure your PC LAN adapter ip address to IP 192.168.1.66 and connect your PC to one of the LAN ports of the router with an Ethernet cable.
Install a tftp server (See above)
Make sure the tftp server is NOT running.
Load the Firmware File
Put the router into failsafe mode FIRST (press reset button and plug power cable release reset button after 3 second), and then launch the tftp server, otherwise it might have problems trying to bind to the PC network interface.
After you launch the tftp server, messages in the serial terminal console will indicate that the process of file transfer is in progress.
After some time you will see all LEDs flashing once, followed by a normal restart of the router.
Install New Firmware
The IP address for the router with TP Link firmware is 192.168.1.1. The router has DHCP running on the LAN ports.
Connect your PC to the router with an Ethernet cable connected to one of the LAN ports.
Point your browser to the router address to access the web interface.
Now you can install an Openwrt FACTORY image via the vendor Firmware Upgrade web page of the router.