January 20, 2022

Orange Pi 4 (Rockchip 3399) serial ports

I am in the midst of trying to make my "truly bare metal" demo talk to the serial console. I know that the serial console is Uart2, and since I am doing all of the initialization, I can choose the baud rate (but I will stick to 1500000 baud).

The RK3399 chip has 5 serial ports (0-4) and I got curious about using one other than "2" for some experiments. This naturally leads to asking just what pins I ought to connect to, which leads to an examination of the TRM (technical reference manual) and the schematic, and a number of discoveries which I will try to summarize here.

In short, only Uart4 is available for use on the Orange Pi 4 board. All of the ports are routed to various package pins through the usual "iomux", which needs to be configured to cause the uart to drive the pins. That is only half the story. The other half is what the pin is connected to on the board.

Here is the story with the various serial ports.

Uart 0 - internally connected to the AP6256 Wifi chip
Uart 1 - internally connected to the RTL8211E ethernet Phy
Uart 2 - our console, but see below
Uart 3 - internally connected to the RTL8211E ethernet Phy
Uart 4 - available on the 40 pin header, pins 19 and 21 (GPIO1 A7 and GPIO1 B0)
The Uart 2 has some surprising issues. It can be routed to 3 different sets of pins, but only one will actually drive the console header, as follows:
Uart 2A - GPIO4 B0 and B1 -- internally connected to the SD card
Uart 2B - GPIO4 C0 and C1 -- on 40 pin header, pins 8 and 10
Uart 2C - GPIO4 C3 and C4 -- connected to the 3 pin console header
So, we want to use "2C". We could use "2B" and connect to the pins on the 40 pin IO header, but this is better left for use with i2c3

Notes on the IO mux

The IO mux is handled by registers in the GRF (for GPIO 2,3, and 4) and by registers in the PMU_GRF (for GPIO 0 and 1). Page 311 of the TRM shows the IOMUX settings for GPIO 4C. Each pin can have one of 4 possible sources as follows:
0 - gpio
1 - uart2dbgc
2 - uarthdcp
3 - reserved
So what do we use? Setting 1 or 2? As it turns out, setting 1 does the job.

Be careful reading the datasheet (as on page 56 which shows the function settings for GPIO4). It shows Func1 through Func 4, but of course to get "Func2" you write 1.


Have any comments? Questions? Drop me a line!

Tom's electronics pages / tom@mmto.org