figatk
Posts: 6
Joined: Wed Sep 07, 2016 1:01 pm

Re: Overlay to remap Pi 3 UART

Wed Sep 07, 2016 2:57 pm

Yeah I got exactly that.

Code: Select all

[email protected]:~ $ raspi-gpio get 14
GPIO 14: level=1 fsel=4 alt=0 func=TXD0
[email protected]:~ $ raspi-gpio get 15
GPIO 15: level=1 fsel=4 alt=0 func=RXD0
Okay thanks for your help, I really didn't know enough about this side of things so I assumed the problem lied here. I'll start trouble shooting elsewhere now, starting with the wiring. Cheers!

Heartburnb4pi
Posts: 4
Joined: Mon Dec 30, 2013 5:13 pm

Re: Overlay to remap Pi 3 UART

Wed Sep 14, 2016 8:40 pm

I just want to thank PhilE and anyone/everyone else who contributed to this UART fix for the Pi 3. I have a project where I'm communicating with an Arduino via a serial port using /dev/ttyAMA0. I recently bought a Pi3, which I LOVE, but was chagrined when I couldn't get it to talk to the Arduino. I'm not using Bluetooth at the moment, so discovering this thread and then invoking the new pi3-disable-bt overlay got me up and running quickly. Great work guys, thank you so much! :D

thof
Posts: 15
Joined: Mon Mar 04, 2013 2:08 pm

Re: Overlay to remap Pi 3 UART

Fri Sep 23, 2016 2:27 pm

I would like to use the expertise here to find a solution to my problem.

I would like to use the pi3-miniuart-bt overlay to have access to the uart same as on a rpi2 and still be able to use bluetooth.
For this I added the following two lines in /boot/config.txt:

Code: Select all

dtoverlay=pi3-miniuart-bt
enable_uart=1
However bluetooth seems not to be working. Should I add something else or change an other file?

Thanks in advance!

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

Re: Overlay to remap Pi 3 UART

Fri Sep 23, 2016 2:44 pm

With pi3-miniuart-bt applied, enable_uart=1 does nothing at all because the uart is enabled by default.

Because of the smaller FIFOs in the miniuart and the lack of flow control to the BT modem, it is necessary to reduce the baud rate requested by Bluetooth. Edit /lib/systemd/system/hciuart.service and change the 921600 to 460800.

Don't expect to run high bandwidth devices like speakers, but it should manage a keyboard and mouse.

thof
Posts: 15
Joined: Mon Mar 04, 2013 2:08 pm

Re: Overlay to remap Pi 3 UART

Fri Sep 23, 2016 2:53 pm

No problem if enable_uart=1 does nothing, I read somewhere it was good to add it anyway.

For BLE tasks the baudrate should be enough...

Changed the baudrate and rebooted, at first I thought it was working as the hciuart service was reporting:

Code: Select all

● hciuart.service - Configure Bluetooth Modems connected by UART
   Loaded: loaded (/lib/systemd/system/hciuart.service; enabled)
   Active: activating (start) since Fri 2016-09-23 14:46:04 UTC; 33s ago
  Control: 420 (hciattach)
   CGroup: /system.slice/hciuart.service
           └─420 /usr/bin/hciattach /dev/serial1 bcm43xx 460800 noflow -
but hcitool dev or bluetoothctl shows no devices.
After those commands hciuart reports:

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 Fri 2016-09-23 14:46:42 UTC; 1min 38s ago
  Process: 420 ExecStart=/usr/bin/hciattach /dev/serial1 bcm43xx 460800 noflow - (code=exited, status=1/FAILURE)

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

Re: Overlay to remap Pi 3 UART

Fri Sep 23, 2016 3:04 pm

Yes, "enable_uart=1" is a safe setting for all Pis, I just wanted you to understand.

Ah yes, there is one more step: the other downside to the miniuart is that its clock varies with the VPU core. Add "core_freq=250" to config.txt to stop the clock from varying. "force_turbo=1" will also stop it changing, but your Pi3 will get rather hot.

thof
Posts: 15
Joined: Mon Mar 04, 2013 2:08 pm

Re: Overlay to remap Pi 3 UART

Fri Sep 23, 2016 3:13 pm

Excellent, that works! Thanks for the quick response!

For other that would like to use bluetooth through the miniuart and keep the old/original uart mapping for other things (old shields or whatever for example):

Add the following to /boot/config.txt:

Code: Select all

dtoverlay=pi3-miniuart-bt
core_freq=250
Change the baudrate from 921600 to 460800 in /lib/systemd/system/hciuart.service:

Code: Select all

ExecStart=/usr/bin/hciattach /dev/serial1 bcm43xx 460800 noflow -

dgordon42
Posts: 752
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: Overlay to remap Pi 3 UART

Fri Sep 23, 2016 8:20 pm

PhilE wrote:With pi3-miniuart-bt applied, enable_uart=1 does nothing at all because the uart is enabled by default.
@PhilE,
Will having "enable_uart=1" not fix the VideoCore clock at 250MHz in this case on the Pi 3B, rather than having to use "core_freq=250"?

Thanks,
Dave.

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

Re: Overlay to remap Pi 3 UART

Fri Sep 23, 2016 8:34 pm

Good question, but the answer is no. enable_uart could also be called enable_console_uart, since it is the primary/console UART that it concerns:

1) On a Pi where the kernel console output (if enabled in cmdline.txt) would go to the pl011/UART0/ttyAMA0, enable_uart=1 is the default and it doesn't limit core_freq. This includes Pi1, Pi2, PiZero and CM, and Pi3 with dtoverlay=pi3-miniuart-bt.

2) On a Pi where the mini-UART/UART1/ttyS0 is the primary/console UART, i.e. a Pi3, or another Pi with an overlay created to swap the UARTs (the assignment is determined by the DT aliases serial0 and serial1), enable_uart=0 is the default. Setting it to one will set core_freq=250, unless force_turbo=1 is used in which case core_freq=450 (and the ARM is fixed at 1.2GHz - not good for heat and lifetime).

This sounds complicated, but the reasoning is simple. It allows you to get a stable UART for a console by limiting/fixing the core clock on a Pi that needs it, but without penalising a Pi that doesn't - it's a set-and-forget option for your SD cards if you use the kernel console.

dgordon42
Posts: 752
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: Overlay to remap Pi 3 UART

Fri Sep 23, 2016 8:49 pm

Got it. Thanks for the answer, and the quick reply.

Dave.

yoodog
Posts: 9
Joined: Sat Dec 10, 2016 12:45 pm

Re: Overlay to remap Pi 3 UART

Sat Dec 24, 2016 10:26 pm

So, I need:
1. Pi3 to communicate over TX/RX UART to serial Telemetry port on Pixhawk
2. BT to be disabled
3. Use minimal power (it simply redirects packages from Pix to 4G modem)

I have RASPBIAN JESSIE kernel 4.4 fresh installed
Have you changed the default for ttyAMA0?

So, if I edit /boot/config.txt to:
dtoverlay=pi3-miniuart-bt
core_freq=250
enable_uart=1

I should be all set?

Question:
1. Will this set BT completely off? (if, no, what should I edit to have it off permanently?)
2. This will stay intact after restart? (I see your comment and it looks like it should)

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

Re: Overlay to remap Pi 3 UART

Fri Dec 30, 2016 10:50 am

To disable Bluetooth and free UART0/ttyAMA0 for your own use, just add:

Code: Select all

dtoverlay=pi3-disable-bt
You don't need pi3-miniuart-bt or core_freq=250. You don't even need enable_uart=1, but there is no harm in keeping it there. Don't forget to remove any console=serial0 or console=ttyAMA0 from cmdline.txt.

This change will persist after a reboot. If you want to prevent the Bluetooth software from trying to start, type this into a shell:

Code: Select all

sudo systemctl disable hciuart

yoodog
Posts: 9
Joined: Sat Dec 10, 2016 12:45 pm

Re: Overlay to remap Pi 3 UART

Mon Jan 09, 2017 5:18 am

PhilE,
Thank you for the reply!

I have added the line to /boot/config.txt

Code: Select all

dtoverlay=pi3-disable-bt
and removed this from cmdline.txt.

Code: Select all

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=....
but running

Code: Select all

sudo service disable hciuart

gave me this

Code: Select all

disable: unrecognized service
after reboot Pi fails with VFS panic - odd, will try again on a clean install of latest noob.

What I'm trying to archive is to get ser2net talking over UDP between Pi3 and Pixhawk - that are no complete manuals yet.

yoodog
Posts: 9
Joined: Sat Dec 10, 2016 12:45 pm

Re: Overlay to remap Pi 3 UART

Mon Jan 09, 2017 5:51 am

I guess the easiest way to understand would be to edit (tell what to do different on pi3 on latest noob) against this manual http://ardupilot.org/dev/docs/raspberry ... vlink.html

Still need to disable serial ? o__O

dgordon42
Posts: 752
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: Overlay to remap Pi 3 UART

Mon Jan 09, 2017 2:04 pm

yoodog wrote:but running

Code: Select all
sudo service disable hciuart


gave me this

Code: Select all
disable: unrecognized service
Try running:

Code: Select all

sudo systemctl disable hciuart
instead.
yoodog wrote:and removed this from cmdline.txt.

Code: Select all
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=....

after reboot Pi fails with VFS panic - odd, will try again on a clean install of latest noob.
A bad '/boot/cmdline.txt' file can crash a Pi. The only part you should remove from this file is "console=serial0,115200", the rest of the file must stay exactly as it is. The '/boot/cmdline.txt' file must only contain 1 line, take care not to split the line when editing, and do not try to add comments.

Hope this helps,
Dave.

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

Re: Overlay to remap Pi 3 UART

Mon Jan 09, 2017 2:08 pm

sudo systemctl disable hciuart
Well spotted - I've corrected my post. Thanks.

yoodog
Posts: 9
Joined: Sat Dec 10, 2016 12:45 pm

Re: Overlay to remap Pi 3 UART

Tue Jan 10, 2017 9:58 pm

Thank you all!

I've re-installed fresh image because I've failed to follow instructions and deleted too much in /boot/cmdline.txt... well :D

Code: Select all

sudo systemctl disable hciuart
:) that worked as expected, thank you

and I added

Code: Select all

 dtoverlay=pi3-disable-bt
to /boot/config.txt

Thank you for that! Is there a way to check that BT is on UART1 and Serial is on UART0/ttyAMA0?

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

Re: Overlay to remap Pi 3 UART

Tue Jan 10, 2017 10:02 pm

Raspbian is configured to put the serial port on /dev/serial0 and Bluetooth on /dev/serial1, which are symbolic links to the underlying UARTs - ttyAMA0 and ttyS0.

Code: Select all

ls -l /dev/serial*
will show you the current mapping.

yoodog
Posts: 9
Joined: Sat Dec 10, 2016 12:45 pm

Re: Overlay to remap Pi 3 UART

Tue Jan 10, 2017 10:05 pm

I ask because if I run
raspi-gpio get

I get this
BANK0 (GPIO 0 to 27):
GPIO 00: level=1 fsel=0 alt= func=INPUT
GPIO 01: level=1 fsel=0 alt= func=INPUT
GPIO 02: level=1 fsel=0 alt= func=INPUT
GPIO 03: level=1 fsel=0 alt= func=INPUT
GPIO 04: level=1 fsel=0 alt= func=INPUT
GPIO 05: level=1 fsel=0 alt= func=INPUT
GPIO 06: level=1 fsel=0 alt= func=INPUT
GPIO 07: level=1 fsel=0 alt= func=INPUT
GPIO 08: level=1 fsel=0 alt= func=INPUT
GPIO 09: level=0 fsel=0 alt= func=INPUT
GPIO 10: level=0 fsel=0 alt= func=INPUT
GPIO 11: level=0 fsel=0 alt= func=INPUT
GPIO 12: level=0 fsel=0 alt= func=INPUT
GPIO 13: level=0 fsel=0 alt= func=INPUT
GPIO 14: level=1 fsel=0 alt= func=INPUT
GPIO 15: level=1 fsel=0 alt= func=INPUT
GPIO 16: level=0 fsel=0 alt= func=INPUT
GPIO 17: level=0 fsel=0 alt= func=INPUT
GPIO 18: level=0 fsel=0 alt= func=INPUT
GPIO 19: level=0 fsel=0 alt= func=INPUT
GPIO 20: level=0 fsel=0 alt= func=INPUT
GPIO 21: level=0 fsel=0 alt= func=INPUT
GPIO 22: level=0 fsel=0 alt= func=INPUT
GPIO 23: level=0 fsel=0 alt= func=INPUT
GPIO 24: level=0 fsel=0 alt= func=INPUT
GPIO 25: level=0 fsel=0 alt= func=INPUT
GPIO 26: level=0 fsel=0 alt= func=INPUT
GPIO 27: level=0 fsel=0 alt= func=INPUT
BANK1 (GPIO 28 to 45):
GPIO 28: level=0 fsel=0 alt= func=INPUT
GPIO 29: level=1 fsel=0 alt= func=INPUT
GPIO 30: level=0 fsel=0 alt= func=INPUT
GPIO 31: level=0 fsel=0 alt= func=INPUT
GPIO 32: level=1 fsel=7 alt=3 func=TXD0
GPIO 33: level=1 fsel=7 alt=3 func=RXD0
GPIO 34: level=1 fsel=7 alt=3 func=SD1_CLK
GPIO 35: level=1 fsel=7 alt=3 func=SD1_CMD
GPIO 36: level=1 fsel=7 alt=3 func=SD1_DAT0
GPIO 37: level=1 fsel=7 alt=3 func=SD1_DAT1
GPIO 38: level=1 fsel=7 alt=3 func=SD1_DAT2
GPIO 39: level=1 fsel=7 alt=3 func=SD1_DAT3
GPIO 40: level=0 fsel=4 alt=0 func=PWM0
GPIO 41: level=0 fsel=4 alt=0 func=PWM1
GPIO 42: level=0 fsel=4 alt=0 func=GPCLK1
GPIO 43: level=1 fsel=4 alt=0 func=GPCLK2
GPIO 44: level=1 fsel=0 alt= func=INPUT
GPIO 45: level=1 fsel=0 alt= func=INPUT
BANK2 (GPIO 46 to 53):
GPIO 46: level=1 fsel=4 alt=0 func=SDA0
GPIO 47: level=1 fsel=4 alt=0 func=SCL0
GPIO 48: level=0 fsel=4 alt=0 func=SD0_CLK
GPIO 49: level=1 fsel=4 alt=0 func=SD0_CMD
GPIO 50: level=1 fsel=4 alt=0 func=SD0_DAT0
GPIO 51: level=1 fsel=4 alt=0 func=SD0_DAT1
GPIO 52: level=1 fsel=4 alt=0 func=SD0_DAT2
GPIO 53: level=1 fsel=4 alt=0 func=SD0_DAT3


Where do 53 GPIO come from and why would TXD0 and RXD0 show up on 32 - 33??

EDIT-------
Thank you, after reboot I got all right

[email protected]:~ $ ls -l /dev/serial*
lrwxrwxrwx 1 root root 7 Jan 10 23:06 /dev/serial0 -> ttyAMA0
lrwxrwxrwx 1 root root 5 Jan 10 23:06 /dev/serial1 -> ttyS0

[email protected]:~ $ raspi-gpio get
BANK0 (GPIO 0 to 27):
GPIO 00: level=1 fsel=0 alt= func=INPUT
GPIO 01: level=1 fsel=0 alt= func=INPUT
GPIO 02: level=1 fsel=0 alt= func=INPUT
GPIO 03: level=1 fsel=0 alt= func=INPUT
GPIO 04: level=1 fsel=0 alt= func=INPUT
GPIO 05: level=1 fsel=0 alt= func=INPUT
GPIO 06: level=1 fsel=0 alt= func=INPUT
GPIO 07: level=1 fsel=0 alt= func=INPUT
GPIO 08: level=1 fsel=0 alt= func=INPUT
GPIO 09: level=0 fsel=0 alt= func=INPUT
GPIO 10: level=0 fsel=0 alt= func=INPUT
GPIO 11: level=0 fsel=0 alt= func=INPUT
GPIO 12: level=0 fsel=0 alt= func=INPUT
GPIO 13: level=0 fsel=0 alt= func=INPUT
GPIO 14: level=1 fsel=4 alt=0 func=TXD0
GPIO 15: level=1 fsel=4 alt=0 func=RXD0

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

Re: Overlay to remap Pi 3 UART

Tue Jan 10, 2017 10:11 pm

Those 54 GPIOs are the full complement of those provided by the BCM283x. TXD0 and RXD0 are on GPIOs 32 and 33 because ttyAMA0 is used to drive the Bluetooth modem on a Pi3. I can also tell from that output that you don't have "enable_uart=1" in config.txt, otherwise TXD1 and RXD1 (ttyS0) would be selected on GPIOs 14 and 15.

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

Re: Overlay to remap Pi 3 UART

Tue Jan 10, 2017 10:13 pm

Ah, I see you've edited your post. That makes more sense after a reboot - I was wondering why the pi3-disable-bt overlay didn't appear to have done its job.

yoodog
Posts: 9
Joined: Sat Dec 10, 2016 12:45 pm

Re: Overlay to remap Pi 3 UART

Tue Jan 10, 2017 10:17 pm

PhilE wrote:Those 54 GPIOs are the full complement of those provided by the BCM283x. TXD0 and RXD0 are on GPIOs 32 and 33 because ttyAMA0 is used to drive the Bluetooth modem on a Pi3. I can also tell from that output that you don't have "enable_uart=1" in config.txt, otherwise TXD1 and RXD1 (ttyS0) would be selected on GPIOs 14 and 15.

Edit my post above. It works, just had to reboot for the change to take place. Thanks, great community here!

I'm making a full manual for 4G controlled Pixhawk-UDP-PI-UDP-4g because most of them are highly outdated or use outdates solutions. like MavProxy with heavy CPU load and TCP rather than ser2net 3.3 with UDP.

rodizio
Posts: 39
Joined: Sat May 07, 2016 2:40 am

Re: Overlay to remap Pi 3 UART

Fri Jan 27, 2017 11:44 am

Just to clarify for me, as I understand, on the Pi3 there are the following options:
- disable BT and have UART0 (ttyAMA0) on the TXD/RXD pins on the GPIO header for external connections

- keep BT enabled and have UART1 (ttyS0) on the TXD/RXD GPIO pins for external connections

- keep BT enabled and have UART0 (ttyAMA0) on the txd/rxd GPIO pins for external connections


Now I would like to:
- Disable BT and have both UART0 and UART1 accessible on some pins for external connections.

- Do the same on the Pi Zero and Pi1/2

Is that possible somehow?
Last edited by rodizio on Fri Jan 27, 2017 12:18 pm, edited 1 time in total.

dgordon42
Posts: 752
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: Overlay to remap Pi 3 UART

Fri Jan 27, 2017 12:07 pm

rodizio wrote:Now I would like to:
- Disable BT and have both the hardware and software serial ports accessible on some pins for external connections.

- Do the same on the Pi Zero and Pi1/2

Is that possible somehow?
Not possible. The only accessible GPIO pins that can be used to connect to the Pi's UARTs are physical pins 8 &10, so you can only connect to 1 UART. This applies to all models of the Pi, except the Compute Module series.

If you need a second Serial Port, you could 'bit bang' one with a library such as @joan's pigpio.

Hope this helps,
Dave.

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

Re: Overlay to remap Pi 3 UART

Fri Jan 27, 2017 12:09 pm

To clarify (I hope):

1) There are two hardware UARTs, but one of them (UART0, ttyAMA0) is more capable than the other (UART1, ttyS0).
2) If you look at page 102 of BCM2835 ARM Peripherals you'll find a map of which functions are available on which GPIO pins. Omitting the flow control pins for clarity:
* UART0 is available on GPIOs 14/15, 32/33, 36/37
* UART1 is available on GPIOs 14/15, 32/33, 40/41
Of these, only 14/15 appears on the header, so there is no way to have both UARTs available except on a Compute Module,

Return to “Device Tree”

Who is online

Users browsing this forum: No registered users and 1 guest