Hardware Reference
In-Depth Information
Finding the Pi's Serial Port
So how can you find your serial port on the Raspberry Pi? Under Linux all serial ports are mapped to a device
node known as a teletypewriter (TTY for short). Back in the days of the mainframes you would have many people
operating a teletypewriter connected to a TTY terminal on the mainframe. This is where the device node name
came from. I would not think there are many physical TTYs around anymore. Today we use the TTY device for serial
communications between many devices and of course as a serial console. Take a look at your dmesg output on your
Raspberry Pi and use grep for tty . In Figure 9-2 you can see the output from my dmesg .
Figure 9-2. The output of dmesg | grep tty
There are two important things to note from this output. The first part is what type of IC the serial port is. In
the case of the Raspberry Pi that is PL011. The PL011 is the UART inside the SoC package. ARM refers to the PL011
as the PrimeCell UART. The PL011 is used on a wide range of ARM devices and not just the Raspberry Pi. The
implementation of the PL011 will determine its functionality; after all, it's a pretty generic UART chip that ARM has
made. There really is not much interesting about the PL011; it's very close to a generic 16550 IC UART that you would
find on most PCs.
The second interesting thing you may have noticed is this ttyAMA0 . On most systems you would notice your first
serial port is ttyS0 . So why is the Raspberry Pi different? To understand why it's different you need to understand
what the name ttyS0 means. By now you already know what the tty part of the name stands for but what about the
S0 ? To best explain this, take a look at Table 9-1 to see a full breakdown of the naming syntax.
Table 9-1. The breakdown of the ttyS0 name
Teletypewriter
Bus
Device Number
tty
S
0
tty
AMA
0
It's now very clear that the S is the bus of the device. In a traditional PC with a 16550-compatible IC you would
get a serial bus, hence the name ttyS0 , which is your first teletypewriter on serial bus zero. In the case of the
Raspberry Pi the PL011 is not part of a serial bus. It lives on a special bus called Advanced Microcontroller Bus
Architecture (also known as AMBA or AMA). This is why your serial port is called ttyAMA0: it's the first teletypewriter
interface on the AMA bus.
The AMBA bus was first introduced in 1996 by ARM. One of the best parts of the AMBA bus is that it is royalty
free, high speed, and well documented. You would be surprised to find a lot of devices in the SoC world use AMBA,
ranging from network interfaces to flash memory controllers. The serial port is the only device on the AMA bus on the
Raspberry Pi that you will have direct access to. Now you know what and where the UARTs on the Raspberry Pi are,
and I bet you're keen to access them.
 
 
Search WWH ::




Custom Search