Can the UART go faster than 115200?


13 posts
by DrZWave » Wed Apr 02, 2014 1:57 pm
I have the UART on my RPi working just fine at 115,200 bps talking to another micro. I released the UART from getty by commenting out the line in /etc/inittab and I know the uart is working just fine.

But I'd like it to go faster - ideally 921600 which is the top speed of my micro.
But when I run
minicom -b 921600 -D /dev/ttyAMA0
and then look at the signals using a scope they are still at 115200 baud.

I can set it lower like 9600 baud and that works fine.

I also tried the python miniterm but it also appears to only run at 115200 even when set for higher baud rates. It also works when setting lower baud rates but appears to max at 115200.

Is there a way to get the UART to go faster than 115200 or is that the maximum on the RPi?


SOLUTION:
Add the following line to /boot/config.txt
init_uart_clock=14745600
or 16X whatever the max baud rate you want.
Last edited by DrZWave on Wed Apr 02, 2014 4:50 pm, edited 1 time in total.
User avatar
Posts: 11
Joined: Mon Jul 15, 2013 6:45 pm
by RaTTuS » Wed Apr 02, 2014 2:17 pm
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe
User avatar
Posts: 9270
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
by joan » Wed Apr 02, 2014 2:24 pm
I think the default UART clock is 3MHz. The maximum baud rate is clock/16.

Try adding the following line to /boot/config.txt and rebooting.

init_uart_clock=14745600

You should then be able to

sudo stty -F /dev/ttyAMA0 921600
User avatar
Posts: 12702
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by RaTTuS » Wed Apr 02, 2014 2:27 pm
^WHS
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe
User avatar
Posts: 9270
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
by DrZWave » Wed Apr 02, 2014 4:46 pm
THANKS!

That totally worked right out of the box! I'm now running at 10X (well almost) what I was running before. Much better :D!

So the solution is that the clock to the UART has to be at least 16X faster than the setting for init_uart_clock in /boot/config.txt. The default is only 3MHz which results in just a little over 115200. So at the default setting, the max UART baud rate is 115200.

Adding the following line to /boot/config.txt
init_uart_clock=14745600

allows the baud rate to be as high as 921600 which is all the speed I need for my application.
Set it even higher for higher baud rates if the other side can handle it.
User avatar
Posts: 11
Joined: Mon Jul 15, 2013 6:45 pm
by Charly86 » Wed Aug 13, 2014 9:39 am
Hi Guys,

Sorry to up this post but for time now I'm trying to set UART speed at 250Kpbs and I'm facing the same problem but solution does not work for me (and never worked). I tried 2 times some months ago but didn't succeded. So I left for update but now I really need this.
I tried all solution without success and it drive me nut. I have 4 Pi (2 models A and 2 model B) and it does not work, I'm using raspian updated with apt-get update apt-get upgrade
Here is my setting
Code: Select all
root@pi03:~# cat /boot/config.txt
# uncomment if you get no picture on HDMI for a default "safe" mode
...
blah blah
...

# for more options see http://elinux.org/RPi_config.txt
gpu_mem=16

init_uart_clock=4000000

root@pi03:~# uname -a
Linux pi03 3.12.22+ #691 PREEMPT Wed Jun 18 18:29:58 BST 2014 armv6l GNU/Linux
root@pi03:~# stty -F /dev/ttyAMA0 115200
root@pi03:~# stty -F /dev/ttyAMA0 250000
stty: invalid argument `250000'
Try `stty --help' for more information.
root@pi03:~#


As you can see, 115200 is working fine but not over, I also tried with init_uart_clock=16000000 with no more success. It seems to work for everybody, I'm asking if I missed something ?!?! Any ideas are welcome before shooting the Pi :lol:

Thanks for your help
Posts: 23
Joined: Wed Mar 06, 2013 9:57 am
by RaTTuS » Wed Aug 13, 2014 9:50 am
it's probably a limitation of stty
the init_uart_clock in /etc/config.txt
sets the base amount ...

let me see if I can find my notes before a more knowledgeable person comes by
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe
User avatar
Posts: 9270
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
by bbodin » Wed Aug 13, 2014 2:33 pm
It appears that stty doesn't support non-standard baud rates. If you want to go higher than 115200 kbps, try a standard value such as 230400, 460800 or 921600.
Binh Bui
Posts: 70
Joined: Sat Jun 28, 2014 3:23 pm
by bbodin » Wed Aug 13, 2014 3:38 pm
Above 115200 kbps, these values are supported by stty: 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000 and 4000000.

Reference: coreutils.info section 19.2.7 Special settings. Use "info stty" to read the built-in info file.
Binh Bui
Posts: 70
Joined: Sat Jun 28, 2014 3:23 pm
by mikronauts » Wed Aug 13, 2014 4:09 pm
Very interesting!

Would I have to add something like:

init_uart_clock=64000000

/boot/config.txt to get to the 4Mbps rate?


bbodin wrote:Above 115200 kbps, these values are supported by stty: 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000 and 4000000.

Reference: coreutils.info section 19.2.7 Special settings. Use "info stty" to read the built-in info file.
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi
User avatar
Posts: 2606
Joined: Sat Jan 05, 2013 7:28 pm
by mikronauts » Wed Aug 13, 2014 4:14 pm
Found another relevant thread:

viewtopic.php?f=44&t=17559

Apparently uart_clock can go as high as 100Mhz, so 25Mbaud is theoretically possible with modifications to bits/termios.h and stty

Edit:

I read more of the other thread... there was some data corruption at 2Mbps in one test.
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi
User avatar
Posts: 2606
Joined: Sat Jan 05, 2013 7:28 pm
by codeforge » Tue Mar 29, 2016 8:12 pm
Anyone know how to set 125000 as baud rate?
Posts: 8
Joined: Fri May 01, 2015 10:09 pm
by joachimniedung » Fri Oct 28, 2016 4:29 pm
Oh yes please let us now how to set custom baudrate on jessie.
A raplacement for all this init_uartclock stuff in boot/config and etc/inittab ? we loved wheezy for and used in so many Midi projects.Cant find anything about it , since Jessies arrival and i am no longer intrested on this Pi3 Uart Drama.

After Jessie i dont want to bi one any more - still using my old pi s on good old wheezy.

(Its the same with this forum. Forget your Username OR your password and you can't use "forget pwd") Think about.
Posts: 1
Joined: Fri Oct 28, 2016 4:10 pm