using raspberry pi and beaglebone launchpad as USB-uart

This is a note collected from internet source


Raspberry pi, uart should pin is enabled by default? yes

Raspberry Pi’s Mini-UART

Warning: Misleading information ahead – See Warren Gay’s comments.
The Raspberry Pi actually has two UARTs. One UART  is part of the internal ARM architecture of the Broadcom BCM2835 chip, in the core of the Raspberry Pi and not accessible externally.  The other UART is sometimes called the RPi’s “Serial Port” (even thou the USB supports serial communications, and therefore a serial port).  The serial port being reference here is serviced by a UART, sometime refereed to as the  “Mini-UART” since it doesn’t appear to be very rich in functionality.  It is basically be used as a console port for access to the Raspberry Pi.  The serial console is a convenient way to interact with the Raspberry Pi for debugging or your network is down and it is the destination of console messages (including boot-up messages).  From the Raspberry Pi pinout and the eLinux wiki, I can see that the serial port (aka Mini-UART) on the Pi is on GPIO Pin 14 (TX) and GPIO Pin 15 (RX):


Since the GPIO pins give access to the Mini UART, you can establish a serial console, which can be used to log in to the Pi, and many other things.  However, normal console device communicate with -12V (logical “1″) and +12V (logical “0″) RS-232, which may just fry something in the 3.3V Pi. Even “TTL level” serial at 5V runs the same risk.  See this tutorial for one example on how to build 3.3V to RS-232 levels converter with a MAX3232CPE and a few passive components.

You can reconfigure the RPi so that the Mini UART isn’t acting as a serial console and use it for outer purposes (e.g. communicate with an attached Arduino or Xbee).  Using the Raspberry Pi’s serial port requires some Linux reconfiguration and the abandonment of the serial console, and potentially some level conversion, but it could be useful. The Mini-UART pins to provide access to Linux’s /dev/ttyAMA0 serial port.  To be able to use the serial port to connect and talk to other devices, the serial port console login needs to be disabled and the post “Raspberry Pi and the Serial Port” shows you how.

Again, keep in mind that RX and TX lines are available on the GPIOs but operate at 3.3 volts. You’ll need a board or cable to level convert 3.3 volt UART signals to connect with other devices (e.g. RS-232, USB).

Disable Serial Port Login

To enable the serial port for your own use you need to disable login on the port. There are two files that need to be edited

The first and main one is /etc/inittab

This file has the command to enable the login prompt and this needs to be disabled. Edit the file and move to the end of the file. You will see a line similar to

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Disable it by adding a # character to the beginning. Save the file.

#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Disable Bootup Info

When the Raspberry Pi boots up, all the bootup information is sent to the serial port. Disabling this bootup information is optional and you may want to leave this enabled as it is sometimes useful to see what is happening at bootup. If you have a device connected (i.e. Arduino) at bootup, it will receive this information over the serial port, so it is up to you to decide whether this is a problem or not.

You can disable it by editing the file /boot/cmdline.txt

The contents of the file look like this

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Remove all references to ttyAMA0 (which is the name of the serial port). The file will now look like this

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait


BBB has usbnet for quick conn

Launchpad G2553 is 9600 uart!

USB 2.0 to TTL UART 6PIN CP2102 Module Converter Connector Adaptor Cable UK



1.This is a USB 2.0 to TTL UART 6PIN CP2102 Module Serial Converter. Connect MCU easily to your computer!
2.Stable and reliable chipset CP2102
3.USB specification 2.0 compliant with full-speed 12Mbps.
4.Standard USB type A male and TTL 6pin connector. 6pins for 3.3V, RST, TXD, RXD, GND & 5V.
5.All handshaking and modem interface signals.
6. Baud rates: 300 bps to 1.5 Mbps.
7. Byte receive buffer; 640 byte transmit buffer.
8. Hardware or X-On/X-Off handshaking supported.
9. Event character support Line break transmission.
10.USB suspend states supported via SUSPEND pins.
11.Temperature Range: -40 to +85.
12.Supports Windows 98SE, 2000, XP, Vista, Window7, Mac OS 9, Mac OS X & Linux 2.40.


The Adafruit IO Python library will export the UART device tree overlays as a convenience. There are five serial ports brought to the expansion headers (UART3 only has a single direction, TX), and one (UART0, serial J1) with dedicated headers that aren’t available to use in your Python programs.



To setup and export the UART, you can do the following:

  1. import Adafruit_BBIO.UART as UART
  2. UART.setup(“UART1”)

That’s it!

Also, there is a cleanup() method ready to go, but it’s not currently working due to a bug in the kernel that causes kernel panics when unloading device tree overlays. We’ll update this when it’s working. A workaround is to either leave the UART enabled, or restart your BeagleBone Black.

Pin Table for UART



UART1 P9_26 P9_24 P9_20 P9_19 /dev/ttyO1
UART2 P9_22 P9_21 /dev/ttyO2
UART3 P9_42 P8_36 P8_34 /dev/ttyO3
UART4 P9_11 P9_13 P8_35 P8_33 /dev/ttyO4
UART5 P8_38 P8_37 P8_31 P8_32 /dev/ttyO5

Using UART with Python

You can use the pyserial module in Python, but you’ll first need to install it using pip. If you don’t have pip installed, you can follow the instructions on the installation pages for this tutorial.

SSH into the BeagleBone Black, and execute the following command:

  1. pip install pyserial

Below is a very simple python program that is a good starting point. Save it to a file, and execute it with ‘python’

  1. import Adafruit_BBIO.UART as UART
  2. import serial
  3. UART.setup(“UART1”)
  4. ser = serial.Serial(port = “/dev/ttyO1”, baudrate=9600)
  5. ser.close()
  7. if ser.isOpen():
  8.   print “Serial is open!”
  9.         ser.write(“Hello World!”)
  10. ser.close()
  11. # Eventually, you’ll want to clean up, but leave this commented for now,
  12. # as it doesn’t work yet
  13. #UART.cleanup()

Testing and Using the UART

You can easily test that everything is working, without having to code anything, or installing any other dependencies to get started.

Next, you’ll want to connect two wires to the UART pins. We’re just going to cross the RX/TX of the UART1 and UART2. The first wire should connect from P9_24 to P9_22. The second wire should connect from P9_26 to P9_21.

Next, export the UART1 and UART2 in the python interpreter with the Adafruit IO library:

  1. root@beaglebone:~# python
  2. Python 2.7.3 (default, May 29 2013, 21:25:00)
  3. [GCC 4.7.3 20130205 (prerelease)] on linux2
  4. Type “help”, “copyright”, “credits” or “license” for more information.
  5. >>> import Adafruit_BBIO.UART as UART
  6. >>> UART.setup(“UART1”)
  7. >>> UART.setup(“UART2”)
  8. >>> exit()

Once you’ve done that, execute the following commands to launch minicom (using two separate ssh sessions using your terminal of choice, mine are separated by tabs in OS X):

  1. #first terminal window:
  2. minicom -b 9600 -D /dev/ttyO1
  3. #second terminal window:
  4. minicom -b 9600 -D /dev/ttyO2

It should look like this once you’ve opened minicom:

Now, type in one of the terminal windows, and hit enter. Look at the other terminal, and you should see something like this:

You can exit from minicom by typing Ctrl-A, then Z, then X, and hit enter at the dialog.


This entry was posted in Uncategorized. Bookmark the permalink.