RS485 u-boot overlay

Struggling to get RS485 to work with overlays

I have been using kernel 3.8.13 (enabling RS485 with python script) with no issues but wanted to upgrade into the modern world.

Used default image and did the steps suggested in this post:

https://groups.google.com/g/beagleboard/c/nMtRpdWSJu0/m/USjb8sF-AgAJ

  • Swapped from CONFIG_SERIAL_8250_OMAP to CONFIG_SERIAL_OMAP and rebuild
  • Used BB-UART4-RS485-00A0.dts but modified it to be for UART1 and the direction pin I am using
    Everything else is untouched

BB-UART1-RS485-00A0.dts:

/dts-v1/;
/plugin/;

#include <dt-bindings/board/am335x-bbw-bbb-base.h>
#include <dt-bindings/pinctrl/am33xx.h>

/ {
compatible = “ti,beaglebone”, “ti,beaglebone-black”, “ti,beaglebone-green”;

// identification
part-number = “BB-UART1-RS485”;
version = “00A0”;

// resources this cape uses
exclusive-use =
“P9.24”, // uart1_txd
“P9.26”, // uart1_rxd
“P8.14”, // uart1_de/re
“gpio0_26”,

“uart1”; // hardware ip used

/*

  • Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
    */
    fragment@0 {
    target-path="/";
    overlay {

chosen {
overlays {
BB-UART1-RS485-00A0 = TIMESTAMP;
};
};
};
};

/*

  • Free up the pins used by the cape from the pinmux helpers.
    */
    fragment@1 {
    target = <&ocp>;
    overlay {
    P9_24_pinmux { status = “disabled”; };
    P9_26_pinmux { status = “disabled”; };
    P8_14_pinmux { status = “disabled”; };
    };
    };

fragment@2 {
target = <&am33xx_pinmux>;
overlay {
bb_uart1_rs485_pins: pinmux_bb_uart1_rs485_pins {
pinctrl-single,pins = <
BONE_P9_24 (PIN_OUTPUT | MUX_MODE6)
BONE_P9_26 (PIN_INPUT | MUX_MODE6)
BONE_P8_14 0x07

;
};
};
};

fragment@3 {
target = <&uart1>;
overlay {
status = “okay”;
pinctrl-names = “default”;
pinctrl-0 = <&bb_uart1_rs485_pins>;
rs485-rts-delay = <0 0>;

rts-gpio = <&gpio0 26 1>; /* GPIO_ACTIVE_HIGH>; */
rs485-rts-active-high;
linux,rs485-enabled-at-boot-time;
};
};
};

/boot/uEnv.txt:

enable_uboot_overlays=1

uboot_overlay_addr0=/lib/firmware/BB-UART1-RS485-00A0.dtbo
disable_uboot_overlay_video=1
disable_uboot_overlay_audio=1
disable_uboot_overlay_wireless=1
disable_uboot_overlay_adc=1

When I boot:

[ 0.460625] 44e09000.serial: ttyO0 at MMIO 0x44e09000 (irq = 30, base_baud = 3000000) is a OMAP UART0
[ 0.472149] 48022000.serial: ttyO1 at MMIO 0x48022000 (irq = 31, base_baud = 3000000) is a OMAP UART1

But it doesnt work.

If I use the normal overlay BB-UART1-00A0.dtbo and swap the direction pin manually it works.

Any help would be very appreciatied!

Jørgen

Hi,

Here is sample of UART4 RS485:
dts-v1/;
/plugin/;

#include <dt-bindings/board/am335x-bbw-bbb-base.h>
#include <dt-bindings/pinctrl/am33xx.h>

/ {
compatible = “ti,beaglebone”, “ti,beaglebone-black”, “ti,beaglebone-green”;

// identification
part-number = “BB-UART4-COM0”;
version = “00A0”;

// resources this cape uses
exclusive-use =
“P9.13”, // uart4_txd
“P9.11”, // uart4_rxd
“P8.35”, // uart4_de/re
“gpio0_8”,

“uart4”; // hardware ip used

/*

  • Free up the pins used by the cape from the pinmux helpers.
    /
    fragment@0 {
    target = <&ocp>;
    overlay {
    P9_13_pinmux { status = “disabled”; }; /
    P9_13: gpmc_wpn.uart4_txd_mux2 /
    P9_11_pinmux { status = “disabled”; }; /
    P9_11: gpmc_wait0.uart4_rxd_mux2 /
    P8_35_pinmux { status = “disabled”; }; /
    P8_35: PIN_OUTPUT_PULLDOWN | MUX_MODE7 (GPIO0_8) */
    };
    };

fragment@1 {
target = <&am33xx_pinmux>;
overlay {
bb_uart4_rs485_pins: pinmux_bb_uart4_rs485_pins {
pinctrl-single,pins = <
BONE_P9_13 (PIN_OUTPUT | MUX_MODE6) /* P9_13: gpmc_wpn.uart4_txd_mux2 /
BONE_P9_11 (PIN_INPUT | MUX_MODE6) /
P9_11: gpmc_wait0.uart4_rxd_mux2 /
BONE_P8_35 0x07 /
P8_35: PIN_OUTPUT_PULLDOWN | MUX_MODE7 (GPIO0_8) */

;
};
};
};

fragment@2 {
target = <&uart4>;
overlay {
status = “okay”;
pinctrl-names = “default”;
pinctrl-0 = <&bb_uart4_rs485_pins>;
rs485-rts-delay = <0 0>;

rts-gpio = <&gpio0 8 1>; /* GPIO_ACTIVE_HIGH>; */
rs485-rts-active-high;
linux,rs485-enabled-at-boot-time;
};
};
};

Regards,
Atique

I forget mention the kernel version: 4.14.71-ti-r80

I have to use the pins P9_24 TX, P9_26 RX and P8_14 de/re as my beaglebone is mounted on a prewired “IO board”.

Tried installing 4.14.71-ti-r80 kernel (8250 driver) and using my UART1-RS485 overlay. But thats not working.

Is it possible to use whatever pin for de/re?
Tried adding some printk() lines in the omap-serial.c on the modified “stock image” kernel before compiling, but nothing related to RS485 in that code seems to get executed. (Dont see any of the printk() in syslog)

tirsdag 19. januar 2021 kl. 09:33:05 UTC+1 skrev atiqu...@gmail.com:

What kernel version are you using?

4.19.94 modified to use omap-serial instead of 8250-omap-serial.
Have also tried 5.4.70 with same modification.

tir. 19. jan. 2021, 11:15 skrev Atique Rehman <atique0072@gmail.com>: