Differences

This shows you the differences between two versions of the page.

doc:hardware:port.serial [2013/02/11 06:05]
karlpinc Add kermit, since it's now open source --
doc:hardware:port.serial [2014/07/11 22:19] (current)
javitury
Line 13: Line 13:
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����������������LJ����������0735750 - 0x80)
 +  BSS:        0x80739790 -  0x80���4���������~�~������߇~����������������������������������5.10
 +  The boot is CFE
 +
 +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.
 +
 +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 85: Line 112:
  * 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):
    ''ttyUSB0::askfirst:/bin/ash --login''     ''ttyUSB0::askfirst:/bin/ash --login''
 +
 +Be aware, using this method won't bring you the possibility to use the bootloader console.
=== Prebuilt Cables === === Prebuilt Cables ===
Line 105: Line 134:
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.
 +| {{:meta:icons:tango:software-update-urgent.png?&nolink|}} | **WARNING:** Some people reported they fried his 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 |
 +
 +**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 137: Line 169:
reference: http://www.nslu2-linux.org/wiki/HowTo/AddASerialPort reference: http://www.nslu2-linux.org/wiki/HowTo/AddASerialPort
-=== Build your own Serial to DB9F RS232 Cable ===+==== 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. 
 + 
 +== 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:
Line 150: Line 193:
http://3.bp.blogspot.com/_JE4GMReEeGU/SpATfyGBmLI/AAAAAAAAAF0/VHTl3Vcs6hU/s1600-h/ttltors2320kf.jpg http://3.bp.blogspot.com/_JE4GMReEeGU/SpATfyGBmLI/AAAAAAAAAF0/VHTl3Vcs6hU/s1600-h/ttltors2320kf.jpg
-This cost minus than 2 Dolars in Chile, i hope it be the same for you!+This cost less than 2 Dolars in Chile, i hope it be the same for you!
I tested it on a Zyxel 600 Series, it works! I tested it on a Zyxel 600 Series, it works!
 +
 +Ensure that the DTR signal at the PC end is asserted, otherwise nothing is received from the router. For example, in the Bray terminal program click on the DTR icon to turn it green.
Source: http://maximi89.blogspot.com/2009/08/hola-intente-modificar-el-bootbase-pero.html Source: http://maximi89.blogspot.com/2009/08/hola-intente-modificar-el-bootbase-pero.html
- 
-==== 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 === 
-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 205:
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.
=== MAX232 Kits === === MAX232 Kits ===
Line 195: Line 231:
Example: Palm IIIc, [[http://www.neophob.com/serendipity/index.php?url=archives/121-Reuse-your-old-Palm-as-Serial-Console.html]]. Example: Palm IIIc, [[http://www.neophob.com/serendipity/index.php?url=archives/121-Reuse-your-old-Palm-as-Serial-Console.html]].
 +
 +==== Use another OpenWrt router as a console ====
 +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:
 +<code>screen /dev/ttyS0 115200</code>
===== Terminal software ===== ===== Terminal software =====
-Windows:+**Linux/Posix:** 
 +  * [[man>screen]]: the most simple, example: <code>screen /dev/ttyUSB0 115200</code> 
 +  * [[http://cutecom.sourceforge.net/|CuteCom]] with a friendly KDE4 GUI 
 +  * [[man>Minicom]] (for POSIX systems) 
 +  * [[http://www.kermitproject.org/|kermit]], a mature terminal emulator 
 +  * [[http://code.google.com/p/picocom/|picocom]] 
 +  * [[man>cu]] (part of the Taylor UUCP package, for POSIX systems) 
 +  * [[http://www.chiark.greenend.org.uk/~sgtatham/putty/|Putty]] 
 + 
 +**Windows:**
  * Hyperterm (comes with many versions of MS Windows)   * Hyperterm (comes with many versions of MS Windows)
  * [[http://www.chiark.greenend.org.uk/~sgtatham/putty/|Putty]] v0.59 or newer (now with serial console support!)   * [[http://www.chiark.greenend.org.uk/~sgtatham/putty/|Putty]] v0.59 or newer (now with serial console support!)
  * [[https://sites.google.com/site/terminalbpp/|Bray's Terminal]]   * [[https://sites.google.com/site/terminalbpp/|Bray's Terminal]]
  * [[http://www.vandyke.com/products/securecrt/|Vandyke SecureCRT]] (commercial but very good)   * [[http://www.vandyke.com/products/securecrt/|Vandyke SecureCRT]] (commercial but very good)
-Linux/Posix: +**Other:**
-  * Minicom (for POSIX systems) +
-  * [[http://www.kermitproject.org/|kermit]], a mature terminal emulator +
-  * [[http://code.google.com/p/picocom/|picocom]] +
-  * cu(1) (part of the Taylor UUCP package, for POSIX systems) +
-  * [[http://cutecom.sourceforge.net/|CuteCom]] with a friendly KDE4 GUI +
-Other:+
  * Pocketterm  (for Palm PDAs)   * Pocketterm  (for Palm PDAs)
 +  * [[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 259:
===== 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/
==== Piezoelectric buzzer method ==== ==== Piezoelectric buzzer method ====

Back to top

doc/hardware/port.serial.1360559152.txt.bz2 · Last modified: 2013/02/11 06:05 by karlpinc