I've been trying to connect to the serial console of a Raspberry Pi 3 with Android Things using USB to TTL cable from my Linux (Ubuntu) machine. Despite I connected the cable as per the documentation, all I get when executing the minicom
command is the following
Setting up a serial console This tutorial will show you how to set up a serial console on a Linux system, and connect to it via a null modem cable. This is quite useful if your Linux server is in a headless configuration (no keyboard or monitor), as it allows you to easily get a console on the system if there are any problems with it. I am trying to connect minicom to a serial device that is connected via a USB-to-serial adapter. This is a PL2303 and from everything I've read no additional drivers are required. I just got my GUC232A cable with a molded-in PL2302 converter chip. Browse other questions tagged linux serial-port usb hardware-interface or ask your own.
with no chance to type in any character. So I neither can see any kernel messages nor shell into the device.
What am I missing?
3 Answers
Linux (Ubuntu)
What's in?
- GNU Screen
- Minicom
- minicom one-line-command (short answer)
- minicom UI (long answer, detailed)
GNU Screen
Run in terminal
See below (step 2) to find out port_name
, e.g /dev/ttyUSB0
. Hit Ctrl-A, then K, then Y to exit screen
. Execute sudo apt-get install screen
if not installed.
Minicom
- Short answer
Run in terminal
See below (step 2) to find out port_name
, e.g /dev/ttyUSB0
. Hit Ctrl-A, then X to exit minicom
.
- Long answer (UI)
minicom
should be properly configured in order to open the connection. The general steps are as follows:
Install
minicom
withConnect Rpi3 with your host machine using USB-to-TTL cable and open the terminal. Find the tty connections with
In my case I get
where ttyUSB0
is the board.
Run
minicom
and select the serial port setup with
You should see
- Check (or set) the settings for the tty connection. Make sure that
/dev/ttyX
corresponds to your connection, the one you get in the step 2 instead ofX
, andBps/Par/Bits
set as per the documentation.
Similar to
- Now hit Exit and, if everything had been properly set up, the connection should be running. If you type the
ls
command you should see Android Thing's root directory
- For exiting
minicom
hit Ctrl-A, then hit Q, then Yes:
Windows (with PuTTY)
- Connect the board to machine with USB-to-TTL cable and find out the COM port using Windows Device Manager. You should look for the the one called USB Serial Port (in my case it was COM3).
- Run PuTTY and set it up. Use the speed as per the documentation (115200):
- Hit Open and type a command in a terminal window popped up.
I'm going to suggest some troubleshooting advice based in my own experience:
Make sure you have the Tx and Rx cables connected correctly because all the other settings won't give you any warning, minicom would connect beautifully to the USB adapter but no info on your screen from your Pi.
I didn't use a USB to TTL like the one you are using, mine has the labels for Tx and Rx inverted on the board. Took me some time and the help of an oscilloscope to figure out what was going on.
Not the answer you're looking for? Browse other questions tagged consoleuartandroid-things or ask your own question.
- 1Serial Console Wiring
The serial console is extremely valuable for many reasons, including the ability to choose menu entries for boot images during boot, as well as having access even when networking and direct monitor/keyboard/mouse are unavailable. This functionality is accessed via the rectangular connector J21, near the power-on button.
The Software Side
Any serial port program should work as a console. Examples are PuTTY, gtkTerm, and minicom. Connection speed is 115200, with 8 bits, no parity, and 1 stop bit (115200 8N1). Flow control will be RTS/CTS.
The USB Serial UART
Because of the custom nature of the TX1 board connector wiring, a USB serial UART is by far the easiest and most reliable way to connect the host side of the serial console. This serial UART is required to handle 3.3V I/O. Most of the serial UARTs available should work if the UART is designed for 3.3V I/O. Beware that other USB serial UART cables are available which support an incompatibile 5V or 12V I/O...do not use these.
Because the FTDI USB chips are so widely available and often have drivers by default for Linux host machines, this chipset is a good starting point when you have many choices. The example USB serial UART used here is the TTL-232R-3V3 by FTDI. One source of this serial UART is here: https://www.digikey.com/product-detail/en/TTL-232R-3V3/768-1015-ND/1836393.
About Serial Port Cabling
The example cable comes with a 6-wire cable and 0.1in spacing 6-pin female header. Five of the 6 pins are used. This cable could be used directly with the J17 UART header, but this information is concerned with showing how to wire the standard 6-wire serial UART cable to connector J21 (J21 has the serial console UART, not J17...don't try the cable with J17 unless you know what you are doing).
Color Codes and Pin Descriptions of the USB Serial UART Cable
Pin 1 of the serial USB UART 6-pin connector should be marked.
- Pin 1 is black.
- This is a ground wire in common with both x86 host and Jetson TX1 ground.
- J21 pin 9 is convenient (there are several ground pins which would work).
- Pin 2 is brown.
- This is the host-side CTS (clear-to-send).
- This will connect to Jetson TX1's RTS (request-to-send).
- J21 pin 11 should be used.
- Pin 3 is red.
- This pin is supplied +5V from the host USB HUB, and is not used.
- Pin 4 is orange.
- This pin is TXD (transmit data).
- This will connect to Jetson TX1's RXD (receive data).
- J21 pin 10 should be used.
- Pin 5 is yellow.
- This pin is RXD (recieve data).
- This will connect to Jetson TX1's TXD (transmit data).
- J21 pin 8 should be used.
- Pin 6 is green.
- This pin is RTS (request-to-send).
- This will connect to Jetson TX1's CTS (clear-to-send).
- J21 pin 36 should be used.
The crossing over between send and receive (as well as request to send and clear to send) means this is a 'NULL modem' or 'crossover' cable.
Note that if you prefer to simplify the assembly, you can ignore the connection between CTS and RTS. Doing so implies using software flow control instead of CTS/RTS flow control
Required Parts
The USB serial UART has already been mentioned. The 6-pin connector is easily used in combination with soldering a ribbon cable to a standard 0.1in connector. The example here should work: https://www.digikey.com/product-detail/en/M20-9990646/952-2270-ND/3728234.
Any standard 0.1in spacing female header should work for the Jetson TX1's J21 connector. A connector capable of self-splicing of an inserted ribbon cable is recommended. Although many of these connectors were not intended to be re-opened and added to at a later date, there isn't usually an issue with opening the connector up and adding wires to a position which has never been used before. Here is a large list of example female 40-pin headers arranged in two rows: https://www.digikey.com/product-search/en?pv88=23&FV=fff40016%2Cfff802f5%2C1640001%2C1680002%2C800000f%2C8000014%2C8cc0003&k=ribbon&mnonly=0&newproducts=0&ColumnSort=0&page=1&quantity=0&ptm=0&fid=0&pageSize=500.
Soldering to the 6-pin header will not be easy without a proper soldering iron. Once soldered these pins need insulation. The example used small diameter heat shrink tubing around each conductor, and then a larger diameter section of heat shrink tubing was used to keep the entire assembly together. Any stray wires may also be insulated with heat shrink tubing.
The cable was generic ribbon cable which thankfully was color coded exactly the same as the 6-pin cable of the USB serial UART. This makes knowing which orientation to use for connecting male and female 6-pin connectors a non-issue. If there is no color coding, then some means of insuring pin 1 of one connector matches pin 1 of the other connector is required.
The Example USB Serial UART Assembly
Here's a picture of what a working assembly is like:
Usb Serial Console Driver
Connecting a Linux Host to Jetson TX1 Serial Console
The final step from your Linux host to connecting to the serial console is to name the serial device file which belongs to the USB serial UART. This can present a challenge and a lot of guessing if you move your USB devices around, as they might enumerate differently depending on order of detecting USB devices.
Linux Serial Port Console
The general naming of serial USB UART devices is of the format /dev/ttyUSB0, /dev/ttyUSB1, /dev/ttyUSB2...these names work well, but may not be convenient in the long run.
The udev automated system of naming device special files also categorizes many devices by type and then by information to the specific device (something like a serial number). These alternate names remain constant, and are simply symbolic links to the more common ttyUSB# scheme. These files are found in /dev/serial/by-id/.
The example USB serial UART has this symbolic link in /dev/serial/by-id/: usb-FTDI_FT232R_USB_UART_A10171DT-if00-port0. Other USB related serial console labels may change, this particular file should stay constant. This makes it easy to have several USB serial devices without mixing them up when operated simultaneously.
Some Serial Port Administration Information
Typically, the serial port requires sudo or root authority to access, which can be irritating. The serial port devices are group dialout, and adding your user to this gains access to serial ports without sudo. Programs requiring lock files (some of which are serial console programs) may require sudo or root access unless your user is a member of group lock. Consider using a non-root developer account and granting these groups:
Note that if you have installed OpenOCD, then udev may attempt to set your ttyUSB group to 'plugdev', rather than to 'dialout'. If 'plugdev' does not exist, then your ttyUSB files will default to group 'root'. If you use Fedora (and who knows how many other distributions), then getting group 'dialout' back requires edit of '/lib/udev/rules.d/99-openocd.rules', replacing 'plugdev' with 'dialout'.