Search code examples
linuxembeddeduart

enable uart2, but reading from it is not right


I have a Ti processor AM335x on a dev board. right not there are two uart connect to processor. uart0 and uart2

by default, only uart0 was enable, and it was for console. after I enable uart2, I wired my GPS to it so that it should output something if I cat /dev/ttyO2. but there are only some garbage code shows up.

then I wired GPS to uart0, use same command cat /dev/ttyO0 everything works fine. GPS output shows up normally.

then I edit my uEnv.txt to switch my console to uart2, it works. and then I wired GPS to uart2, I can cat /dev/ttyO2 to get everything. But when I wired GPS to uart0. garbage code shows up.

I did use stty to do tty setup, make them all same, still, I can only read from the uart which I connect my console.

I run command dmesg | grep tty , this is the output

    [0.000000] Kernel command line: console=ttyO2,115200n8 root=/dev/mmcblk0 rw ext4 rootwait verbose debug
    [0.234749] 44e09000.serial: ttyO0 at MMIO 0x44e09000 (irq = 154m, base_baud = 3000000) is a OMAP UART0
    [0.235338] 48024000.serial: ttyO2 at MMIO 0x48024000 (irq = 155m, base_baud = 3000000) is a OMAP UART2   
    [0.824084] console [ttyO2] enabled

first and fourth would change base on which uart I put my console on. Are there any config I missed? why I can only read precise data from the uart I put my console on. and others doesn't work.

any idea would help. Thanks.

This is how I change my code to enable uart2. linux compile for enable uart2


Solution

  • It turns out that is BAUDRATE problem.

    not because I didn't setup right, is because a hardware problem. as soon as I connect my GPS to uart2. the uart2 baudrate would change to 9600 and that gives me garbage output.

    if I stty setup the baudrate to 115200 and start read. THEN connect my GPS. I get everything I need with correct format.

    Still don't know what issue with GPS, but that's shouldn't be part of this question. so I will close this.

    Thank you, @domen without you I won't double check that baudrate.