Post

UART Serial Connection to D-Link Router - Complete Guide

UART Serial Connection to D-Link Router - Complete Guide

Introduction

UART (Universal Asynchronous Receiver-Transmitter) is a fundamental protocol used in embedded systems and networking devices for serial communication. D-Link routers often have a UART interface that allows direct access to the bootloader, kernel logs, and device shell. This guide will walk you through the process of connecting to a D-Link router via UART for debugging, troubleshooting, and advanced configuration.

What is UART?

UART is a serial communication protocol that transmits data one bit at a time over two wires: TX (transmit) and RX (receive).

Key UART Parameters

  • Baud Rate: Speed of transmission (typically 115200 bps for routers)
  • Data Bits: Usually 8 bits per character
  • Stop Bits: Usually 1 bit
  • Parity: Usually None
  • Flow Control: Usually None
  1. Access bootloader and uboot console
  2. View boot messages and kernel logs
  3. Get root shell access without web interface
  4. Recover from failed firmware updates
  5. Debug hardware issues
  6. Modify firmware or configuration before booting

Required Hardware

To connect to a D-Link router via UART, you’ll need:

  • USB-to-UART Adapter: Commonly uses CH340, FTDI, or CP2102 chips
  • Jumper Wires: Female-to-female or appropriate connectors
  • Computer: With terminal emulation software
  • D-Link Router: With exposed UART pins
  • Optional Power Supply: If you need to power the router separately
  • Multimeter: For identifying pins (optional but helpful)

Most D-Link routers have UART headers with 4 pins arranged as:

1
2
VCC  TX  RX  GND
 1   2   3   4

Or sometimes labeled directly on the board:

1
3.3V  TX  RX  GND

Identifying Pins with a Multimeter

  1. Set multimeter to voltage mode (DC)
  2. Connect one probe to a known ground point (like the GND pad)
  3. Measure voltage on suspected pins
  4. VCC will show steady 3.3V
  5. TX will show variable voltage, press reset button or restart, you should observe the change in voltage
  6. RX will show 0 voltage since it’s expecting input, some devices have this pin disabled, limiting the connection to read-only

Hardware Connection Guide

Step 1: Prepare Your Router

  • Unplug the router from power
  • Remove the case (use pry tool gently)
  • Locate the UART header or test pads
  • Identify VCC, TX, RX, and GND pins

Step 2: Connect the USB-to-UART Adapter

Connect your adapter to the router according to this mapping:

Router PinUSB Adapter Pin
VCCVCC (usually not needed)
TXRX
RXTX
GNDGND

Important: TX on the router connects to RX on the adapter, and vice versa (cross connection).

Step 3: Plug in USB Adapter

  • Connect the USB-to-UART adapter to your computer
  • Do not power on the router yet
  • Install drivers if needed (CH340, FTDI, or CP2102)

Step 4: Open Terminal Software

On Linux:

1
sudo screen /dev/ttyUSB0 115200

Or using minicom:

1
sudo minicom -s

Configure minicom with:

  • Serial Device: /dev/ttyUSB0
  • Baud Rate: 115200
  • Data Bits: 8
  • Stop Bits: 1
  • Parity: None

On macOS:

1
screen /dev/tty.usbserial-* 115200

On Windows:

  • Download PuTTY
  • Select Serial connection type
  • Set COM port (e.g., COM3)
  • Set speed to 115200
  • Click Open

Step 5: Power On the Router

  • Plug in the power adapter to the D-Link router
  • You should see boot messages appearing in the terminal
  • If nothing appears, check your connections and baud rate

Step 6: Access the Bootloader

During boot, you may see messages like:

1
2
3
4
5
6
U-Boot 1.1.4 (Apr 20 2015 - 14:23:45) D-Link

DRAM:  64 MB
Kernel Params:
...
Press SPACE to stop autoboot:  3

To interrupt autoboot:

  • Press the SPACE key during the countdown
  • You’ll get a uboot prompt: uboot>

Common uboot commands:

1
2
3
4
5
6
7
8
help                    # Show available commands
printenv                # Display environment variables
setenv                  # Set environment variables
md 0x80000000 32       # Read memory
mw 0x80000000 0xff     # Write to memory
tftpboot               # Load image via TFTP
boot                   # Boot the kernel
reset                  # Reboot the device
ModelBaud RateTX PinRX PinGND PinNotes
DIR-882115200234Standard UART
DIR-X5460115200234Same as DIR-882
DSL-2750B115200TXRXGNDLabeled pins
DAP-1520115200234AUX header
AC1200115200TXDRXDGNDLabeled

Note: Check your specific router model’s datasheet or forums for exact pin locations.

Getting Root Shell Access

Once you have uboot access, you can interrupt the kernel boot:

1
2
Press SPACE to stop autoboot:  1
uboot> bootm

Then press Ctrl+C during kernel boot to drop to a shell (if available):

1
Press Enter for console, or Ctrl-C for bootloader console

Once in Linux shell, you typically have limited access. To get full root:

1
2
3
4
5
/bin/sh
# su
Password: 
# id
uid=0(root) gid=0(root)

Some routers have default passwords or no password required.

Troubleshooting

No output on terminal

  • Verify baud rate is 115200
  • Check TX/RX are not swapped
  • Ensure GND is properly connected
  • Verify USB driver is installed
  • Try a different USB port
  • Check that the router is powered on

Garbled characters

  • Baud rate mismatch: Try 9600, 38400, or other rates
  • Wrong USB driver installed
  • Defective USB cable

Device not recognized

  • Install CH340/FTDI/CP2102 drivers for your OS
  • Try different USB port
  • Check USB cable with multimeter for continuity

Can’t interrupt autoboot

  • Try holding SPACE key before powering on
  • Try other keys like DEL or ESC
  • Some routers require rapid key presses

Connection disconnects

  • Check for loose connections
  • Reduce cable length or shielding
  • Check for power issues
  • Verify stable power supply

Security Considerations

  • UART access provides root-level access to your device
  • Anyone with physical access to UART can compromise your router
  • Consider disabling UART in production if possible
  • Cover UART headers with epoxy or encapsulate the board
  • Keep the router physically secure
  • Be cautious with modified firmware

Advanced Topics

Getting SSH Access After UART

Once you have shell access via UART:

1
2
3
4
5
6
7
8
9
# Start SSH service
/etc/init.d/sshd start

# Or modify startup scripts to enable SSH
vi /etc/rc.d/rc.local
# Add: /etc/init.d/sshd start

# Find your router's IP
ifconfig eth0

Then SSH to the device:

Backing Up Firmware via UART

Using TFTP and uboot:

1
2
3
4
5
6
7
# On your Linux PC, set up TFTP server
# Then in uboot:

uboot> printenv ipaddr
uboot> setenv ipaddr 192.168.1.2
uboot> setenv serverip 192.168.1.100
uboot> tftpboot 0x80060000 firmware.bin

Modifying Bootloader Environment

1
2
3
4
5
6
7
8
# Set new kernel arguments
uboot> setenv bootargs console=ttyS0,115200 root=/dev/mtdblock3

# Save changes
uboot> saveenv

# Boot with new settings
uboot> boot

References

  • U-Boot Documentation: https://source.denx.de/u-boot/u-boot/-/wikis/home
  • D-Link OpenWrt Support: https://openwrt.org/toh/d-link/start
  • UART Pinouts Database: https://pinouts.ru/
  • Linux Serial Port Configuration: https://www.kernel.org/doc/html/latest/admin-guide/serial-console.html

Conclusion

UART serial connection is a powerful tool for embedded systems development and device recovery. With the knowledge from this guide, you should be able to safely connect to your D-Link router, access the bootloader, and perform advanced diagnostics and maintenance. Always remember to exercise caution, as improper connections or commands can damage your device or void your warranty.

Happy tinkering!

This post is licensed under CC BY 4.0 by the author.