Max_G
Posts: 20
Joined: Sat May 28, 2016 8:27 am

Re: Pi3 UART stopped working? Read this.

Mon Sep 19, 2016 12:26 pm

I am gob smacked... just bought 2 Pi3 to run a python script reading serial via USB and it does not work...

As a matter of principle: why would anyone implement a change like this? Instead of giving Bluetooth a new serial port rather than using an existing one and breaking backwards compatibility? This is beyond me. Sorry, no other words for this.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1434
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Pi3 UART stopped working? Read this.

Mon Sep 19, 2016 12:44 pm

It's either because ttyAMA0 is the more capable UART with larger FIFOs and a clock which is immune to core frequency changes, or because we hate you - pick whichever suits your world view.

User avatar
scruss
Posts: 1444
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Pi3 UART stopped working? Read this.

Mon Sep 19, 2016 2:42 pm

Max_G wrote:I am gob smacked... just bought 2 Pi3 to run a python script reading serial via USB and it does not work...
If you're reading serial via USB — which I take to mean you are using USB serial adapters with a USB type A plug on one end and something like an RS232 9-pin connector on the other — the Pi3 UART change does not affect you. If this is the case, it might be better to start another thread to ask for help with it.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

Max_G
Posts: 20
Joined: Sat May 28, 2016 8:27 am

Re: Pi3 UART stopped working? Read this.

Tue Sep 20, 2016 9:43 am

PhilE wrote:It's either because ttyAMA0 is the more capable UART with larger FIFOs and a clock which is immune to core frequency changes, or because we hate you - pick whichever suits your world view.
Well put... thanks! This clearly demonstrates that I should not be talking about things I do not understand.
As such, I do apologise for my commentary.

Mane
Posts: 2
Joined: Sat Oct 08, 2016 9:19 am

Re: Pi3 UART stopped working? Read this.

Wed Oct 19, 2016 5:49 pm

Max_G
I share the same disappointment. One of my initial reasons to get a Raspberry Pi was that I can use the serial port to communicate several measuring devices. "In the good old days" PCs had such and they were accessible. Nope today. The USB -RS232 converters just make a simple thing over complicated. A TTL-to RS232 converter needs only a MAX3232 + 5 capacitors, no drivers etc.
Even with Pi2 getting UART to communicate was over complex. I first thought that in Raspi setup enabling serial port would enable it to communication. Instead it enabled it to console use and disabled the normal use, as I understand it.

User avatar
scruss
Posts: 1444
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Pi3 UART stopped working? Read this.

Wed Oct 19, 2016 6:21 pm

Mane wrote:"In the good old days" PCs had such and they were accessible. Nope today. The USB -RS232 converters just make a simple thing over complicated
In those days you were hitting hardware interrupts directly, and were running a single-tasking OS barely capable of network access. Linux and Unix does make serial port access more complex because you're abstracted away from the hardware. You can't guarantee realtime I/O any more, and too much of the DOS-age code relied upon that.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

Mane
Posts: 2
Joined: Sat Oct 08, 2016 9:19 am

Re: Pi3 UART stopped working? Read this.

Sun Nov 06, 2016 7:30 am

I finally got it working by following this guide:
http://spellfoundry.com/2016/05/29/conf ... ding-pi-3/

(Regarding to my previous post, I never got a GPS receiver to work with a PC using RS232-to-USB-dongle but with Pi3 and a MAX3232 RS232 to 3,3V TTL it works now perfect. I found that the Deltaco dongle even imitates a modem by giving replies to AT commands. That was the most frustrating part of that story.)

naikrovek
Posts: 7
Joined: Fri Nov 04, 2016 3:27 pm

Re: Pi3 UART stopped working? Read this.

Mon Nov 07, 2016 11:23 pm

So I was having the corruption issue when I used cat to check the output of /dev/ttyS0 and that turned out to be a mistake.

I think. Maybe. I'm not 100% sure yet, so I'll tell you guys what I did and you can tell me what I did wrong.

5 seconds of backstory:
I've been using Debian since I think kernel 1.3 when a CD of the then-current Debian distro was included in "net" magazine. Back then, the only way I knew how to interact with serial streams was through a program called minicom.

So after seeing corruption via 'cat' I installed and tried minicom.

No corrupt data.

So, my hypothesis here is that the data isn't corrupt when it appears to be. I suspect that there's something wrong with an stty setting or something set on that tty that is causing unprintable characters (other than the usual ones) when viewing the serial stream with cat. Minicom is known to do magic-y things to the serial port before using it, or at least that's what my memory is telling me.

In my case, the serial stream is from the Adafruit GPS module. I haven't tried, and I'll ask anyway; will GPSd see this data correctly or no? Bonus question: what magic does minicom do to the serial port before showing serial data?

User avatar
davidcoton
Posts: 2576
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Pi3 UART stopped working? Read this.

Tue Nov 08, 2016 1:26 am

Set the baud rate?
"If it ain't broke, fix it until it is."
“Raspberry Pi is a trademark of the Raspberry Pi Foundation”
The Pink Unicorn is a symbol of commitment to sensible discussion of future versions of the Raspberry Pi ™

naikrovek
Posts: 7
Joined: Fri Nov 04, 2016 3:27 pm

Re: Pi3 UART stopped working? Read this.

Tue Nov 08, 2016 12:20 pm

davidcoton wrote:Set the baud rate?
No, the baud rate is set. In fact, everything EXCEPT the cat command show the proper data.

Cat is just not a good way to validate serial data, I guess.

JPelletier
Posts: 17
Joined: Fri Mar 13, 2015 1:34 pm

Re: Pi3 UART stopped working? Read this.

Tue Nov 15, 2016 6:59 pm

I've just downloaded the latest Raspbian Lite image and booted on a PI2. My program was not working normally and found out this error: /dev/ttyAMA0: No such file or directory

I found that I had to set enable_uart=1 in boot/config.txt file to make it work, it was at 0. Though it was the defautl value only on PI3?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1434
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Pi3 UART stopped working? Read this.

Wed Nov 16, 2016 9:33 am

On all Pis, enable_uart=1 will activate the primary UART (ttyS0 by default on a Pi3, ttyAMA0 on the others, although DT overlays can change that), which is accessible through /dev/serial0. And on all Pis, enable_uart=0 will disable it. The difference between Pi models is the default value - what happens when enable_uart isn't specified in config.txt - which is 1 when the primary UART is ttyAMA0 and 0 when it is ttyS0. This is because getting a stable baudrate on ttyS0 requires the VPU clock to be fixed.

By adding enable_uart=0 to config.txt (which raspi-config will do if you opt to disable the serial port) you have overridden the default - out of the box, config.txt doesn't mention enable_uart - and your UART is correctly disabled.

User avatar
scootergarrett
Posts: 26
Joined: Sat Apr 19, 2014 2:36 pm

Re: Pi3 UART stopped working? Read this.

Fri Nov 18, 2016 9:36 pm

I'm having the same issue with missing data sent on the UART line. I have a micro controller sending the alphabet one letter a second. My laptop with minicom works fine but when I use a Pi3 with Jessie and /dev/ttyS0 the pi seems to miss a lot of data. I have changed around the /boot/config.txt file to include core_freq=250 and it still misses data but gets some so Its not a wiring error. Any ideas
Attachments
Junk Data.png
Junk Data.png (11.52 KiB) Viewed 5137 times
Config file change.png
Config file change.png (44.99 KiB) Viewed 5137 times

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1434
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Pi3 UART stopped working? Read this.

Fri Nov 18, 2016 9:50 pm

Do the baud rates match? How high is that rate? With no flow control and smaller FIFOs, data may be dropped at high transmission rates.

Try sending the same character repeatedly before switching to the next - are you just losing characters or is there corruption?

User avatar
scootergarrett
Posts: 26
Joined: Sat Apr 19, 2014 2:36 pm

Re: Pi3 UART stopped working? Read this.

Fri Nov 18, 2016 10:33 pm

The baud rate used on the Pi is the same as I use on my computer and the pi 2 with wheezy; 115200. There doesn’t seem to be corruption as the letters are in the correct order its just missing a lot in the middle. When I tie the RX to the TX there is no lost data.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1434
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Pi3 UART stopped working? Read this.

Fri Nov 18, 2016 10:53 pm

Is the sender paced in any way? At 115200 baud the FIFOs will fill in around a millisecond, so anything that keeps the ARM busy with interrupts disabled for a millisecond or more may cause characters to be dropped.

User avatar
scootergarrett
Posts: 26
Joined: Sat Apr 19, 2014 2:36 pm

Re: Pi3 UART stopped working? Read this.

Fri Nov 18, 2016 10:53 pm

I don't know what you mean by paced? it just in a loop so every second it send characters.

When I send the same character repeatedly ( like 'AAA' the pause then 'BBB' exc.) it still misses data and never sees two or three of the same letter. Also when I probe both TX and RX I see the same data with a slight delay. Pi TXD is CH1 yellow line, and RXD is CH2. I don't know why the pi is sending info back to the microcontroller
Attachments
Probe.png
Probe.png (3.55 KiB) Viewed 5045 times

User avatar
jojopi
Posts: 3033
Joined: Tue Oct 11, 2011 8:38 pm

Re: Pi3 UART stopped working? Read this.

Sat Nov 19, 2016 1:24 pm

scootergarrett wrote:I have a micro controller sending the alphabet one letter a second. My laptop with minicom works fine but when I use a Pi3 with Jessie and /dev/ttyS0 the pi seems to miss a lot of data.
Out of interest, how were you connecting the 3.3V micro to the laptop, and did you try the same method with the Pi?
I don't know why the pi is sending info back to the microcontroller
Do you have a getty (serial login manager) running? If getty and minicom are both reading from the same port, it is non-deterministic which one gets any particular byte. Getty echoes, because it is intended for remote interactive use.

User avatar
scootergarrett
Posts: 26
Joined: Sat Apr 19, 2014 2:36 pm

Re: Pi3 UART stopped working? Read this.

Sun Nov 20, 2016 7:37 pm

jojopi, thanks for the tip
Do you have a getty (serial login manager) running?
I added

Code: Select all

sudo systemctl stop serial-getty@ttyS0.service
To the end of /etc/profile and now it seems to get all the data. I don't even have core_freq = 250. I think I all set now.
Thanks again.

User avatar
DougieLawson
Posts: 30941
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Pi3 UART stopped working? Read this.

Sun Nov 20, 2016 9:10 pm

Why not use
sudo systemctl disable serial-getty@ttyS0.service
so it never gets started?
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

User avatar
scootergarrett
Posts: 26
Joined: Sat Apr 19, 2014 2:36 pm

Re: Pi3 UART stopped working? Read this.

Mon Nov 21, 2016 12:22 am

I did see the disable option, what would be the advantage? Boot up faster? It's work now so I'm happy

User avatar
DougieLawson
Posts: 30941
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Pi3 UART stopped working? Read this.

Mon Nov 21, 2016 9:34 am

scootergarrett wrote:I did see the disable option, what would be the advantage? Boot up faster? It's work now so I'm happy
Of course, it will boot faster. You're not starting and stopping a pointless (for you) service.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1434
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Pi3 UART stopped working? Read this.

Mon Nov 21, 2016 9:38 am

Since the getty is being started because the "console=serial0,115200" in /boot/cmdline.txt, just remove that.

ilkertemir
Posts: 2
Joined: Wed Oct 05, 2016 8:02 pm

Re: Pi3 UART stopped working? Read this.

Wed Jan 25, 2017 7:11 am

I have written a script to make usage of UART easier, available on GitHub: https://github.com/itemir/raspberry_pi_utils

It basically disables Bluetooth on RPi3, even though it can be enhanced to automatically configure Bluetooth on the mini-uart.

JamesPi123
Posts: 72
Joined: Fri Sep 23, 2016 10:02 pm
Location: Inside my Pi

Re: Pi3 UART stopped working? Read this.

Tue Apr 25, 2017 9:27 am

I have a FTDI 232-3V3R cord connected correctly and the enable_uart=1 fag in config.txt and it prints random garbage. When I connect this cord to my B 512mb and raspi-config, it works. ??? for what's going on with my 2x 3B's
:?: :)

Return to “Troubleshooting”

Who is online

Users browsing this forum: cjan, RlTA and 32 guests