A talk I gave at Hackware v1.6 about issues relating to the UART and Bluetooth issues associated with the new Raspberry Pi 3.
The recorded video of this talk can be found here. https://engineers.sg/video/raspberry-pi-3-uart-bluetooth-issues--609
You can also consult my Github Gist on configuring UART and Bluetooth on Arch Linux. https://gist.github.com/yeokm1/d6c3ca927919c61257cd
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
Raspberry Pi 3 + UART/Bluetooth issues
1. Raspberry Pi 3 + UART/Bluetooth Issues
By: Yeo Kheng Meng (yeokm1@gmail.com)Hackware v1.6 (30 Mar 2016)
1
Video of my presentation can be found here:
• https://engineers.sg/video/raspberry-pi-3-uart-bluetooth-issues--609
2. Whats new? (Features)
Specifications Raspberry Pi 2 Raspberry Pi 3
CPU BCM2836
Cortex-A7
900Mhz
ARMv7
BCM2837
Cortex-A53
1.2Ghz
ARMv8 (64-bit)
GPU 250Mhz Videocore IV
1080p,30FPS,H.264 video decoding
400Mhz Videocore IV
1080p,60FPS,H.264 video decoding
Wifi - 802.11n, 2.4Ghz only,
single stream 150Mbps
Bluetooth - Bluetooth 4.1 (Dual-mode)
Classic and BLE
2http://raspi.tv/2016/raspberry-pi-3-model-b-launches-today-64-bit-quad-a53-1-2-ghz-bcm2837
3. Whats new? (Board)
Specifications Raspberry Pi 2 Raspberry Pi 3
LED positions Top left Bottom left
microSD storage Spring No Spring
3
6. UART (Serial Debug console) issue
Received output.
• Garbled or nothing
• Output is 72000 instead of 115200 baud
Expected output
6
7. Hardware architecture (≤ RPi 2)
System on Chip
BCM2835 (RPi 1 B/B+)
/ BCM2836 (RPi 2)
• BCM283x has 2 UARTs
• UART0: Full UART (/dev/ttyAMA0)
• Based on ARM Primecell PL011
• Larger FIFO buffers
• 16x8 transmit
• 16x12 receive
• High performance full feature serial port
• Older RPi models breaks out UART0 to the pin header
• Default use: Debug console
• UART1: “mini UART” (/dev/ttyS0)
UART0
UART1
BCM2835 datasheet: Page 10
https://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
7
8. System on Chip
BCM2837 (RPi 3)
Hardware architecture (RPi 3)
SDIO
BCM43438 wireless chip
http://raspi.tv/2016/raspberry-pi-3-model-b-launches-today-64-bit-quad-a53-1-2-ghz-bcm2837
Bluetooth 4.1Wifi
8
• UART0: Full UART (/dev/ttyAMA0)
• UART1: “mini UART” (/dev/ttyS0)
UART1
UART0
9. Why is UART1 a problem?
BCM2835 datasheet: Page 10- 11
https://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
9
Note:
I use BCM2835 datasheet as
datasheets of newer chips have not
been released by Broadcom.
Mini UART implementation should be
the same across BCM283x.
Problem Explanation
• 𝑏𝑎𝑢𝑑𝑟𝑎𝑡𝑒 =
𝑐𝑜𝑟𝑒𝐹𝑟𝑒𝑞
8 ∗(𝑏𝑎𝑢𝑑𝑅𝑎𝑡𝑒𝑅𝑒𝑔+1)
• RPi 3 boot time core frequency is 400Mhz
• RPI baud rate default 115200
• 115200 =
400 000 000
8 ∗ (𝑏𝑎𝑢𝑑𝑅𝑎𝑡𝑒𝑅𝑒𝑔+1)
• baudRateReg calculated on core
frequency retrieved at boot time
• Frequency scaling, may drop to 250Mhz to
save power under low load
• Fluctuating core frequency -> Fluctuating
baud rate
10. Who is affected?
Anyone who uses the TX/RX header pins
• People who use the serial debug console
• Headless systems
• RPi shields that uses the UART
• Eg. RS232, GPS/GSM
• Device-Device communication to other MCUs or MPUs
• Require high UART performance (aka full UART) and Bluetooth
10
11. How do we solve this? Part (1/2)
Lock a constant core frequency during boot time
• (For old firmware) Add “core_freq=250” XOR “force_turbo=1” to /boot/config.txt
• Lock core core_freq to minimum or maximum (400Mhz) respectively
• Minimum -> RPi 3 performance will be affected.
• Maximum -> Requires good cooling.
• Can still be throttled to 250 Mhz under low voltage or high temperature conditions
• (For new firmware) Add “enable_uart=1” to /boot/config.txt
• All RPi distributions will eventually support this option going forward
• Similar to “core_freq=250” with clearer intent
• Raspbian latest stable updates does not support this yet
• Need bleeding-edge firmware update: “sudo apt-get install rpi-update” & “sudo rpi-update”
• Arch Linux requires an update to use this option: Just use “pacman –Syu”
• Distros that support this option will disable debug console if “enable_uart=1” is not set
• “enable_uart=1” explanation Raspberry Pi Foundation Engineer Phil Elwell (pelwell)
• https://github.com/raspberrypi/firmware/issues/553#issuecomment-199486644
11
12. How do we solve this? Part (2/2)
Remap header pins to use Full UART with device
tree overlay (pin-crossbar)
• Add “dtoverlay=pi3-disable-bt” to /boot/config.txt
• Disables Bluetooth in the process as UART1 is unconnected
• Requires extra “sudo systemctl disable hciuart” for Raspbian
• Or add “dtoverlay=pi3-miniuart-bt” to /boot/config.txt
• Bluetooth now uses mini-UART
• Need to add “core_freq=250” or “force_turbo=1” to
/boot/config.txt so Bluetooth via mini UART is usable
• Edit “/lib/systemd/system/hciuart.service” and replace
“ttyAMA0” with “ttyS0” for Raspbian
• Bluetooth’s performance will be affected. Only low-
throughput BLE may be effectively usable.
• If any of these options are used, the serial console will
be enabled unless “enable_uart=0”
12
System on Chip
BCM2837 (RPi 3)
SDIO
BCM43438 wireless chip
Bluetooth 4.1Wifi
• UART0: Full UART (/dev/ttyAMA0)
• UART1: “mini UART” (/dev/ttyS0)
UART0
UART1
13. Solution summary
Set in /boot/config.txt
• Serial console and normal Bluetooth
• Lock frequency
• Old: “core_freq=250” XOR “force_turbo=1”
• New: ”enable_uart=1”. Add “force_turbo=1” to lock at high frequency.
• High performance Serial
• Switch UART0 and UART1 pins
• No Bluetooth
• “dtoverlay=pi3-disable-bt”
• (Raspbian) Run “sudo systemctl disable hciuart”
• Slow Bluetooth Classic or BLE
• “dtoverlay=pi3-miniuart-bt” AND (“core_freq=250” XOR “force_turbo=1”)
• (Raspbian) Edit “/lib/systemd/system/hciuart.service” and replace “ttyAMA0” with “ttyS0”
• Add “enable_uart=0” to disable debug console
• The use of the mini UART will always require locking of Core frequency
13
14. Arch Linux Bluetooth’s issues
• Raspbian uses “pi-bluetooth” to provide Bluetooth features
• “pi-bluetooth” has not been ported to Arch Linux
• Someone has posted a temporary package to AUR
• https://archlinuxarm.org/forum/viewtopic.php?f=67&t=10017s
• https://aur.archlinux.org/packages/pi-bluetooth/
• My setup instructions using that package
• https://gist.github.com/yeokm1/d6c3ca927919c61257cd
14
15. Useful links
1. BCM2835 datasheet: https://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
2. Original Github issue: https://github.com/raspberrypi/firmware/issues/553
3. “enable_uart=1” explanation by Raspberry Pi Foundation Engineer Phil Elwell
https://github.com/raspberrypi/firmware/issues/553#issuecomment-199486644
4. UART DT overlays: http://www.briandorey.com/post/Raspberry-Pi-3-UART-Boot-Overlay-Part-Two
5. Detailed DT overlays: https://github.com/raspberrypi/linux/blob/rpi-4.1.y/arch/arm/boot/dts/overlays/README
6. Arch Linux ARM Bluetooth forum issue thread: https://archlinuxarm.org/forum/viewtopic.php?f=65&t=9961
7. Instructions to enable Arch Linux Bluetooth: https://gist.github.com/yeokm1/d6c3ca927919c61257cd
15