legacy:common:application_note:gpio:uart

UART Interface on the 40 Pin Header

You can use a general purpose UART interface on the 40 pin header on ODROID-N2/C4.
Please see the 40 pin expansion descriptions for N2 or C4 first.
As you can see, with physical pin #8, #10 UART_EE_A and #15, #35 UART_EE_B can be enabled for the alternative UART interface on ODROID-N2.
And, with physical pin #8, #10 UART_EE_A and #15, #33 UART_EE_B can be enabled for the alternative UART interface on ODROID-c4.
Since the default pin function is GPIO-input, you have to change the device tree file to activate the UART mode.

  • If you enable UART functionality of the pins, you cannot use them as GPIO or the other alternative function.

Basically, the necessary nodes for UART functionality are already defined in the device source tree. Their node names that we're able to use are uart_A and uart_B.

So we just can enable the node we're going to use.

You don't have to make any changes for that file by yourself. Use device-tree-compiler program in Linux system.

Install device-tree-compiler.

target
sudo apt install device-tree-compiler

First of all, this let's get UART_EE_A to work.

Enter the following command to check if the device tree node for uart_A is enabled.

It should output disabled by default.

ODROID-n2

target
sudo fdtget /media/boot/meson64_odroidn2.dtb /serial@ffd24000 status
 
# returns
disabled

ODROID-C4

target
sudo fdtget /media/boot/meson64_odroidc4.dtb /serial@ffd24000 status
 
# returns
disabled

Enter the following commands to enable that.

ODROID-N2

target
sudo fdtput -t s /media/boot/meson64_odroidn2.dtb /serial@ffd24000 status "okay"
sudo fdtget /media/boot/meson64_odroidn2.dtb /serial@ffd24000 status
 
# returns
okay

ODROID-C4

target
sudo fdtput -t s /media/boot/meson64_odroidc4.dtb /serial@ffd24000 status "okay"
sudo fdtget /media/boot/meson64_odroidc4.dtb /serial@ffd24000 status
 
# returns
okay

Reboot.

After reboot, you can find the extra ttyS1 device file in the device list.

target
ls -al /dev/ttyS?
 
# returns
crw--w---- 1 root tty     238, 0 May 28 18:36 /dev/ttyS0
crw-rw---- 1 root dialout 238, 1 Jan 29  2018 /dev/ttyS1

In the same way, uart_B can be enabled as changing the status property of serial@ffd23000 to okay.

ODROID-N2

target
sudo fdtput -t s /media/boot/meson64_odroidn2.dtb /serial@ffd23000 status "okay"
sudo fdtget /media/boot/meson64_odroidn2.dtb /serial@ffd23000 status
 
# returns
okay

ODROID-C4

target
sudo fdtput -t s /media/boot/meson64_odroidc4.dtb /serial@ffd23000 status "okay"
sudo fdtget /media/boot/meson64_odroidc4.dtb /serial@ffd23000 status
 
# returns
okay

If those 2 UARTs are enabled, the devices should list like the below. /dev/ttyS2 is created by enabling UART_EE_B.

target
ls -al /dev/ttyS?
 
# returns
crw--w---- 1 root tty     238, 0 May 29 15:23 /dev/ttyS0
crw-rw---- 1 root dialout 238, 1 Jan 29  2018 /dev/ttyS1
crw-rw---- 1 root dialout 238, 2 May 29 15:28 /dev/ttyS2

4-pin CON5 pin map of our UART(/dev/ttyS0) is,

_____UART____
|           |
|Pin 4 - GND|
|Pin 3 - RXD|
|Pin 2 - TXD|
|Pin 1 - VCC|
|_          |
  |_________|

3.3V LVTTL

UART_EE_A (/dev/ttyS1)

J2 Header Pin # UART Module Pin # Role
9 4 GND
10 3 RxD
8 2 TxD
38 1 VCC

UART_EE_B (/dev/ttyS2)

J2 Header Pin # UART Module Pin # Role
9 4 GND
15 3 RxD
35 (N2)/33(C4) 2 TxD
38 1 VCC

Connect the cables like the following picture, which shows when using UART_EE_A.

The RxD and TxD pins must be twisted together.

ODROID-N2

ODROID-C4

Connect the opposite side of the UART module to your host PC.

  • Assume that your host PC is Debian/Ubuntu system.

Enter the following commands to set /dev/ttyS1 up.

target
sudo stty -F /dev/ttyS1 115200

At your host PC, install minicom to serial communication.

host
sudo apt install minicom

Check the UART module installed as /dev/ttyUSB*. Then open minicom with the options.

host
ls /dev/ttyUSB*
 
# results
/dev/ttyUSB0
host
minicom -b 115200 -D /dev/ttyUSB0

At your target board, put something to /dev/ttyS1 device.

target
echo something | sudo tee /dev/ttyS1

And you can see the message on the minicom screen at your host PC.

  • legacy/common/application_note/gpio/uart.txt
  • Last modified: 2021/04/26 15:06
  • by joshua