linux下串口调试记录

转载参考如下链接:

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 ram=768M@0x0 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

[root@rk3399:/]# 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、查看串口驱动基本信息

[root@rk3399:/]# 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

[root@rk3399:/]# cat /proc/tty/driver/usbserial 
usbserinfo:1.0 driver:2.0

[root@rk3399:/]# cat /proc/tty/driver/fiq-debugger 
fiq-debugger driver
0: state:1

 

  • 2
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值