SK-AM62: RTS signal when serial rs485 is disabled

Part Number: SK-AM62
Other Parts Discussed in Thread: PROCESSOR-SDK-AM62X

Tool/software:

Hi,

I'm testing UART with SK-AM62.

I disable rs485 using serial_rs485 structure.

When RTS becomes active, the falling edge of RTS signal is occurred twice.

Is the working correct?

My processor SDK is PROCESSOR-SDK-AM62X 09.02.01.09 and I'm using GPMC0_CSN1.GPIO0_42 for RTS.

Best Regards,

Koji

  • Hi Koji,

    I disable rs485 using serial_rs485 structure.

    Do you mean you "enable" rs485?

    When RTS becomes active, the falling edge of RTS signal is occurred twice.

    What signal is the cyan line in the scope capture?

    Is the working correct?

    I am not sure, I don't think I never checked the RTS signal in rs485 use cases. But this doesn't sounds right.

    Please provide the kernel device tree change which you used to enable the UART in rs485 mode.

  • Hi,

    Do you mean you "enable" rs485?

    No, I disable rs485.

    rs485conf.flags &= ~(SER_RS485_ENABLED);

    What signal is the cyan line in the scope capture?

    The cyan line is RTS signal using GPMC0_CSN1.GPIO0_42.

    I attach the device tree change.

    diff --git a/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi b/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi
    index 3b599e88ed2a..402ba55e569a 100644
    --- a/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi
    +++ b/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi
    @@ -15,6 +15,7 @@ aliases {
                    serial0 = &mcu_uart0;
                    serial1 = &wkup_uart0;
                    serial2 = &main_uart0;
    +               serial3 = &main_uart5;
                    mmc0 = &sdhci0;
                    mmc1 = &sdhci1;
                    mmc2 = &sdhci2;
    @@ -186,6 +187,13 @@ AM62X_IOPAD(0x1cc, PIN_OUTPUT, 0) /* (E14/E11) UART0_TXD */
                    >;
            };
    
    +       main_uart5_pins_default: main-uart5-pins-default {
    +               pinctrl-single,pins = <
    +                       AM62X_IOPAD(0x1d8, PIN_INPUT, 1) /* (C15/B13) UART5_RXD */
    +                       AM62X_IOPAD(0x1dc, PIN_OUTPUT, 1) /* (E15/A15) UART5_TXD */
    +                       AM62X_IOPAD(0x00ac, PIN_OUTPUT, 7) /* (L21) GPMC0_CSN1.GPIO0_42 */
    +               >;
    +       };
    +
            main_i2c0_pins_default: main-i2c0-pins-default {
                    pinctrl-single,pins = <
                            AM62X_IOPAD(0x1e0, PIN_INPUT_PULLUP, 0) /* (B16/E12) I2C0_SCL */
    @@ -348,6 +356,12 @@ &main_uart1 {
            status = "reserved";
     };
    
    +&main_uart5 {
    +       status = "okay";
    +       pinctrl-names = "default";
    +       pinctrl-0 = <&main_uart5_pins_default>;
    +       rts-gpios = <&main_gpio0 42 GPIO_ACTIVE_LOW>;
    +};
    +
     &main_i2c0 {
            status = "okay";
            pinctrl-names = "default";
    --
    2.34.1

    Best Regards,

    Koji

  • No, I disable rs485.

    rs485conf.flags &= ~(SER_RS485_ENABLED);

    rs485 by default is not enabled.

    Where did you add this line of the code, in your application or kernel?

    Please describe the details how you tested the UART5 with RTS.

  • 1. Change the device tree. The content was already attached.

    2. Build kernel.

    MACHINE=am62xx-evm ARAGO_RT_ENABLE=1 bitbake linux-ti-staging-rt

    3. Build C application.

    #include <stdio.h>
    #include <stdlib.h>
    #include <sys/ioctl.h>
    #include <fcntl.h>
    #include <unistd.h>
    #include <linux/serial.h>
    #include <errno.h>
    
    #define SERIAL_PORT     "/dev/ttyS3"
    
    void main(int argc, char *argv[])
    {
            int fd;
            struct serial_rs485 rs485conf;
            int ercd;
            int mode;
            int i;
            char *buf = argv[2];
    
            fd = open(SERIAL_PORT, O_RDWR);
    
            ioctl(fd, TIOCGRS485, &rs485conf);
    
            rs485conf.flags &= ~(SER_RS485_ENABLED);
    
            ercd = ioctl(fd, TIOCSRS485, &rs485conf);
    
            if(ercd < 0)
            {
                    printf("Set ioctl: errno is %d\n", errno);
            }
    
            while(1)
            {
                    for(i = 0; (*(buf + i) != 0x00); i++)
                    {
                            write(fd, (buf + i), 1);
                    }
            }
    
            close(fd);
    
            return;
    }

    4. Booting SK-AM62 with SD image including the built kernel and app.

    5. After login on console, execute the app with transmit data as argument.

    6. The transmit data is sent from UART5.

    7. The previous capture is when starting to send data.

    If this still doesn't explain well, please let me know what's missing.

    Best Regards,

    Koji

  • Hi Koji,

    If you have SER_RS485_ENABLED cleared, why do you use these RS485 related IOCTLs? Are you trying to do something which rs232 doesn't do?

  • Hi,

    I would like to use UART5 port for testing rs232 and rs485 and switch the mode in application.

    The currently issue I care is about the RTS edge.

    I don't understand how the issue relates why I use IOCTL.

    Best Regards,

    Koji

  • Hi Koji,

    I don't understand how the issue relates why I use IOCTL.

    I am a kernel guy and don't do much of user space programming. I am not sure if it is expected to use RS485 ioctl but with SER_RS485_ENABLED unset. I never saw any program does this. It is either use rs485 config with SER_TS485_ENABLED set to use RS485 mode, or not use rs485conf at all and directly use termios for RS232 mode. So can you please check if the RTS pin still have such behavior without using rs485conf in your program?