RS-485 RTS drive RS-485 Tx-enable from Kernel

I have been struggling to get RS-485 Tx enable coms working on Beaglebone black.
As a newbie, Robert Nelson and Zmatt have been very helpful (and patient) with instructions to help me get this working.
I now have RTS and CTS enabled on my UART1 using BB-UART1-00A0.dts
I can drive RTS high and low from my CPP app, but the kernel does not automatically drive RTS for my RS-485 driver Tx-enable as I hoped.

I noted there was also a BB-UART4-RS485-00A0.dts file which pretty much models what I did to BB-UART1-00A0.dts except with UART4
The significant change was fragment 3 which has RS-485 related parameters which looked hopeful.

    fragment@3 {
        target = <&uart4>;
        __overlay__ {
            status = "okay";
            pinctrl-names = "default";
            pinctrl-0 = <&bb_uart4_rs485_pins>;
            rs485-rts-delay = <0 0>;

            rts-gpio = <&gpio3 19 1>; /*  GPIO_ACTIVE_HIGH>; */

So I tried this adding the following to my /boot/uEnv.txt file


sudo ./ gives me:

P9.11                             28 T17 fast rx      6 uart 4 rxd       serial@481a8000 (pinmux_bb_uart4_rs485_pins)
P9.13                             29 U17 fast         6 uart 4 txd       serial@481a8000 (pinmux_bb_uart4_rs485_pins)
P9.27                            105 C13 fast    down 7 gpio 3.19        serial@481a8000 (pinmux_bb_uart4_rs485_pins)

I am not driving P9 pin 27 in my CPP app, hoping the Kernel will control it automatically but my scope shows it stays low even when I transmit.

I feel I am very close now but just need help to get this over the line.


Hi Robert and Matt and anyone else following this.

I finally have it working on:

  • UART 1 using BB-UART1-00A0.dts
  • UART 4 using BB-UART4-00A0.dts

I had not configured the rs485conf struct using termios in my CPP test app properly.

If anyone follows this, please note:
RTS logic levels are backwards from what you might expect eg to set RTS high while transmitting you need:

  • rs485conf.flags &= ~(SER_RS485_RTS_ON_SEND);
  • rs485conf.flags |= (SER_RS485_RTS_AFTER_SEND);

You must also set the delays eg:
rs485conf.delay_rts_before_send = 1; /* Delay before send (milliseconds) /|
rs485conf.delay_rts_after_send = 0; /
Delay after send (milliseconds) */|

Thanks for your help - I really appreciate your time!
Best regards