作者:安静2502917547 | 来源:互联网 | 2023-09-18 09:45
当前系统uboot采用ttyAMA1启动,串口也用串口1,这样如何操作串口0呢?
方法1
root@linux:~# tty
/dev/ttyAMA1
root@linux:~# stty -F /dev/ttyAMA1 -a
speed 115200 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ;
eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar 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 -flusho -extproc
root@linux:~#
root@linux:~# stty -F /dev/ttyAMA0 -a // 默认波特率9600
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ;
eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar 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 -flusho -extproc
root@linux:~#
root@linux:~# stty -F /dev/ttyAMA0 ispeed 115200 ospeed 115200 cs8
root@linux:~# stty -F /dev/ttyAMA0 -a
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ;
eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar 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 -flusho -extproc
root@linux:~#
root@linux:~# echo 1234567890 > /dev/ttyAMA0
在ttyAMA0里面可以看到 1234567890
方法2
getty -L ttyAMA0 115200 vt100
需要strace和ftrace分析一下流程
参考文档
1 getty
https://wiki.debian.org/getty
2 Linux getty命令
https://www.runoob.com/linux/linux-comm-getty.html
3 为什么linux的TTY登录程序getty/agetty一般都会设置一个-L的option?
https://www.cnblogs.com/super119/archive/2012/06/04/2534994.html
4 linux+getty+串口_嵌入式er日常系列!修改u-boot与Linux调试串口痛苦经历及感触
https://blog.csdn.net/weixin_30193461/article/details/111942845
5 嵌入式Linux终端自动登陆
https://blog.csdn.net/Zhu_Zhu_2009/article/details/81357395
6 init getty login shell
https://blog.csdn.net/elijah5748/article/details/2290672
7 Linux文件系统启动过程及login的实现
https://blog.csdn.net/cl11010/article/details/24484979