How to access serial-port?

I am trying to verify that serial port(rs485) is working properly or not quickly on imx8 based board. for that I am using below commands but they are throwing errors

jvgediya@localhost:~$ echo "Hello" > /dev/ttymxc1
-bash: /dev/ttymxc1: Permission denied
jvgediya@localhost:~$ sudo echo "Hello" > /dev/ttymxc1
-bash: /dev/ttymxc1: Permission denied

My gadget is already providing slot for /dev/ttymcx1. What should I do so that the above command run successfull?

Do I need to create my application that write/read to serial node and snap which provide plug for this serial node, connect it to gadget slot and then perform read/write from application?

Please let me know if there is any other solution possible?

sudo echo is always wrong (the sudo only applies to the echo in that case … not to the redirect that > does) :wink:

you want something like:

echo "foo" | sudo tee /dev/ttymxc1

Hi @ogra Thanks, This solved the tx issue, and transmit is working fine. However, I am still not successful in reading the data from the serial port.

I have tried the command “sudo cat /dev/ttymxc1”, it is blocking for read but there is no data received. I have tried this command after properly setting serial parameters using stty command. I have verified that my pin muxing and dts entries for this specific UART is proper.

I have also tried to implement my own snap so I can manually connect the interfaces but still receive/read is not working even using this serial-test app.

jvgediya@localhost:~$ snap interfaces
Slot                       Plug
imx8mqevk-gadget:serial-0  serial-test:serial-port
imx8mqevk-gadget:serial-1  serial-test:serial-port
imx8mqevk-gadget:serial-2  serial-test:serial-port

I have tried to make /dev/ttymxc1 as a debug console instead of default /dev/ttymxc0, then it works properly, I am able to see the kernel logs and also able to enter the commands on Linux console so Rx/Tx are working when this serial-port is configured as debug console(from U-Boot bootargs).

I am using the same kernel for yocto also. Ubuntu core have some extra configs enabled on top of yocto linux config. There is no change in device tree between both the kernels. All serial ports are working perfectly fine when I boot linux built through yocto on my board but with ubuntu-core, receive doesn’t work.

@ogra Please let me know if you have any pointers to debug this issue.

I would really appreciate it if ubuntu core experts on this forum can let me know if I am missing any important aspect of how serial-ports work in ubuntu-core and if any specific test method needs to be used to test them.


well, if the cat doesnt work this is a kernel or driver problem or your input simply doesnt arrive at the serial, how do you/what generate(s) the data you expect to see coming in there when running the cat command ?

@ogra I am running an echo command from the Linux PC where another end of the serial cable is connected. The same setup is working fine when tested with Yocto built images.

@ogra It was an issue with sdma firmware loading. The UART I was trying to test was having sdma channels configured for it in dts.

by the time, kernel in-built sdma driver was trying to load sdma controller firmware, it was not able to access the firmware from /lib/firmware directory even though it was after INIT started as per the boot logs.

I configured sdma driver as module and it solved the problem.

1 Like

phew :slight_smile:

1 Like