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.

SK-AM62P-LP: UART Com from Linux SDK

Part Number: SK-AM62P-LP

Tool/software:

Hi experts,

We are trying to use uart5 from A53 core(main domain) to run the uart communication from the Linux system.

I have done a quick check-in device tree file looks like it is not defined there.

Can you please tell me how can I access this?

Regards,
Debashis

  • Hi Debashis,

    You would have to enable UART5 in kernel devicetree to use the UART in Linux. Please refer to the instruction linked below.

    https://dev.ti.com/tirex/explore/node?node=A__AS4TOb7e5T1d6.5bfnXv2Q__AM62P-ACADEMY__fp5YxRM__LATEST&placeholder=true

  • Hi Bin Liu,

    I have checked the menuconfig first and found that it's already enabled by default.
    So, I directly changed the device tree file(k3-am62p5-sk.dts) for main_uart5 by reference to a similar file for main_uart1.

    aliases {
    		serial0 = &wkup_uart0;
    		serial2 = &main_uart0;
    		serial3 = &main_uart1;
    		serial5 = &main_uart5;
    		mmc0 = &sdhci0;
    		mmc1 = &sdhci1;
    		mmc2 = &sdhci2;
    		spi0 = &ospi0;
    		ethernet0 = &cpsw_port1;
    		ethernet1 = &cpsw_port2;
    		usb0 = &usb0;
    		usb1 = &usb1;
    	};
    main_uart5_pins_default: main-uart5-default-pins {
    		pinctrl-single,pins = <
    			AM62PX_IOPAD(0x1d8, PIN_INPUT, 1)	/* (B23) UART0_RXD */
    			AM62PX_IOPAD(0x1dc, PIN_OUTPUT, 1)	/* (F20) UART0_TXD */
    		>;
    		bootph-all;
    	};
    	
    &main_uart5 {
    	pinctrl-names = "default";
    	pinctrl-0 = <&main_uart5_pins_default>;
    	/* Main UART5 is used by USER firmware */
    	status = "okay";
    	bootph-all;
    };


    After that, I built and transferred the .dtb file to the target board.

    Output:
    root@am62pxx-evm:~# cat /proc/tty/driver/serial
    serinfo:1.0 driver revision:
    0: uart:unknown port:00000000 irq:0
    1: uart:unknown port:00000000 irq:0
    2: uart:8250 mmio:0x02800000 irq:251 tx:20146 rx:429 RTS|DTR|DSR
    3: uart:unknown port:00000000 irq:0
    4: uart:unknown port:00000000 irq:0
    5: uart:8250 mmio:0x02850000 irq:253 tx:8016 rx:7561 DSR
    6: uart:unknown port:00000000 irq:0
    7: uart:unknown port:00000000 irq:0
    8: uart:unknown port:00000000 irq:0
    9: uart:unknown port:00000000 irq:0
    10: uart:unknown port:00000000 irq:0
    11: uart:unknown port:00000000 irq:0
    root@am62pxx-evm:~# dmesg | grep base_baud
    [    1.669955] 2800000.serial: ttyS2 at MMIO 0x2800000 (irq = 251, base_baud = 3000000) is a 8250
    [    1.684830] 2850000.serial: ttyS5 at MMIO 0x2850000 (irq = 253, base_baud = 3000000) is a 8250
    


    Is it Correct whatever I did?

    When I loop back the RX and TX by running echo "hello" > /dev/ttyS5 in one terminal and cat /dev/ttyS5 in another, the data is coming through, but with some erratic behavior. There is an unusual amount of vertical blank space appearing between the data. This blank space continues until I press Control-C to stop it.

    Regards,
    Debashis

  • Hi Debashis,

    Is it Correct whatever I did?

    Yes, UART5 seems to be configured correct.

    When I loop back the RX and TX by running echo "hello" > /dev/ttyS5 in one terminal and cat /dev/ttyS5 in another, the data is coming through, but with some erratic behavior. There is an unusual amount of vertical blank space appearing between the data. This blank space continues until I press Control-C to stop it.

    I am not sure what causes the problem, but please run the following commands before doing echo/cat commands, and let me know if this resolve the issue.

    # systemctl disable serial-getty@ttyS5.service
    # stty -F /dev/ttyS5 115200 -echo

  • Hi Bin Liu,

    Now it's working. Thanks very much for your support. Actually, I have tried the same before, but the disable thing I wasn't aware of, and in the document, it's also not available, I guess.

    Regards,
    Debashis


  • Hi Bin,

    Now I am not able to run that stty command its stuck. And I am having the same problem. Can to tell me how can I verify that it's reverted to 115200 and am I have to do it every time or is there any method to fix it?

    Issue:

    root@am62pxx-evm:~# systemctl disable serial-getty@ttyS5.service
    Removed '/etc/systemd/system/getty.target.wants/serial-getty@ttyS5.service'.
    [ 1461.657287] systemd-ssh-generator[1271]: Binding SSH to AF_UNIX socket /run/ssh-unix-local/socket.
    [ 1461.658092] systemd-ssh-generator[1271]: → connect via 'ssh .host' locally
    [ 1461.686934] systemd-sysv-generator[1273]: SysV service '/etc/init.d/ethercat' lacks a native systemd unit file. Recycle️ Automatically generating a unit file for compatibility. Please update package to include a native systemd unit file, in order to make it safe, robust and future-proof. Warning️ This compatibility logic is deprecated, expect removal soon. Warning
    root@am62pxx-evm:~# stty -F /dev/ttyS5 115200 -echo

    Regards,
    Debashis

  • Hi Bin,

    I saw this print statement also from the kernel side.

    [ 258.795712] audit: type=1112 audit(1735627359.362:243): pid=886 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='op=login acct="oohhh" exe="/usr/bin/login" hostname=am62pxx-evm addr=? terminal=ttyS5 res=failed'

  • Hi Bin,
    When I run simple write and read code to read the uart data you can see the erratic behavior.

    root@am62pxx-evm:/home/uart# ./serial_posix 
    Read from serial port: Hello, Serial Port!
    Login incorrect
    
    root@am62pxx-evm:/home/uart# ./serial_posix 
    Read from serial port: Hello, Serial Port!
    root@am62pxx-evm:/home/uart# ./serial_posix 
    Read from serial port: Hello, Serial Port!
    root@am62pxx-evm:/home/uart# ./serial_posix 
    Read from serial port: Hello, Serial Port!
    root@am62pxx-evm:/home/uart# ./serial_posix 
    Read from serial port: Hello, Serial Port!
    root@am62pxx-evm:/home/uart# ./serial_posix 
    Read from serial port: p
    am62pxx-evm login: 
    am62pxx-evm login: Debian GNU/Linux trixie/sid am62pxx-evm ttyS5
    p
    am62pxx
    root@am62pxx-evm:/home/uart# ./serial_posix 
    Read from serial port: -evm login: 
    am62pxx-evm login: Debian GNU/Linux trixie/sid am62pxx-evm ttyS5
    p
    am62pxx-evm login
    root@am62pxx-evm:/home/uart# ./serial_posix 
    Read from serial port: : 
    am62pxx-evm login: Debian GNU/Linux trixie/sid am62pxx-evm ttyS5
    p
    am62pxx-evm login: 
    am62px
    


    It's reading some login-related thing.


    Regards,
    Debashis

  • Hi Debashis,

    The Processor SDK rootfs provides a UART tool called serialcheck. Please use this tool to check UART read and write access.

  • Hi Bin,

    You can take a look at the screenshot.
    I have one doubt that cts and rts are required to run this serial check because I just connected the RX to TX with the jumper wire.



    Regards,
    Debashis

  • Hi Debashis,

    Since you didn't connect cts and rts pins, please run serialcheck program without '-h' option to not use hardware flow control.

  • Hi Bin Liu,

    I have gone through the code of serialcheck.c and I have some doubts about it.

    1. we are setting it to read 64 bytes and the time out 0.8sec with blocking read and write because it's using this function(ret = fcntl(fd, F_SETFL, 0);)

    new_term.c_cc[VMIN] = 64;
    new_term.c_cc[VTIME] = 8;


    If my understanding is correct to get the data there is some poll mechanism used, so let's say when it receives a read interrupt it will go and read the data, and as well as I can see the count also increased with that but why is the read not blocked till 0.8 sec or till it received 64 bytes can please explain to me I want to know why?

    Regards,
    Debashis

  • Hi Debashis,

    This seems to be related to kernel TTY framework or Linux userspace terminal programing, not related to the platform UART module, sorry I don't have an answer.