Pinout Xtreme

From UpWiki
Jump to: navigation, search

Pinout

Device
(Linux)
Function Linux GPIO
(sysfs)
UP Pinout Pin
Pin
 
UP Pinout Linux GPIO
(sysfs)
Function Device
(Linux)
3.3V 1 2 5V
/dev/i2c-2 I2C1_SDA 2 GPIO1 3 4 5V
/dev/i2c-2 I2C1_SCL 3 GPIO2 5 6 Ground
iio:device0 ADC0 4 GPIO3 7 8 GPIO16 14 UART1_TX /dev/ttyS7
Ground 9 10 GPIO17 15 UART1_RX /dev/ttyS7
/dev/ttyS7 UART1_RTS 17 GPIO4 11 12 GPIO18 18
27 GPIO5 13 14 Ground
22 GPIO6 15 16 GPIO19 23
3.3V 17 18 GPIO20 24
/etc/spidev0.x SPI0_MOSI 10 GPIO7 19 20 Ground
/etc/spidev0.x SPI0_MISO 9 GPIO8 21 22 GPIO21 25
/etc/spidev0.x SPI0_CLK 11 GPIO9 23 24 GPIO22 8 SPI0_CS0 /etc/spidev0.0
Ground 25 26 GPIO23 7 SPI0_CS1 /etc/spidev0.1
/dev/i2c-1 I2C0_SDA 0 GPIO10 27 28 GPIO24 1 I2C0_SCL /dev/i2c-1
5 GPIO11 29 30 Ground
6 GPIO12 31 32 GPIO25 12
13 GPIO13 33 34 Ground
19 GPIO14 35 36 GPIO26 16 UART1_CTS /dev/ttyS7
26 GPIO15 37 38 GPIO27 20
Ground 39 40 GPIO28 21
Pin Legend
GPIO
UART
I2C
SPI
PWM
I2S
Warning Warning: Pin Linux number for I2C devices depend on kernel configuration. To check your bus numbering go to I2C Ports.

Accessing the peripherals on the UP Xtreme

GPIO

On UP Xtreme at system start all the pin in the hat connector are configured in function mode.

So for example the hat pin 3 associated with I2C_SDA function at start is configured as an I2C channel

You can switch the function after booting accessing the gpio pin using linux sysfs gpio interface. For example the following commands will blink an led connected to pin 13 :

$ sudo -i
$ cd /sys/class/gpio
$ echo 432 > export
$ cd gpio432
$ echo "out" > direction
$ watch -n 0.5 'echo 1 > value; sleep 0.5 ; echo 0 > value'

after finishing to use the gpio we need to unexport it.

$ echo "in" > direction
$ cd ..
$ echo 432 > unexport
Warning Warning: The current pinctrl driver implementation does not allow to restore a pin in function mode (e.g. uart) once it has been already swithed to gpio mode until the operating system is rebooted.
Warning Warning: when a pin is unexported it retains the last value/direction. So if you don't intend to use the gpio again better set it to input to protect it from short/electrical problem.

The gpio could also be accessed with RPi numbering so for example we can have done the same example with

$ sudo -i
$ cd /sys/class/gpio
$ echo 27 > export
$ cd gpio27
$ echo "out" > direction
$ watch -n 0.5 'echo 1 > value; sleep 0.5 ; echo 0 > value'
$ echo "in" > direction
$ cd ..
$ echo 27 > unexport

Of course you cannot use different numbering scheme on the same pin as the same time.

Interrupts

Currently interrupts are only supported using the linux gpio numbering scheme (e.g. use 432 gpio umber instead of Rpi gpio number 27).

The most simple way to use interrupts from userspace is to use userspace software library like mraa

Example IRQ test using Python Periphery

1. Download the following file and extract it on the board File:Irqtest.zip

2. install python3-pip

sudo apt update && sudo apt install python3-pip

3. install periphery from pip

sudo -H pip3 install python-periphery

4. launch the script

sudo python3 irqtest.py

UART

To identify the tty device node number in Linux corresponding to a particular hardware uart open a terminal and execute the following command

$ ls /sys/bus/pci/devices/0000\:00\:*/dw-apb-uart*/tty/ | grep tty

/sys/bus/pci/devices/0000:00:19.2/dw-apb-uart.4/tty/:
ttyS5
/sys/bus/pci/devices/0000:00:1e.0/dw-apb-uart.5/tty/:
ttyS6
/sys/bus/pci/devices/0000:00:1e.1/dw-apb-uart.6/tty/:
ttyS7

The ttyS7 UART (associated to dw-apb-uart.6) is the uart on the HAT connector. The uart ttyS5 associated with dw-apb-uart.4 is a uart on CN16

So to access the uart on the HAT on ubilinux I have to open the device file /devttyS7

sudo screen /dev/ttyS7 115200

To identify the tty device node for COM1 and COM2 execute the following command:

$ ls /sys/bus/pnp/devices/00\:0*/tty/ | grep tty

/sys/bus/pci/devices/00:02/tty/:
ttyS0
/sys/bus/pci/devices/00:03/tty/:
ttyS1


I2C ports

Similar to UART ports above, I2C device nodes in Linux can be identified as follows:

  • i2c_designware.2 -> I2C channel on hat (pin 27,28 ID_SD ID_SCL)
ls /sys/bus/pci/devices/0000\:00\:15.3/i2c_designware*/ | grep i2c
i2c-1
  • i2c_designware.3 -> I2C channel on hat (pin 3,5 on HAT)
ls /sys/bus/pci/devices/0000\:00\:19.0/i2c_designware*/ | grep i2c
i2c-2

So the linux device node for the first i2c channel is /dev/i2c-1

To detect all the peripherals on the first i2c bus do the following

$ sudo apt install i2c-tools
$ sudo i2cdetect -y -r <b>1
    0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- 61 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --


SPI

Installing ACPI overrides to enable spi in userspace

By default no spi device is created for user access by default. To enable access to spi from userspace you should add an acpi override on the kernel

  1. Download this zip file and uncompress it:
    Spi-enable_upxtreme.zip
  2. enter in the extracted directory and type in a terminal:
  3.  $ sudo ./install_hooks && sudo acpi-add spidev*
  4. reboot the system

now you should see the spi devices under /dev

$ ls /dev/spi*
/dev/spidev0.0  /dev/spidev0.1

LEDs

The UP Xtreme includes 3 LEDs (yellow, green and red) on the underside of the board, which are controlled by the pin control CPLD on the board. As root, you can use the following commands to control the LEDs:

# Turn on the Green LED
echo 1 > /sys/class/leds/upboard\:green\:/brightness
# Turn off the Green LED
echo 0 > /sys/class/leds/upboard\:green\:/brightness

For other LEDS, replace "green" with "red" or "yellow" in the commands above.

Watchdog

The watchdog was is implemented using f71808e_wdt and is identified as /dev/watchdog

To check the device, follow the instructions in Ubuntu guides section.