steaky1212
Posts: 19
Joined: Wed Sep 07, 2011 5:18 pm

Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART)?

Tue Mar 01, 2016 9:20 am

Hi,

I saw a brief comment on the forum (The Raspberry Pi 3 Model B Q&A thread) that the new Bluetooth module uses the PL011 UART and the GPIO header will be using Broadcom's mini-UART instead. Is this the case?

I have a project where I needed a 9-bit UART and so was modifying the parity bit (mark/space/one/zero) on an 8bit UART to get this to work. As the mini-UART is not fully 16550 compliant (and doesn't have a parity bit), then this will not work.

Am I correct in all of this? And if so then how do I get a fully functioning UART on the RPi3 (FTDI chips are not an option)?

Thanks in advance,
Steaky

fanoush
Posts: 1114
Joined: Mon Feb 27, 2012 2:37 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Tue Mar 01, 2016 9:57 am

If this is an issue then hopefully it should be possible to create device overlay that disables bluetooth and puts the uart right back where it was. Atleast the page http://elinux.org/RPi_BCM2835_GPIOs lists this as alternative configuration (ALT0 vs ALT5 for GPIO14,15)

BloodyCactus
Posts: 2
Joined: Tue Mar 01, 2016 3:06 pm
Location: Lexington VA

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Tue Mar 01, 2016 3:10 pm

noo! I hope this is wrong. I use the hardware uart on the gpio pins for rs485. Swapping this to the crappy mini uart is a bad design decision. ugh.

lb
Posts: 301
Joined: Sat Jan 28, 2012 8:07 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Tue Mar 01, 2016 4:32 pm

Yes, this is a *serious* shortcoming! I may need parity for some applications, too.
Is the GPIO configuration flexible enough to swap around the UARTs? Bluetooth doesn't really need all that much bandwidth, right?

Edit: looking at the possible pin configurations and the Pi 3 DT configuration, it looks like it is possible to just swap around the UARTs, either PL011 or the Mini UART could have been used for Bluetooth. So why was the PL011 used?

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 33356
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Tue Mar 01, 2016 5:32 pm

BloodyCactus wrote:noo! I hope this is wrong. I use the hardware uart on the gpio pins for rs485. Swapping this to the crappy mini uart is a bad design decision. ugh.
Use a Pi2?

As to the decision, sometimes, decisions have to be made. Since the huge majority of people are more likely to want BT that this UART in exactly the format you want, I guess the decision was fairly simple.
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

BloodyCactus
Posts: 2
Joined: Tue Mar 01, 2016 3:06 pm
Location: Lexington VA

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Tue Mar 01, 2016 5:49 pm

jamesh wrote:As to the decision, sometimes, decisions have to be made. Since the huge majority of people are more likely to want BT that this UART in exactly the format you want, I guess the decision was fairly simple.
yes it is a simple decision to be sure, if you dont think about it. its just boneheaded decision really.

1 - existing users, existing solutions, expect things to stay the same.
2 - BT is low power, low speed. it does not need a full hardware uart.

a much simpler decision to make would be to add BT with the mini uart and not break existing solutions.

someone didnt spend the 5 seconds it takes to think about this change.

at least, it looks like it can be reconfigured so not all is lost!

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3133
Joined: Thu Jul 11, 2013 2:37 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Tue Mar 01, 2016 5:54 pm

BloodyCactus wrote:
yes it is a simple decision to be sure, if you dont think about it. its just boneheaded decision really.

1 - existing users, existing solutions, expect things to stay the same.
2 - BT is low power, low speed. it does not need a full hardware uart.

a much simpler decision to make would be to add BT with the mini uart and not break existing solutions.
wrong
someone didnt spend the 5 seconds it takes to think about this change.
Also wrong
at least, it looks like it can be reconfigured so not all is lost!
Correct, you can still use the wifi and steer the PL011 UART pins back to the GPIO header.
Rockets are loud.
https://astro-pi.org

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 33356
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Tue Mar 01, 2016 5:58 pm

BloodyCactus wrote:
jamesh wrote:As to the decision, sometimes, decisions have to be made. Since the huge majority of people are more likely to want BT that this UART in exactly the format you want, I guess the decision was fairly simple.
yes it is a simple decision to be sure, if you dont think about it. its just boneheaded decision really.

1 - existing users, existing solutions, expect things to stay the same.
2 - BT is low power, low speed. it does not need a full hardware uart.

a much simpler decision to make would be to add BT with the mini uart and not break existing solutions.

someone didnt spend the 5 seconds it takes to think about this change.

at least, it looks like it can be reconfigured so not all is lost!
Impressive that someone with a two post count comes striding in thinking he knows better than the very professional and competent engineers at the Foundation, who are on their 4th iteration of a board that's sold 8 million devices. One would think they might actually be pretty good at this sort of thing by now.

Can I suggest that you may not be fully conversant with all the facts, and therefore may not be in the best situation to comment?
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

lb
Posts: 301
Joined: Sat Jan 28, 2012 8:07 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Tue Mar 01, 2016 6:01 pm

Ignoring the trolling, it would be interesting to know why the PL011 UART is used for the BT, and if it's actually possible to use the Mini UART with BT (with lower performance or whatever).

steaky1212
Posts: 19
Joined: Wed Sep 07, 2011 5:18 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Wed Mar 02, 2016 8:34 am

Hi,

It's really difficult to ask why something was done in a particular way without frustrating the engineer that worked on it - one of my weekly challenges at code/design review meetings. I am sure design reviews are carried out at RPF so I'm not suggesting that this was a boneheaded decision.

Datasheets for the BCM43438 are pretty hard to come by so there's probably some hidden qwerk that requires a fully compliant UART to operate so the mini-UART could not be used etc etc. With this in mind:
- It would be interesting to know why the PL011 was used over the mini-UART.
- Is there any way that the mini-UART could be used for the Bluetooth and the PL011 is exposed on the GPIO header?

I know my goto response for the second question would be NO (I deal with those sorts of questions from people who don't understand the system on a daily basis), but in truth the answer is never so simple. The answer is normally "yes BUT the speed will be limited, might drop the odd packet, it doesn't quite fit into the codebase as elegantly, and will take 5x as long".

From some of the answers above I guess that I can just not use the Bluetooth and remap the PL011 to the GPIO header, but (just like a normal customer) I would like to have both Bluetooth and an exposed PL011.

Thanks again,
Steaky

flag26838
Posts: 13
Joined: Wed Mar 02, 2016 12:14 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Thu Mar 03, 2016 10:21 am

Ok guys, a couple of questions:

1) What's the mini-uart? And what's so different from a "normal" UART?
2) How do i get my serial console back in full work on my pi3?

This change should be mentioned in the RaspberryPI3 release notes or in a FAQ, IMHO, at first i thought i had a faulty hardware.

fanoush
Posts: 1114
Joined: Mon Feb 27, 2012 2:37 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Thu Mar 03, 2016 12:10 pm

flag26838 wrote: 2) How do i get my serial console back in full work on my pi3?
viewtopic.php?p=917865#p917865

steaky1212
Posts: 19
Joined: Wed Sep 07, 2011 5:18 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Thu Mar 03, 2016 1:16 pm

More importantly, how do I get the Bluetooth working with the mini-UART? Or is this mapping not possible?

lb
Posts: 301
Joined: Sat Jan 28, 2012 8:07 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Thu Mar 03, 2016 2:33 pm

The Mini UART has less buffering, so you may want to use a lower baud rate. That's not a big deal for most use cases, I guess.
What's more problematic is that the Mini UART uses the core clock, which can vary, particularly in case of thermal events or when there's too little power. However, this applies to *all* users of the Mini UART...

Maybe the baud rate should be tuned by the firmware whenever the core clock is changed. There would still be glitches, but it wouldn't just completely fail to work like it currently does.
A workaround for now (although not nice) would be to fix core clock to a low speed (e.g. 250 MHz).

Mapping the Mini UART to Bluetooth pins is possible. I have yet to test the Mini UART with Bluetooth. My Device Tree knowledge is quite limited, but I'll give it a try. :)

lb
Posts: 301
Joined: Sat Jan 28, 2012 8:07 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Tue Mar 08, 2016 8:17 am

FWIW, with the new pi3-miniuart-bt overlay, Bluetooth works fine and stable with the Mini UART. I was able to scan, pair, send files over OBEX, and so on. Of course, it is 8x slower than the PL011 UART at 115200 baud. Keep in mind to adjust the "console" value in cmdline.txt and to lock the core clock with core_freq=250 or alternatively force_turbo=1 in config.txt. Also, you have to adjust the systemd control file to use ttyS0 and a lower baud rate of 115200 for hciattach.

steaky1212
Posts: 19
Joined: Wed Sep 07, 2011 5:18 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Tue Mar 08, 2016 8:28 am

lb wrote:FWIW, with the new pi3-miniuart-bt overlay, Bluetooth works fine and stable with the Mini UART. I was able to scan, pair, send files over OBEX, and so on. Of course, it is 8x slower than the PL011 UART at 115200 baud. Keep in mind to adjust the "console" value in cmdline.txt and to lock the core clock with core_freq=250 or alternatively force_turbo=1 in config.txt. Also, you have to adjust the systemd control file to use ttyS0 and a lower baud rate of 115200 for hciattach.
lb,

Thanks for looking into that. Now I just need to understand how to apply the overlays :lol: .

Steaky

twelvearrays
Posts: 2
Joined: Wed Mar 09, 2016 11:15 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Wed Mar 09, 2016 11:52 pm

@steaky1212

To apply an overlay edit your /boot/config.txt file

Code: Select all

sudo nano /boot/config.txt 
Then add:

Code: Select all

dtoverlay=pi3-miniuart-bt-overlay
Save and then reboot.

I have gotten that far! LOL I now have serial communication over GPIO14 & GPIO15 but now I have now bluetooth.
I receive this error:

Code: Select all

hciuart.service - Configure Bluetooth Modems connected by UART
   Loaded: loaded (/lib/systemd/system/hciuart.service; enabled)
   Active: failed (Result: exit-code) since Wed 2016-03-09 23:44:11 UTC; 48s ago
  Process: 376 ExecStart=/usr/bin/hciattach /dev/ttyS0 bcm43xx 115200 noflow - (code=exited, status=1/FAILURE)
with this command:

Code: Select all

systemctl status hciuart.service
config.txt:

Code: Select all

dwc_otg.lpm_enable=0 console=serial1,115200  console=tty1 root=/dev/mmcblk0p2  kgdboc=serial1,115200 rootfstype=ext4 elevator=deadline fsck.repair=yes  rootwait
hcitool dev sees no devices?

Any advice?

lb
Posts: 301
Joined: Sat Jan 28, 2012 8:07 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Thu Mar 10, 2016 9:50 am

@twelvearrays

Lock the core clock by adding core_freq=250 to config.txt. Also try launching hciattach manually, what does it say?

twelvearrays
Posts: 2
Joined: Wed Mar 09, 2016 11:15 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Thu Mar 10, 2016 5:04 pm

@lb
lb wrote:@twelvearrays

Lock the core clock by adding core_freq=250 to config.txt. Also try launching hciattach manually, what does it say?
I added core_freq=250 and tried to attach manually and I get a timeout.

Code: Select all

sudo hciattach ttyS0 bcm43xx 115200
bcm43xx_init
Initialization timed out.

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

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Fri Mar 11, 2016 7:06 pm

Change the serial1 in cmdline.txt to serial0. (That use of serial1 was a short-lived special needed when the miniuart overlay was first added - with the latest firmware it is no longer necessary, and serial0 is always the non-BT uart).

User avatar
Arjan
Posts: 265
Joined: Sat Sep 08, 2012 1:59 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Sat Mar 12, 2016 4:22 pm

steaky1212 wrote: - Is there any way that the mini-UART could be used for the Bluetooth and the PL011 is exposed on the GPIO header?
Did we get an answer for above?

I am using the PL011 for several applications. It would be a shame if the RPi 3 does not support the PL011 on the GPIO header.

Thanks, Arjan
http://www.raspberrypi-dmx.com/
http://www.raspberrypi-dmx.org/
Open Source DMX/RDM/MIDI/OSC/Art-Net/sACN solutions

clivem
Posts: 114
Joined: Sun Aug 03, 2014 11:18 am

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Sat Mar 12, 2016 7:23 pm

dtoverlay=pi3-miniuart-bt

User avatar
Arjan
Posts: 265
Joined: Sat Sep 08, 2012 1:59 pm

Re: Raspberry Pi 3 - Bluetooth PL011 UART (9bit on mini-UART

Sun Mar 13, 2016 12:46 pm

clivem wrote:dtoverlay=pi3-miniuart-bt
Thanks. But this is for Linux. Are there any detailed instructions for a baremetal environment?

- Arjan
http://www.raspberrypi-dmx.org/
Open Source DMX/RDM/MIDI/OSC/Art-Net/sACN solutions

Return to “Advanced users”