Pinout UP2
Pinout
Device (ubilinux) |
Function | Linux GPIO No. |
RPi GPIO | Pin ▽ |
Pin |
RPi GPIO | Linux |
Function | Device (ubilinux) | |
---|---|---|---|---|---|---|---|---|---|---|
3.3V | 1 | 2 | 5V | |||||||
/dev/i2c-* | I2C1_SDA | 462 | BCM2_SDA | 3 | 4 | 5V | ||||
/dev/i2c-* | 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-* | I2C0_SDA | 464 | BCM0_ID_SD | 27 | 28 | BCM1_ID_SCL | 465 | I2C0_SCL | /dev/i2c-* | |
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 |
![]() |
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^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
![]() |
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. |
![]() |
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\: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-0
- i2c_designware.1 -> I2C channel 0 on hat (pin 3,5 on HAT)
ls /sys/bus/pci/devices/*/i2c_designware.1/ | grep i2c i2c-1
So the linux device node for the first i2c channel is /dev/i2c-0
To detect all the peripherals on the first i2c bus do the following
$ sudo apt install i2c-tools $ sudo i2cdetect -y -r 0 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
- Download this zip file and uncompress it:
Spi-enable.zip - enter in the extracted directory and type in a terminal:
- reboot the system
$ chmod +x acpi-add acpi-upgrades install_hooks $ sudo ./install_hooks && sudo acpi-add spidev*
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
![]() |
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
Group | Function | Pin | Pin | Function | Group |
---|---|---|---|---|---|
MAX10-GPIO/LVDS | GPIO | 1 | 2 | GPIO | MAX10-GPIO/LVDS |
MAX10-GPIO/LVDS | GPIO | 3 | 4 | GPIO | MAX10-GPIO/LVDS |
MAX10-GPIO/LVDS | GND | 5 | 6 | GND | MAX10-GPIO/LVDS |
MAX10-GPIO/LVDS | GPIO | 7 | 8 | GPIO | MAX10-GPIO/LVDS |
MAX10-GPIO/LVDS | GPIO | 9 | 10 | GPIO | MAX10-GPIO/LVDS |
MAX10-GPIO/LVDS | GND | 11 | 12 | GND | MAX10-GPIO/LVDS |
MAX10-GPIO/LVDS | GPIO | 13 | 14 | GPIO | MAX10-GPIO/LVDS |
MAX10-GPIO/LVDS | GPIO | 15 | 16 | GPIO | MAX10-GPIO/LVDS |
MAX10-GPIO/LVDS | GND | 17 | 18 | GND | MAX10-GPIO/LVDS |
MAX10-GPIO/LVDS | GPIO | 19 | 20 | GPIO | MAX10-GPIO/LVDS |
MAX10-GPIO/LVDS | GPIO | 21 | 22 | GPIO | MAX10-GPIO/LVDS |
MAX10-GPIO/LVDS | GND | 23 | 24 | GND | MAX10-GPIO/LVDS |
MAX10-GPIO/LVDS | GPIO | 25 | 26 | GPIO | MAX10-GPIO/LVDS |
MAX10-GPIO/LVDS | GPIO | 27 | 28 | GPIO | MAX10-GPIO/LVDS |
GND | 29 | 30 | GND | ||
LPC | INT_SERIRQ_R | 31 | 32 | LPC_R_CLKOUT0 | LPC |
LPC | LPC_CLKRUN_N | 33 | 34 | GND | LPC |
GND | 35 | 36 | LPC_R_AD3 | LPC | |
SPI | SIO_SPI_1_TXD | 37 | 38 | LPC_R_AD2 | LPC |
SPI | SIO_SPI_1_RXD | 39 | 40 | LPC_R_AD1 | LPC |
SPI | SIO_SPI_1_FS0 | 41 | 42 | LPC_R_AD0 | LPC |
SPI | SIO_SPI_1_FS1 | 43 | 44 | GND | LPC |
SPI | SIO_SPI_1_CLK | 45 | 46 | LPC_FRAME_R | LPC |
GND | 47 | 48 | GND | ||
I2C | I2C_SCL6_3V3 | 49 | 50 | AVS_DMIC_CLK_A1 | DMIC |
I2C | I2C_SDA6_3V3 | 51 | 52 | AVS_DMIC_CLK_B1 | DMIC |
I2C | GND | 53 | 54 | AVS_DMIC_CLK_AB2 | DMIC |
I2C | I2C_SCL5_3V3 | 55 | 56 | GND | DMIC |
I2C | I2C_SDA5_3V3 | 57 | 58 | AVS_DMIC_DATA_1 | DMIC |
GND | 59 | 60 | AVS_DMIC_DATA_2 | DMIC |
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.
Watchdog
The iTCO Watchdog will be implemented for UP2 4.6 BIOS.
To check the device, follow the instructions in Ubuntu guides section.