The raspberry pi has a UART interface, with which it can send debug information to a serial console. As a basic step of Embedded Linux Development, let’s see the procedure to connect the Raspberry Pi UART to a computer.
Significance of UART in embedded Linux development
Linux porting is a difficult task. We can’t simply boot a Linux board by building u-boot, kernel, and root file system images. This type of approach never works. It will end up with several issues like kernel panics, device driver issues, device tree issues, bootloader issues, etc…
So to debug entire system, we need an interface that can send debug information from Linux hardware (raspberry pi) to a computer. There are three possible ways
Network and Video interfaces are not so popular in terms of system debugging. They need special hardware and initializations. Much custom Linux hardware doesn’t come with and video and network interface. In fact, network and video interface are not available during first a bootloader stage.
But UART is considered to be a basic peripheral for all SOCs. UART does not require any special hardware. Transmitter (Tx) and receiver (Rx) lines are enough to debug entire system.
Raspberry PI UART pins
For any board, first of all you need to find the ‘tx’ and ‘rx’ lines of the UART. For this, you need board schematics. Download raspberry pi schematics from the above link.
For raspberry, UART ‘tx’ and ‘rx’ pins are available on GPIO header (J8 connector). Refer “GPIO EXPANSION“ section in the schematics.
On GPIO header, pin-8 and pin-10 are UART ‘tx’ and ‘rx’ pins.
PIN8 – TXD
PIN10 – RXD
Raspberry Pi board ‘tx’, ‘rx’ pin identification has shown below. You can use PIN6 as common ground between raspberry Pi and a computer.
RPi UART to a computer
Two ways you can connect the UART to a computer
Via a USB to UART converter
Via a standard RS232 port
USB to serial converter
You can connect Raspberry pi to a computer using a USB to UART converter. In fact, it is the easiest way and also less risk involved.
Note that, the TTL logic levels of Broadcom SOC are Logic0-0v and Logic1-3.3v. So, before purchasing a USB to UART converter, make sure that it supports UART with 3.3v TTL logic levels.
USB to UART with 3v3 TTL logic levels
Three female-to-female cables
If you have a USB to UART converter with 3v3 TTL logic levels, then connections are as simple as shown below.
TXD and RXD pins of the USB to UART converter and Raspberry Pi should connect as shown below.
Warning: If you have a USB to UART converter with 5V TTL logic levels, then don’t dare to connect to raspberry Pi. It defiantly damages your pi’s UART controller. In such cases, better buy a Logic Level Converter that converts 3.3V to 5V, vice versa.
Via standard RS232 port
Raspberry pi can connect to an RS232 port using MAX3232. You already know about MAX 232, it is a level converter that converts UART TTL-5V logic levels to RS232 logic levels. Similarly MAX3232 converts UART TTL 3v3 logic levels to RS232 levels.
You can purchase max3232 PCB online. You can also design your own MAX3232 board using below links.
In datasheet, refer 10.2 section for circuit diagram. as per data sheet, For 3.3v Vcc, use 100nF (0.1 uF) capacitors.
Warning:Try at your own risk