This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM4377: RS-485 communication

Part Number: AM4377
Other Parts Discussed in Thread: AM4372

Tool/software: Linux

Hi sir:

There is a problem really confusing me very much,about the rs485 serial communication.

I had a configuration ,as shown as follow, in the device tree.

436         uart4_pins: uart4_pins {
437                 pinctrl-single,pins = <
438                         AM4372_IOPAD(0x968, PIN_INPUT | INPUT_EN | PIN_INPUT_PULLUP | DS0_PULL_UP_DOWN_EN | MUX_MODE1) /* uart0_ctsn.uart4_rxd */
439                         AM4372_IOPAD(0x96c, PIN_OUTPUT | PULL_DISABLE | SLEWCTRL_FAST | DS0_PULL_UP_DOWN_EN | MUX_MODE1) /* uart0_rtsn.uart4_txd */
440                         AM4372_IOPAD(0x8d4, PIN_OUTPUT | MUX_MODE7)     /* gpio0-9 */
441                 >;
442         };

710 &uart4 {
711         status = "okay";
712         pinctrl-names = "default";
713         pinctrl-0 = <&uart4_pins>;
714         rts-gpio = <&gpio0 9 GPIO_ACTIVE_HIGH>;
715         rs485-rts-active-high;
716         rs485-rts-delay = <0 0>;
717         linux,rs485-enabled-at-boot-time;
718 };

But when I operating the "/dev/ttyS4" using only the system call function:open , write and close, I comfirmed  that the Tx cable had the signals, but the rts cable didn't have voltage changed as its value 0.

I didn't do any configuration for the serial communication in my c programe,not using ioctl or termios function.Because I had configured it in the device tree, the omap_serial driver will do the configuration

in rs485_probe function in probe function.

When i using system call function write(), I think it will call the uart_write() function in the serial_core, then after the message need to send has been copy to the THR , the __uart_start() ,in serial_core, will be called, and then the function serial_omap_start_tx() will be called to active the rts gpio high, using the gpio_set_value().

But the result is that the rts gpio's value is not high as the Tx sending message and even so there is no logs for the functions in a bad situation.

So what might be the root cause of it?

It will be very pleasure for you answer.

Best wish!

  • Hi Beata,

    Do you use AM437x TI board or custom board?

    Do you use AM437x TI PSDK? If yes, which version?

    Regards,
    Pavel
  • Hi  Pavel:

    Thanks for your reply very much!

    The board I used is custom board.And the SDK version is:ti-processor-sdk-linux-rt-am437x-evm-04.03.00.05-Linux-x86-Install.bin.

    Can the layout  affect the UART's RS485 function?  I just chose the gpio0_9 as the rts gpio of the uart4 in mode 7.

    And I think the layout may just work as the conductor, the uart has no signals been send out ,so there will be nothing in the cable connected to the rts gpio(0_9).

    Best regards!

    Beata

  • Hi  Pavel:

    I had find out why the rts gpio can't work.Just because the driver,for the omap uart, is the 8250_omap.c, not as my expected driver  omap_serial.c,and the 8250_omap.c has not the process for the

    rs485.

    So I go to the file "/arch/arm/configs/tisdk_am437x... " to change the configuration, removed the configuration for the 8250 and config the omap_serial.But when power on my board,I can only see the

    message for the u-boot, the message for the kernel is not shown.So the parameter "console=ttyS3", in the command line for the kernel start up passed from the u-boot  , my be wrong.Or the macro

    "CONFIG_SERIAL_OMAP_CONSOLE" in map_serial.c is not defined,that makes serial not working, if it's true ,can you tell me where the macro is defined? I just find the same string in the ".config" file.

    Also I find that the uart's interrupt number not match the number configed in the device tree,as the uart drivered by the 8250 driver.It can be see from the "proc/tty/driver/serial", there is no file named

    "/proc/tty/driver/OMAP_SERIAL" as had from the TI community.

    Best regards!

     

  • Beata,

    Yes, PSDK4.03 kernel comes with /drivers/tty/serial/8250/8250_omap.c by default. You need to change it to /drivers/tty/serial/omap-serial.c through menuconfig. You need also switch from 8250 to serial in u-boot and rootfs. Check the below wiki for more info, it explains how to switch from serial to 8250, but you can reuse the same approach for the switch from 8250 to serial:

    processors.wiki.ti.com/.../Sitara_Linux_UART_-_Switching_to_8250_Driver

    Check also below pointers:

    e2e.ti.com/.../684314
    e2e.ti.com/.../687661

    Let me know if you have more questions.

    Regards,
    Pavel
  • Hi Pavel:

    Thanks for your advice.

    The problem had been solved.I enabled both the 8250 and  omap_serial driver in the menuconfig.And also changed the compatible property that used to match the driver with the device,avoid to the uart4 and uart5 registed by the 8250 driver.

    Finally the uart1-uart3 were registed by the 8250 and uart4-uart5 by the omap_serial.It can been seen from the /proc/tty/  virtual file system.

    And it can works well.But it confused me very much that 8250 can't work as rs485 drive.

    Best regards!

    Beata

  • Beata,

    There has been upstream activity to allow use of the UART RTS pin for RS-485 in 8250 driver, but I am not sure what the current status is. You can try with 8250 driver coming with PSDK 5.00 (kernel 4.14.40) and check if there will be any improvement.

    Also the below e2e thread looks like RS485 works fine with 8250 driver for AM335x BBB board.

    e2e.ti.com/.../2575299

    Regards,
    Pavel
  • If you have no more questions related to the subject of this e2e thread, please close/verify/resolve this thread.

    Regards,
    Pavel