Enable RS485 in imx6ull aster board UARTB

Hello Team,
I want to enable RS485 in UARTB & C with gpio pin as enable pin for that i made changes in imx6ull-colibri.dtsi
``'/* Colibri UART_B */
&uart2 {
pinctrl-names = “default”;
pinctrl-0 = <&pinctrl_uart2>;
rts-gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>;
rs485-rts-delay = <0 0>;
// uart-has-rtscts;
fsl,dte-mode;
};

and in imx6ull-colibri-aster.dtsi

&uart2 {
rs485-rts-active-high;
linux,rs485-enabled-at-boot-time;
status = “okay”;
};


after that i compile and deploy kernel and rebuild image but i am not getting effect in UARTB, help me with steps how to do and and how to test it

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:


Hello,

To enable RS-485 on UARTB for the i.MX6ULL on the Aster carrier board, your device tree modifications seem to be on the right path. However, let’s ensure all necessary steps are correctly followed and clarify the testing procedure.

  1. Device Tree Configuration: Your modifications in the imx6ull-colibri.dtsi and imx6ull-colibri-aster.dtsi files are mostly correct. However, ensure that the rs485-rts-active-high property in your imx6ull-colibri-aster.dtsi should match the logic level of your RS-485 transceiver’s DE (Driver Enable) and RE (Receiver Enable) pins. If your transceiver requires a low logic level to enable the driver, you should use rs485-rts-active-low instead. Since you’re using a GPIO pin as the enable pin, ensure that the rts-gpios definition matches the physical connection of your RS-485 transceiver’s DE/RE pins to the GPIO1_IO01 pin on the i.MX6ULL.

  2. Kernel Configuration: Ensure your Linux kernel is configured with RS-485 support. This typically involves enabling the appropriate serial driver with RS-485 support in the kernel configuration.

  3. Testing RS-485 Communication: To test RS-485 communication, you can use standard serial communication tools like minicom or picocom on Linux. However, to specifically test RS-485 mode, you might need to write a simple application that uses the TIOCSRS485 ioctl to configure the serial port for RS-485 operation, as described in the RS-485 Kernel Documentation. This application would set the SER_RS485_ENABLED flag along with any other necessary flags for your specific RS-485 setup.

  4. Troubleshooting: If you’re not observing the expected behavior:

    • Verify your hardware connections, including the RS-485 transceiver wiring and any necessary pull-up or pull-down resistors on the DE/RE lines.
    • Use an oscilloscope or logic analyzer to confirm that the GPIO pin used for RS-485 enable (DE/RE) toggles as expected during transmission.
    • Ensure that the RS-485 transceiver is powered and correctly connected to the UART signals (TXD, RXD) and the GPIO pin used for DE/RE control.
    • Check the kernel log (dmesg) for any errors or warnings related to

Please, also check if these links can help you solve your problem:

UART (Linux) | Toradex Developer Center.

I already tried both ways but i am unable to start RS485, enable pin is not toggling, it only stays high

Hi @Prial,

To further check can you please share exact BSP version and sample code which you are using to test?

Additionally please confirm if you are able to receive data using RS 485 port?

You can also use overlay to apply such changes. Please check below documentation

Bets regards
Ritesh Kumar

hello @ritesh.tx
I am using imx6ull Aster Carrier Board.
No i am not able to receive data from rs-485 port.

Prial

Hello @Prial
Can you paste the output of the kernel startup in debug mode in this thread? There might be some clues in there.

hello @DaveM
I attached the kernel log file.
logs.txt (20.5 KB)

Standalone uart is working but there is a issue with enable pin

Hi @Prial

Interesting how the log only shows:

[ 0.708895] 2020000.serial: ttymxc0 at MMIO 0x2020000 (irq = 199, base_baud = 5000000) is a IMX
[ 1.577080] printk: console [ttymxc0] enabled
[ 1.584412] 21e8000.serial: ttymxc1 at MMIO 0x21e8000 (irq = 200, base_baud = 5000000) is a IMX
[ 1.595543] 21f4000.serial: ttymxc4 at MMIO 0x21f4000 (irq = 201, base_baud = 5000000) is a IMX

But doesn’t show any rs485 init text. Perhaps there isn’t any in the kernel, but it sure would be nice if you knew those ports were being inited properly with whatever configuration you’re using in the device tree.

Also a bit interesting how the kernel command line has:

console=tty1 console=ttymxc0,115200n8

Most of my command lines have only a single “console” parameter.

You’re using:

pinctrl-0 = <&pinctrl_uart2>;
rts-gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>;
Did you modify those particular pieces to make sure they are set up for gpio use and not some other function?

Hello @DaveM
According to cat /sys/kernel/debug/gpio command SODIMM 63 will be gpio1 1, that’s why i tried <&gpio1 1 GPIO_ACTIVE_HIGH> but later after i tried <&gpio2 1 GPIO_ACTIVE_HIGH> by this SODIMM 63 is configured as rts sucessfully.
Still SODIMM 63 always being high, unable to receive anything because pin never goes low

Search around in your dts layering for pinctrl_uart2 and any references to SODIMM 63 (seems like that is gpio2 1 on the colibri (that’s what you’re using I assume?) You need to get all of that straight. You’ll need to remove any current uses of that gpio and insert your use appropriately.

We are using imx6ull Aster Carrier Board with TDX Wayland with XWayland Upstream 6.7.0-devel-20240710125113+build.0 (kirkstone) Colibri-iMX6ULL-eMMC_Reference-Multimedia-Image-upstream tdx-reference-multimedia-image (OS)

We have used external 485 IC. we have connected Expansion headers’ pin x18 1st (SODIMM 63) with enable pin of the 485 IC. Currently we are not accessing the UART using code but we are testing in the terminal via microcom.

DTSI files modifications:
build/tmp/work-shared/colibri-imx6ull-emmc/kernel-source/arch/arm/boot/dts/imx6ull-colibri.dtsi

/* Colibri UART_B */
&uart2 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_uart2>;
	rts-gpios = <&gpio2 1 GPIO_ACTIVE_HIGH>;
	rs485-rts-delay = <0 0>;
	status = "okay";
	uart-has-rtscts;
	fsl,dte-mode;
};
&iomuxc {
	pinctrl_adc1: adc1grp {
		fsl,pins = <
			MX6UL_PAD_GPIO1_IO00__GPIO1_IO00        0x3000 /* SODIMM 8 */
			//MX6UL_PAD_GPIO1_IO01__GPIO1_IO01        0x3000 /* SODIMM 6 */
			MX6UL_PAD_GPIO1_IO08__GPIO1_IO08        0x3000 /* SODIMM 4 */
			MX6UL_PAD_GPIO1_IO09__GPIO1_IO09        0x3000 /* SODIMM 2 */
		>;
	};
	pinctrl_uart2: uart2grp {
		fsl,pins = <
			MX6UL_PAD_UART2_TX_DATA__UART2_DTE_RX	0x1b0b1 /* SODIMM 36 */
			MX6UL_PAD_UART2_RX_DATA__UART2_DTE_TX	0x1b0b1 /* SODIMM 38 */
			MX6UL_PAD_ENET1_RX_DATA1__GPIO2_IO01	0xb0b0 /* SODIMM 63 */
			//MX6UL_PAD_UART2_CTS_B__UART2_DTE_RTS	0x1b0b1 /* SODIMM 32 */
			//MX6UL_PAD_UART2_RTS_B__UART2_DTE_CTS	0x1b0b1 /* SODIMM 34 */
		>;

build/tmp/work-shared/colibri-imx6ull-emmc/kernel-source/arch/arm/boot/dts/imx6ull-colibri-aster.dtsi

&uart2 {
	rs485-rts-active-high;
	linux,rs485-enabled-at-boot-time;
	status = "okay";
};

UART access:
microcom -s 115200 /dev/colibri-uartb

@ritesh.tx @DaveM please reply

You don’t want both gpio and rtscts support enabled in your dts. You had rtscts commented out originally but above it’s not. Comment it back out again.

I can’t vouch for microcom doing the right things with TIOCSRS485. I’m not saying microcom doesn’t do things correctly, but you could control everything with some sample code that works the serial port in 485 mode.

You could also never open the port and try and toggle the gpio manually over the console using some sort of gpio tools to convince yourself you can actually move it up and down.

hello @DaveM
I also tried using the code, but still the RS485 port is not working; able to transmit data but unable to receive. The enable pin is just high because of the changes in the DTSI. I have attached the code below.
rs485.c (2.1 KB)