Skip to content

Pinout_UPSPro

AAEONAEU-SW edited this page Aug 2, 2021 · 7 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 Pro

Below instructions are for BIOS version R1.2 and higher. Currently available version for UPS Pro is R1.1

GPIO

On UP Squared Pro 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 <b>0</b>
     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

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 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 Pro 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 Pro since BIOS ?.

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

Clone this wiki locally