openwrt stty

I saw a lot of forum questions asking "how to change serial port speed", and I thought it was easy, but it is not that easy.

OpenWrt has uart serial port baudrade speed set via kernel command line option, so it is hardwired into kernel, and as far as I know this method is the only way to change baudrate speed of serial port.

If you are lucky

If you are lucky maybe your kernel supports changing serial port speeds, then you can just try stty or mgetty commands:

mgetty -s 19200 /dev/ttyS0 
OR
stty -F /dev/ttyS0 9600 clocal cread cs8 -cstopb -parenb 
For reading serial port settings use:
stty -F /dev/ttyS0 -a 
In recent builds, you can easilly install stty from packages as follows:
opkg update
opkg install coreutils-stty
You will find stty in your menuconfig under
Base system -> busybox -> Coreutils -> stty

First method

For example for TP-Link WR741ND V4.x it is set to: "console=ttyATH0,115200"

Now the question is how to change this kernel command line, only way to do this is to compile your own kernel with different "console=" line.

First you need to know which speed you need to set. In this example we use TP-LINK WR741ND which uses has it's uart serial port baudrate speed set to 115200 and we need to change it to 19200.

First check check what baudrate and which port your current router uses, telnet or ssh to your router and then find out your current settings. Usual uart serial ports are ttyS0 or ttyATH0.

Use these command to check your serial port settings

  • fw_printenv
    • baudrate=115200
    • console=console=ttyS0,115200
  • OR:  logread | grep tty

find where is your config file:

  • grep ttyATH0 ./trunk/target/linux/ar71xx/ -R

edit file before building your own image:

  • ./trunk/target/linux/ar71xx/image/Makefile

find line for your modem:

  • tlwr740_cmdline=board=TL-WR741ND console=ttyS0,115200
  • tlwr740v4_cmdline=board=TL-WR741ND-v4 console=ttyATH0,115200

Change "console=ttyATH0,115200" to speed you need:

  • tlwr740_cmdline=board=TL-WR741ND console=ttyS0,19200
  • tlwr740v4_cmdline=board=TL-WR741ND-v4 console=ttyATH0,19200

Second method

You can change the Kernel command line within kernel_menuconfig:

  • kernel_menuconfig > Kernel hacking > Default kernel command string

Then you have to recompile the Kernel with 'make target/clean world' and reflash.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

技术在路上

帮助需要的人

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值