Raspberry Pi4 UART
------------------

The [BCM2711](https://www.raspberrypi.com/documentation/computers/processors.html#bcm2711) used in the Raspberry Pi 4 Model B, the Raspberry Pi 400, and the Raspberry Pi Compute Module 4 has 4 additional UART (uart2-uart5) in addition to uart0/1 on the older Pi (only one of which can be used as they share GPIO).  
Functionally these are equivalent to the fully featured PL011 UART on uart0 and can optionally be configured with CTS/RTS.
See [UART configuration](https://www.raspberrypi.com/documentation/computers/configuration.html#configuring-uarts) for Foundation documentation.

These can be enabled (by editing `/boot/config.txt`), but this requires careful consideration of the impact on GPIO functionality.  
Activation of CTS/RTS functionality has additional impact.  
> NOTE you can enable overlays on the fly e.g `sudo dtoverlay uart4`.   
Manually loaded overlays can be removed e.g `sudo dtoverlay -r uart4`

 - uart2 uses GPIO0/1 which are reserved<sup>1</sup> and possibly impact on normal
   Raspbian functionality.
 - uart3 uses GPIO4/5 which is OK, although GPIO4 is commonly used for other purposes.
 - uart4 uses GPIO8/9 which are used for SPI0.
 - uart5 uses GPIO12/13 which conflict with the default pin allocation
   of gpio-fan (although this can be changed).  
<sup>1</sup> *These pins are documented as "RESERVED". It is possible to configure uart2 in `config.txt` (at least if no HATs are present). Impact on functionality is unknown.* 

If additional UARTs are enabled they will appear as `/dev/ttyAMAn`  
The first will be `/dev/ttyAMA1` and increment if additional UART are enabled.

```
Name:   uart0
Info:   Change the pin usage of uart0
Load:   dtoverlay=uart0,<param>=<val>
Params: txd0_pin                GPIO pin for TXD0 (14, 32 or 36 - default 14)

        rxd0_pin                GPIO pin for RXD0 (15, 33 or 37 - default 15)

        pin_func                Alternative pin function - 4(Alt0) for 14&15,
                                7(Alt3) for 32&33, 6(Alt2) for 36&37


Name:   uart1
Info:   Change the pin usage of uart1
Load:   dtoverlay=uart1,<param>=<val>
Params: txd1_pin                GPIO pin for TXD1 (14, 32 or 40 - default 14)

        rxd1_pin                GPIO pin for RXD1 (15, 33 or 41 - default 15)


Name:   uart2
Info:   Enable uart 2 on GPIOs 0-3
Load:   dtoverlay=uart2,<param>
Params: ctsrts                  Enable CTS/RTS on GPIOs 2-3 (default off)


Name:   uart3
Info:   Enable uart 3 on GPIOs 4-7
Load:   dtoverlay=uart3,<param>
Params: ctsrts                  Enable CTS/RTS on GPIOs 6-7 (default off)


Name:   uart4
Info:   Enable uart 4 on GPIOs 8-11
Load:   dtoverlay=uart4,<param>
Params: ctsrts                  Enable CTS/RTS on GPIOs 10-11 (default off)


Name:   uart5
Info:   Enable uart 5 on GPIOs 12-15
Load:   dtoverlay=uart5,<param>
Params: ctsrts                  Enable CTS/RTS on GPIOs 14-15 (default off)
```

The following summarises the pin usage:-

```
		TXD	RXD	CTS	RTS		Board Pins
uart0	14	15				8	10
uart1	14	15				8	10
uart2	0	1	2	3		27	28	(I2C0)
uart3	4	5	6	7		7	29
uart4	8	9	10	11		24	21 	(SPI0)
uart5	12	13	14	15		32	33	(gpio-fan)
```


----------
You CAN use uart2 on Pi4 but need to disable other uses of GPIO0/1 with `force_eeprom_read=0` & `disable_poe_fan=1`