User avatar
abelectronicsuk
Posts: 19
Joined: Thu Jan 21, 2016 1:17 pm
Location: Swanage, United Kingdom
Contact: Website

Raspberry Pi 3 login via UART on GPIO Baud Rates broken

Tue Mar 01, 2016 1:50 pm

My new shiny Raspberry Pi 3 arrived today and I tried to set it up as I normally do using a USB-UART adapter which plugs into the GPIO header. I use this as I don’t always have a network connection available and it’s easier to setup the static IP config and setup the wifi using the serial console which has always worked at 115200 baud.

When I powered on the Raspberry Pi 3 I only got garbled data from the serial console and so I connected the Pi to a network and logged in via SSH to configure the Pi. The serial console is enabled in raspi-config but this didn’t change anything.

I then connected a logic analyser to the UART pins and found that the baud rate when set to 115200 is actually 72000 !
Using this new baud rate I was able to access the pi using the serial console. I then tried changing the baud rate on the pi to use 9600 but the data logger shows that it is actually sending at 6002 baud which is around 1.6 times slower than it should be.

Does anyone know how to fix this as I needed to be able to use the UART port on an external data logger and if the baud rate is broken or outputting at random multiples of the set frequency the new Raspberry Pi 3 is useless for the application.

User avatar
topguy
Posts: 3428
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Raspberry Pi 3 login via UART on GPIO Baud Rates broken

Tue Mar 01, 2016 1:56 pm

And you have of course done a full "apt-get update + dist-upgrade" ?

User avatar
abelectronicsuk
Posts: 19
Joined: Thu Jan 21, 2016 1:17 pm
Location: Swanage, United Kingdom
Contact: Website

Re: Raspberry Pi 3 login via UART on GPIO Baud Rates broken

Tue Mar 01, 2016 2:03 pm

topguy wrote:And you have of course done a full "apt-get update + dist-upgrade" ?
Yes, all the updates are installed.

User avatar
RaTTuS
Posts: 9442
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Raspberry Pi 3 login via UART on GPIO Baud Rates broken

Tue Mar 01, 2016 2:31 pm

it may be because the serial comms bit is now used for the BT
do you have a [dang something nobbled my post ]
so something may have changed in the /boot/overlays
Last edited by RaTTuS on Tue Mar 01, 2016 3:02 pm, edited 1 time in total.
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

gregeric
Posts: 1494
Joined: Mon Nov 28, 2011 10:08 am

Re: Raspberry Pi 3 login via UART on GPIO Baud Rates broken

Tue Mar 01, 2016 2:58 pm

It's cos the console is now using /dev/ttyS0 & the baud rate is skewed cos the core clock is 400MHz not 250MHz.

See:
viewtopic.php?f=63&t=137932&start=50#p915614
viewtopic.php?f=98&t=80472&p=863957#p863957

User avatar
joan
Posts: 12738
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Raspberry Pi 3 login via UART on GPIO Baud Rates broken

Tue Mar 01, 2016 3:07 pm

On my Pi3 there are regular bursts of data on TXD (GPIO14). The baud rate seems to change after each burst (about once a second) and when I capture some at 9600 it seems like it might be a login prompt.

Code: Select all

$ pigs slro 14 9600 8
$ pigs -a slr 14 100
100 /sid paul ttyS0\x0d\x0a\x0d\x0ag\xfe\xfe#\x97v+\xfd\x87\xde\xf6\xc6xTHGTiYZc\x13\xbf\x94\xf8aul login: \x0d\x0d\x0aRaspbian GNU/Linux stretch/sid paul ttyS0\x0d
I just moved a card from a Pi2B to the Pi3B.

Edited to add.

My problem disappeared after an update.
Last edited by joan on Tue Mar 01, 2016 8:28 pm, edited 1 time in total.

User avatar
abelectronicsuk
Posts: 19
Joined: Thu Jan 21, 2016 1:17 pm
Location: Swanage, United Kingdom
Contact: Website

Re: Raspberry Pi 3 login via UART on GPIO Baud Rates broken

Tue Mar 01, 2016 5:35 pm

I have found a sort of fix but it drops the speed of the raspberry pi.

If you edit

Code: Select all

/boot/config.txt
and add

Code: Select all

core_freq=250
at the end of the file it will set the core frequency down to 250MHz and the UART port starts to work at the correct baud rate. The problem is the CPU frequency is now only 600MHz.

Koldur
Posts: 6
Joined: Tue Mar 01, 2016 12:36 pm

Re: Raspberry Pi 3 login via UART on GPIO Baud Rates broken

Tue Mar 01, 2016 9:09 pm

abelectronicsuk wrote:I have found a sort of fix but it drops the speed of the raspberry pi.

If you edit

Code: Select all

/boot/config.txt
and add

Code: Select all

core_freq=250
at the end of the file it will set the core frequency down to 250MHz and the UART port starts to work at the correct baud rate. The problem is the CPU frequency is now only 600MHz.
This sounds like a great fix for me, I only want the Pi's I am using to change the network settings so that students can SSH into the Pi without the need to connect a monitor or anything else to it. This is doable now, they can just change the txt file in Windows and after they are able to SSH into the Pi they can change the config back in Raspbian. A bit of a workaround, but also very educational when considering how the Pi works.

Thanks for the info!

diederik
Posts: 389
Joined: Wed Mar 26, 2014 11:17 pm

Re: Raspberry Pi 3 login via UART on GPIO Baud Rates broken

Wed Mar 02, 2016 12:42 pm

joan wrote:My problem disappeared after an update.
Which update was that? I'm still suffering from this issue.

User avatar
joan
Posts: 12738
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Raspberry Pi 3 login via UART on GPIO Baud Rates broken

Wed Mar 02, 2016 12:50 pm

diederik wrote:
joan wrote:My problem disappeared after an update.
Which update was that? I'm still suffering from this issue.
My problem was with login prompts at varying baud rates being written to GPIO 14 (TXD). It went away once I did a sudo apt-get update/upgrade/dist-upgrade sequence.

The wrong baud rate seen by the OP is a separate issue. For that you'll need to use the /boot/config.txt fix and reboot.

diederik
Posts: 389
Joined: Wed Mar 26, 2014 11:17 pm

Re: Raspberry Pi 3 login via UART on GPIO Baud Rates broken

Wed Mar 02, 2016 1:00 pm

Thanks.
I don't think that crippling the performance of the Pi 3 is a proper solution though ... I'll keep looking and/or file a bug for it.

User avatar
joan
Posts: 12738
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Raspberry Pi 3 login via UART on GPIO Baud Rates broken

Wed Mar 02, 2016 1:17 pm

diederik wrote:Thanks.
I don't think that crippling the performance of the Pi 3 is a proper solution though ... I'll keep looking and/or file a bug for it.
I just updated to 4.1.18-v7+ #848 with rpi-update and my original problem is back. Unexpected traffic on GPIO 14.

Changing baud rates. Caught a login prompt at 5882 bps.

Code: Select all

gavin:~ $ pigs slrc 14
gavin:~ $ pigs slro 14 5882 8
gavin:~ $ pigs -a slr 14 100
41 \x0d\x0d\x0aRaspbian GNU/Linux 8 gavin ttyS0\x0d\x0a\x0d\x0ab\xfe
webm video http://abyz.co.uk/videos/random-uart.webm


Koldur
Posts: 6
Joined: Tue Mar 01, 2016 12:36 pm

Re: Raspberry Pi 3 login via UART on GPIO Baud Rates broken

Wed Mar 02, 2016 4:40 pm

diederik wrote:Reported it here: https://github.com/RPi-Distro/repo/issues/22
That thread gives some great insights! Just adding "force_turbo=1" to the config.txt sounds like the best option, unless you are using the serial while the Pi heats up above 80C as the core clock will clock down and the BAUD rate will be out of sync once again. Let's hope for a better solution soon, but at least this one will be lest impactful than the core clock lowering (which will impact the GPU more than anything as I have come to understand now).

EDIT:
Another drawback of this option is that the CPU constantly runs at its highest clock speed. So this isn't a great solution when you want to save some power (especially when using a battery). Which makes sense when reading the explanation where you reported the issue.

ark76r
Posts: 1
Joined: Fri Mar 18, 2016 11:51 pm

Re: Raspberry Pi 3 login via UART on GPIO Baud Rates broken

Sat Mar 19, 2016 12:01 am

Hi,

First of all, thanks for the information. My serial connection has started to work!

I've added core_freq=250 to /boot/config.txt on my Pi 3.
vcgencmd get_config arm_freq reports 1200 and /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq shows 600000 and 1200000. It looks like performance of the board didn't decrease.

Of course I use /dev/ttyS0 device.

x92127
Posts: 6
Joined: Mon Dec 28, 2015 4:56 pm

Re: Raspberry Pi 3 login via UART on GPIO Baud Rates broken

Sun Jun 19, 2016 2:21 pm

Here's a great write-up on this issue, as well as solutions:
http://spellfoundry.com/2016/05/29/conf ... ment-66323

Return to “General discussion”

Who is online

Users browsing this forum: stubright and 57 guests