Uart1 and Uart2 not showing up in Rasp5

Hi,

I’ve run into an issue where the dtoverlay for uart1 and uart2 does not show up in the docker, but uart0, spi0 and spi1 does. Also, the interface is created on the host for all the overlays.

The code was developed and tested running Raspbian directly on a rasp5. When it runs in docker, the code doesn’t fail because the Uart 1 & Uart 2 interfaces exist but no data comes through because the hardware pins are not set to be uarts as can be seen in the “pinctrl” output below.

DtOverlay config value:

"uart0,txd0_pin=14,rxd0_pin=15","uart1,txd1_pin=0,rxd1_pin=1","uart2,txd2_pin=4,rxd2_pin=5","spi0-1cs","spi1-1cs"

Config file:

root@:~# cat /mnt/boot/config.txt
arm_64bit=1
arm_boost=1
avoid_warnings=1
camera_auto_detect=1
disable_overscan=1
disable_splash=1
display_auto_detect=1
dtoverlay=uart0,txd0_pin=14,rxd0_pin=15
dtoverlay=uart1,txd1_pin=0,rxd1_pin=1
dtoverlay=uart2,txd2_pin=4,rxd2_pin=5
dtoverlay=spi0-1cs
dtoverlay=spi1-1cs
dtparam=
max_framebuffers=2
otg_mode=1

In Raspbian docker:

root@:~# pinctrl
 0: ip    pu | hi // ID_SD/GPIO0 = input
 1: ip    pu | hi // ID_SC/GPIO1 = input
 2: no    pu | -- // PIN3/GPIO2 = none
 3: no    pu | -- // PIN5/GPIO3 = none
 4: no    pu | -- // PIN7/GPIO4 = none
 5: no    pu | -- // PIN29/GPIO5 = none
 6: no    pu | -- // PIN31/GPIO6 = none
 7: no    pu | -- // PIN26/GPIO7 = none
 8: op dh pu | hi // PIN24/GPIO8 = output
 9: a0    pn | lo // PIN21/GPIO9 = SPI0_MISO
10: a0    pn | lo // PIN19/GPIO10 = SPI0_MOSI
11: a0    pn | lo // PIN23/GPIO11 = SPI0_SCLK
12: no    pd | -- // PIN32/GPIO12 = none
13: no    pd | -- // PIN33/GPIO13 = none
14: a4    pn | hi // PIN8/GPIO14 = TXD0
15: a4    pu | hi // PIN10/GPIO15 = RXD0
16: no    pd | -- // PIN36/GPIO16 = none
17: no    pd | -- // PIN11/GPIO17 = none
18: op dh pd | hi // PIN12/GPIO18 = output
19: a0    pd | lo // PIN35/GPIO19 = SPI1_MISO
20: a0    pd | lo // PIN38/GPIO20 = SPI1_MOSI
21: a0    pd | lo // PIN40/GPIO21 = SPI1_SCLK
22: no    pd | -- // PIN15/GPIO22 = none
23: no    pd | -- // PIN16/GPIO23 = none
24: no    pd | -- // PIN18/GPIO24 = none
25: no    pd | -- // PIN22/GPIO25 = none
26: no    pd | -- // PIN37/GPIO26 = none

Raspbian docker interfaces:

root@d15a318:/dev# dir
autofs           gpiomem1      media0     ptp0   random      tty13  tty3   tty46  tty62      vc-mem  vcsu2   video28
btrfs-control    gpiomem2      media1     pts    rfkill      tty14  tty30  tty47  tty63      vcio    vcsu3   video29
bus              gpiomem3      media2     ram0   rtc0        tty15  tty31  tty48  tty7       vcs     vcsu4   video30
cachefiles       gpiomem4      mem        ram1   shm         tty16  tty32  tty49  tty8       vcs1    vcsu5   video31
cdc-wdm0         hwrng         mmcblk0    ram10  snapshot    tty17  tty33  tty5   tty9       vcs2    vcsu6   video32
console          input         mmcblk0p1  ram11  snd         tty18  tty34  tty50  ttyAMA0    vcs3    vga_arbiter  video33
cpu_dma_latency  kmsg          mmcblk0p2  ram12  spidev0.0   tty19  tty35  tty51  ttyAMA1    vcs4    vhci    video34
cuse             kvm           mmcblk0p3  ram13  spidev1.0   tty2   tty36  tty52  ttyAMA10   vcs5    vhost-net       video35
dma_heap         loop-control  mmcblk0p4  ram14  spidev10.0  tty20  tty37  tty53  ttyAMA2    vcs6    vhost-vsock  video36
fd               loop0         mmcblk0p5  ram15  stderr      tty21  tty38  tty54  ttyUSB0    vcsa    video19         video37
full             loop1         mmcblk0p6  ram2   stdin       tty22  tty39  tty55  ttyUSB1    vcsa1   video20         watchdog
fuse             loop2         mqueue     ram3   stdout      tty23  tty4   tty56  ttyUSB2    vcsa2   video21         watchdog0
gpiochip0        loop3         net        ram4   tty         tty24  tty40  tty57  ttyUSB3    vcsa3   video22         zero
gpiochip1        loop4         null       ram5   tty0        tty25  tty41  tty58  ttyprintk  vcsa4   video23         zram0
gpiochip2        loop5         port       ram6   tty1        tty26  tty42  tty59  ubi_ctrl   vcsa5   video24
gpiochip3        loop6         ppp        ram7   tty10       tty27  tty43  tty6   uhid       vcsa6   video25
gpiochip4        loop7         pps0       ram8   tty11       tty28  tty44  tty60  uinput     vcsu    video26
gpiomem0         mapper        ptmx       ram9   tty12       tty29  tty45  tty61  urandom    vcsu1   video27

In Raspbian directly on rasp5:

$ pinctrl
 0: a2    pn | hi // ID_SDA/GPIO0 = TXD1
 1: a2    pu | hi // ID_SCL/GPIO1 = RXD1
 2: no    pu | -- // GPIO2 = none
 3: no    pu | -- // GPIO3 = none
 4: a2    pn | hi // GPIO4 = TXD2
 5: a2    pu | hi // GPIO5 = RXD2
 6: no    pu | -- // GPIO6 = none
 7: no    pu | -- // GPIO7 = none
 8: op dh pu | hi // GPIO8 = output
 9: a0    pn | lo // GPIO9 = SPI0_MISO
10: a0    pn | lo // GPIO10 = SPI0_MOSI
11: a0    pn | lo // GPIO11 = SPI0_SCLK
12: no    pd | -- // GPIO12 = none
13: no    pd | -- // GPIO13 = none
14: a4    pn | hi // GPIO14 = TXD0
15: a4    pu | hi // GPIO15 = RXD0
16: no    pd | -- // GPIO16 = none
17: no    pd | -- // GPIO17 = none
18: op dh pd | hi // GPIO18 = output
19: a0    pd | lo // GPIO19 = SPI1_MISO
20: a0    pd | lo // GPIO20 = SPI1_MOSI
21: a0    pd | lo // GPIO21 = SPI1_SCLK
22: no    pd | -- // GPIO22 = none
23: no    pd | -- // GPIO23 = none
24: no    pd | -- // GPIO24 = none
25: no    pd | -- // GPIO25 = none
26: no    pd | -- // GPIO26 = none

I’ve also tried just creating a “uart1” or “uart2” dtoverlay with no defined pins (so that it uses the default) and a “uart1,txd1_pin=0,rxd1_pin=1” or “uart2,txd2_pin=4,rxd2_pin=5” overlay but neither works (with uart0, spi0, spi1 removed completely).

Any ideas?

Thanks,
Sebastian

Any help from the dev team?

Thanks
Sebastian

Hello @tempusername let me ask the balena devices team if they can help!

It’s been over a week, emails, forum and nothing to show from it. We’ve since switched to another product that allows us to run Raspbian with OTA docker updates and none of the above problems. Good luck with the fix.

Hi there, I’m really sorry you hit this issue! I did some digging into it and there definitely looks to be an issue with enabling secondary UARTs in the rpi5 device types, this is still a fairly new device and we are working out the rough edges.

The team will continue to dig into this and hopefully have a fix in the coming versions.

1 Like

Fixed by https://github.com/balena-os/balena-raspberrypi-temp/pull/161

1 Like

Just to add a bit more colour to the fix. It seems it was an issue with the upstream kernel ( https://forums.raspberrypi.com/viewtopic.php?t=359173 ) which explains why it worked in Raspberry Pi OS but not in balenaOS, which has an older kernel version.

The suggested fix was to bump the kernel to 6.1, so the fix linked above by Florin bumps the pi5 kernel in balenaOS to 6.6.22 . This will take a bit of time to be deployed, but for anyone looking to use multiple UARTs on the pi5, please check that your kernel version is > 6.1 :smiley:

1 Like