RS485 on imx6 / ixora


I’m trying to implement a Modbus RTU communication, RS485 half-duplex.

This is my system:

  • imx6q / Ixora (V1.2)
  • Linux apalis-imx6-10887206 5.4.129-rt61-0+git.c43bc2d53067 #1 SMP PREEMPT_RT
  • Kernel: linux-toradex-mainline
  • I didn’t change the device tree.

I tried to follow the documentation, but it doesn’t work so far. Since this is not my area of expertise, I hope someone can give me some pointers.

First, I would like to use the X21 header on the Ixora board. If I understand it correctly, for my use case, that would be pin 3 (UART2_RS232_RXD) and pin 4 (UART2_RS232_RTS). Is this correct?

For testing, I followed the advice from this article to set the following flags:

struct serial_rs485 rs485conf;

/* Enable RS485 mode: */
rs485conf.flags |= SER_RS485_ENABLED;
/* Set logical level for RTS pin equal to 0 when sending: */
rs485conf.flags &= ~(SER_RS485_RTS_ON_SEND);
/* Set logical level for RTS pin equal to 1 after sending: */
rs485conf.flags |= SER_RS485_RTS_AFTER_SEND;
/* Enable receiver during sending, required for i.MX devices */
rs485conf.flags |= SER_RS485_RX_DURING_TX;
ioctl(fd, TIOCSRS485, &rs485conf);

I implemented a simple program using libmodbus to read a register from a server (slave) device. It doesn’t seem to be doing anything.

I will further experiment and test this myself, but it seems that I’m missing some basic information. Therefore, my questions are:

  1. Are the pins I’m using correct (without changing the device tree from the default)?
  2. Do I need to do something else to use RS485 half-duplex on my system, or should the above (ioctl) work already?
  3. How can I best debug this?

Many thanks in advance for any inputs.

After reading the schematics more closely, I just realized that the Ixora board doesn’t have any RS485 transceiver on it. This means that RS485 is not possible without hardware modification on this carrier board.

This answer is probably obvious to many users. For me, the above linked tutorial was a bit confusing (and I know other carrier boards where RS232 and RS485 can be switched).

Anyway, if I understand it correctly, to make RS485 work on Ixora, one would need to replace the RS232 transceiver with a RS485 one, or disable the UART and just use the pins with an external RS485 transceiver. For my current project, I’ll go with a USB - RS485 adapter.

If there is another way, please let me know. Thank you.

Yes the Ixora carrier board has no RS485 transceiver. And mentioned article is describing how to set driver to use RTS output to control a RS-485 transceiver . You can use an external RS232 to RS485 Serial Converter Adapter like this one or similar.

Thank you for confirming @alex.tx. It is now clearer to me how to read the article. However, I think the paragraph about RS485 could be a bit more explicit, e.g. the following text:

The Toradex Carrier Board implements RS-485 using a single transceiver in a half-duplex communication mode, […] The RS-485 support has been tested using the configuration as found on Toradex Carrier Boards.

I’ll mark the question as resolved.

Toradex Apalis Evaluation board has a RS-422/RS-485 Interface based on Analog Devices ADM3491ARZ IC