Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Raspberry Pi 3 + UART/Bluetooth issues


Published on

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.

You can also consult my Github Gist on configuring UART and Bluetooth on Arch Linux.

Published in: Engineering
  • Follow the link, new dating source: ❤❤❤ ❤❤❤
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating for everyone is here: ♥♥♥ ♥♥♥
    Are you sure you want to  Yes  No
    Your message goes here

Raspberry Pi 3 + UART/Bluetooth issues

  1. 1. Raspberry Pi 3 + UART/Bluetooth Issues By: Yeo Kheng Meng ( v1.6 (30 Mar 2016) 1 Video of my presentation can be found here: •
  2. 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 2
  3. 3. Whats new? (Board) Specifications Raspberry Pi 2 Raspberry Pi 3 LED positions Top left Bottom left microSD storage Spring No Spring 3
  4. 4. UART (Debug console) issues on RPi 3 4
  5. 5. UART Debug Console + USB-TTL cable • Universal asynchronous receiver/transmitter 5
  6. 6. UART (Serial Debug console) issue Received output. • Garbled or nothing • Output is 72000 instead of 115200 baud Expected output 6
  7. 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 7
  8. 8. System on Chip BCM2837 (RPi 3) Hardware architecture (RPi 3) SDIO BCM43438 wireless chip Bluetooth 4.1Wifi 8 • UART0: Full UART (/dev/ttyAMA0) • UART1: “mini UART” (/dev/ttyS0) UART1 UART0
  9. 9. Why is UART1 a problem? BCM2835 datasheet: Page 10- 11 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. 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. 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) • 11
  12. 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. 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. 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 • • • My setup instructions using that package • 14
  15. 15. Useful links 1. BCM2835 datasheet: 2. Original Github issue: 3. “enable_uart=1” explanation by Raspberry Pi Foundation Engineer Phil Elwell 4. UART DT overlays: 5. Detailed DT overlays: 6. Arch Linux ARM Bluetooth forum issue thread: 7. Instructions to enable Arch Linux Bluetooth: 15