RS485 u-boot overlay

63 views
Skip to first unread message

Jørgen Sirum

unread,
Jan 19, 2021, 3:19:15 AM1/19/21
to BeagleBoard
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:

- 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


Atique Rehman

unread,
Jan 19, 2021, 3:30:28 AM1/19/21
to beagl...@googlegroups.com
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

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/cfc7f9c4-2c72-44ff-976e-2ec69db2c7efn%40googlegroups.com.


--
Regards,
Atique u Rehman

Atique Rehman

unread,
Jan 19, 2021, 3:33:05 AM1/19/21
to beagl...@googlegroups.com
I forget mention the kernel version: 4.14.71-ti-r80

Jørgen Sirum

unread,
Jan 19, 2021, 5:02:04 AM1/19/21
to BeagleBoard
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)

Atique Rehman

unread,
Jan 19, 2021, 5:15:23 AM1/19/21
to beagl...@googlegroups.com
What kernel version are you using?

Jørgen Sirum

unread,
Jan 19, 2021, 5:23:14 AM1/19/21
to beagl...@googlegroups.com
4.19.94 modified to use omap-serial instead of 8250-omap-serial.
Have also tried 5.4.70 with same modification. 

You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/tq-iAbS8iRY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CAOzcuAg4Uf0gyJ%3DtXrXkwnBxeD5B8Fpb%3DuiZ-hN6k54eca%2BFNw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages