# echo uart-test > /dev/ttyS1
# echo uart-test > /dev/ttyS2
# echo uart-test > /dev/ttyS0
uart-test
# echo uart-test > /dev/ttyS3
sh: write error: I/O error
uart0_pins_a: uart0 {
pins = "PE0", "PE1";
function = "uart0";
bias-pull-up;
};
uart1_pins_a: uart1 {
pins = "PA2", "PA3";
function = "uart1";
bias-pull-up;
};
uart2_pins_a: uart2 {
pins = "PE7", "PE8";
function = "uart2";
bias-pull-up;
};
&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_pins_a>;
status = "okay";
};
&uart1 {
pinctrl-names = "default";
pinctrl-1 = <&uart1_pins_a>;
status = "okay";
};
&uart2 {
pinctrl-names = "default";
pinctrl-2 = <&uart2_pins_a>;
status = "okay";
};
#include <fcntl.h>
int fd;
int uart_init()
{
fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY);
struct termios oldtio = { 0 };
struct termios newtio = { 0 };
tcgetattr(fd, &oldtio);
//设置波特率为115200
newtio.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
newtio.c_iflag = 0; // IGNPAR | ICRNL
newtio.c_oflag = 0;
newtio.c_lflag = 0; // ICANON
newtio.c_cc[VTIME] = 0;
newtio.c_cc[VMIN] = 1;
tcflush(fd, TCIOFLUSH);
tcsetattr(fd, TCSANOW, &newtio);
//设置为非阻塞模式,这个在读串口的时候会用到
fcntl(fd, F_SETFL, O_NONBLOCK);
return fd;
}
/* 功能:uart_send 串口数据发送函数
* 参数:无
* 返回值:int:-1 失败
* 备注:---
*/
int uart_send(void)
{
uint8_t buffer[4] = {0};
buffer[0] = 'T';
buffer[1] = 'X';
buffer[2] = '\n';
buffer[3] = '\n';
int ret = write(fd, buffer, sizeof(buffer));
return ret;
}
离线
linux启动log有没有显示 ttyS1/2正常?
您好,我的启动logo里面显示的是这样的,好像配置正常呀,你看下对吗?
[ 0.290349] console [ttyS0] disabled
[ 0.310569] 1c25000.serial: ttyS0 at MMIO 0x1c25000 (irq = 24, base_baud = 6250000) is a 16550A
[ 0.626305] console [ttyS0] enabled
[ 0.652017] 1c25400.serial: ttyS1 at MMIO 0x1c25400 (irq = 25, base_baud = 6250000) is a 16550A
[ 0.682913] 1c25800.serial: ttyS2 at MMIO 0x1c25800 (irq = 26, base_baud = 6250000) is a 16550A
离线
正常。
# echo uart-test > /dev/ttyS1
# echo uart-test > /dev/ttyS2这样之后 cat /proc/interrupts 看串口中断次数有无增加。
您好,我试了下,发现ttyS0下面两个中断有增加,但是为什么没显示名字呀,难道配置还有问题?
# echo uart-test > /dev/ttyS1
# echo uart-test > /dev/ttyS1
# echo uart-test > /dev/ttyS1
# echo uart-test > /dev/ttyS1
# echo uart-test > /dev/ttyS1
# echo uart-test > /dev/ttyS1
# echo uart-test > /dev/ttyS2
# echo uart-test > /dev/ttyS2
# echo uart-test > /dev/ttyS2
# echo uart-test > /dev/ttyS2
# echo uart-test > /dev/ttyS2
# cat /proc/interrupts
CPU0
16: 42900 sun4i_irq 13 Edge timer@1c20c00
17: 13471 sun4i_irq 7 Edge mv64xxx_i2c
18: 628722 sun4i_irq 10 Edge sun6i-spi
19: 388 sun4i_irq 29 Edge 1c0c000.lcd-controller
20: 17353 sun4i_irq 23 Edge sunxi-mmc
24: 10496 sun4i_irq 1 Edge ttyS0
25: 13 sun4i_irq 2 Edge
26: 24 sun4i_irq 3 Edge
64: 663 sunxi_pio_edge 35 Edge gt911
离线
最近编辑记录 颜水花生 (2020-08-12 16:12:24)
离线
大佬
大佬可以分享下您的DTS配置吗? 我对比看看有没有哪里不对的,感谢
最近编辑记录 颜水花生 (2020-08-12 16:15:03)
离线
确实挺奇怪的,你参考一下这个帖子:
终于把V3s三个串口全部榨干, 控制台只能用 ssh 了, 泪崩 (dropbear大法好,还能秘钥登录)
http://whycan.cn/t_1183.html#p5971
(出处:哇酷开发者社区【全志 V3S/F1C100s/X3】)
离线
这次我每个空格都对过了,发现我的配置 这个不对,我的是ttyS1 pinctrl-1,应该都改成0 pinctrl-0
ttyS1,数据发送正常了
但是cat中断显示还是不对,不显示名称
# cat /proc/interrupts
CPU0
16: 24277 sun4i_irq 13 Edge timer@1c20c00
17: 19131 sun4i_irq 7 Edge mv64xxx_i2c
18: 649811 sun4i_irq 10 Edge sun6i-spi
19: 388 sun4i_irq 29 Edge 1c0c000.lcd-controller
20: 9839 sun4i_irq 23 Edge sunxi-mmc
24: 19517 sun4i_irq 1 Edge ttyS0
25: 82 sun4i_irq 2 Edge
64: 946 sunxi_pio_edge 35 Edge gt911
Err: 0
uart0_pins_a: uart0@0 {
pins = "PE0", "PE1";
function = "uart0";
};
uart1_pins_a: uart1@0 {
pins = "PA2", "PA3";
function = "uart1";
bias-pull-up;
};
uart2_pins_a: uart2@0 {
pins = "PE7", "PE8";
function = "uart2";
bias-pull-up;
};
&uart0 {
pinctrl-0 = <&uart0_pins_a>;
pinctrl-names = "default";
status = "okay";
};
&uart1 {
pinctrl-0 = <&uart1_pins_a>;
pinctrl-names = "default";
status = "okay";
};
&uart2 {
pinctrl-0 = <&uart2_pins_a>;
pinctrl-names = "default";
status = "okay";
};
最近编辑记录 颜水花生 (2020-08-12 16:52:29)
离线