Page 2 of 2

Re: Pi-4 Activating additional UART ports

Posted: Tue Aug 06, 2019 3:42 pm
by PhilE
i2c0 is irrelevant when you have i2c1!

But seriously, it depends on your application - if you are building a network-connected serial port concentrator then i2c is probably not that important.

Re: Pi-4 Activating additional UART ports

Posted: Tue Aug 06, 2019 4:58 pm
by danjperron
i2c0 is irrelevant when you have i2c1!
This mean that ID_SD(pin 27) and ID_SC (pin 28) could be used for other things?
I though they were reserved for eerom on hat board ?

Re: Pi-4 Activating additional UART ports

Posted: Tue Aug 06, 2019 6:35 pm
by PhilE
On all Pis with 40-pin headers, pins 27 and 28 are wired to GPIOs 0 & 1, which are configured for I2C0. GPIOs 2 & 3, which can be configured for I2C1, are available on other header pins (3 & 5). This means that I2C0 is notionally reserved for the firmware (e.g. for driving the camera), but in practise on many Pis (including the 4B) by the time the ARMs are started the firmware will not use I2C0 again unless you use the camera.

Re: Pi-4 Activating additional UART ports

Posted: Tue Aug 06, 2019 7:53 pm
by danjperron
Thanks PhilE,

Are you sure that is pin 28 and 29 . I think it is 27 and 28.

To summarize.

uart2 uses pins that could conflict with the camera and any kind of "hat" with eerom. Also If you enable the handshake, I2C1 has to be disabled.
uart3 use GPIO4 then you should consider to change 1 wire GPIO pin if you need 1 wire.
uart4 use the SPI GPIOs. SPI needs to be disabled.
No conflict with the uart5. This is the safest one to use.

oops uart3 uses GPIO7 if you enable handshake then you need to disable SPI.

Re: Pi-4 Activating additional UART ports

Posted: Tue Aug 06, 2019 8:20 pm
by PhilE
> Are you sure that is pin 28 and 29 . I think it is 27 and 28.

You're right - corrected. It comes from preferring to count from zero.

Re: Pi-4 Activating additional UART ports

Posted: Wed Aug 07, 2019 10:08 am
by asafyurdakul
Thank you PhilE
I have found my problem.

I have checked command "raspi-gpio get 0-15". I see that there is no problem like your result.
But when I run my program , the result of this command changed. 4,5 (Uart3) and 13 (Uart5) gpio pins "alt=4" properties are cleared and "func" properties are changed.

My program is runnig on mono c# platform.
I am using Unosquare library "https://github.com/unosquare/raspberryio". That is perfect library for mono.


On my program I was enabled SPI. I noticed that when I was done it 4,5 and 13 pins properties changed.
Cancelled codes are below
Pi.Init<BootstrapWiringPi>();
Pi.Spi.Channel0Frequency = SpiChannel.MinFrequency;

So, I cancelled these SPI init codes and problem solved. Now all 5 uarts works without any problem.

Best regards

Re: Pi-4 Activating additional UART ports

Posted: Wed Aug 07, 2019 10:15 am
by PhilE
I'm happy you found the problem. A lot of libraries talk directly to the hardware, bypassing the Linux drivers, sometimes for good reasons (the old sysfs API to GPIOs is notoriously slow - the new ioctl-based gpiolib interface is much quicker), sometimes not. If the Unosquare library had used a Linux API then it would have received an error indicating that the pins were in use, which should have been easier to track down.

Re: Pi-4 Activating additional UART ports

Posted: Wed Aug 07, 2019 1:31 pm
by leoP4
Hi everyone

I'm interested in the topic, but how to use the script? I can't understand the passage.
Sorry for the trivial question.

Re: Pi-4 Activating additional UART ports

Posted: Wed Aug 07, 2019 1:36 pm
by PhilE
Which script are you referring to? If you just want to enable one of the additional serial ports on Pi4, just add "dtoverlay=uart2" to config.txt, where "uart2" could also be "uart3", "uart4" or "uart5". After rebooting, and if you don't have a clash with something else that needs the same pins, you will find a new /dev/ttyAMA*.

Re: Pi-4 Activating additional UART ports

Posted: Wed Aug 07, 2019 1:43 pm
by leoP4
I was referring to the script mentioned above, that is #! / bin / sh

Re: Pi-4 Activating additional UART ports

Posted: Mon Aug 12, 2019 3:39 pm
by PhilE
That script just sends the characters 0-5 to ttyAMA0-5 every second. Attaching a serial cable to one of the groups of UART pins, the character that appears in your terminal emulator reveals which ttyAMA* it is connected to.