Serial Port Control Signal

Hi,

Device Detail : Verdin iMX 8MP Quad WB IT.
OS: Torizon OS

I need to use Data Terminal Ready (DTR) control signal in RS-232 serial port.
My serial port interface device requires DTR signal support to send data to iMX, how can I enable it on iMX8MP.
On the Pinout Designer (torizon.io)
I can see CTS RTS RXD TXD supported. What needs to be done here?

Regards
Samarth

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


:handshake:

Hi, Samarth

The Verdin iMX8MP module does not natively support the DTR (Data Terminal Ready) signal on its UART interfaces. The standard UART signals available are CTS, RTS, RXD, and TXD, as you mentioned.

To use the DTR signal, you would typically need to implement it in software or use an external hardware solution. Here are a couple of approaches you could consider:

  1. Software Emulation: You can use one of the available GPIO pins to emulate the DTR signal. This involves configuring a GPIO pin as an output and controlling it through your application to mimic the DTR behavior. You can use the GPIO sysfs interface or a dedicated GPIO library to control the pin.

  2. External Hardware: If software emulation is not suitable, you might need to use an external UART-to-RS232 converter that supports the DTR signal. These converters can handle the DTR signal and interface with the Verdin module’s UART.

For software emulation, here is a basic example of how you might control a GPIO pin in a Linux environment:

# Export the GPIO pin (replace <gpio_pin_number> with the actual pin number)
echo <gpio_pin_number> > /sys/class/gpio/export

# Set the GPIO pin as an output
echo out > /sys/class/gpio/gpio<gpio_pin_number>/direction

# Set the GPIO pin to high (DTR active)
echo 1 > /sys/class/gpio/gpio<gpio_pin_number>/value

# Set the GPIO pin to low (DTR inactive)
echo 0 > /sys/class/gpio/gpio<gpio_pin_number>/value

You would need to integrate this control into your application logic to manage the DTR signal as required by your serial communication protocol.

Best regards,
Toradex AI Assistant

UART device tree node supports the dtr-gpios property.
So you need to add the DTR GPIO to the iomux config and the property to the UART node. More information here: https://www.kernel.org/doc/Documentation/devicetree/bindings/serial/serial.txt

Hi @kaam1 & @ritesh.tx

Since I have physically shorted the RTS and DTR by soldering it. i.e pin 4 7 and 8 on a RS232 port. Now I want to set the DTR(RTS since I have shorted) to low so as to signal Data terminal ready to my peripheral device and start receiving data. Don’t need to make use of GPIO as of now. JFYI my device required only DTR output from iMX8mp and ofc Rx and Tx.
How can I set the RTS pin on imx8mp to low. Can it be done with a device tree overlay . Or I can set it directly with some linux command. Where should I start with?

Best regards,
Samarth

Hi, there are several ways:

  • physically connect the pin to a pull-down resistor on the board
  • modify the device tree iomux settings for the pin to enable internal imx8 pull-down resistor
  • set the pin to low with command line:
echo N > /sys/class/gpio/export
echo out > /sys/class/gpio/gpioN/direction
echo 0 > /sys/class/gpio/gpioN/value

N is the pin number (i think it’s (gpio_bank-1)*32+gpio_pin))

Hi,

I’m not making use of the GPIO pins rather UART pins on my SoM verdin imx8mp with torizon os.

I’ve attached the pin layout from torizon pin out design tool. Want to make pin no 133 as low.

Can I achieve this with some c/c++ code using termios library or any other library?
Will the above given commands work for these pins?
Would prefer the easiest way to achieve the same.

Hi @kaam,

Can you pls provide some directions here.

JFYI, I tried to disable rtscts signal with stty command, on checking with multimeter initially the voltage was 1.78. On disabling rtscts the voltage dropped to 0 for RTS pin. So if I say “active low” for specific pin does that mean the same as lowering the voltage to zero for that pin? Also as for my original requirement I need to set the DTR pin to low, now since my DTR and RTS and CTS pins are shorted my DTR will also go to low. Will it work?

Best regards,
Samarth

Hi @ritesh.tx & @jeremias.tx

After my previous post when I’m checking the voltage on rts pin with multimeter, I’m getting only 1.8v.
Earlier the stty -F /dev/ttymxc0 -crtscts command made the voltage low, but now its not working.
Can you please help?

Best regards,
Samarth

Hi @Sudharshan ,
Is your issue solved ?

Hi @sahil.tx ,

No not yet. We have few changes in requirement. I’ll explain,

I’m expecting to receive continuous data from serial peripheral device using RS232 cable.
My peripheral device has specific requirement of expecting the DTR signal as high, only then it will start sending data.
Since, the iMX8MP doesn’t has DTR pin assigned, I achieved to pull up the DTR pin to high through the adaptor board I have on my Yavia board.
Now my peripheral device is sending the data to the iMX8MP on UART1, but I am unable to receive data on iMX8MP by opening /dev/ttymxc0 using minicom and my specific serial configuration.
The same peripheral, when I’m connecting to USB i.e /dev/USB0 , I’m receiving the data properly and as expected.

The above image shows the logic analyzers output confirming data received on SoM UART pins.
I’m expecting the data to show up when opening /dev/ttymxc0 with minicom, but it is not received.

When I send the data on the same DB9 port on my adaptor board from a test PC using a RS232 to USB cable( RS232 on iMX side) I receive the data on /dev/ttymxc0 which means the RX is fine on the DB9 port and SoM pins. But not with my peripheral device.

What could be the potential cause of the data not receiving on /dev/ttymxc0 for my use case?

Regards,
Samarth

Hi @Sudharshan ,
You can simply test your UART’s for send/receive through command line.
Connect it with PC and test.
Make sure that your are not using the default UART port used for debug otherwise you may need to disable serial console first.
You can also test other UART’s to narrow down the issue

Hi @sahil.tx

We have tested the Tx and Rx from iMX to test PC and vice-versa. Communication is working fine.

No, we are not using the debug UART.

We are receiving the waveform at UART_Rx pin of the iMX, snapshot attached above.

We are running a container with privilege access, within the container we are running minicom opening /dev/ttymxc0 for reading data.

Regards,
Samarth

Hi @Sudharshan,
So is it the you are not able to receive data from your serial peripheral device but it works as expected when tested with the PC?

Hi @sahil.tx ,

When trying to send data from a PC to iMX8MP and vice versa, /dev/ttymxc0 is able to read write data.

Only when I try to read data from my serial device /dev/ttymxc0 is not able to receive any data.
On checking with logic analyser, we can see the data going to iMX8MP SoM pins. Same SS is attached in the previous post.

Regards
Samarth

Hi @Sudharshan,
The issue seems to be related to configuration mismatch between the sender and receiver.
Check all the settings using stty
eg stty -F /dev/ttymxc0 -a
Modify the setting which is not as per your serial device

Hi @sahil.tx ,

I’ve verified the configuration settings. The same setting when given to a windows PC, works for my serial device. I’ve tried using standard tools like minicom, SerialTest, but neither is working. FYI I’m expecting binary data from the serial port.

Regards,
Samarth

Hi @Sudharshan ,

So the below works
PC <---------------------> i.MX8MP
PC <--------------------->Serial Device

and the below does not work.
iMX8MP <------------> Serial Device

Did you observed any difference in the timing diagrams of logic analyzer?
What serial device you have ?
Also, can you confirm whether is it atleast able to read garbage values or nothing at all?

Hi @sahil.tx,

Yes that’ the correct understanding.

We have identified some discrepancy with the parity bit in the frame we are receiving from our serial device. At current it seems like given the same configuration, the windows PC hardware is ignoring the parity and accepting the data but the iMX8MP’s UART is rejecting the data.

Hi @sahil.tx ,

We wanted to check how the driver handles the data coming on iMX8MPs UART.
For that we want to add some kernel logs in the driver, and debug(with logs) the discarding or acceptance on data in driver level.

So for that, need to know from you about the correct driver code for uart on iMX8MP and the tools and environment required to build kernel, load new kernel with UART logs on torizon os and check connecting with my serial device. Attaching the tdx-info FYR.
tdx-info.txt (1.0 KB)

Regards,
Samarth