Page 1 of 1

How to use UART 1 on Raspberry Pi CM3 ?

Posted: Wed Mar 15, 2017 11:07 am
by ShadyProgrammer
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

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

Posted: Wed Mar 15, 2017 11:46 am
by scotty101

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

Posted: Wed Mar 15, 2017 12:25 pm
by ShadyProgrammer
I'm not trying to disable the default serial port, what I want to do is to enable the extra serial port

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

Posted: Wed Mar 15, 2017 12:58 pm
by klricks
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.

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

Posted: Wed Mar 15, 2017 2:29 pm
by ShadyProgrammer
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 ?

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

Posted: Wed Mar 15, 2017 2:33 pm
by ShadyProgrammer
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 ?

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

Posted: Wed Mar 15, 2017 3:15 pm
by fruitoftheloom
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 ;)

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

Posted: Wed Mar 15, 2017 3:43 pm
by jamesh
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.

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

Posted: Wed Mar 15, 2017 4:02 pm
by nixy82
Try adding

Code: Select all

core_freq=250
to /boot/config.txt

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

Posted: Wed Mar 15, 2017 5:06 pm
by ShadyProgrammer
@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 ?

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

Posted: Tue Apr 04, 2017 8:51 am
by JohW
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