轉載參考如下連結:
https://blog.csdn.net/jirryzhang/article/details/70136134
https://blog.csdn.net/u011228513/article/details/79989768
https://blog.csdn.net/QQ2010899751/article/details/81178753
Linux下UART調試記錄:
1、 ls -l /dev/ttyPS*
crw-rw---- 1 root root 247, 0 Jan 1 00:46 /dev/ttyPS0
crw-rw---- 1 root root 247, 1 Jan 1 00:52 /dev/ttyPS1
2、 cat /proc/tty/driver/xuartps
serinfo:1.0 driver revision:
0: uart:xuartps mmio:0xE0000000 irq:29 tx:35087 rx:0 CTS|DSR|CD
1: uart:xuartps mmio:0xE0001000 irq:30 tx:171557 rx:327 RTS|CTS|DTR|DSR|CD
3、 cat /proc/cmdline
console=ttyPS1,115200 [email protected] root=/dev/ram rw earlyprintk quiet ubi.mtd=5 mtdparts=pl35x-nand:10m(fsbl_uboot_bitstream),512k(env),512k(devicetree),5m(kernel),10m(rootfs),-(data)
啟動指令行查詢所用的UART口為ttyPS1。
4、 while : ;do echo 1234 > /dev/ttyPS1 ;sleep 1;done; 回環測試,循環操作
或者 while true;do echo 1234 > /dev/ttyS4;sleep 1;done
5、 cat /dev/ttyPS1 查詢接收資料
6、 echo 1111 > /dev/ttyPS1 發送資料
7、序列槽tx和rx短接,回環測試。
$ cat dev/ttyS4 &
$ while true;do echo 1234 > /dev/ttyS4;sleep 1;done
8、stty檢視某個序列槽配置資訊
$ stty -F /dev/ttyS4 -a
[[email protected]:/]# stty -F /dev/ttyS4 -a
[ 234.586134] ttyS4 - failed to request DMA, use interrupt mode
speed 9600 baud;stty: /dev/ttyS4
line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke
9、stty配置序列槽
stty -F /dev/ttyS0 ispeed 115200 ospeed 115200 cs8
該指令将序列槽1(/dev/ttyS0)設定成115200波特率,8位資料模式。一般情況下設定這兩個參數就可以了,如果顯示資料亂碼,可能還需要設定其它參數,使用man檢視stty其它設定選項。
10、檢視序列槽驅動基本資訊
[[email protected]:/]# cat /proc/tty/driver/serial
serinfo:1.0 driver revision:
0: uart:16550A mmio:0xFF180000 irq:38 tx:0 rx:0
1: uart:unknown port:00000000 irq:0
2: uart:16550A mmio:0xFF1A0000 irq:39 tx:0 rx:0
3: uart:unknown port:00000000 irq:0
4: uart:16550A mmio:0xFF370000 irq:41 tx:0 rx:0
[[email protected]:/]# cat /proc/tty/driver/usbserial
usbserinfo:1.0 driver:2.0
[[email protected]:/]# cat /proc/tty/driver/fiq-debugger
fiq-debugger driver
0: state:1