Activating additional UARTs on Raspberry Pi 4B

Device: Raspberry Pi 4B v1.2
Image: 2020-11-07-ubiquity-xenial-lxde

Hello all, I’m using the Ubiquity image for a project that does not involve the Magni, and I’d like to enable the additional UART ports available on the RPi 4.

I’ve followed the instructions at https://learn.ubiquityrobotics.com/GPIO_lines to free up the GPIO lines, and I’ve added the following lines to config.txt to enable the four extra uart ports:

#Enable the additional uarts for serial communication
enable_uart=1
dtoverlay=miniuart-bt
dtoverlay=uart2
dtoverlay=uart3
dtoverlay=uart4
dtoverlay=uart5

However, after a reboot, running the command sudo raspi-gpio get returns the following:

BANK0 (GPIO 0 to 27):
  GPIO 00: level=1 fsel=3 alt=4 func=AVEIN_VCLK
  GPIO 01: level=1 fsel=3 alt=4 func=AVEIN_DSYNC
  GPIO 02: level=1 fsel=0 alt=  func=INPUT
  GPIO 03: level=1 fsel=0 alt=  func=INPUT
  GPIO 04: level=1 fsel=3 alt=4 func=AVEIN_VID0
  GPIO 05: level=1 fsel=3 alt=4 func=AVEIN_VID1
  GPIO 06: level=1 fsel=0 alt=  func=INPUT
  GPIO 07: level=1 fsel=0 alt=  func=INPUT
  GPIO 08: level=1 fsel=3 alt=4 func=AVEIN_VID4
  GPIO 09: level=1 fsel=3 alt=4 func=AVEIN_VID5
  GPIO 10: level=0 fsel=0 alt=  func=INPUT
  GPIO 11: level=0 fsel=0 alt=  func=INPUT
  GPIO 12: level=1 fsel=3 alt=4 func=AVEIN_VID8
  GPIO 13: level=1 fsel=3 alt=4 func=AVEIN_VID9
  GPIO 14: level=1 fsel=4 alt=0 func=TXD0
  GPIO 15: level=1 fsel=4 alt=0 func=RXD0
  GPIO 16: level=0 fsel=0 alt=  func=INPUT
  GPIO 17: level=0 fsel=0 alt=  func=INPUT
  GPIO 18: level=0 fsel=0 alt=  func=INPUT
...

The four pairs of GPIO lines returning functions beginning with ‘AVEIN_’ should be returning RX and TX like GPIO 14 and 15.

I used sudo raspi-gpio funcs to inspect the pin layout returned by raspi-gpio, which returns the following:

GPIO, DEFAULT PULL, ALT0, ALT1, ALT2, ALT3, ALT4, ALT5
0, UP, SDA0, SA5, PCLK, AVEOUT_VCLK, AVEIN_VCLK, -
1, UP, SCL0, SA4, DE, AVEOUT_DSYNC, AVEIN_DSYNC, -
2, UP, SDA1, SA3, LCD_VSYNC, AVEOUT_VSYNC, AVEIN_VSYNC, -
3, UP, SCL1, SA2, LCD_HSYNC, AVEOUT_HSYNC, AVEIN_HSYNC, -
4, UP, GPCLK0, SA1, DPI_D0, AVEOUT_VID0, AVEIN_VID0, ARM_TDI
5, UP, GPCLK1, SA0, DPI_D1, AVEOUT_VID1, AVEIN_VID1, ARM_TDO
6, UP, GPCLK2, SOE_N_SE, DPI_D2, AVEOUT_VID2, AVEIN_VID2, ARM_RTCK
7, UP, SPI0_CE1_N, SWE_N_SRW_N, DPI_D3, AVEOUT_VID3, AVEIN_VID3, -
8, UP, SPI0_CE0_N, SD0, DPI_D4, AVEOUT_VID4, AVEIN_VID4, -
9, DOWN, SPI0_MISO, SD1, DPI_D5, AVEOUT_VID5, AVEIN_VID5, -
10, DOWN, SPI0_MOSI, SD2, DPI_D6, AVEOUT_VID6, AVEIN_VID6, -
11, DOWN, SPI0_SCLK, SD3, DPI_D7, AVEOUT_VID7, AVEIN_VID7, -
12, DOWN, PWM0, SD4, DPI_D8, AVEOUT_VID8, AVEIN_VID8, ARM_TMS
13, DOWN, PWM1, SD5, DPI_D9, AVEOUT_VID9, AVEIN_VID9, ARM_TCK
14, DOWN, TXD0, SD6, DPI_D10, AVEOUT_VID10, AVEIN_VID10, TXD1
15, DOWN, RXD0, SD7, DPI_D11, AVEOUT_VID11, AVEIN_VID11, RXD1
16, DOWN, FL0, SD8, DPI_D12, CTS0, SPI1_CE2_N, CTS1
17, DOWN, FL1, SD9, DPI_D13, RTS0, SPI1_CE1_N, RTS1
18, DOWN, PCM_CLK, SD10, DPI_D14, I2CSL_SDA_MOSI, SPI1_CE0_N, PWM0
...

So it appears that funcs is returning the wrong GPIO pin setup for the Pi 4B. Has anyone successfully gotten uart2-uart5 working on a Ubiquity Pi image? Is there something I can do to force raspi-gpio to recognize that it is a Pi4B with a bcm2711 and use the appropriate pin setup?

Any help would be appreciated.

In case anyone in the future is wondering, building the newest version of raspi-gpio from source using the instructions on the GitHub page and adding the directory to the start of the PATH fixed the pin mapping. After a reboot, a loopback test confirmed all five serial ports were functioning as expected.

Thanks to the crew at Ubiquity for making this image freely available.

1 Like

This is very helpful @astan thank you for following up and finding a fix.

I had duplicated your earlier problem but had not dug in to look for a solution yet.

Thanks for the followup post as I had known more ports were possible on the Pi4 but had not tried it yet.

1 Like

I hit another thing requiring a small hack. The apt get of automake gave me a rev 1.15 and the aclocal.m4 that is included in the raspi-gpio repository was setup to require automake 1.16.
So I removed aclocal.m4, edit configure and change rev like this:
am__api_version=‘1.15’

I pulled src with: git clone https://github.com/RPi-Distro/raspi-gpio

Then I could do the make as per the github for raspi-gpio and was able to enable a port, in my case uart3.

Thought this mention may help others to fix this make issue. Thanks.

2 Likes

Hi Mark! I owe you and your team 16.04 beers for solving the “Ubuntu 16.04 isn’t compatible with RPi 4B” problem, but your buy us a beer link at https://www.ubiquityrobotics.com/dl-thank-you/ appears to be broken. Please advise.

2 Likes

Thank you. I have passed this on to our web guy. This is some sort of effect due to some recent web site change. Thanks for pointing this out

For now the Donate button on the other downloads page should work: https://downloads.ubiquityrobotics.com/pi.html

Thanks
Rohan