So in contrast to the [[doc:​hardware:​port.JTAG|JTAG-Port]],​ the Serial Port needs some software running on the CPU so we can use it! If the bootloader is damaged, or doesn'​t offer such a feature, the port is useless.

So in contrast to the [[doc:​hardware:​port.JTAG|JTAG-Port]],​ the Serial Port needs some software running on the CPU so we can use it! If the bootloader is damaged, or doesn'​t offer such a feature, the port is useless.

-

Finding an UART on a router is fairly easy since it only needs 3 signals (without modem signaling) to work: GND, TX and RX (often accompanied by VCC). Since your router is very likely to have its I/O pins working at 3.3V ([[wp>​Transistor–transistor logic|TTL]] level voltage), you'll need a level shifter such as a Maxim MAX232 to change the level from 3.3V to your computer level which is usually at 12V.

+

Finding an UART on a router is fairly easy since it only needs 3 signals (without modem signaling) to work: GND, TX and RX (often accompanied by VCC). Since your router is very likely to have its I/O pins working at 3.3V ([[wp>​Transistor–transistor logic|TTL]] level voltage), you'll need [[doc:​hardware:​port.serial#​usb.to.rs232.ttl.converter.module]] or a level shifter such as a Maxim MAX232 to change the level from 3.3V to your computer level which is usually at 12V.

-

To find out the serial console pins on the PCB, you'll be looking for a populated or unpopulated 4-pin header, which can be far from the SoC (signals are relatively slow) and usually with tracks on the top or bottom layer of the PCB, and connected to the TX and RX.

+

Check the table of hardware [[toh:​start]] for your router and if you don't find serial pinout there try looking for a populated or unpopulated 4-pin header, which can be far from the SoC (signals are relatively slow) and usually with tracks on the top or bottom layer of the PCB, and connected to the TX and RX.

Once found, you can easily check where is the GND, which is connected to the same ground layer than the power connector. The VCC should be fixed at 3.3V and connected to the supply layer ; the TX is also at 3.3V level, but using a multimeter as an ohm-meter, if you find an infinite resistance between the TX and VCC pins, it means they'​re distinct signals (else, you'll need to find the correct TX or VCC pin). The RX and GND are by default at 0V, so you can check them using the same technique.

Once found, you can easily check where is the GND, which is connected to the same ground layer than the power connector. The VCC should be fixed at 3.3V and connected to the supply layer ; the TX is also at 3.3V level, but using a multimeter as an ohm-meter, if you find an infinite resistance between the TX and VCC pins, it means they'​re distinct signals (else, you'll need to find the correct TX or VCC pin). The RX and GND are by default at 0V, so you can check them using the same technique.

Line 31:

Line 31:

Most devices supported by OpenWrt include a serial port. These serial ports typically provide a console to the bootloader and, when the firmware has booted, a console to the running system. Typically, a console to the bootloader will allow you to configure a network, fetch and flash a new firmware, which can be a life-saver when the firmware is broken. A console to the running system will let you correct a misconfigured network.

Most devices supported by OpenWrt include a serial port. These serial ports typically provide a console to the bootloader and, when the firmware has booted, a console to the running system. Typically, a console to the bootloader will allow you to configure a network, fetch and flash a new firmware, which can be a life-saver when the firmware is broken. A console to the running system will let you correct a misconfigured network.

-

====== Connectors ======

+

===== Connectors =====

All [[soc]]s have some sort of [[wp>​Universal asynchronous receiver/​transmitter|UART]],​ often in combination with a [[wp>​RS-232]]-Interface connected with the [[wp>​Printed circuit board|PCB]]. Now depending on the model, the device'​s serial port could be available

All [[soc]]s have some sort of [[wp>​Universal asynchronous receiver/​transmitter|UART]],​ often in combination with a [[wp>​RS-232]]-Interface connected with the [[wp>​Printed circuit board|PCB]]. Now depending on the model, the device'​s serial port could be available

* as a 9-pin D connector accessible from the exterior of the case,

* as a 9-pin D connector accessible from the exterior of the case,

Line 38:

Line 39:

For help with the latter two, see [[soldering]]. But even if there is 9-pin D connector, beware the Voltage levels!

For help with the latter two, see [[soldering]]. But even if there is 9-pin D connector, beware the Voltage levels!

+

+

Hint: in case of unpopulated holes try fitting the pins from a disassembled SubD9 male plug into the holes instead of soldering the cable directly to the board. Fit perfectly on unbricked Asus and TP-Link routers and leaves no trace. ​

If the serial port is not readily accessible from the exterior of the device enclosure, you have some choices:

If the serial port is not readily accessible from the exterior of the device enclosure, you have some choices:

Line 48:

Line 51:

* access to the serial port is needed only very occasionally;​ and/or

* access to the serial port is needed only very occasionally;​ and/or

* you have many devices you would rather not modify.

* you have many devices you would rather not modify.

+

+

===== Serial modes =====

+

+

Sometimes by shortcutting some pins, connecting them to ground or to power you can change the serial mode. Some of them can help you to restore the bootloader since they allow you to write directly to memory or load something to ram through the serial connection, which can be useful for restoring a bootloader. Also if the original bootloader is password protected with this method you can replace it with a custom bootloader and bypass it.

+

+

For example in lantiq danube socs the default mode is CFG 01, but changing to CFG 04 which is known as UART mode allows you to upload to ram through the serial connection and automatically execute a bootloader in ascii format through the serial connection.

+

+

It is recommended that you don't try blindly to shortcut or connect to anything the pins as it can brick the device. Find documentation before doing anything.

===== Voltage levels =====

===== Voltage levels =====

Line 65:

Line 76:

You will also need a terminal emulation program on your computer, such as minicom, hyperterminal,​ etc. The terminal emulation program needs to be configured to be compatible with your device, in particular, with regard to baud rate and flow control. ​ If you are using only three wires (GND, TX, and RX) then hardware flow control should be turned off; you aren't using the pins (RTS and CTS) necessary for it to work. Rarely, the baud rate that the device expects //might// be different in the bootloader and the running firmware; if so, you'll need to modify the baud rate settings in your terminal emulator after the firmware boots up.

You will also need a terminal emulation program on your computer, such as minicom, hyperterminal,​ etc. The terminal emulation program needs to be configured to be compatible with your device, in particular, with regard to baud rate and flow control. ​ If you are using only three wires (GND, TX, and RX) then hardware flow control should be turned off; you aren't using the pins (RTS and CTS) necessary for it to work. Rarely, the baud rate that the device expects //might// be different in the bootloader and the running firmware; if so, you'll need to modify the baud rate settings in your terminal emulator after the firmware boots up.

+

+

Troubleshooting parts:

+

If you get something like this during the bootcycle (output is garbled)

+

+

����������������������������������|� 2000-2008 Broadcom Corporation.

+

Init Arena

+

Init Devs.

+

This is ���������������������?​����������?​����BCM4wXX����������������Ǉ����������0735750 - 0x80)

then probably the GND is not connected (soldered?) well. The router wont listen to any keyboard actions.

+

After solving the problem output should look fine.

+

+

Another possible cause for the garbled output is wrong serial port speed, try different settings, most common ones are 9600, 38400 and 115200 bps.

+

+

If you successfully receive router bootup logs but seem unable to send data (e.g. some keyboard input which might be required to intercept bootup, and where you're unable to stop continued kernel bootup), then this may be due to having configured the connection as hardware flow control rather than software (happened on TL-WDR3600 in my case).

+

===== Considerations =====

===== Considerations =====

Some things to consider:

Some things to consider:

Line 83:

Line 112:

* Install the appropriate packages, e.g. kmod-usb-serial and kmod-usb-serial-ftdi for FTDI based converters or kmod-usb-serial-pl2303 for prolific based converters

* Install the appropriate packages, e.g. kmod-usb-serial and kmod-usb-serial-ftdi for FTDI based converters or kmod-usb-serial-pl2303 for prolific based converters

-

* Add the new serial port to /​etc/​inittab,​ (if you have multiple adaptors find the right one in /​proc/​tty/​driver/​usbserial):​

+

* Add the new serial port to /​etc/​inittab,​ (if you have multiple adaptors find the right one in /​proc/​tty/​driver/​usbserial):​\\ <code bash>ttyUSB0::​askfirst:/​bin/​ash --login</​code>​

-

''​ttyUSB0::​askfirst:/​bin/​ash --login'​'

+

+

Be aware, using this method won't bring you the possibility to use the bootloader console.

You may need to rewire the terminals of the TTL cables to match your device pinout.

You may need to rewire the terminals of the TTL cables to match your device pinout.

-

===USB to RS232 TTL Converter Module===

+

=== USB to RS232 TTL Converter Module ===

These things make it simple to connect a computer (USB port) to the serial pins on the router.

These things make it simple to connect a computer (USB port) to the serial pins on the router.

+

{{:​doc:​hardware:​usbtors232.ttl.jpeg|}}

{{:​doc:​hardware:​usbtors232.ttl.jpeg|}}

-

They are usuaually ​shipped with four jumper cables. Try [[http://​www.dealextreme.com/​p/​usb-to-uart-5-pin-cp2102-module-serial-converter-81872?​item=20|Dealextreme SKU 81872]].

+

They are usually ​shipped with four jumper cables. Try [[http://​www.dealextreme.com/​p/​usb-to-uart-5-pin-cp2102-module-serial-converter-81872?​item=20|Dealextreme SKU 81872]]. Or on [[http://​www.amazon.com/​CP2102-Module-Download-Serial-Converter/​dp/​B009T2ZR6W/​|Amazon B009T2ZR6W]]. Or on ebay there are plenty of these cheap adapters.

Simply connect the jumper cables to the pins like this:

Simply connect the jumper cables to the pins like this:

^ Router ^ Converter module ^

^ Router ^ Converter module ^

-

| GND | GND |

+

| **GND** | **GND** |

-

| TXD | RXD |

+

| **<color green>TXD</​color>​** ​| **<color blue>RXD</​color>​** ​|

-

| RXD | TXD |

+

| **<color blue>RXD</​color>​** ​| **<color green>TXD</​color>​** ​|

Unless you need to power the device, you don't have to connect the voltage pins.

Unless you need to power the device, you don't have to connect the voltage pins.

+

+

<WRAP center round alert 60%>

+

**WARNING!:​** Some people reported they fried their router connecting the voltage pins spite it isn't neccesary. **NEVER** connect voltage pins when using USB adapters unless you know what are you doing

+

</​WRAP>​

+

+

**Please note** that some USB serial adapters (The CP2102-based one in the Amazon link above, for example) have the RX and TX connectors labelled according to what you should connect them to, not what they actually do. If connecting TX -> RX and RX -> TX doesn'​t work for you, try switching to TX -> TX and RX -> RX.

=== USB-serial parts ===

=== USB-serial parts ===

Line 136:

Line 173:

reference: http://​www.nslu2-linux.org/​wiki/​HowTo/​AddASerialPort

reference: http://​www.nslu2-linux.org/​wiki/​HowTo/​AddASerialPort

+

==== DB9 serial port ====

+

=== Level conversion ===

+

+

TTL-RS-232 level conversion is a fairly common problem, so there are a number of ICs on the market that convert between these voltage levels. ​ [[http://​www.maxim-ic.com|Maxim IC]] has made a few handy little ICs for us to use. The best (IMHO) is the MAX3232, which can operate at different voltages depending on the capacitors in the circuit. This guide will tell you how to solder everything together to get a pc-compatible serial port on your OpenWrt router.

+

+

=== From scratch ===

+

== With MAX233x IC ==

+

First, you need an "​RS232-TTL level converter chip." ​ RS232 refers to the standard defining what plugs into your computer, and TTL is a family of chips that use 0V and 0.8V as low and 2.2V and 5V as high. They can be purchased new (the [[http://​www.maxim-ic.com|Maxim IC]] MAX233x line is popular). ​ Most vendors have large minimums, but some (e.g. [[http://​mouser.com/​|Mouser Electronics]]) sell components in small quantities.

+

+

The wiring is fairly simple, but it depends on the chip. Generally, it involves connecting Vcc from the router to the chip's Vcc pin, both router and rs-232 grounds to the ground pin, and the TX and RX wires to the chip. Remember that the router'​s TX will "​connect"​ to the same level conversion bank as the computer'​s RX. Additionally,​ some of these level converters require external capacitors, while some have them built in. Much of this varies, so consult the chip's spec.

-

=== Build your own Serial to DB9F RS232 Cable ===

+

== With basic components ​==

I found an easy way to get a cable working, it just require 7 components:

I found an easy way to get a cable working, it just require 7 components:

TTL-RS-232 level conversion is a fairly common problem, so there are a number of ICs on the market that convert between these voltage levels. ​ [[http://​www.maxim-ic.com|Maxim IC]] has made a few handy little ICs for us to use. The best (IMHO) is the MAX3232, which can operate at different voltages depending on the capacitors in the circuit. This guide will tell you how to solder everything together to get a pc-compatible serial port on your OpenWrt router.

-

-

=== From scratch ===

-

First, you need an "​RS232-TTL level converter chip." ​ RS232 refers to the standard defining what plugs into your computer, and TTL is a family of chips that use 0V and 0.8V as low and 2.2V and 5V as high. They can be purchased new (the [[http://​www.maxim-ic.com|Maxim IC]] MAX233x line is popular). ​ Most vendors have large minimums, but some (e.g. [[http://​mouser.com/​|Mouser Electronics]]) sell components in small quantities.

-

-

The wiring is fairly simple, but it depends on the chip. Generally, it involves connecting Vcc from the router to the chip's Vcc pin, both router and rs-232 grounds to the ground pin, and the TX and RX wires to the chip. Remember that the router'​s TX will "​connect"​ to the same level conversion bank as the computer'​s RX. Additionally,​ some of these level converters require external capacitors, while some have them built in. Much of this varies, so consult the chip's spec.

=== From a PDA or cell phone serial cable ===

=== From a PDA or cell phone serial cable ===

Line 169:

Line 209:

If you've found a good cell phone cable to use, you merely need to determine which wires are the VCC, GND, TX, and RX connections. Usually the VCC is red and the GND is black, but the other colors may vary (though blue and orange are common). There should be no need to modify the PCB embedded in the cable.

If you've found a good cell phone cable to use, you merely need to determine which wires are the VCC, GND, TX, and RX connections. Usually the VCC is red and the GND is black, but the other colors may vary (though blue and orange are common). There should be no need to modify the PCB embedded in the cable.

-

One type of the "Made in China" ones, not mentioned at http://​www.nslu2-linux.org/​wiki/​HowTo/​AddASerialPort ist the "​S30880-S5601-A802-1";​ its WHITE wire is data out (TX) and the ORANGE one is data in (RX), VCC and GND are red and black. Its a 3.3V converter built with the MAX3386E chip.

+

One type of the "Made in China" ones, not mentioned at http://​www.nslu2-linux.org/​wiki/​HowTo/​AddASerialPort ist the "​S30880-S5601-A802-1";​ its WHITE wire is data out (TX) of the DTE (PC) and conntcts to the RX of the DCE (Router); ​the ORANGE one is data in (RX) of the DTE (PC) and conntcts to the TX of the DCE (Router), VCC and GND are red and black. Its a 3.3V converter built with the MAX3386E chip.

First [[doc/​recipes/​terminate.console.on.serial|disable the console]] in the router you want to use it as a serial console adapter and install screen in it. Connect to the target router the serial pins, and then execute screen in the first router:

* [[http://​www.gnu.org/​software/​screen/​|GNU Screen]] (available on most OSes, including Windows (cygwin)) can connect to a serial device. The format is:<​code>​screen {path to device} {baud rate},​{options}</​code>​A common set of options (for setting 8N1) is ''​cs8,​-parenb,​-cstopb''​. For example, to connect to an Asus WL-520GU (115200 baud, 8N1) with a USB-serial adapter on OSX: <​code>​screen /​dev/​tty.SLAB_USBtoUART 115200,​-parenb,​-cstopb,​cs8</​code>​The command on Linux is the same with a different device path. For other routers, you may need to adjust the speed and options.

===== Serial port pinouts =====

===== Serial port pinouts =====

Line 215:

Line 263:

===== Finding Serial Console =====

===== Finding Serial Console =====

-

First, check the OpenWrt wiki page describing your hardware and do a Google search. Most of the time, the serial port(s), if they exist, have already been documented by others.

+

First, check the OpenWrt wiki page describing your hardware and do a Google search. Most of the time, the serial port(s), if they exist, have already been documented by others. ​If methods listed here are not enough for you, consider to go deeper reading http://​www.devttys0.com/​2012/​11/​reverse-engineering-serial-ports/​