This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM625: 尝试在6.1.46版本内核中让串口tty能够使用76800波特率,没有成功所以请求支持

Part Number: AM625

如标题,我在使用AM6254的6.1.46版本内核时,开发板运行命令如下命令失败,所以想要调试解决该问题:
# stty -F /dev/ttyS1 76800
stty: invalid argument ‘76800’
Try 'stty --help' for more information.

我查看了内核中的这个文件:drivers/tty/tty_baudrate.c

$ vi drivers/tty/tty_baudrate.c
....

static const speed_t baud_table[] = {
        0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400,
        4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800,
#ifdef __sparc__
        76800, 153600, 307200, 614400, 921600, 500000, 576000,
        1000000, 1152000, 1500000, 2000000
#else
        500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000,
        2500000, 3000000, 3500000, 4000000
#endif
};

static const tcflag_t baud_bits[] = {
        B0, B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, B2400,
        B4800, B9600, B19200, B38400, B57600, B115200, B230400, B460800,
#ifdef __sparc__
        B76800, B153600, B307200, B614400, B921600, B500000, B576000,
        B1000000, B1152000, B1500000, B2000000
#else
        B500000, B576000, B921600, B1000000, B1152000, B1500000, B2000000,
        B2500000, B3000000, B3500000, B4000000
#endif
};
..

发现在baud_table以及baud_bits中存在76800波特率的配置,于是我在该文件的开头部分添加了:
+ #define __sparc__

这一行代码,但是在编译时我就遇到了这个问题:

drivers/tty/tty_baudrate.c:37:9: error: ¡®B76800¡¯ undeclared here (not in a function); did you mean ¡®B460800¡¯?
   37 |         B76800, B153600, B307200, B614400, B921600, B500000, B576000,
      |         ^~~~~~
      |         B460800
drivers/tty/tty_baudrate.c:37:17: error: ¡®B153600¡¯ undeclared here (not in a function); did you mean ¡®B57600¡¯?
   37 |         B76800, B153600, B307200, B614400, B921600, B500000, B576000,
      |                 ^~~~~~~
      |                 B57600
drivers/tty/tty_baudrate.c:37:26: error: ¡®B307200¡¯ undeclared here (not in a function)
   37 |         B76800, B153600, B307200, B614400, B921600, B500000, B576000,
      |                          ^~~~~~~
drivers/tty/tty_baudrate.c:37:35: error: ¡®B614400¡¯ undeclared here (not in a function); did you mean ¡®B600¡¯?
   37 |         B76800, B153600, B307200, B614400, B921600, B500000, B576000,
      |                                   ^~~~~~~
      |                                   B600
make[3]: *** [scripts/Makefile.build:250: drivers/tty/tty_baudrate.o] Error 1
make[3]: *** Waiting for unfinished jobs....

我不知道这样修改是否是正确的,我注意到设备树中使用的串口驱动是8250:

$ vi k3-am62-main.dtsi
...
main_uart0: serial@2800000 {
                compatible = "ti,am64-uart", "ti,am654-uart";
                reg = <0x00 0x02800000 0x00 0x100>;
                interrupts = <GIC_SPI 178 IRQ_TYPE_LEVEL_HIGH>;
                power-domains = <&k3_pds 146 TI_SCI_PD_EXCLUSIVE>;
                clocks = <&k3_clks 146 0>;
                clock-names = "fclk";
                status = "disabled";
        };
...        

$ grep am654-uart drivers/tty -nR
Binary file drivers/tty/serial/8250/8250_omap.o matches
drivers/tty/serial/8250/8250_omap.c:1263:	{ .compatible = "ti,am654-uart", .data = &am654_platdata, }

希望有人能够告诉我如何能够让ttyS0成功配置波特率为76800,非常感谢。