UART on RPi-CM4-IO with Radxa CM3

Hi,
I’m struggling to get UARTs working on the Radxa CM3.
I’ve followed this Guide on how to install the OS: Rock3/installusb-install-radxa-cm3-rpi-cm4-io - Radxa Wiki
And used the latest release of Ubuntu: Release 20221101-0118 · radxa-build/radxa-cm3-io · GitHub

Connecting with ssh works fine.

Then I followed the “Help! Something doesn’t work!” steps. (But everytime I use “sudo update_extlinux.sh” this is getting reverted?)

I’ve edited the /boot/config.txt with this “dtoverlay=rk3568-uart2-m0” but that didn’t help.
The /boot/uEnv.txt is nowhere to be found and creating one didn’t help either.

mraa-uart and mraa-gpio list also don’t show any pins :man_shrugging:

So now I don’t know what to do next I searched for hours and tried many things but they all didn’t change a thing.

Would appreciate if someone could help me here.
My goal is to use UART2_TX and _RX.

The image should have the rsetup utility. Start it, select overlays, manage overlays.
Enable uart2-m0, reboot.

Can’t find it :frowning:

Right, ubuntu seems not to have it.

Then edit /boot/config.txt

Add

dtoverlay=rk3568-uart2-m0

comment out this line, if you have it, it probably conflicts with your use

dtoverlay=rk3568-fiq-debugger-uart2m0

execute

sudo update_extlinux.sh

reboot

I allready tried that just like I wrote in my post.
But I tried it again but still doesnt work.

Post the content of your /boot/extlinux/extlinux.conf

#timeout 10
#menu title select kernel

label kernel-4.19.193-58-rockchip-gbac1feba87f0
    kernel /vmlinuz-4.19.193-58-rockchip-gbac1feba87f0
    initrd /initrd.img-4.19.193-58-rockchip-gbac1feba87f0
    devicetreedir /dtbs/4.19.193-58-rockchip-gbac1feba87f0
    append   root=UUID=0602c1f0-267a-45b9-b4a0-6d9eb681e877 earlyprintk console=ttyFIQ0,1500000n8 console=tty1 consoleblank=0 loglevel=7 panic=10 rootwait rw init=/sbin/init rootfstype=ext4 cgroup_enable=cpuset cgroup_memory=1 cgroup_en>

Hmm, no

fdtoverlays

line was generated. Should be after the devicetreedir line.
update_extlinux.sh probably cannot parse your /boot/config.txt, probably there are errors in it. Post it please.

dtoverlay= MUST be in the first column (i.e. no space in front), No space between “dtoverlay” and “=”

i.e., should look like that

#
# dt overlay line: started with "dtoverlay=". One dt overlay one line.
#
dtoverlay=rk3568-uart2-m0
#dtoverlay=rk3568-fiq-debugger-uart2m0
dtoverlay=rk3568-disable-npu

ye ok i had a typo in my config.txt but the uarts still dont show up here is the new extlinux.conf:

#timeout 10
#menu title select kernel

label kernel-4.19.193-58-rockchip-gbac1feba87f0
    kernel /vmlinuz-4.19.193-58-rockchip-gbac1feba87f0
    initrd /initrd.img-4.19.193-58-rockchip-gbac1feba87f0
    devicetreedir /dtbs/4.19.193-58-rockchip-gbac1feba87f0
    fdtoverlays  /dtbs/4.19.193-58-rockchip-gbac1feba87f0/rockchip/overlay/rk3568-uart2-m0.dtbo /dtbs/4.19.193-58-rockchip-gbac1feba87f0/rockchip/overlay/rk3568-disable-npu.dtbo
    append   root=UUID=0602c1f0-267a-45b9-b4a0-6d9eb681e877 earlyprintk console=ttyFIQ0,1500000n8 console=tty1 consoleblank=0 loglevel=7 panic=10 rootwait rw init=/sbin/init rootfstype=ext4 cgroup_enable=cpuset cgroup_memory=1 cgroup_en>

and for reference my config.txt:

# Execute "update_extlinux.sh" after changing file /boot/config.txt.

#
# kernel command line: started with "cmdline:"
#

# For console
cmdline: earlyprintk console=ttyFIQ0,1500000n8 console=tty1 consoleblank=0 loglevel=7

# For rootfs
cmdline: panic=10 rootwait rw init=/sbin/init rootfstype=ext4

# Docker optimizations
cmdline: cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1

cmdline: switolb=1
cmdline: coherent_pool=1m


#
# dt overlay line: started with "dtoverlay=". One dt overlay one line.
#

dtoverlay=rk3568-uart2-m0
dtoverlay=rk3568-disable-npu

Why?

fdtoverlays /dtbs/4.19.193-58-rockchip-gbac1feba87f0/rockchip/overlay/rk3568-uart2-m0.dtbo ...

now it should be loaded.

mraa-uart list doesnt show anything.
And ls -l /dev also doesnt show any serial ports.

What output gives dmesg | grep ttyS?

Should be something like

[ 5.076144] feb50000.serial: ttyS2 at MMIO 0xfeb50000 (irq = 90, base_baud = 1500000) is a 16550A

(this is from an rk3588, addresses might be different on rk3568)

[    0.488557] fe650000.serial: ttyS1 at MMIO 0xfe650000 (irq = 56, base_baud = 1500000) is a 16550A
[    0.489322] fe660000.serial: ttyS2 at MMIO 0xfe660000 (irq = 57, base_baud = 1500000) is a 16550A
[    4.448316] ttyS1 - failed to request DMA, use interrupt mode
[    4.448772] ttyS1 set divisor fail, quot:156 != dll,dlh:0
[    4.448862] ttyS1 set divisor fail, quot:156 != dll,dlh:0
[    4.448904] ttyS1 set divisor fail, quot:13 != dll,dlh:0

So you have UART2. To double check that, you could remove the overlay again, the ttyS2 line should be gone. That said, I have no clue why it does not work with mraa. But I wouldn’t be surprised if the mraa lib is just to old. I did not use the Ubuntu images.

Try this:
mraa-uart list
journalctl | grep mraa

On my machine I got

libmraa version v2.2.0 initialised by user 'xxx' with EUID xxxx
libmraa initialised for platform 'Radxa ROCK 5B' of type 36

If your board is detected, might be something with the permissions to access /dev/ttyS2.

dir /dev/ttyS2
92 0 crw-rw---- 1 root dialout 4, 66 Jun 26 01:36 /dev/ttyS2

groups $USER
xxx: ... dialout ...

If not, try to build a recent version from source, this is rather simple.

journalctl | grep mraa:

libmraa initialised for platform 'Unknown platform' of type 98
libmraa version v2.1.0 initialised by user 'xxx' with EUID 1000
Unknown Platform, currently not supported by MRAA

groups $USER:

xxx: rock sudo audio video

no dialout here is this a problem?

dir /dev/ttyS2
/dev/ttyS2

ls -l /dev/ttyS2:

crw-rw---- 1 root dialout 4, 66 Jun 26 09:54 /dev/ttyS2

Btw do you know how I can change the baudrate to 115200?

Thank you allready for the help, I’m not so used to working with linux :confused:

That’s as I feared:

Unknown Platform, currently not supported by MRAA

The libmraa is too old and does not support your board. So, you have 3 options here if you need libmraa:

  1. try update (I doubt that will help)
  2. switch to Radxa Debian (I think they have an updated version, but no promises)
  3. compile from source

Regarding the permissions, either add your user to group dialout, or use sudo to start programs that access /dev/ttyS2

Okay and what about the baudrate? :thinking:

With libmraa: Use the mraa function to set.
Without: use standard ioctl on the device

The device is there: From now, it is a “normal Linux/Unix” task to access it. What exactly you what to do with the UART?