gobot.io/x/gobot@v1.16.0/platforms/tinkerboard/README.md (about) 1 # Tinker Board 2 3 The ASUS Tinker Board is a single board SoC computer based on the Rockchip RK3288 processor. It has built-in GPIO, PWM, SPI, and I2C interfaces. 4 5 For more info about the Tinker Board, go to [https://www.asus.com/uk/Single-Board-Computer/Tinker-Board/](https://www.asus.com/uk/Single-Board-Computer/Tinker-Board/). 6 7 ## How to Install 8 9 We recommend updating to the [latest Debian TinkerOS](https://github.com/TinkerBoard/debian_kernel/releases) when using the Tinker Board. 10 11 You would normally install Go and Gobot on your workstation. Once installed, cross compile your program on your workstation, transfer the final executable to your Tinker Board, and run the program on the Tinker Board as documented here. 12 13 ``` 14 go get -d -u gobot.io/x/gobot/... 15 ``` 16 17 ### Enabling GPIO pins 18 19 To enable use of the Tinker Board GPIO pins, you need to perform the following steps as a one-time configuration. Once your Tinker Board has been configured, you do not need to do so again. 20 21 Note that these configuration steps must be performed on the Tinker Board itself. The easiest is to login to the Tinker Board via SSH (option "-4" is used to force IPv4, which is needed for some versions of TinkerOS): 22 23 ``` 24 ssh -4 linaro@192.168.1.xxx 25 ``` 26 27 #### Create a group "gpio" 28 29 Create a Linux group named "gpio" by running the following command: 30 31 ``` 32 sudo groupadd -f --system gpio 33 ``` 34 35 If you already have a "gpio" group, you can skip to the next step. 36 37 #### Add the "linaro" user to the new "gpio" group 38 39 Add the user "linaro" to be a member of the Linux group named "gpio" by running the following command: 40 41 ``` 42 sudo usermod -a -G gpio linaro 43 ``` 44 45 If you already have added the "gpio" group, you can skip to the next step. 46 47 #### Add a "udev" rules file 48 49 Create a new "udev" rules file for the GPIO on the Tinker Board by running the following command: 50 51 ``` 52 sudo vi /etc/udev/rules.d/91-gpio.rules 53 ``` 54 55 And add the following contents to the file: 56 57 ``` 58 SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", PROGRAM="/bin/sh -c 'chown root:gpio /sys/class/gpio/export /sys/class/gpio/unexport ; chmod 220 /sys/class/gpio/export /sys/class/gpio/unexport'" 59 SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add", PROGRAM="/bin/sh -c 'chown root:gpio /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value ; chmod 660 /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value'" 60 ``` 61 62 Press the "Esc" key, then press the ":" key and then the "q" key, and then press the "Enter" key. This should save your file. After rebooting your Tinker Board, you should be able to run your Gobot code that uses GPIO. 63 64 ### Enabling I2C 65 66 To enable use of the Tinker Board I2C, you need to perform the following steps as a one-time configuration. Once your Tinker Board has been configured, you do not need to do so again. 67 68 Note that these configuration steps must be performed on the Tinker Board itself. The easiest is to login to the Tinker Board via SSH: 69 70 ``` 71 ssh linaro@192.168.1.xxx 72 ``` 73 74 #### Create a group "i2c" 75 76 Create a Linux group named "i2c" by running the following command: 77 78 ``` 79 sudo groupadd -f --system i2c 80 ``` 81 82 If you already have a "i2c" group, you can skip to the next step. 83 84 #### Add the "linaro" user to the new "i2c" group 85 86 Add the user "linaro" to be a member of the Linux group named "i2c" by running the following command: 87 88 ``` 89 sudo usermod -a -G gpio linaro 90 ``` 91 92 If you already have added the "i2c" group, you can skip to the next step. 93 94 #### Add a "udev" rules file 95 96 Create a new "udev" rules file for the I2C on the Tinker Board by running the following command: 97 98 ``` 99 sudo vi /etc/udev/rules.d/92-i2c.rules 100 ``` 101 102 And add the following contents to the file: 103 104 ``` 105 KERNEL=="i2c-0" , GROUP="i2c", MODE="0660" 106 KERNEL=="i2c-[1-9]*", GROUP="i2c", MODE="0666" 107 ``` 108 109 Press the "Esc" key, then press the ":" key and then the "q" key, and then press the "Enter" key. This should save your file. After rebooting your Tinker Board, you should be able to run your Gobot code that uses I2C. 110 111 ## How to Use 112 113 The pin numbering used by your Gobot program should match the way your board is labeled right on the board itself. 114 115 ```go 116 r := tinkerboard.NewAdaptor() 117 led := gpio.NewLedDriver(r, "7") 118 ``` 119 120 ## How to Connect 121 122 ### Compiling 123 124 Compile your Gobot program on your workstation like this: 125 126 ```bash 127 $ GOARM=7 GOARCH=arm GOOS=linux go build examples/tinkerboard_blink.go 128 ``` 129 130 Once you have compiled your code, you can you can upload your program and execute it on the Tinkerboard from your workstation using the `scp` and `ssh` commands like this: 131 132 ```bash 133 $ scp tinkerboard_blink linaro@192.168.1.xxx:/home/linaro/ 134 $ ssh -t linaro@192.168.1.xxx "./tinkerboard_blink" 135 ```