慢慢欣赏linux之串口驱动代码分析 串口与tty挂接方法

当前系统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 = <undef>;
eol2 = <undef>; swtch = <undef>; 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 = <undef>;
eol2 = <undef>; swtch = <undef>; 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 = <undef>;
eol2 = <undef>; swtch = <undef>; 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值