Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Serial console broken on RPi 3 #22
Comments
|
You can also get around the issue by adding |
diederikdehaas
commented
Mar 2, 2016
|
It does indeed work Is there some side effect that causes that? Because logically I don't see the connection ... |
|
Something to do with the source clock for the serial. I don't know the specifics. |
diederikdehaas
commented
Mar 2, 2016
|
Thanks Is this the official solution or is there another one in the pipe-line? |
|
I think I saw someone say that it may have already been fixed in newer firmware, but I couldn't see that in the commit messages. @pelwell Is this something that can be or has been fixed? |
pelwell
commented
Mar 2, 2016
|
There are some inescapable facts:
You can reduce clock rate fluctuations using force_turbo=1, but there is still the possibility of an enforced clock rate reduction because of an over-temperature situation. Between 80C and 85C the ARM overclock is disabled, then at 85C all other clocks (core, sdram, v3d, isp, h264) are also reduced to minimum. It may be possible to ameliorate the issue by automatically reprogramming the uart clock divisor when the core clock changes, but that will depend on there being a suitable ratio between the overclock and the minimum. Therefore the only way to be sure that the baud rate doesn't ever change is to set core_freq to minimum to start with, which is 250MHz. Setting core_freq to 250MHz does not limit the ARMs to 600MHz. Those clocks are all independent. The main clocks are controlled by the config.txt settings arm_freq, core_freq, sdram_freq, v3d_freq, isp_freq and h264_freq. gpu_freq is an alias for the non-ARM clocks that haven't been set explicitly. Until the most recent firmware there was an oversight that meant that setting core_freq implicitly by setting gpu_freq wasn't being communicated to the Linux world, causing incorrect baud rates. The latest rpi-update firmware fixes that issue, but you can avoid it by using core_freq instead of gpu_freq. |
|
Ah, thanks for the full explanation. Related raspberrypi/firmware#553 |
Mwt-Anthony
commented
Mar 3, 2016
|
I have same problems... I can't use my RPI3... I put my sdcard into my RPI2 it work like a charm... I hope problem can be solve quickly. |
|
Careful, that's force_turbo, not force-turbo. |
pelwell
commented
Mar 3, 2016
|
A user on the other thread has found that gpu_freq=300 works for them. |
josn0
commented
Mar 4, 2016
|
Phil (pelwell) is right. I started to retrieve all frequency settings on a earlier Pi (using 'vcgencmd get_config int | grep freq'), copying all to config.txt to overrule the new defaults, and the problem was gone. Then, to get performance back, I stepwise increased the settings until I reached the new defaults (also found with get_config). After I reached all new default settings, everything kept working. Then I commented-out the _freq settings until the problem re-appeared; that was with gpu_freq. So put that back and the problem was all over, without changing any settings. My theory is that, pre-kernel-boot, something needs to set some frequencies, reads them out of the config.txt, and if not present, uses the (old) defaults. I think that is done in the start.elf files. Alas, they are closed-source. But, by grep-ing them, I found the texts 'gpu_freq' and 'config.txt', which makes my assumption more plausible. Another thing that is probably done there, is 'patching' the kernel's commandline parameters: file 'cmdline.txt' now contains 'console=serial,115200' instead of 'console=ttyAMA0,115200'. But whether the console is named 'serial' or 'ttyAMA0', if you check /proc/cmdline, both are changed to 'ttyS0'. I think that is also done in the start*.elf code. If so, it is a pity that such non-transparent 'hacks' are buried in closed-source proprietary code. Please dont do that. I can understand that the start*.elf file need to be closed-source, because it needs to interact with the proprietary gpu, but then keep the code in there as small as possible and as transparant as possible. Put strange hacks somewhere else, like in the kernel code, that everyone can read. |
diederikdehaas
commented
Mar 4, 2016
I haven't investigated it, but I noticed that too. |
ladyada
commented
Mar 4, 2016
|
verifying that the baud rate is ~72Kbps not 115Kbps - works great if I set my serial cable to 72000, note that prolific chipsets (PL230x) cannot do weird baud rates, try an FTDI or SiLabs chip :) |
pelwell
commented
Mar 4, 2016
|
@josn0 I was surprised that I couldn't find a standard DT mechanism for giving serial ports a chosen name. The PL011 driver attempts to renumber its own instances based on serial aliases, but it calls its instances ttyAMA instead of ttyS and other serial drivers don't seem to obey the same rule. The reason for the cmdline rewriting by the firmware is to allow a single SD card image to work in any Pi until we have worked out a better mechanism in the kernel. I don't particularly like it but our options were limited and time was short. @ladyada 72Kbps is 115200*(250/400), with 400 being the standard VPU overclock and 250 being the minimum used in overtemp or undervolt situations. I think you will see the power LED blinking off, indicating undervolt. I had to change my power supply to 2.5A model - I have any inline switch in the USB power cable and with the additional loss it adds the startup current for WiFi and Bluetooth is sufficient to drag the voltage down below the threshold. |
glynhudson
commented
Mar 4, 2016
|
I am trying to connect an Arduino @ 38400 baud to the Rpi3 via ttyAMA0 with no joy. Zero comms. Is this related this this thread or should I start another issue? I am using an SD card upgraded from Jessie that worked fine on RPi2. Serial console has been disconnected from terminal in the usual way |
pelwell
commented
Mar 4, 2016
|
It is related. ttyAMA0 on a Pi3 is configured to communicate with the Bluetooth modem. Try ttyS0. |
glynhudson
commented
Mar 4, 2016
|
How can I try ttyS0? I am connecting via Pi's UART pins on GPIO. It;s not On 4 March 2016 at 10:18, Phil Elwell notifications@github.com wrote:
Glyn Hudson http://megni.co.uk |
pelwell
commented
Mar 4, 2016
|
UART1/MiniUART/ttyS0 is available as Alt function 5 on GPIOs 14 and 15. UART0/ttyAMA0 is Alt function 0. If you run:
on a Pi2 you will see that GPIO14 is mapped to a0 (TXD0), whereas on a Pi3 it is mapped to a5 (TXD1). In other words, just open ttyS0 instead - the pin-muxing has already been configured to bring it out onto 14 and 15 (pins 8 and 10). |
diederikdehaas
commented
Mar 4, 2016
Only on the Pi3 or should I use ttyS0 on all Pi's now? |
pelwell
commented
Mar 4, 2016
|
Only on Pi3. ttyAMA0 is a better serial port, immune from core clock changes, and it would be a shame to deny it to all Pi users just so we can use it for Bluetooth on the Pi3. |
diederikdehaas
commented
Mar 4, 2016
|
Ok, thanks for the info. Right now we use the following as the start of our |
grigorig
commented
Mar 4, 2016
|
How much does core_freq=250 affect performance, really? I wasn't able to measure any difference with some simple CPU benchmarks. It might be a suitable workaround if you absolutely need a stable Mini UART. Still, is there any way to change behaviour in low voltage or thermal event situations? It doesn't look like setting core_freq_min has any effect. |
pelwell
commented
Mar 4, 2016
|
That's what the "serial" aliases were created for. The firmware will look for I can easily improve the mechanism to also work for kgdboc, but I also want to base the rewriting on the contents of the DTB rather than have it hard-coded for the Pi3, so that users who don't need Bluetooth can restore the previous behaviour with a DT overlay. |
diederikdehaas
commented
Mar 4, 2016
|
Thanks again |
glynhudson
commented
Mar 4, 2016
|
Thanks @pelwell that explains it. Using ttyS0 I can see serial coms from my device (ATmega328 @ 38400 baud), however there also seems to be some other unexpected traffic on the same port. Serial messages from my device are slightly garbled and my device is reporting receiving serial traffic when minicom is open. I have tried adding |
pelwell
commented
Mar 4, 2016
|
The order in cmdline.txt and config.txt shouldn't make any differences. DT overlays are applied in order, but provided the overlays don't overlap then there shouldn't be a problem. If you are seeing garbled serial port data when the core frequency is fixed then it suggests that the CPU is being throttled due to over-temperate or under-voltage (but that won't happen if you have pegged the core at 250MHz). A 2.5A power supply is recommended. I've just completed a firmware mod that improves the serial port alias handling:
|
added a commit
to raspberrypi/firmware
that referenced
this issue
Mar 4, 2016
added a commit
to Hexxeh/rpi-firmware
that referenced
this issue
Mar 4, 2016
pelwell
referenced this issue
in raspberrypi/firmware
Mar 5, 2016
Closed
Raspberry Pi 3 model B Serial console does not use correct baudrate #553
referenced
this issue
in swarren/u-boot
Mar 6, 2016
lurch
commented
Mar 8, 2016
Would it also be possible to do something similarly clever with udev rules, so that Linux-side applications could be configured to use e.g. /dev/serial0 or similar; which would be a symlink to /dev/ttyS0 on a Pi3 or a symlink to /dev/ttyAMA0 on other models? (thereby allowing the same application to work the same on all Pi models without reconfiguration) |
pelwell
commented
Mar 8, 2016
|
Either udev or, if we can't make that work, a systemd script - all it would take is |
lurch
commented
Mar 9, 2016
|
...and then once it's included in Raspbian by default, maybe raspi-config could be modified to be take advantage of the I'm not familiar with udev / systemd / etc. but is there any reason that |
|
I think I've come up with some rules.
%c is replaced with output of PROGRAM. Not sure if the check itself is good enough, but it seems to work for the simple/default case. Edit:
|
pelwell
commented
Mar 9, 2016
|
Thanks - that PROGRAM usage completes the puzzle for me. Leaving aside ownership, these rules work for me:
with a modified hciuart.service:
The rule accepts ttyAMA1 as well as ttyAMA0 in case we drop the patch that prevents the port renumbering. |
grigorig
commented
Mar 9, 2016
|
There's another problem when it comes to Bluetooth: you have to reduce the baudrate to make it work with the Mini UART. |
pelwell
commented
Mar 9, 2016
|
Yes. That's why Bluetooth is configured to use ttyAMA0 by default, and why the pi3-miniuart-bt overlay documentation says:
|
diederikdehaas
referenced this issue
in debian-pi/raspbian-ua-netinst
Mar 11, 2016
Closed
Question - RaspberryPi 3 Compatibility #375
|
Should we change cmdline.txt to use serial0 by default? Regarding permissions, it seems like when getty runs, it changes the ownership group to tty, then login changes it to the logged in user. |
pelwell
commented
Mar 11, 2016
|
Yes we should - has that not happened yet? We did talk about it. |
|
Wasn't sure, thanks. |
This was referenced Mar 16, 2016
manasb
commented
Apr 14, 2016
|
Was directed here from the Adafruit forums I tried connecting to the Pi 3b's serial console through the GPIO ports with this cable https://www.adafruit.com/products/954 This is what I saw on the screen upon attempting to connect with |
pelwell
commented
Apr 14, 2016
•
|
I suspect that if you add |
manasb
commented
Apr 14, 2016
|
@pelwell I am unable to send reliable input to the Pi over the serial connection. Is there some other way to apply those changes? |
pelwell
commented
Apr 14, 2016
|
Either plug in a monitor and keyboard or take out the SD card and edit it in another computer. |
manasb
commented
Apr 14, 2016
|
@pelwell Great, thanks! I don't have a HDMI cable but I can edit on a different computer :) |
manasb
commented
Apr 14, 2016
|
@pelwell I tried making that change and booting again. My input & output are both still mostly garbled. |
pelwell
commented
Apr 14, 2016
•
|
That should have said |
manasb
commented
Apr 14, 2016
|
@pelwell It works now, thanks for your help. |
manasb
commented
Apr 15, 2016
|
I have run
|
Arun22
commented
Apr 16, 2016
•
|
Hi, i was using my Pi3 for last few weeks.my serial output was good after i fix the core_clock to 250. btw, I tired the following suggestion from this post: so far no luck so far, if you guys see anything obvious thing i miss here, please let me know.
|
popcornmix
commented
Apr 16, 2016
|
Try enable_uart=1 |
lurch
commented
Apr 18, 2016
|
raspberrypi/firmware#553 (comment) has a bit more detail on how things work after an rpi-update. |
agherzan
commented
Apr 21, 2016
pelwell
commented
Apr 21, 2016
|
@agherzan Only the GPU core clock (which ironically doesn't really affect the graphics performance) is limited. It should have no impact on ARM performance except where it is waiting imperceptibly longer for the VPU to do something. |
agherzan
commented
Apr 21, 2016
•
|
@pelwell so why don't we just set it to minimum by default on rpi3? Where is the downside? |
pelwell
commented
Apr 21, 2016
|
Because certain operations - 60fps h264 decode, high quality deinterlace - which aren't performed on the ARM may be affected, and we wouldn't want to do that to users who don't want to use the serial port. |
agherzan
commented
Apr 22, 2016
|
Clarified. Thanks @pelwell |
agherzan
commented
Apr 22, 2016
|
I have a hard time trying to get boot messages over serial. Getty message are the first ones I get on serial after boot. Is the console initialized too late or am I missing something? |
pelwell
commented
Apr 22, 2016
|
What do you have in cmdline.txt? It should contain (amongst other things) "console=serial0,115200" (or another baudrate of your choosing). |
agherzan
commented
Apr 22, 2016
•
|
@pelwell Indeed. I have what I need for console and the proper loglevels:
Ignore the debug/loglevel redundancy. |
pelwell
commented
Apr 22, 2016
|
Have you tried adding an explicit baudrate? And I would recommend "serial0" instead of "ttyS0" - the firmware will rewrite it appropriately. |
agherzan
commented
Apr 22, 2016
|
I've been trying all the combinations. serial0/ttyS0, enable_uart/cpu_freq and nothing seems to change anything. Now, trying to explicitly set the baudrate did the trick. Any idea what's going on? |
pelwell
commented
Apr 22, 2016
|
My guess would be that the default baudrate on ttyS0 is not 115200, but getty is probably explicitly selecting 115200. Note that the firmware is setting 115200, so the serial driver must be changing it. Yes, the code confirms it - the ultimate fallback baudrate for the ttyS0 is 9600. |
agherzan
commented
Apr 22, 2016
|
Understood. Can you point me to the code? Is this valid for any rpi version now? Cause this was not the case before. |
agherzan
commented
Apr 22, 2016
|
One more tiny question. Is the current firmware (master HEAD) using the same replacement mechanism for kgdboc too as it does for console? |
pelwell
commented
Apr 22, 2016
|
drivers/tty/serial/8250/8250_port.c It is valid for any Pi with console=ttyS0 on the kernel command line, which is probably only Pi3s but has probably always been the case.
Yes. It looks for '=serial0' and '=serial1' and replaces them appropriately. |
agherzan
commented
Apr 22, 2016
|
What I meant is that on RPI2 this was not the case. Thank you @pelwell . Everything is clear now. |
agherzan
commented
Apr 22, 2016
|
I see some references in this thread of setting core_freq in cmdline.txt . They must by typos and should be read config.txt , right? |
pelwell
commented
Apr 22, 2016
|
|
agherzan
commented
Apr 22, 2016
|
I thought there is some black magic happened lately. Back in normal state :) Thanks @pelwell |
chaderick9
commented
Apr 24, 2016
•
|
I ended up here from Adafruit. I am not having success with the Raspberry Pi 3 getting the following product to work: https://www.adafruit.com/product/746 Following this tutorial: https://learn.adafruit.com/downloads/pdf/adafruit-ultimate-gps-on-the-raspberry-pi.pdf Using UART instead of USB, installed latest version of Jessie light and full. Any suggestions? Edit |
|
@chaderick9 Try using ttyS0, instead of ttyAMA0 and make sure you set core_freq correctly or, if your firmware is recent enough, use enable_uart=1. If that doesn't work, it might be best to post the question on the forum, providing more information. |
KBoonie
commented
Apr 28, 2016
|
I've finally found a thread that validates my theory (and pdf reading). |
nowls
referenced this issue
in agherzan/meta-raspberrypi
May 10, 2016
Closed
Feature request: configuration parameter for freeing up /dev/ttyAMA0 on RPi2 #18
|
Since the enable_uart option is in raspi-config, I think this issue can be closed. |
XECDesign
closed this
May 20, 2016
This was referenced Jun 9, 2016
jamesoxford08
commented
Jun 15, 2016
•
|
I am a rpi noob so I might not understand the culture, so I apologize if I'm "speaking out of school" but reading this thread, and various other commentaries around the interwebs, its frustrating. Sometimes I scratch my head and wonder what developers are thinking. Like...
Why? why is gpu h264 decoding @ 60fps even necessary on a raspberry pi? You know what does it even better? Literally any other computer; and they all do it without sacrificing other systems. What do I need a full hdmi output for? It was honestly an inconvenience just to hook up to get the thing running for the first time. I guess my point is, why try to make the thing compete with devices that are already designed to do things like stream HD media or display digital signage, and they are better equipped to do so in the first place. If I wanted a device that just did media I'd buy a Roku, or a NUC. You know how heavy a GUI is and what is likely sacrificed to include one? If I wanted a GUI I could just install ubuntu in a VM; and get better performance ...and a better looking GUI... or HDMI... or 4 full sized USB ports...put a USB header on the board and let people use it if they need it. I can understand the benefit of wlan and bluetooth, even though I personally will probably never use either. Its a bit like trying to turn a ferrari into a 4x4... or perhaps a smart into a race car is the better analogy. My frustrations are coming out here but it seems to be kind of a prevailing trend; "lets make things do everything and be mediocre at all of them" instead of making something that is really good at a few things. You can't please everyone; but you can most definitely disappoint everyone trying. |
|
@jamesoxford08, Closed github issues is definitely not the place to vent. I'd recommend going on the forum for that. The main answer to your question consists of cost, power consumption and individual needs. You're basically asking "Why would anybody buy a bicycle when a ferrari is faster." Not everybody can afford or wants a ferrari and there's a whole other set of features that a bicycle provides that a ferrari doesn't. Many of us use raspberry pis as home theatre pcs and aren't at all disappointed. When it comes to decoding, it's usually a matter of whether it's real time. If the raspberry pi does the job, why pay for something else? When I don't need it as a media centre, I can use it as a NAS (yes, it's fast enough for those of us who don't have fiber internet), if not that I can find another 100 uses for it. I don't need to buy 50 different devices for each different thing I might need to do. I really don't understand the argument against having USB ports on it. Why should I need to buy additional hardware for basic functionality? This isn't Apple. It's cheaper to buy a board with USB ports which you'll definitely want to use (if you're the target market) than to provide a board for each feature. If you have an infinite supply of money and don't care about how wisely you spend it. By all means, buy NUCs, a rack of servers, a NAS, a high end desktop to run all your VMs on, a home theatre box, a 4x4, a smart car and a ferrari. However, that's probably not practical or desirable for 99% of people. |
lurch
commented
Jun 15, 2016
|
@jamesoxford08 In addition to what @XECDesign said... I believe there are vastly many more people who want full-speed GPU features, than who want to access the UART. That's probably why the decision was made to run the GPU at full-speed by default (and require a tweak to be made to access the UART), rather than running the GPU at a reduced speed so that the UART is usable by default (and require a tweak to run the GPU at full speed). |
agherzan
commented
Jul 21, 2016
•
|
There seems to be another related issue that I just found out. If I have console=tty1 and then I want to start a getty process on ttyS0 (using enable_uart=1), there is no getty output on serial port. If I add console=ttyS0,115200, systemd uses a generator and the getty works correctly. I suspect that I miss an initialization step or so if the serial port is not mentioned as console. CC @popcornmix |
agherzan
commented
Jul 21, 2016
|
Found the problem: baudrate which is by default 9600 |
lurch
commented
Jul 21, 2016
|
Might be worth having a look at what https://github.com/RPi-Distro/raspi-config does when you enable or disable the serial console. |
agherzan
commented
Jul 21, 2016
|
But there is an issue here. If you remove console from cmdline, and start getty with 115200, boom! |
|
@agherzan This is systemd's intended behaviour. It auto-generates the serial getty units from cmdline. enable_uart=1 only enables the hardware and is not meant to do anything else. I think raspi-config should additionally ask whether to start the getty or only enable the hardware, but that's a separate issue. |
my007ms
referenced this issue
in agherzan/meta-raspberrypi
Aug 9, 2016
Closed
Enable bluetooth in Pi3 #26
agherzan
commented
Aug 23, 2016
|
I do agree that it is another issue but there is one. |
CJ-01
commented
Sep 16, 2016
|
I use the change by adding core_freq=250 for my Pi 3. I did notice the Pi 3 boots a lot faster. Not sure which change caused it. Ok, enough foreplay. My question is will I also have different images for my Pi Zeros as I go forward. I'm not sure of the variable to check to see what pi model I'm using but I need to know is this a possibility and/or will the changes added cause issues between the Pi 3 or Pi Zero. Any help is appreciated! |
pelwell
commented
Sep 16, 2016
|
The reason for the introduction of If, however, ttyAMA0 is the main serial port (i.e. if this isn't a Pi3 or if it a Pi3 with the pi3-disable-bt or pi3-miniuart-bt overlay loaded) then |
lurch
commented
Sep 16, 2016
|
And to answer the second part of your question: Yes, you can use conditional blocks in config.txt if you want to apply different settings to different Pis. See the bottom of https://www.raspberrypi.org/documentation/configuration/config-txt.md |
pelwell
commented
Sep 16, 2016
|
Yes, but you don't need to for this issue. In order to get a stable console serial port on any Pi, just add |


diederikdehaas commentedMar 2, 2016
Using the raspbian-jessie-lite image dd 2016-02-26 (and performing all updates after that), I can't get the serial console working on a RPi 3. When I put the image in a RPi 2, everything is fine.
By not working, I mean that I mostly get garbled output and I am unable to use my keyboard to interact with the system.
There is a forum thread about it and (apparently) someone found a workaround ... by crippling the performance of the RPi 3 by adding
core_freq=250to/boot/cmdline.txtwhich also reduces the CPU speed to 600 Mhz.I don't consider that an valid option.