# 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 erroruart0_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离线
应该是不正常的, 我的是这样的:
# cat /proc/interrupts
           CPU0
 19:   32979735     GIC-0  27 Level     arch_timer
 21:          0     GIC-0  50 Level     /soc/timer@01c20c00
 22:         13     GIC-0  82 Level     1c02000.dma-controller
 23:          0     GIC-0 103 Level     musb-hdrc.1.auto
 24:        448     GIC-0 104 Level     ehci_hcd:usb1
 25:        399     GIC-0 105 Level     ohci_hcd:usb2
 30:          0     GIC-0  62 Level     sun4i-a10-lradc-keys
 32:     235182     GIC-0  32 Level     ttyS0
 33:    1329272     GIC-0  33 Level     ttyS1
 34:         10     GIC-0  34 Level     ttyS2离线
最近编辑记录 颜水花生 (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)
离线
楼主,我刚测试了,cat /proc/interrupts 即便是没有名称,其他也是工作一切正常。中断是收和发加在一起的。如果把收和发在物理上连起来,echo /dev/ttyS1 一个 过去,会有两个中断。如果没有连起来,收接3.3V,echo /dev/ttyS1 一个,只有一个中断。如此即可判断是否正常工作。即便是正常工作,收和发物理上连起来,echo /dev/ttyS1之后 cat /dev/ttyS1 也是什么也没有。
离线
@颜水花生 
我的也没名字,不知道怎么解决
离线
@颜水花生
这里是只配置了1个引脚?不是还应该有个gpio_in用来接收么?
离线
@颜水花生
这里是只配置了1个引脚?不是还应该有个gpio_in用来接收么?
现在搞明白自己错在哪里了……
离线
请问问题出在哪里,我也遇到相同问题
离线
@哇酷小二 
大牛,您好,我的和楼主的一样,只有ttys0的名字,没有ttys1 和ttys2的名字,请问是什么原因呢,我用的是nano pi neo老板子。谢谢。
离线