Search code examples
pythonlinuxgoogle-coral

Cannot open UART on the 40-pin header


I am working on a Coral dev-board. I am trying to use UART1_TXD/RXD, UART3_TXD/RXD on the 40-pin header on the dev-board. I am following the tutorial Connect to the GPIO pins.

[serial_test.py]

from periphery import Serial

serial = Serial("/dev/ttyS0", 115200)

serial.write(b"Hello World!")

buf = serial.read(128, 0.5)
print("read %d bytes: _%s_" % (len(buf), buf))
serial.close()

When I test the board:

$ python3 serial_test.py
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/periphery/serial.py", line 166, in _open
    termios.tcsetattr(self._fd, termios.TCSANOW, [iflag, oflag, cflag, lflag, ispeed, ospeed, cc])
termios.error: (5, 'Input/output error')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "serial.py", line 5, in <module>
    serial = Serial("/dev/ttyS0", 115200)
  File "/usr/local/lib/python3.5/dist-packages/periphery/serial.py", line 60, in __init__
    self._open(devpath, baudrate, databits, parity, stopbits, xonxoff, rtscts)
  File "/usr/local/lib/python3.5/dist-packages/periphery/serial.py", line 168, in _open
    raise SerialError(e.errno, "Setting serial port attributes: " + e.strerror)
AttributeError: 'error' object has no attribute 'errno'

$ stty -F /dev/ttyS0
stty: /dev/ttyS0: Input/output error

And the rest of the ttyS1~3 have the same result.

What is the correct device path?


Solution

  • The two UART ports exposed on the Coral dev board (UART1 and UART3) map to the following file handles:

    • UART1/dev/ttymxc0
    • UART3/dev/ttymxc2

    You can access these ports through the 40-pin I/O connector and through the serial console interface (the USB to UART bridge exposes two ports when connected to your workstation).

    The current release of Mendel (chef) comes with the following caveats:

    1. UART1 is shared with the serial debug console. You will need to disable the console in Linux to use this port with applications.
    2. UART3 is not enabled by default in the base package. You need to update the packages on your board to enable this. We've added instructions to the I/O documentation.