-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Raspberry Pi 3 model B Serial console does not use correct baudrate #553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
An issue with gpu_freq/core_freq handling was discovered and fixed in an rpi-update release made on the 29th, but that hasn't made its way to a Raspbian build yet. You can run "sudo rpi-update" to get the latest firmware, wait for a Raspbian update, or use a workaround: set the frequency using core_freq instead of gpu_freq. |
Thanks for the response. I tried a rpi-update; it did not help. Then tried adding 'core_freq=300'; that did not help either. Put back my 'gpu_freq=300', which again solved the problem. So it seems the issue is not fixed correctly. |
It looks like there might be a clocking issue - we will investigate. |
My Pi3 serial port (ttyS0) has been rock solid with force_turbo=1 and a 2.5A power supply. I think you may be suffering from under-voltage. The gpu_freq=300 setting will have the effect of scaling back all of the non-ARM clocks, which will save power. |
@pelwell, I don't get if this issue will be resolved or not. I'm using a 2.5A power supply and force_turbo which makes it work again but I think some firmware needs to be updated to make it work the right way (without force_turbo) or am I missing something? |
See my answer in this thread: |
have the same problem. unfortunately the gpu_freq setting does not work. rpib3 login: gej now running version 30fe8178d61c1ff9bc168edaafdbcb101aa6245e (05-02) |
If the red power LED flickers then your power supply isn't sufficient. You need a good 2.5A supply. There are extra current demands at boot time, with WiFi and Bluetooth starting and increased parallelism thanks to systemd. |
@pelwell The powersupply used is a 5A powersupply and the red led is not flickering. |
It's the core_freq=250 that makes the difference - if your maximum core freq is the same as the minimum core freq then it never changes. |
@pelwell Maybe I just don't get it but I'm trying to make it clear. I'm now using a power supply that can deliver up to 12A of current but I still need force_turbo to make the serial output work (= readable). Peak current is around 2.3A at boot. Is the need of force_turbo a workaround for an unresolved bug in the firmware or what is causing this? I don't have this problem with all the other models, that's why I'm asking and trying to understand. |
I can confirm that only the core_freq=250 works. |
The answers are in the other thread (RPi-Distro/repo#22), but the short version is that the clock is also reduced if the chip is getting too hot. By setting the core VPU clock to the minimum value (250) you avoid this problem. |
I pulled down the latest firmware, and I still see some issues re: serial console. Let me know if I should file this as a separate bug. I think it's within the realm of this bug though. On the RPi 0/1/2, whatever is loaded as kernel.img can immediately start writing to the UART's TX FIFO, and that data will appear on the GPIO header pin at the expected baud rate. However, on the RPi 3, the following steps are required before this works. I believe the firmware should provide the same guarantees/initial-conditions on all system, so none of these steps should be necessary:
For reference, see the most recent commit at https://github.com/swarren/u-boot/commits/rpi_dev. (For the RPi 0/1/2, we do actually do step 4 too. However, Eric Anholt has submitted a patch to skip this so that U-Boot honors whatever the firmware programmed, which means it follows whatever the user requested via config.txt, which makes for a nicer user experience). One particularly nice benefit of the firmware doing this is that step 4 can be skipped, which means U-Boot wouldn't have to query the core clock rate from the firmware in order to calculate the divider. (Assuming the core clock rate hasn't changed, but there really isn't anything we can do about that.) |
Before (considering) undertaking this work, I'd like to clarify something. I had considered the fact that the firmware leaves uart0 mapped to GPIOs 14 and 15 to be anomalous - it seems to go against the DT philosophy of only enabling that which is requested in the DTB. Are you saying that having a UART enabled at boot is the preferred behaviour? |
FIXME: - split up into n patches - describe Signed-off-by: Stephen Warren <[email protected]>
DT isn't meant to prescribe a certain HW configuration; it's simply there to represent the actual HW setup. So, whether the GPIO pins are "pre-muxed" to the UART or not is entirely unrelated to DT. Most pins on the GPIO expansion header are set up as GPIO in by default solely because there's no way to know ahead of time what the user will use those pins for. This means that if the RPi was to actively drive those pins to a particular output state at boot, then one/both of the following could happen:
The only way to prevent those potential issues is to have the RPi not actively drive the signals by default, until explicitly instructed (via HAT EEPROM content for example) how those signals will be used (or should be configured). However, some of the GPIO expansion header signals have a known dedicated purpose. For example, two of the pins are used for the HAT EEPROM I2C bus. For pins with such a dedicated purpose, it is entirely safe to configure them at boot, since it's known which are input vs. output etc. I would argue that the console UART pins fall into this category; they have a dedicated purpose. I don't sure if the HAT specification defines those pins with a fixed purpose, but the Raspbian images certainly use those pins for serial console by default without explicit acknowledgement-from/interaction-with the end-user, so at the very least they have a de-facto dedicated purpose. Even if the user were to connect the UART pins to some other external device (i.e. not a host's serial port) in an external circuit, they'd have to do so with the full knowledge that a standard RPi SW stack would use the TX pin as an output, and toggle it by default with serial data, and hence they would have to design their external circuit to be compatible with this fact. My expectation is that the FW would configure all fixed-purpose pins at boot but obviously leave all the undedicated pins at the SoC default (GPIO in w/ pull). IIUC, this is exactly what it does on RPi 0/1/2. At least, that's the reasoning NVIDIA applied when choosing the default pinmux setup for the Jetson TX1 Developer Kit's GPIO expansion header, which happens to have the same pinout as the RPi 40-pin connector. BTW, what do config.txt's init_uart_baud and init_uart_clock options do on the RPi 3? Do they still affect the PL01x UART? I suppose that is backwards compatible in a sense, but if you consider those options to semanticalyl be related to configuration of the console (rather than configuration of a particular UART HW module), then they should configure the mini UART. |
Thanks for the clarification. Currently both init_uart_clock and init_uart_baud still apply to the PL01x. init_uart_clock is meaningless for the mini-UART since the source clock is the core clock, but I think it would be reasonable to pre-configure the mini-UART using the value in init_uart_baud. |
pelwell, did you get a chance to think about this? I'd like to get the U-Boot support for RPi 3 upstream ASAP (i.e. within the next ~3 weeks, before the current merge window closes), and it'd be nice not to have to include all the extra pinmux and UART setup code if at all possible. Thanks! |
I'm optimistic I can look at this on Thursday, but probably not before. |
Hmm. The existence of pi3-disable-bt-overlay.dts and pi3-miniuart-bt-overlay.dts will complicated this rather. How is code other than the DT-aware Linux kernel (e.g. consider U-Boot, bare metal code, RiscOS?) meant to know whether the mini UART or the regular UART is supposed to be used? I'm confused why there are overlays to promote all kinds of different HW setups rather than just standardizing on one working configuration. |
The overlays use DT aliases (serial0 and serial1) to indicate which UART is the primary in the sense that it has the console. The firmware already reads these aliases, using them to rewrite cmdline.txt replacing serial0 and serial1 with the appropriate UART for the platform, so it should simply be a matter of writing some initialisation code for the mini UART and calling it as necessary. Some of our users rely on the more capable (larger FIFOs, 8+1 bits) UART for their own applications and are prepared to accept lower BT performance (or forego it completely). Other OSs are free to implement any policy they like - forcing a particular hardware configuration, for example - but as long as Linux has the flexibility why wouldn't we give users the choice? |
@swarren there is a test firmware here: It includes this from @pelwell
It will appear in next official firmware update (probably in the next few days). |
@popcornmix I'm afraid that firmware doesn't work for me; I just get a rainbow square on HDMI and nothing else. Switching back to the latest files in firmware.git/boot/ works fine, and I changed nothing else either changing to or from the FW in that .zip file. |
The situation is a bit more complicated with that firmware than simply "doesn't work": On the RPi3, in either 32- or 64-bit mode, with U-Boot hard-coded to use the mini UART, everything works, with or without U-Boot initializing the pinmux or baud rate of the mini UART. That last part is good since it means the enhancements work. On the RPi 3 with U-Boot hard-coded to use the PL01x (and without any DT overlay specified in config.txt to request the FW/kernel do the same), I see the HDMI rainbow. I guess when the ARM touches the unclocked/reset PL01x, there's some system-/bus-level error which triggers the rainbow? On the RPi2, with U-Boot hard-coded to use either the PL01x or mini UART, I see the HDMI rainbow. On an RPi1 B+, with U-Boot hard-coded to use a PL01x, I see the HDMI rainbow. On an RPi1 B+, with U-Boot hard-coded to use the mini UART, it seems like the system is rapidly repeatedly rebooting without fully achieving HDMI sync, since my HDMI monitor keeps repeating the "no signal" display in a way that I think means sync is appearing and disappearing. Or, perhaps the Pi is simply hanging with no HDMI output at all. So I guess that firmware was tested on the RPi3 but not elsewhere, where the DT defaults or alias values for the UART selection are different? |
Sorry, I think the issues I saw with the RPi2 and RPi1 B+ were because I'd forgotten to disable the config.txt options I used to make AArch64 booting work on the RPi3. I've now seen both of those boards work with the new firmware. But now I'm not convinced the new FW is actually enabling the mini UART in the aux module, setting its baud rate, and setting up the pinmux, although I swear this did work before. I think I'm going to give up on testing this tonight and come back some other time. |
kernel: BCM270X_DT: Switch Compute Module to MMC kernel: pwm overlays: Params must have in-overlay targets kernel: BCM270X_DT: Build and document the wittypi overlay firmware: di_adv: Avoid setting undefined flags in first deinterlaced frame firmware: di_adv: acquire user and main when we are releasing every frame See: #546 firmware: arm_loader: Initialise the mini-UART when appropriate See: #553 firmware: vchi_services: Increase number of connections to services from 3 to 8 See: #567 firmware: audio_decode: Don't report format changes when passthough is enabled See: xbianonpi/xbian#807
kernel: BCM270X_DT: Switch Compute Module to MMC kernel: pwm overlays: Params must have in-overlay targets kernel: BCM270X_DT: Build and document the wittypi overlay firmware: di_adv: Avoid setting undefined flags in first deinterlaced frame firmware: di_adv: acquire user and main when we are releasing every frame See: raspberrypi/firmware#546 firmware: arm_loader: Initialise the mini-UART when appropriate See: raspberrypi/firmware#553 firmware: vchi_services: Increase number of connections to services from 3 to 8 See: raspberrypi/firmware#567 firmware: audio_decode: Don't report format changes when passthough is enabled See: xbianonpi/xbian#807
@pelwell @swarren How do I use mkknlimg on a non-kernel binary to ensure overlays get applied on RPI3 with my custom firmware? $ ./linux/scripts/mkknlimg test.bin kernel7.img
Adding --dtok and --283x does help me get rid of the error, but I don't see the overlays get applied while booting (get no prints on uart0). I tested this by adding pl011 support to @swarren rpi-3-aarch64-demo. (my changes here https://github.com/sukantoghosh/rpi-3-aarch64-demo/commits/pl01x_master) My config.txt: enable_uart=1 |
I've tested PL011 on the RPi3 in 32-bit mode by running the RPi2 port of U-Boot on it. I did use the --dtok option to mkknlimg, but not --283x. A bit more info is at https://github.com/swarren/u-boot/blob/rpi_dev/arch/arm/mach-bcm283x/Kconfig#L47. I only used dtoverlay=pi3-miniuart-bt in config.txt. I wonder if the pi3-disable-bt overlay causes problems applying the other one for some reason? In this U-Boot configuration, don't use kernel_old=1. Using that option might also be why my rpi-3-aarch64-demo doesn't work with PL011; I think it prevents the FW from applying DT overlays. |
@sukantoghosh Because mkknlimg doesn't see any compatible string it recognises it is going into manual mode - you have to tell it which flags to set. You need:
You don't need |
@swarren |
@swarren Placing @pelwell I did try only --dtok and I didn't work. BTW I see that the prebuilt kernel7.img in firmware repo has some more tags. Not sure if they are making a difference here.
|
Yes I see the same results with mkknlimg, I do not get
is there an other options or build flag I need to get the addresses? for 270x and 283x ? I'd like to get as close to foundation kernel as I can. |
Looks like those extra fields are only in the 4.4 tree (and above) version of the script, not the 4.1 tree |
those are y/n though not the same type of values, I'll run tests with the 4.4 tree today, Maybe if they are using the 4.4 version of the script on the foundation 4.1 kernels that is what happens when you use the 4.1 version of knlinfo, it doesn't know to put y or n. I'm just off to work but once I get there I'll run the 4.4 script on my kernel and check it with the 4.1 knlinfo see fi it looks the same. Thanks for the idea @lurch |
yup @lurch was right, I used the 4.4 version of mkknlimg using --dtok --270x and with the 4.1 version of knlinfo I get
so that is all they are doing I'll switch my builds to use the 4.4 version of the script so it matches, thanks for the help @lurch Or maybe the version from 4.4 should get moved into the 4.1 tree? |
I have to confess that I only got the idea after getting an auto-notification email from GitHub saying that raspberrypi/linux#1195 had been closed. |
think I should open a new ticket to ask for the mkknlimg form 4.4 to be copied into 4.1 branch? since the official kernel.img and kernel7.img which is 4.1 but is using the 4.4 mkknlimg tool with 270x enabled ? I want to release my 4.1.21 today but I'd like to get that resolved first if at all possible. |
and now the current 4.1.21 kernel in the firmware repo is using the mkknlimg from 4.1 and not 4.4 like the hash before it ;) I guess nothing needs to get copied after all. |
kernel: BCM270X_DT: Switch Compute Module to MMC kernel: pwm overlays: Params must have in-overlay targets kernel: BCM270X_DT: Build and document the wittypi overlay firmware: di_adv: Avoid setting undefined flags in first deinterlaced frame firmware: di_adv: acquire user and main when we are releasing every frame See: raspberrypi#546 firmware: arm_loader: Initialise the mini-UART when appropriate See: raspberrypi#553 firmware: vchi_services: Increase number of connections to services from 3 to 8 See: raspberrypi#567 firmware: audio_decode: Don't report format changes when passthough is enabled See: xbianonpi/xbian#807
See: raspberrypi/linux@adc10c5 firmware: arm_loader: Use the correct UART on non-DT systems See: raspberrypi#553 firmware: vchiq_arm: Tweak the logging output firmware: arm_loader: Add enable_uart setting
See: raspberrypi/linux#1361 kernel: vchiq_arm: Access the dequeue_pending flag locked See: raspberrypi/linux@a7419d5 kernel: BCM270X_DT: Add pi3-act-led overlay See: raspberrypi/linux#1363 firmware: sdram: cache the last set_frequency firmware: pwm_sdm: Set SDRAM turbo frequency to default if pwm_sdm is enabled See: https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=136445 firmware: vchiq_lib: Don't overwrite loop count mid-loop See: https://discourse.osmc.tv/t/frequent-random-muting-then-freezing/9875/104 firmware: arm_loader: Change mini-UART initialisation order See: raspberrypi#553
Quick question on the behavior of enable_uart. Is it only applicable to Raspberry Pi3 or is it also used for other platforms? Thanks in advance. |
It applies to all Pis and CMs, but the setting defaults to 1 (true, enabled) on devices where the main UART isn't used for Bluetooth. |
kernel: BCM270X_DT: Switch Compute Module to MMC kernel: pwm overlays: Params must have in-overlay targets kernel: BCM270X_DT: Build and document the wittypi overlay firmware: di_adv: Avoid setting undefined flags in first deinterlaced frame firmware: di_adv: acquire user and main when we are releasing every frame See: raspberrypi#546 firmware: arm_loader: Initialise the mini-UART when appropriate See: raspberrypi#553 firmware: vchi_services: Increase number of connections to services from 3 to 8 See: raspberrypi#567 firmware: audio_decode: Don't report format changes when passthough is enabled See: xbianonpi/xbian#807
See: raspberrypi/linux@adc10c5 firmware: arm_loader: Use the correct UART on non-DT systems See: raspberrypi#553 firmware: vchiq_arm: Tweak the logging output firmware: arm_loader: Add enable_uart setting
See: raspberrypi/linux#1361 kernel: vchiq_arm: Access the dequeue_pending flag locked See: raspberrypi/linux@a7419d5 kernel: BCM270X_DT: Add pi3-act-led overlay See: raspberrypi/linux#1363 firmware: sdram: cache the last set_frequency firmware: pwm_sdm: Set SDRAM turbo frequency to default if pwm_sdm is enabled See: https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=136445 firmware: vchiq_lib: Don't overwrite loop count mid-loop See: https://discourse.osmc.tv/t/frequent-random-muting-then-freezing/9875/104 firmware: arm_loader: Change mini-UART initialisation order See: raspberrypi#553
Sorry about the necro... Following a comment from @lurch above, I have written some basic UART documentation which, if the participants of this thread have time, I would like to have checked over. Don't worry about grammar etc, that will be sorted by our copy editors here, but content comments I am looking for. I reckon it's a bit skimpy so far, so if people could give pointers on where things could be expanded that would be great. https://github.com/raspberrypi/documentation/blob/JamesH65-uart-docs/configuration/uart.md |
@JamesH65 could you submit that as a "WIP" PR, so that we have somewhere suitable to leave comments? :) |
Hi @lurch, didn't realise you could not comment on a branch. I'll PR it. |
Serial console seems to give a incorrect baudrate. Overriding frequencies to previous Raspberries in /boot/config.txt helps: everything works as normal. After some iterations, I found that setting 'gpu_freq=300' solves the problem, although that is the default setting on a rpi 3. Probably someone reads that value to initialise the baudrate generator, and uses the old default 'gpu_freq=250' if the value is not set. This is almost certainly done in the closed-source /boot/start*.elf files. All those files do contain the texts 'config.tst' as well as 'gpu_freq'. Please repair this issue..
The text was updated successfully, but these errors were encountered: