Skip to content

Commit

Permalink
beaglebone: update pin naming, docs, and examples for the latest Debi…
Browse files Browse the repository at this point in the history
…an OS releases

Signed-off-by: Ron Evans <[email protected]>
  • Loading branch information
deadprogram committed Feb 13, 2018
1 parent f6c1a02 commit f544033
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 53 deletions.
2 changes: 1 addition & 1 deletion examples/beaglebone_button.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

func main() {
beagleboneAdaptor := beaglebone.NewAdaptor()
button := gpio.NewButtonDriver(beagleboneAdaptor, "P8_9")
button := gpio.NewButtonDriver(beagleboneAdaptor, "P8_09")

work := func() {
button.On(gpio.ButtonPush, func(data interface{}) {
Expand Down
2 changes: 1 addition & 1 deletion examples/beaglebone_direct_pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
func main() {
beagleboneAdaptor := beaglebone.NewAdaptor()
led := gpio.NewDirectPinDriver(beagleboneAdaptor, "P8_10")
button := gpio.NewDirectPinDriver(beagleboneAdaptor, "P8_9")
button := gpio.NewDirectPinDriver(beagleboneAdaptor, "P8_09")

work := func() {
gobot.Every(500*time.Millisecond, func() {
Expand Down
2 changes: 1 addition & 1 deletion examples/beaglebone_makey_button.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

func main() {
beagleboneAdaptor := beaglebone.NewAdaptor()
button := gpio.NewMakeyButtonDriver(beagleboneAdaptor, "P8_9")
button := gpio.NewMakeyButtonDriver(beagleboneAdaptor, "P8_09")

work := func() {
button.On(gpio.ButtonPush, func(data interface{}) {
Expand Down
31 changes: 9 additions & 22 deletions platforms/beaglebone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import (

func main() {
beagleboneAdaptor := beaglebone.NewPocketBeagleAdaptor()
led := gpio.NewLedDriver(beagleboneAdaptor, "P1_2")
led := gpio.NewLedDriver(beagleboneAdaptor, "P1_02")

work := func() {
gobot.Every(1*time.Second, func() {
Expand Down Expand Up @@ -114,7 +114,7 @@ You must also configure hardware settings as described below.

### Updating your board to the latest OS

We recommend updating your BeagleBone to the latest Debian OS. It is very easy to do this using the Etcher (https://etcher.io/) utility program.
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.

First, download the latest BeagleBone OS from http://beagleboard.org/latest-images

Expand All @@ -134,29 +134,16 @@ http://beagleboard.org/getting-started

### Configure hardware settings

In order to enable the various hardware devices on your BeagleBone or PocketBeagle, you need to configure a special file named `/boot/uEnv.txt`.
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.

This file controls all of the different hardware options used at startup time, so you can enable or disable features based on your specific needs. You only need to do this once, and then the settings will apply each time you start up your BeagleBone.
If you want to dig in and learn more about this check out:

First connect to the BeagleBone using ssh:
https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays

```
ssh [email protected]
```

Once you are connected to the BeagleBone, edit the /boot/uEnv.txt file like this:
### Upgrading from an older version

```
sudo nano /boot/uEnv.txt
```

To enable GPIO, PWM, I2C, and SPI, modify the `##Example v4.1.x` section to add a line to enable the cape manager:

```
##Example v4.1.x
cape_enable=bone_capemgr.enable_partno=cape-universaln,BB-ADC
```
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:

Save the file, then reboot your BeagleBone.
sudo dd if=/dev/zero of=/dev/mmcblk1 count=1 seek=1 bs=128k

You will now be able to run your Gobot programs to control the various hardware.
Thanks to [@RobertCNelson](https://github.com/RobertCNelson) for the tip on the above.
8 changes: 3 additions & 5 deletions platforms/beaglebone/beaglebone_adaptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestBeagleboneAdaptor(t *testing.T) {
fs := sysfs.NewMockFilesystem([]string{
"/dev/i2c-2",
"/sys/devices/platform/bone_capemgr",
"/sys/devices/platform/ocp/ocp:P8_7_pinmux/state",
"/sys/devices/platform/ocp/ocp:P8_07_pinmux/state",
"/sys/devices/platform/ocp/ocp:P9_11_pinmux/state",
"/sys/devices/platform/ocp/ocp:P9_12_pinmux/state",
"/sys/devices/platform/ocp/ocp:P9_22_pinmux/state",
Expand Down Expand Up @@ -154,12 +154,12 @@ func TestBeagleboneAdaptor(t *testing.T) {
gobottest.Assert(t, err, errors.New("Not a valid pin"))

fs.Files["/sys/class/gpio/gpio66/value"].Contents = "1"
i, err = a.DigitalRead("P8_7")
i, err = a.DigitalRead("P8_07")
gobottest.Assert(t, i, 1)
gobottest.Assert(t, err, nil)

fs.WithReadError = true
_, err = a.DigitalRead("P8_7")
_, err = a.DigitalRead("P8_07")
gobottest.Assert(t, err, errors.New("read error"))
fs.WithReadError = false

Expand Down Expand Up @@ -214,7 +214,6 @@ func TestBeagleboneAnalogReadFileError(t *testing.T) {

func TestBeagleboneDigitalPinDirectionFileError(t *testing.T) {
fs := sysfs.NewMockFilesystem([]string{
"/sys/devices/platform/bone_capemgr/slots",
"/sys/class/gpio/export",
"/sys/class/gpio/gpio60/value",
"/sys/devices/platform/ocp/ocp:P9_12_pinmux/state",
Expand All @@ -232,7 +231,6 @@ func TestBeagleboneDigitalPinDirectionFileError(t *testing.T) {

func TestBeagleboneDigitalPinFinalizeFileError(t *testing.T) {
fs := sysfs.NewMockFilesystem([]string{
"/sys/devices/platform/bone_capemgr/slots",
"/sys/class/gpio/export",
"/sys/class/gpio/gpio60/value",
"/sys/class/gpio/gpio60/direction",
Expand Down
10 changes: 5 additions & 5 deletions platforms/beaglebone/black_pins.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package beaglebone

var bbbPinMap = map[string]int{
// P8_1 - P8_2 GND
// P8_3 - P8_6 EMCC
"P8_7": 66,
"P8_8": 67,
"P8_9": 69,
// P8_01 - P8_2 GND
// P8_03 - P8_6 EMCC
"P8_07": 66,
"P8_08": 67,
"P8_09": 69,
"P8_10": 68,
"P8_11": 45,
"P8_12": 44,
Expand Down
36 changes: 18 additions & 18 deletions platforms/beaglebone/pocketbeagle_pins.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package beaglebone

var pocketBeaglePinMap = map[string]int{
// P1_1 - VIN
"P1_2": 87,
// P1_3 - USB1-V_EN
"P1_4": 89,
// P1_5 - USB1-VBUS
"P1_6": 5,
// P1_7 - USB1-VIN
"P1_8": 2,
// P1_9 - USB1-DN
// P1_01 - VIN
"P1_02": 87,
// P1_03 - USB1-V_EN
"P1_04": 89,
// P1_05 - USB1-VBUS
"P1_06": 5,
// P1_07 - USB1-VIN
"P1_08": 2,
// P1_09 - USB1-DN
"P1_10": 3,
// P1_11 - USB1-DP
"P1_12": 4,
Expand Down Expand Up @@ -38,15 +38,15 @@ var pocketBeaglePinMap = map[string]int{
"P1_35": 88,
"P1_36": 110,

"P2_1": 50,
"P2_2": 59,
"P2_3": 23,
"P2_4": 58,
"P2_5": 30,
"P2_6": 57,
"P2_7": 31,
"P2_8": 60,
"P2_9": 15,
"P2_01": 50,
"P2_02": 59,
"P2_03": 23,
"P2_04": 58,
"P2_05": 30,
"P2_06": 57,
"P2_07": 31,
"P2_08": 60,
"P2_09": 15,
"P2_10": 52,
"P2_11": 14,
// P2_12 - PWR-BTN
Expand Down

0 comments on commit f544033

Please sign in to comment.