Pinout UP2

From UpWiki
Jump to: navigation, search

Pinout

Device
(ubilinux)
Function Linux
GPIO No.
RPi GPIO Pin
Pin
 
RPi GPIO Linux
 
Function Device
(ubilinux)
3.3V 1 2 5V
/dev/i2c-6 I2C1_SDA 462 BCM2_SDA 3 4 5V
/dev/i2c-6 I2C1_SCL 463 BCM3_SCL 5 6 Ground
433 BCM4 7 8 BCM14_TXD 477 UART1_TX /dev/ttyS1
Ground 9 10 BCM15_RXD 476 UART1_RX /dev/ttyS1
/dev/ttyS1 UART1_RTS 478 BCM17 11 12 BCM18_PWM0 326 AVS_I2S6_BCLK
432 BCM27 13 14 Ground
431 BCM22 15 16 BCM23 471 PWM3 /sys/class/pwm/pwmchip0/pwm3
3.3V 17 18 BCM24 405
/etc/spidev1.x SPI0_MOSI 422 BCM10_MOSI 19 20 Ground
/etc/spidev1.x SPI0_MISO 421 BCM9_MISO 21 22 BCM25 402
/etc/spidev1.x SPI0_CLK 418 BCM11_SCLK 23 24 BCM8_CE0 419 SPI0_CS0 /etc/spidev1.0
Ground 25 26 BCM7_CE1 420 SPI0_CS1 /etc/spidev1.1
/dev/i2c-5 I2C0_SDA 464 BCM0_ID_SD 27 28 BCM1_ID_SCL 465 I2C0_SCL /dev/i2c-5
430 BCM5 29 30 Ground
404 BCM6 31 32 BCM12_PWM0 468 PWM0 /sys/class/pwm/pwmchip0/pwm0
/sys/class/pwm/pwmchip0/pwm1 PWM1 469 BCM13_PWM1 33 34 Ground
AVS_I2S6_WS_SYNC 327 BCM19 35 36 BCM16 479 UART1_CTS /dev/ttyS1
403 BCM26 37 38 BCM20 328 AVS_I2S6_SDI
Ground 39 40 BCM21 329 AVS_I2S6_SDO
Pin Legend
GPIO
UART
I2C
SPI
PWM
I2S

Accessing the peripherals on the UP^2

GPIO

On UP^2 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
  1. install python3-pip
sudo apt update && sudo apt install python3-pip
  1. install periphery from pip
sudo -H pip3 install python-periphery
  1. 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\:18.?/dw-apb-uart.*/tty/ | grep tty

/sys/bus/pci/devices/0000:00:18.0/dw-apb-uart.8/tty/:
ttyS0
/sys/bus/pci/devices/0000:00:18.1/dw-apb-uart.9/tty/:
ttyS1

The first UART (associated to dw-apb-uart.8) is the uart on the M10 connector, and the one associated with dw-apb-uart.9 is the one on the HAT.

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

sudo screen /dev/ttyS1 115200

I2C ports

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

  • i2c_designware.0 -> I2C channel 0 on hat (ID_SD ID_SCL)
ls /sys/bus/pci/devices/*/i2c_designware.0/ | grep i2c
i2c-5
  • i2c_designware.1 -> I2C channel 0 on hat (pin 3,5 on HAT)
ls /sys/bus/pci/devices/*/i2c_designware.1/ | grep i2c
i2c-6

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

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

$ sudo apt install i2c-tools
$ sudo i2cdetect -y -r 5
    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 Ports

SPI device nodes in Linux can be identified as follows:

$ ls /sys/bus/pci/devices/0000\:00\:19.*/pxa2xx-spi.*/spi_master/ | grep spi
/sys/bus/pci/devices/0000:00:19.0/pxa2xx-spi.10/spi_master/:
spi1
/sys/bus/pci/devices/0000:00:19.2/pxa2xx-spi.11/spi_master/:
spi3

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.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/spidev1.0  /dev/spidev1.1

PWM ports

There's just one PWM controller on APL-I, and it provides 4 PWM outputs.

These can be controlled via /sys/class/pwm/pwmchip0

Of those 4 ports only port 0, 1 and 3 are available to the user and correspond on

PWM channel HAT PIN
pwm0 32: PWM0
pwm1 33: PWM1
pwm2 Not Available
pwm3 16: PWM3

If you don't see the above directory double check that in the bios the option

Main > CRB Setup > CRB Chipset > South Bridge > OS Selection

is set to: Intel Linux

Warning Warning: Add information about maximum pwm frequency/duty cycle

Example: Generate PWM signal on PWM0

To generate a 293 Hz square wave pulse on pin 32, with a duty cycle of approximately 50% on PWM0 pin, execute the following commands as root:

$ echo 0 > /sys/class/pwm/pwmchip0/export
$ echo 3413333 > /sys/class/pwm/pwmchip0/pwm0/period
$ echo 1706667 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
$ echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable

I2S

exHAT Pinout

exHAT connector

FPGA

The Intel Fpga MAX10 10M02 fpga act as a level shifter between the Intel Soc and the Hat/exHAT interfaces.

The Emutex pinctrl driver reconfigure the pin direction (input/output/highz) between the external connector and the soc.

Because almost every connection to hat/exhat passes through the fpga is also possible to provide customized firmware to expose other peripherals/pin mapping on hat/exHAT or to implement custom devices in the fpga fabric.

LEDs

The UP Squared includes 4 LEDs (yellow, green, red and blue) on the underside of the board (underneath Ethernet dual port), which are controlled by the pin control FPGA 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","blue" or "yellow" in the commands above.