User avatar
ShadyProgrammer
Posts: 27
Joined: Fri Dec 16, 2016 11:33 am

How to use UART 1 on Raspberry Pi CM3 ?

Wed Mar 15, 2017 11:07 am

I'm using gpio pins 32(TX) and 33(RX) and want to establish serial communications with a peripheral board. From what I've read so far the above pins should have a secondary function for serial communications. I've added

Code: Select all

dtoverlay=uart1
to the end of /boot/config.txt file in the hopes that everything will work fine. I've conducted some tests and found that by adding this line all that happened when I tried using /dev/ttyS0 that appeared as a result of it was that I was getting garbage on UART0 (/dev/ttyAMA0) gpio pins 14 and 15. Then I added

Code: Select all

enable_uart=1
to the end of the same file but it had no effect.

Could anyone please help me ? I'm really stuck

scotty101
Posts: 3247
Joined: Fri Jun 08, 2012 6:03 pm

Re: How to use UART 1 on Raspberry Pi 3 ?

Wed Mar 15, 2017 11:46 am

Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

User avatar
ShadyProgrammer
Posts: 27
Joined: Fri Dec 16, 2016 11:33 am

Re: How to use UART 1 on Raspberry Pi 3 ?

Wed Mar 15, 2017 12:25 pm

I'm not trying to disable the default serial port, what I want to do is to enable the extra serial port

klricks
Posts: 5913
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: How to use UART 1 on Raspberry Pi 3 ?

Wed Mar 15, 2017 12:58 pm

ShadyProgrammer wrote:...I'm not trying to disable the default serial port, what I want to do is to enable the extra serial port
You can't use both at the same time as they are both mapped to the same physical pins 8 & 10.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Stretch w/ Desktop OS.

User avatar
ShadyProgrammer
Posts: 27
Joined: Fri Dec 16, 2016 11:33 am

Re: How to use UART 1 on Raspberry Pi 3 ?

Wed Mar 15, 2017 2:29 pm

klricks wrote:
ShadyProgrammer wrote:...I'm not trying to disable the default serial port, what I want to do is to enable the extra serial port
You can't use both at the same time as they are both mapped to the same physical pins 8 & 10.
Apologies but I just noticed that I didn't add "Compute module" to the title. I'm working on Compute module 3. Two UARTs should be ready available on CM3 am I right ?

User avatar
ShadyProgrammer
Posts: 27
Joined: Fri Dec 16, 2016 11:33 am

Re: How to use UART 1 on Raspberry Pi 3 ?

Wed Mar 15, 2017 2:33 pm

I've currently changed "brcm,pins" of "fragment1" on this file:

https://github.com/raspberrypi/linux/bl ... verlay.dts

to 32 and 33 instead of 14 and 15 in the hopes to get UART 1 working this way. I compiled it and moved to /boot/overlays/. Then I added it to /boot/config.txt . I am now able to communicate with UART 1 but unfortunately all I'm getting on the serial port is garbage. Is this the right to go about it at all ?

Also just to get some confusion out of the way when I research the internetz about it:

If I understand correctly UART 1 on pins 32, 33 is called PL011
The native (default) UART 0 on 14. 15 is called mini-UART

is this right ?

fruitoftheloom
Posts: 17838
Joined: Tue Mar 25, 2014 12:40 pm

Re: How to use UART 1 on Raspberry Pi 3 ?

Wed Mar 15, 2017 3:15 pm

ShadyProgrammer wrote:
klricks wrote:
ShadyProgrammer wrote:...I'm not trying to disable the default serial port, what I want to do is to enable the extra serial port
You can't use both at the same time as they are both mapped to the same physical pins 8 & 10.
Apologies but I just noticed that I didn't add "Compute module" to the title. I'm working on Compute module 3. Two UARTs should be ready available on CM3 am I right ?
The Mods have moved the post to Compute Module Section and fixed the title, they are great :D :D

The RPF web site have a Section devoted to CM: https://www.raspberrypi.org/documentati ... putemodule ;)
Adieu

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

Re: How to use UART 1 on Raspberry Pi 3 ?

Wed Mar 15, 2017 3:43 pm

ShadyProgrammer wrote:I've currently changed "brcm,pins" of "fragment1" on this file:

https://github.com/raspberrypi/linux/bl ... verlay.dts

to 32 and 33 instead of 14 and 15 in the hopes to get UART 1 working this way. I compiled it and moved to /boot/overlays/. Then I added it to /boot/config.txt . I am now able to communicate with UART 1 but unfortunately all I'm getting on the serial port is garbage. Is this the right to go about it at all ?

Also just to get some confusion out of the way when I research the internetz about it:

If I understand correctly UART 1 on pins 32, 33 is called PL011
The native (default) UART 0 on 14. 15 is called mini-UART

is this right ?
Just to double check - you are using the correct (and matching) voltages on your source and destination? The Pi UART is 3v3 IIRC- make sure whatever is on the other end is also 3v3 or you are using a converter (MAX232 rings a bell). Getting the voltages wrong does result in garbled messages.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

nixy82
Posts: 40
Joined: Sat Sep 12, 2015 9:19 am

Re: How to use UART 1 on Raspberry Pi CM3 ?

Wed Mar 15, 2017 4:02 pm

Try adding

Code: Select all

core_freq=250
to /boot/config.txt

User avatar
ShadyProgrammer
Posts: 27
Joined: Fri Dec 16, 2016 11:33 am

Re: How to use UART 1 on Raspberry Pi CM3 ?

Wed Mar 15, 2017 5:06 pm

@jamesh and @nixy82

Adding

Code: Select all

core_freq=250
to /boot/config.txt file solved the problem. I don't know why and would like to find out if possible why it solved the problem.

Also If possible I'd like to know how come the modification to uart_1 device tree file above worked okay without ruining functionality of UART 0 and how come I didn't have to do anything like:

Code: Select all

gpio -g mode 32 alt5
gpio -g mode 33 alt5
To explicitly change the pins from being GPIOs to TX/RX as shown on page 102 here: https://www.raspberrypi.org/wp-content/ ... herals.pdf ?

JohW
Posts: 8
Joined: Wed Mar 01, 2017 9:17 am

Re: How to use UART 1 on Raspberry Pi CM3 ?

Tue Apr 04, 2017 8:51 am

I had the same problem (using both UARTS on a CM3 simultaneously)

The UART1 depends on the system clock which can be changed by the "ondemand" governor. So the only way I found to get UART1 working reliably is to disable the governor. Here is my config, also with some explanations:

Code: Select all

force_turbo=1
enable_uart=1

# UART0 /dev/ttyAMA0
# this doesn't wirk yet, the log shows
# $ sudo vcdbg log msg
# Failed to load overlay 'uart0
# and I had to set the GPIO pins manually to A2
# raspi-gpio set 36 a2
# raspi-gpio set 37 a2
dtoverlay=uart0,txd0_pin=36,rxd0_pin=37

# UART1 /dev/ttyS0
dtoverlay=uart1,txd1_pin=32,rxd1_pin=33

Return to “Compute Module”