samveen
Posts: 48
Joined: Sun Nov 29, 2020 7:45 am

Attaching both UARTS to GPIO pins on a Raspberry Pi Zero v1.3

Mon Sep 18, 2023 10:45 am

I have a raspberry Pi Zero (call this B) with it's serial console enabled. I need it to monitor the serial console of another Raspberry Pi Zero (call this N) without disabling the console on the first one. How do I go about re-assigning the pins for uart1 to another

I want to be able to access the serial console of B, then access the serial console of N from B.

However, for the I am not being able to figure out how to have both the uart functional at the same time such that :
- B.serial0 is active at on B.{GPIO14/GPIO15} and connected to a USB/serial converter.
- N'.serial0 is active on N.{GPIO14/GPIO15} and needs to be connected to some non-SPI and non I2C pins on B.GPIO.

What I am hoping to do is to enable B.serial1 on some non-SPI and non-I2C pins of B.GPIO (GPIO0 and GPIO5 look great for it on https://pinout.xyz/pinout/uart# - Pins 27/29)

How do I go about such a pin assignment, so that I can talk to N.serial0 using B.serial1 ?

I have read https://www.raspberrypi.com/documentati ... ring-uarts end to end, I have also searched the forums, seen the disable-bt overlay (https://github.com/raspberrypi/linux/bl ... verlay.dts) and researched a lot. That has not given me any clear answers.

EDIT: After reading the datasheet for the bcm2835 peripherals I see that what I want is not possible:
- Both the UARTs are wired to the same sets of alternate pins
- The first possible alternate pins are beyond GPIO27, which is the last available GPIO pin on the 40 pin header:

Code: Select all

samveen@zero2w:~ $ pinout |sed 's/\s/\n/g' |grep GPIO  |sort -tO -k2n |tail -n1
GPIO27
I'll use a cheap USB to serial dongle on the B.USB1 and use to connect to N.serial0
Last edited by samveen on Mon Sep 18, 2023 11:48 am, edited 1 time in total.

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

Re: Attaching both UARTS to GPIO pins on a Raspberry Pi Zero v1.3

Mon Sep 18, 2023 11:14 am

I'm afraid that what you are asking for is not possible - BCM2835 (and BCM2836 and BCM2837) only has one position in the range GPIO 0 to GPIO 27 (the GPIOs that appear on the 40-pin header) for each UART TX and RX, i.e. TXD0, RXD0, TXD1 and RXD1, and those positions are the same: TXD0 and TXD1 are both available on GPIO14 and nowhere else (except on the higher GPIOs), and RXD0 and RXD1 are available on GPIO15.

I can't think of a way to achieve the connectivity you want without external hardware - either a USB UART (e.g. our Debug Probe) or an I2C-attached UART such as an SC16IS750.

samveen
Posts: 48
Joined: Sun Nov 29, 2020 7:45 am

Re: Attaching both UARTS to GPIO pins on a Raspberry Pi Zero v1.3

Mon Sep 18, 2023 11:50 am

Thanks for the reply, phil. I reached the same conclusion after reading through the BCM2835 ARM Peripherals document .

On the topic of the debug probe, it's a quite bit expensive as compared to other USB to Serial converters and 3 times more expensive that a Pico. I could use a pico by writing the debug probe firmware on it, but the pico, in turn, is 3 times more expensive than a converter, even if immeasurably more versatile.
Last edited by samveen on Mon Sep 18, 2023 12:43 pm, edited 1 time in total.

aBUGSworstnightmare
Posts: 7871
Joined: Tue Jun 30, 2015 1:35 pm

Re: Attaching both UARTS to GPIO pins on a Raspberry Pi Zero v1.3

Mon Sep 18, 2023 11:51 am

If you need to have multiple UARTs 'on-chip' why not change the device 'B' to a Pi4?

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

Re: Attaching both UARTS to GPIO pins on a Raspberry Pi Zero v1.3

Mon Sep 18, 2023 12:02 pm

Because not everyone likes the idea of discarding what seemed like perfectly good hardware until one small problem was found? Because the case isn't large enough? There are many possible reasons.

samveen
Posts: 48
Joined: Sun Nov 29, 2020 7:45 am

Re: Attaching both UARTS to GPIO pins on a Raspberry Pi Zero v1.3

Mon Sep 18, 2023 12:46 pm

Exactly as Phil said. Why would I throw away my perfectly good Zero, then spend 35 USD (plus import duties), to spend more time, my energy and power and rearrange the existing setup around a 4B when a USB serial module costs a single dollar, delivered at home ( as quick as a 4B, at 1/35th the cost)

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

Re: Attaching both UARTS to GPIO pins on a Raspberry Pi Zero v1.3

Mon Sep 18, 2023 12:56 pm

I guess you are right about the cost - we have previously used FTDI UART cables and FTDI JTAG adaptors, and in comparison to both of those the Debug Probe is super cheap, but there's no comparison to something that costs a dollar if all you want is a UART.

samveen
Posts: 48
Joined: Sun Nov 29, 2020 7:45 am

Re: Attaching both UARTS to GPIO pins on a Raspberry Pi Zero v1.3

Mon Sep 18, 2023 1:30 pm

On the topic of the UART, if I were to solder the USB lines from the module(a CP2102)to the 5V/D+/D-/GND test points on the back of the Pi Zero and power the whole thing via 5V (pin 2/4), can I expect the module to work as if plugged into the USB port?

User avatar
rpdom
Posts: 22400
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Attaching both UARTS to GPIO pins on a Raspberry Pi Zero v1.3

Mon Sep 18, 2023 1:50 pm

samveen wrote:
Mon Sep 18, 2023 1:30 pm
On the topic of the UART, if I were to solder the USB lines from the module(a CP2102)to the 5V/D+/D-/GND test points on the back of the Pi Zero and power the whole thing via 5V (pin 2/4), can I expect the module to work as if plugged into the USB port?
Yes. There are various add-ons (the Zero4U 4-port USB hub, for example) that use the USB and power test points in that manner. Obviously you won't be able to use the USB port at the same time.
Unreadable squiggle

aBUGSworstnightmare
Posts: 7871
Joined: Tue Jun 30, 2015 1:35 pm

Re: Attaching both UARTS to GPIO pins on a Raspberry Pi Zero v1.3

Mon Sep 18, 2023 2:10 pm

PhilE wrote:
Mon Sep 18, 2023 12:02 pm
Because not everyone likes the idea of discarding what seemed like perfectly good hardware until one small problem was found? Because the case isn't large enough? There are many possible reasons.
samveen wrote: Exactly as Phil said. Why would I throw away my perfectly good Zero, then spend 35 USD (plus import duties), to spend more time, my energy and power and rearrange the existing setup around a 4B when a USB serial module costs a single dollar, delivered at home ( as quick as a 4B, at 1/35th the cost)
Never spoke about discarding!
Anyhow, still struggle to understand the role of 'B'.
How to control the Pi Zero 1.3 if the only USB port is used by the USB-to-UART? Adding a hub - which cost some USD as well - as there is no Wifi on a Zero V1.3.

Sure, if the 'use case' is just sniffing the data and writing it to uSD that's fine though ...
So if you think about adding 'another UART' you should consider https://ftdichip.com/wp-content/uploads ... T4232H.pdf as an option.

samveen
Posts: 48
Joined: Sun Nov 29, 2020 7:45 am

Re: Attaching both UARTS to GPIO pins on a Raspberry Pi Zero v1.3

Mon Sep 18, 2023 2:40 pm

The B is a BMC (or in this case, a bare bones OOB controller), to capture and allow access to the serial console of the Node N (this could actually be any Pi, but using a Zero as a stand in for testing). This is a component of my project to figure out a simple BMC using a Pi Zero, with no addons, or atleast the bare minimum addons. (https://github.com/samveen/PiZBMC). Think of it as a 3rd world cousin of the pikvm.

Return to “Device Tree”