gobot.io/x/gobot@v1.16.0/platforms/upboard/up2/README.md (about)

     1  # UP2
     2  
     3  The UP2 Board aka "Up Squared" is a single board SoC computer based on the Intel Apollo Lake processor. It has built-in GPIO, PWM, SPI, and I2C interfaces.
     4  
     5  For more info about the UP2 Board, go to [http://www.up-board.org/upsquared/](http://www.up-board.org/upsquared/).
     6  
     7  ## How to Install
     8  
     9  ### Update operating system and BIOS on UP2 board
    10  
    11  We recommend updating to the latest Ubuntu 16.04 and BIOS v3.3 when using the UP2 board. To update your UP2 OS go to:
    12  
    13  https://downloads.up-community.org/download/up-squared-iot-grove-development-kit-ubuntu-16-04-server-image/
    14  
    15  To update your UP2 BIOS, go to:
    16  
    17  https://downloads.up-community.org/download/up-squared-uefi-bios-v3-3/
    18  
    19  Once your UP2 has been updated, you will need to provide permission to the `upsquared` user to access the GPIO or I2C subsystems on the board.
    20  
    21  ### Configuring GPIO on UP2 board
    22  
    23  To access the GPIO subsystem, you will need to create a new group, add your user to the group, and then add a UDEV rule.
    24  
    25  First, run the following commands on the board itself:
    26  
    27  ```
    28  sudo groupadd gpio
    29  sudo adduser upsquared gpio
    30  ```
    31  
    32  Now, add a new UDEV rule to the UP2 board. Add the following text as a new UDEV rule named `/etc/udev/rules.d/99-gpio.rules`:
    33  
    34  ```
    35  SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c '\
    36          chown -R root:gpiouser /sys/class/gpio && chmod -R 770 /sys/class/gpio;\
    37          chown -R root:gpiouser /sys/devices/virtual/gpio && chmod -R 770 /sys/devices/virtual/gpio;\
    38          chown -R root:gpiouser /sys$devpath && chmod -R 770 /sys$devpath\
    39  '"
    40  ```
    41  
    42  ### Configuring built-in LEDs on UP2 board
    43  
    44  To use the built-in LEDs you will need to create a new group, add your user to the group, and then add a UDEV rule.
    45  
    46  First, run the following commands on the board itself:
    47  
    48  ```
    49  sudo groupadd leds
    50  sudo adduser upsquared leds
    51  ```
    52  
    53  Now add the following text as a new UDEV rule named `/etc/udev/rules.d/99-leds.rules`:
    54  
    55  ```
    56  SUBSYSTEM=="leds*", PROGRAM="/bin/sh -c '\
    57          chown -R root:leds /sys/class/leds && chmod -R 770 /sys/class/leds;\
    58          chown -R root:leds /sys/devices/platform/up-pinctrl/leds && chmod -R 770 /sys/devices/platform/up-pinctrl/leds;\
    59          chown -R root:leds /sys/devices/platform/AANT0F01:00/upboard-led.* && chmod -R 770 /sys/devices/platform/AANT0F01:00/upboard-led.*;\
    60  '"
    61  ```
    62  
    63  ### Configuring I2C on UP2 board
    64  
    65  To access the I2C subsystem, run the following command:
    66  
    67  ```
    68  sudo usermod -aG i2c upsquared
    69  ```
    70  
    71  You should reboot your UP2 board after making these changes for them to take effect.
    72  
    73  **IMPORTANT NOTE REGARDING I2C:** 
    74  The current UP2 firmware is not able to scan for I2C devices using the `i2cdetect` command line tool. If you run this tool, it will cause the I2C subsystem to malfunction until you reboot your system. That means at this time, do not use `i2cdetect` on the UP2 board.
    75  
    76  ### Local setup
    77  
    78  You would normally install Go and Gobot on your local workstation. Once installed, cross compile your program on your workstation, transfer the final executable to your UP2, and run the program on the UP2 as documented below.
    79  
    80  ```
    81  go get -d -u gobot.io/x/gobot/...
    82  ```
    83  
    84  ## How to Use
    85  
    86  The pin numbering used by your Gobot program should match the way your board is labeled right on the board itself.
    87  
    88  ```go
    89  r := up2.NewAdaptor()
    90  led := gpio.NewLedDriver(r, "13")
    91  ```
    92  
    93  You can also use the values `up2.LEDRed`, `up2.LEDBlue`, `up2.LEDGreen`, and `up2.LEDYellow` as pin reference to access the 4 built-in LEDs. For example:
    94  
    95  ```go
    96  r := up2.NewAdaptor()
    97  led := gpio.NewLedDriver(r, up2.LEDRed)
    98  ```
    99  
   100  ## How to Connect
   101  
   102  ### Compiling
   103  
   104  Compile your Gobot program on your workstation like this:
   105  
   106  ```bash
   107  $ GOARCH=amd64 GOOS=linux go build examples/up2_blink.go
   108  ```
   109  
   110  Once you have compiled your code, you can you can upload your program and execute it on the UP2 from your workstation using the `scp` and `ssh` commands like this:
   111  
   112  ```bash
   113  $ scp up2_blink upsquared@192.168.1.xxx:/home/upsquared/
   114  $ ssh -t upsquared@192.168.1.xxx "./up2_blink"
   115  ```