IMX8x UARTC packet loss in the middle

I’m using UARTB and UARTC on my board, UARTB works properly but I noticed an issue on UARTC, when it receives more than 16 bytes I lost bytes in the middle of the buffer, for example I send a buffer with sequential numbers

1 2 3 4 5…65 66 67 and I receive the begin and the end of the buffer but I lost some bytes in the middle generally 16 or more all together.

for example see below

sent from host
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49

received by UARTC
01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 47 48 49

I tried in blocking mode and no blocking mode. I’m using in both uarts an isolated RS485 the circuit is the same the only difference is that I’m using UARTB with RTS and UARTC with an Output pin (because I’ve not a RTS pin).

Do you know if there is some issue with this port?

Hello @fabrizio.camagna,

This issue is not expected. The test for the UART on our Linux BSP 6.5.0, which Torizon OS 6.5.0 is based on, has passed.
This test includes the UARTC port and RS485.

What software and hardware versions are you using?
Most of the relevant information can be obtained by running tdx-info or sudo tdx-info on Torizon OS.

Best Regards,
Bruno

sudo tdx-info

Software summary

Bootloader: U-Boot
Kernel version: 5.15.148-rt74-6.6.0-devel+git.23a8e831749d #1-TorizonCore SMP PREEMPT_RT Tue Aug 9 12:56:10 UTC 2022
Kernel command line: root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3 ostree=/ostree/boot.1/torizon/a9a73faf9474e42a92543f59ce5b1d1364c5253db73cad90d7bd2e1190182f0b/0
Distro name: NAME=“TorizonCore with PREEMPT_RT”
Distro version: VERSION_ID=6.6.0-devel-202403-build.22
Distro variant: VARIANT=“Docker”
Hostname: colibri-imx8x-06846833

Hardware info

HW model: Toradex Colibri iMX8QXP on Colibri Evaluation Board V3
Toradex version: 0051 V1.0D
Serial number: 06846833
Processor arch: aarch64

Do you think could be PREEMPT_RT version the problem?

Thanks for the information.

This could be the cause of the problem, when using the PREEMPT_RT patch, the interrupts are turned into tasks which are scheduled by the real time scheduler.

Do you need the RT capabilities for your application?
If yes, so we can narrow down the problem, would it be possible for you to test on a non-PREEMPT_RT image?

Best Regards,
Bruno

I tried with the PREEMPT image but I have the same issue only on uartc

sent (100 bytes)
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60 61 62 63 64

received (68)
01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 63 64

Software summary

Bootloader: U-Boot
Kernel version: 5.15.148-6.6.0-devel+git.23a8e831749d #1-TorizonCore SMP PREEMPT Thu Feb 29 20:25:21 UTC 2024
Kernel command line: root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3 ostree=/ostree/boot.1/torizon/3afce5d545bef9345d701522875bce64de6a0588bb1a368fbb91a79755692a5e/0
Distro name: NAME=“TorizonCore”
Distro version: VERSION_ID=6.6.0-devel-20240404072834-build.0
Distro variant: VARIANT=“Docker”
Hostname: colibri-imx8x-06846833

Hardware info

HW model: Toradex Colibri iMX8QXP on Colibri Evaluation Board V3
Toradex version: 0051 V1.0D
Serial number: 06846833
Processor arch: aarch64

HI @fabrizio.camagna ,

What exactly does this statement mean?

You might want to include the relevant device tree pieces for UARTB and UARTC, along with a description on how your hardware is exactly connected to the module.

Hello @fabrizio.camagna
We’re not aware of any issues currently affecting UARTC on the Colibri iMX8X. Our automated serial tests pass successfully.

As @DaveM already said, it would be nice if you gave more details about your hardware setup, especially regarding this RTS.

Rafael

To exclude the circuit I set the driver direction of 485 to 0 (always input), but is always the same
here my circuit but it works properly on uart B, the only difference is that with uartb i use RTS instead in
uart c I use an output (now I excluded direction and put the driver always in input).

The strange thing is that the gap is in the middle.

I could try the same hardware with jumpers with uarta or uartd, but uarta is used from another process, and uartd is not inlcuded in torizon image, how can I enable it.

Thanks

I executed a simple test on my Colibri iMX8X on the Colibri Evaluation Board. I connected a serial-to-USB converter directly to pins X11:A2 and X11:A3. The software image I used was the Multimedia Reference Image version 6.6.0 (TDX Wayland with XWayland 6.6.0+build.12).

With the USB converter connected to my PC, I started microcom on the target:

$ microcom -s 115200 /dev/colibri-uartc

Then, on my PC side, I set the baud rate on the serial port:

$ stty -F /dev/ttyUSB0 115200

After, I sent some data on the serial port from my PC to the Colibri with:

$ echo "0123456789abcdefghijklmnopqrstuvxyz0123456789abcdefghijklmnopqrstuvxyz0123456789abcdefghijklmnopqrstuvxyz" | wc -c
106
$ echo "0123456789abcdefghijklmnopqrstuvxyz0123456789abcdefghijklmnopqrstuvxyz0123456789abcdefghijklmnopqrstuvxyz" > /dev/ttyUSB0

And on the Colibri side, I could see:

root@colibri-imx8x-06858909:~# microcom -s 115200 /dev/colibri-uartc
0123456789abcdefghijklmnopqrstuvxyz0123456789abcdefghijklmnopqrstuvxyz0123456789abcdefghijklmnopqrstuvxyz

I also tested with a lower baud rate of 19200, with the same results.

Are you seeing this issue sporadically or all the time?

Could you try to replicate this simple test on your side and report back?

I tested with TTL uart and usb/TTL converter and is the same uartc lost packets as with RS485 in the middle. (The serial is connected directly to SODIMM 19 RXC without any kind of circuit)

I tried also with echo commands and other kind of host

i send 1234567890abcdefghilmnopqrstuvzABCDEGFGHILMNOPQRSTUVZ

on the target board
$microcom -s 9600 /dev/colibri-uartc
1234567890abcdefghiVZ

sometimes it recevices all and sometimes not.

I deactivated also the container. Maybe some problem on the SOM? Is it possible add to the image uartd to do some test on another port?

on the target board
$microcom -s 9600 /dev/colibri-uartc

Are you always using 9600 as the baud rate?

I didn’t try with this rate. Did you also try with higher rates?

Rafael only 9600 and also all my previous tests.

I reproduced the issue at 9600, and it seems related to a certain buffer size. Sending a 160-character buffer like I was sending before works, but sending a 50-character buffer fails.

Sending the following sequence of characters only works sometimes:

echo "1234567890abcdefghijklmnopqrstuvxyz"

At 19200 this issue didn’t occur. Is it a requirement to use 9600 in your application, or can this be changed?

Yes 9600 is important because is the standard baud rate for Modbus protocol. There is some workaround, or possibility to change the port (uartd)? Do you know if IMX6 has the same issue?

It should be possible to enable UART D, but currently, we don’t have ready-made examples of that.
In the end, it’s a matter of enabling the correct lpuart instance on the device tree and set the pinmux of the desired pins, taking care to not use any pin that’s already mapped to another necessary function.

Do you know if IMX6 has the same issue?

I’m not aware of a similar issue on the iMX6, but we were also not aware of this one on the iMX8X. We captured this one as a bug but I can’t provide a timeline for the fix at the moment.