gobot.io/x/gobot/v2@v2.1.0/platforms/beaglebone/README.md (about) 1 # Beaglebone 2 3 The BeagleBone is an ARM based single board computer, with lots of GPIO, I2C, and analog interfaces built in. 4 5 The Gobot adaptor for the BeagleBone supports all of the various BeagleBone boards such as the BeagleBone Black, SeeedStudio BeagleBone Green, SeeedStudio BeagleBone Green Wireless, and others that use the latest Debian and standard "Cape Manager" interfaces. 6 7 For more info about the BeagleBone platform go to [http://beagleboard.org/getting-started](http://beagleboard.org/getting-started). 8 9 In addition, there is an separate Adaptor for the PocketBeagle, a USB-key-fob sized computer. The PocketBeagle has a different pin layout and somewhat different capabilities. 10 11 For more info about the PocketBeagle platform go to [http://beagleboard.org/pocket](http://beagleboard.org/pocket). 12 13 14 ## How to Install 15 16 We recommend updating to the latest Debian OS when using the BeagleBone. The current Gobot only supports 4.x versions of the OS. If you need support for older versions of the OS, you will need to use Gobot v1.4. 17 18 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 BeagleBone, and run the program on the BeagleBone itself as documented here. 19 20 ``` 21 go get -d -u gobot.io/x/gobot/v2/... 22 ``` 23 24 ## How to Use 25 26 The pin numbering used by your Gobot program should match the way your board is labeled right on the board itself. 27 28 Gobot also has support for the four built-in LEDs on the BeagleBone Black, by referring to them as `usr0`, `usr1`, `usr2`, and `usr3`. 29 30 ```go 31 package main 32 33 import ( 34 "time" 35 36 "gobot.io/x/gobot/v2" 37 "gobot.io/x/gobot/v2/drivers/gpio" 38 "gobot.io/x/gobot/v2/platforms/beaglebone" 39 ) 40 41 func main() { 42 beagleboneAdaptor := beaglebone.NewAdaptor() 43 led := gpio.NewLedDriver(beagleboneAdaptor, "P9_12") 44 45 work := func() { 46 gobot.Every(1*time.Second, func() { 47 led.Toggle() 48 }) 49 } 50 51 robot := gobot.NewRobot("blinkBot", 52 []gobot.Connection{beagleboneAdaptor}, 53 []gobot.Device{led}, 54 work, 55 ) 56 57 robot.Start() 58 } 59 ``` 60 61 To use the PocketBeagle, use `beaglebone.NewPocketBeagleAdaptor()` like this: 62 63 ```go 64 package main 65 66 import ( 67 "time" 68 69 "gobot.io/x/gobot/v2" 70 "gobot.io/x/gobot/v2/drivers/gpio" 71 "gobot.io/x/gobot/v2/platforms/beaglebone" 72 ) 73 74 func main() { 75 beagleboneAdaptor := beaglebone.NewPocketBeagleAdaptor() 76 led := gpio.NewLedDriver(beagleboneAdaptor, "P1_02") 77 78 work := func() { 79 gobot.Every(1*time.Second, func() { 80 led.Toggle() 81 }) 82 } 83 84 robot := gobot.NewRobot("pocketBeagleBot", 85 []gobot.Connection{beagleboneAdaptor}, 86 []gobot.Device{led}, 87 work, 88 ) 89 90 robot.Start() 91 } 92 ``` 93 94 ## How to Connect 95 96 ### Compiling 97 98 Compile your Gobot program on your workstation like this: 99 100 ```bash 101 $ GOARM=7 GOARCH=arm GOOS=linux go build examples/beaglebone_blink.go 102 ``` 103 104 Once you have compiled your code, you can you can upload your program and execute it on the BeagleBone from your workstation using the `scp` and `ssh` commands like this: 105 106 ```bash 107 $ scp beaglebone_blink debian@192.168.7.2:/home/debian/ 108 $ ssh -t debian@192.168.7.2 "./beaglebone_blink" 109 ``` 110 111 In order to run the preceeding commands, you must be running the official Debian Linux through the usb->ethernet connection, or be connected to the board using WiFi. 112 113 You must also configure hardware settings as described below. 114 115 ### Updating your board to the latest OS 116 117 We recommend using your BeagleBone with the latest Debian OS. It is very easy to do this using the Etcher (https://etcher.io/) utility program. 118 119 First, download the latest BeagleBone OS from http://beagleboard.org/latest-images 120 121 Now, use Etcher to create an SD card with the OS image you have downloaded. 122 123 Once you have created the SD card, boot your BeagleBone using the new image as follows: 124 125 - Insert SD card into your (powered-down) board, hold down the USER/BOOT button (if using Black) and apply power, either by the USB cable or 5V adapter. 126 127 - If all you want to do it boot once from the SD card, it should now be booting. 128 129 - If using BeagleBone Black and desire to write the image to your on-board eMMC, you'll need to follow the instructions at http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#Flashing_eMMC. When the flashing is complete, all 4 USRx LEDs will be steady on or off. The latest Debian flasher images automatically power down the board upon completion. This can take up to 45 minutes. Power-down your board, remove the SD card and apply power again to be complete. 130 131 These instructions come from the Beagleboard web site's "Getting Started" page located here: 132 133 http://beagleboard.org/getting-started 134 135 ### Configure hardware settings 136 137 Thanks to the BeagleBone team, the new "U-Boot Overlays" system for enabling hardware and the "cape-universal", the latest Debian OS should "just work" with any GPIO, PWM, I2C, or SPI pins. 138 139 If you want to dig in and learn more about this check out: 140 141 https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays 142 143 ### Upgrading from an older version 144 145 Please note that if you are upgrading a board that has already run from an older version of Debian OS, you might need to clear out your older eMMC bootloader, otherwise the new U-Boot Overlays in the newer U-Boot may not get enabled. If so, login using SSH and run the following command on your BeagleBone board: 146 147 sudo dd if=/dev/zero of=/dev/mmcblk1 count=1 seek=1 bs=128k 148 149 Thanks to [@RobertCNelson](https://github.com/RobertCNelson) for the tip on the above.