Skip to content

Pinout_UP2

Teteh Camillus Chinaedu edited this page Dec 1, 2021 · 11 revisions

Pinout


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 Squared

GPIO

On UP Squared at the system start, all the pins in the hat connector are configured in function mode.

So for example the hat pin 3 associated with I2C_SDA function at the 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: The current pinctrl driver implementation does not allow to restore a pin in function mode (e.g. UART) once it has been already switched to GPIO mode until the operating system is rebooted.

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 problems.


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 a different numbering scheme on the same pin at the same time.

Interrupts

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

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

Example IRQ test using Python Periphery

  1. Download this file and extract it on the board
  2. 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/:
 ttyS4
 /sys/bus/pci/devices/0000:00:18.1/dw-apb-uart.9/tty/:
 ttyS5

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 you have to open the device file '''/dev/ttyS5'''

sudo screen /dev/ttyS5 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: -- -- -- -- -- -- -- --

Change I2C clock speed

Reboot the board and enter the BIOS settings menu.

You should now see the I2C configuration menu.

 LPSS I2C #1 refers to I2C0 on HAT pins 27,28
 LPSS I2C #2 refers to I2C1 on HAT pins 3,5
  • To change the speed on I2C1, select Set LPSS I2C #2 Speed and press Enter.

  • The 4 speeds listed are:

    • Standard Mode = 100kHz
    • Fast Mode = 400kHz
    • Fast Plus Mode = 1MHz
    • High Speed Mode = 3MHz
  • Select the desired speed and press Enter.

  • Press F4 to save changes and reboot.

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.
  2. Enter in the extracted directory and type in a terminal:
$ chmod +x acpi-add acpi-upgrades install_hooks
$ sudo ./install_hooks && sudo acpi-add spidev*
  1. 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: 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

ADC ports

UP squared has 4 channels ADC support for Analog input but this is only available in E3940 / E3950 processor SKU.

Before using ADC please check the items below

These can be controlled via /sys/bus/iio/devices/iio:device0/in_voltageX_raw, X is 0 ~ 3.

Run 'cat' command with DevicePath to read the ADC value

$ cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw

Please note that the path name may change, but you should be able to find the in_voltage0_raw under /sys/bus/iio/devices/iio:device or device0

ADC channel HAT PIN DeviceName in Linux SPI ADC124S101 in BIOS
ADC_in1 7 in_voltage0_raw channel 0
ADC_in2 11 in_voltage1_raw channel 1
ADC_in3 13 in_voltage2_raw channel 2
ADC_in4 15 in_voltage3_raw channel 3

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 reconfigures 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 is implemented on UP Squared since BIOS 4.6.

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

Clone this wiki locally