myk777
Posts: 11
Joined: Mon Jun 08, 2020 8:19 pm

Re: Pi-4 Activating additional UART ports

Tue Jul 14, 2020 7:44 pm

PhilE wrote:
Tue Jun 23, 2020 11:08 am
If it solves the problem for you it will become part of the next release of the raspberrypi-sys-mods package.
How would I know or be able to check when this gets incorporated? Thanks

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

Re: Pi-4 Activating additional UART ports

Tue Jul 14, 2020 8:02 pm

/etc/udev/rules.d/99-com.rules will have grown to include separate rules for ttyAMA0 and ttyAMA1, rather than a combined rule ("ttyAMA[01]") for both of them. You can also watch the repository at https://github.com/RPi-Distro/raspberrypi-sys-mods for the next release.

ttteed
Posts: 1
Joined: Mon Aug 10, 2020 9:40 am

Re: Pi-4 Activating additional UART ports

Mon Aug 10, 2020 9:44 am

PhilE wrote:
Sat Jul 06, 2019 7:09 am

Code: Select all

$ dtoverlay -a | grep uart
This will show that there are four new overlays - uart2 to uart5.

Code: Select all

$ dtoverlay -h uart2
The help info shows the GPIOs used by each new UART - 0-3 for UART 2, 4-7 for 3, 8-11 for 4 and 12-15 for 5. This does mean that UART 5 overlaps with the standard UARTs on 14 & 15, but UART 5 has its flow control signals there - TXD5 and RXD5 appear on 12 & 13.

Code: Select all

$ raspi-gpio funcs
Run on a Pi 4, this will show all of the alternate functions available on the 4.
I wonder, as GPIO 14 and 15 already used for uart0, how could its flow control use GPIO 14 & 15 ?

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

Re: Pi-4 Activating additional UART ports

Tue Aug 11, 2020 8:05 am

I wonder, as GPIO 14 and 15 already used for uart0, how could its flow control use GPIO 14 & 15 ?
By not enabling UART0.

rhowell2
Posts: 2
Joined: Mon Mar 23, 2020 11:38 pm

Re: Pi-4 Activating additional UART ports

Mon Oct 26, 2020 10:07 pm

I've developed an application on the RPi4B that is being used to serially communicate, over a UART, to a wireless radio board which aggregates data from wireless clients. A lot of this thread has been helpful to me for configuring overlays, so thanks for that. I used the guidance here to configure this machine from a different project a while back as follows:

Code: Select all

dtoverlay=vc4-fkms-v3d
dtdebug=ON
dtoverlay=uart3
enable_uart=1
This configured ttyAMA1 to be tied to UART3 at GPIO4/5. This seems to work verifying over PuTTy with a simple jumpered connection test. This may be outside the scope of this thread, but my serial configuration requirements are still the same for this project, and I was intending to just repurpose that old setup: a connection to ttyAMA1 as a non-canonical, non-blocker at 115k 8/1/none. My questions are:

1.) Is there any reason that this application configuration wouldn't work over the RPi-4B's USB? (ttyUSB0). It would be really convenient to plug the USB from my Pi to the microUSB of the radio board's FTDI-232 UART in this scenario.

2.) Another nice to have feature would be to echo anything I printf() in my application to the screen in case someone wanted to plug into the HDMI port and see what's happening. I figure I'll need to reconfigure the application to write console prints to a different UART. Is there anything regarding the overlay configuration to pay attention to in either case? Can I just edit /boot/cmdline.txt with

Code: Select all

 console=tty1 
or something? I am relatively new to this OS/model.

Thanks!

sparseMatrix
Posts: 5
Joined: Wed Jul 08, 2020 11:07 pm

Re: Pi-4 Activating additional UART ports

Tue Apr 06, 2021 2:44 pm

You wont want to connect serial devices over usb if you want logical device names to remain stable across reboots.

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

Re: Pi-4 Activating additional UART ports

Tue Apr 06, 2021 3:57 pm

You would use udev to distinguish between multiple FTDI serial interfaces, for example with this neat little rule that creates symbolic links based on the serial numbers:

Code: Select all

SUBSYSTEM=="tty",SUBSYSTEMS=="usb",DRIVERS=="usb",SYMLINK+="device_%s{serial}"

hooverphonique
Posts: 20
Joined: Wed Nov 06, 2019 2:10 pm

Re: Pi-4 Activating additional UART ports

Tue Sep 21, 2021 8:27 am

danjperron wrote:
Tue Aug 06, 2019 3:29 pm
uart5 is the best one to enable if you need I2c and SPI.
can this be done with uart0 enabled as well? TDX0/CTS5 and RXD0/RTS5 overlap, but is it possible to tell the linux uart driver *not* to set the alternate function of GPIO14/15 to CTS5/RTS5?

and is there a generic way to do the same for other peripherals with overlapping GPIOs? Is this set in the device tree and then the OS drivers leave the function mapping of the GPIO alone?

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

Re: Pi-4 Activating additional UART ports

Tue Sep 21, 2021 9:02 am

is it possible to tell the linux uart driver *not* to set the alternate function of GPIO14/15 to CTS5/RTS5?
Yes (ish - it isn't the driver that configures the pins, it's the pinctrl framework):

Code: Select all

$ dtoverlay -h uart5
Name:   uart5

Info:   Enable uart 5 on GPIOs 12-15. BCM2711 only.

Usage:  dtoverlay=uart5,<param>

Params: ctsrts                  Enable CTS/RTS on GPIOs 14-15 (default off)
In other words, "dtoverlay=uart5" will only claim and change GPIOs 12 & 13 - one would have to append ",ctsrts" to also claim 14 & 15.

hooverphonique
Posts: 20
Joined: Wed Nov 06, 2019 2:10 pm

Re: Pi-4 Activating additional UART ports

Tue Sep 21, 2021 12:24 pm

PhilE wrote:
Tue Sep 21, 2021 9:02 am
In other words, "dtoverlay=uart5" will only claim and change GPIOs 12 & 13 - one would have to append ",ctsrts" to also claim 14 & 15.
Thanks, that looks easy enough, and I suppose I can make the change permanent by mentioning the overlay in the boot config!?

I had a look at uart5-overlay.dts to see, if I could create another param to enable nothing more than the TXD pin. I suppose a fragment like so would work?

Code: Select all

...
fragment@2 {
	target = <&uart5_pins>;
	__dormant__ {
		brcm,pins = <12>;
		brcm,pull = <0>;
	};
};
	
__overrides__ {
	ctsrts = <0>,"=1";
	txonly = <0>,"=2";
};

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

Re: Pi-4 Activating additional UART ports

Tue Sep 21, 2021 12:43 pm

I suppose I can make the change permanent by dropping the dtbo in the boot partition!?
If you mean adding "dtoverlay=uart5" to config.txt in the boot partition, then yes.
I suppose a fragment like so would work?
Yes - that should work nicely.

Return to “Device Tree”