Firefly开源社区

[Linux] UART波特率修改问题

87

积分

0

威望

0

贡献

技术小白

积分
87
发表于 2020-9-3 16:08:23     
本帖最后由 tigerlh 于 2020-9-4 10:31 编辑

日志输出的串口ttyS0波特率参照文档修改成了115200;
但是,其它的串口试了多种方法都无法修改波特率,使用过的方法有:
1. stty -F /dev/ttyS3 speed 115200
2. dtsi文件修改:
        uart3: serial@ff0d0000 {
                compatible = "rockchip,rk3308-uart", "snps,dw-apb-uart";
                reg = <0x0 0xff0d0000 0x0 0x100>;
                interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&cru SCLK_UART3>, <&cru PCLK_UART3>;
                clock-names = "baudclk", "apb_pclk";
                baudrate = <115200>;
                speed = <115200>;
                 = <115200>;
                reg-shift = <2>;
                reg-io-width = <4>;
                dmas = <&dmac0 10>, <&dmac0 11>;
                dma-names = "tx", "rx";
                pinctrl-names = "default";
                pinctrl-0 = <&uart3_xfer>;
                status = "okay";
        };
之后用stty -F /dev/ttyS3查看波特率依然为9600:
speed 9600 baud; line = 0;
intr = <undef>; quit = <undef>; erase = <undef>; kill = <undef>; eof = <undef>;
start = <undef>; stop = <undef>; susp = <undef>; rprnt = <undef>;
werase = <undef>; lnext = <undef>; discard = <undef>; min = 0; time = 0;
-brkint -icrnl -imaxbel
-opost -onlcr
-isig -icanon -iexten -echo -echoe -echok -echoctl -echoke

请指教
回复

使用道具 举报

87

积分

0

威望

0

贡献

技术小白

积分
87
发表于 2020-9-4 12:01:43     
补充下, 如下将9600改为115200后只有Uart0有效,其它端口依然是9600
int uart_register_driver(struct uart_driver *drv)
{
        struct tty_driver *normal;
        int i, retval;

        BUG_ON(drv->state);

        /*
         * Maybe we should be using a slab cache for this, especially if
         * we have a large number of ports to handle.
         */
        drv->state = kzalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL);
        if (!drv->state)
                goto out;

        normal = alloc_tty_driver(drv->nr);
        if (!normal)
                goto out_kfree;

        drv->tty_driver = normal;

        normal->driver_name        = drv->driver_name;
        normal->name                = drv->dev_name;
        normal->major                = drv->major;
        normal->minor_start        = drv->minor;
        normal->type                = TTY_DRIVER_TYPE_SERIAL;
        normal->subtype                = SERIAL_TYPE_NORMAL;
        normal->init_termios        = tty_std_termios;
        normal->init_termios.c_cflag = B115200 | CS8 | CREAD | HUPCL | CLOCAL;
        normal->init_termios.c_ispeed = normal->init_termios.c_ospeed = 115200;
回复

使用道具 举报

1万

积分

18

威望

20

贡献

神级创客

Rank: 8Rank: 8

积分
10850

突出贡献

发表于 2020-9-6 09:49:35     
多试几遍或者等会再查看
ttys3.png
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表