UART0 (ttyAMA0) Comms Quirk In Raspbian Firmware 4.9+

The Raspberry Pi 3 board features on board Bluetooth and WiFi adapters, in order to get the on-board Bluetooth module to work correctly the Raspberry Pi dev team found they needed to use the primary comms port ttyAMA0 rather than ttyS0 and as a result made some changes to the OS configuration. These changes involved swapping internal serial port alias ids as well as moving the IO pins UART0 (ttyAMA0) and UART1 (ttyS0) were assigned to. If you spend some time Googling the subject you'll find this caused quite a stir at the time as the removal of ttyAMA0 from the IO conector impacted a lot of setups.

Whilst the Compute Module 3 doesn't have these Pi3 features integrated we do still need to take notice of the changes made to the firmware to accomodate them on the standard Pi3 board, and effectively reverse them so the internal aliases once again match the UARTs we are using as standard.

This step has already been performed on the stock image available for download, however customers running kernel 4.4.x should perform the below patch to assure compatibility going foward.

To do this we first need to create a device tree overlay file called uart_swap.dts (see /root/device-tree for this file) containing the below :

        compatible = "brcm,bcm2708";

        fragment@0 {
                target-path = "/aliases";
                __overlay__ {
                        serial0 = "/soc/serial@7e215040";
                        serial1 = "/soc/serial@7e201000";

Then compile it and copy to the overlays folder in /boot/

# dtc -@ -I dts -O dtb -o uart_swap.dtb uart_swap.dts 
# cp uart_swap.dtb /boot/overlays/uart_swap.dtbo


Add that add the overlay in after the serial port assignments in /boot/config.txt

### UART0 ###
# MODE 1 : Enable ttyAMA0 TX/RX to pins 32/33

# MODE 2 : Enable ttyAMA0 CTS/RTS/TX/RX to pins 30/31/32/33

### UART1 ###
# Console Port (Alter cmdline.txt to disable)
# Enable ttyS0 TX/RX to pins 14/15
# Note : set 'core_freq=250' below to avoid baud rate issues

# Required to correct firmware serial port assignments from their Pi3 defaults

Lastly we need to amend the kernel cmdline console assignment:to match the correct serial port by editing the file /boot/cmdline.txt

console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait


This set of steps ensures the serial ports work correctly.

Contact us now to discuss your project

Ready to order, contact us today for pricing or samples

Contact Us