Page 1 of 2

Second UART

Posted: Thu Nov 20, 2014 11:01 am
by deshipu
I want to use the second UART to talk to another device. I have connected the G#8 and G#10 pins, as well as ground. But every time I try to use /dev/ttyS1, I'm getting Input/Output error. That includes:

Code: Select all
# cat /dev/ttyS1
# stty -F /dev/ttyS1 -a
# screen /dev/ttyS1 9600


Do I need to do anything special to enable the second UART?

Re: Second UART

Posted: Fri Nov 21, 2014 4:40 am
by Vonger
Hi,
You need change the dts and recompile openwrt. I have a blog http://vonger.cn/?p=1409 for this

Re: Second UART

Posted: Sat Nov 22, 2014 5:23 pm
by deshipu
Thank you, that works.

I switched the console to use /dev/ttyS1, and have /dev/ttyS0 free for my use.

I couldn't use /dev/ttyS1, because I'm getting some weird binary data in there randomly. Any idea what that may be?

Re: Second UART

Posted: Tue Nov 25, 2014 1:12 am
by darksoul
deshipu wrote:
I couldn't use /dev/ttyS1, because I'm getting some weird binary data in there randomly. Any idea what that may be?


Same here, if you solved the problem, please reply.

Re: Second UART

Posted: Tue Nov 25, 2014 2:38 am
by darksoul
Can some one PLEASE write a step by step guide how to enable the second UART and move the console to the second UART??

Re: Second UART

Posted: Thu Nov 27, 2014 2:26 am
by deshipu
The weird binary data was just kernel messages written in different speed.

I will describe what I did when I have a moment.

Re: Second UART

Posted: Thu Nov 27, 2014 6:56 pm
by darksoul
deshipu wrote:The weird binary data was just kernel messages written in different speed.

I will describe what I did when I have a moment.




i will be very thankful for that.

Re: Second UART

Posted: Fri Nov 28, 2014 11:49 am
by deshipu
Ok, so there are basically four different things being written to the UART:
  • das uboot bootloader messages
  • kernel booting messages
  • kernel "printk" messages (aka dmesg)
  • console

Disabling the console is the easiest: just edit /etc/inittab and comment out (with #) or delete the line that has "askconsole" in it. On the next boot no console will be started.

You can disable the "printk" messages in two ways, either just disable them in the "Global Build Settings" in the menuconfig when you are building the image, or add a line saying "kernel.printk = 0 4 1 7" to the /etc/sysctl.conf

The kernel booting messages can be disabled by changing the kernel boot parameters. If you look at target/linux/ramips/dts/VOCORE.dts you can see that it includes file rt5350.dtsi, which in turns has this:

Code: Select all
   chosen {
      bootargs = "console=ttyS0,57600";
   };


You can copy it to VOCORE.dts and change to:
Code: Select all
   chosen {
      bootargs = "console=null";
   };


You can't do anything about the bootloader, without compiling your own version. And I think you really don't want -- because you want to have some emergency way of flashing a different image when something goes wrong. My solution is to just ignore anything on the serial line until a handshake sequence appears.

See http://wiki.openwrt.org/doc/recipes/ter ... .on.serial for another way.

If instead of disabling it you want to redirect it to the second UART, you can do that. Do what is described in http://vonger.cn/?p=1409 and change the bootargs line above to point to ttyS1 instead of ttyS0. All the rest will switch over automatically, I think.

Re: Second UART

Posted: Mon Dec 01, 2014 4:05 am
by darksoul
deshipu wrote:Ok, so there are basically four different things being written to the UART:



You rock man!!!
thank you for your help!
I will do your steps tomorrow and reply the results!

Re: Second UART

Posted: Tue Feb 24, 2015 7:15 pm
by blark
I'd like to echo the request of a previous poster. If someone could do a quick step by step instruction to enable the second UART I'd really appreciate it.

The whole blob of source code on the linked page isn't very helpful for me as I'm not intimately familiar with OpenWRT. Also, there seems to be an alternate solution mentioned in the comments.. patching pinctrl-rt2880.c. Again, help a noob out and explain where this file is and what the best way to apply the patch is, please?

Thanks very much