hybridgroup.gobot/platforms/rockpi
Thomas Kohler bfba1ab9e0
i2c/spi: remove offensive terminology (#1071)
2024-02-13 18:16:18 +01:00
..
LICENSE Build(v2): revert move to v2 subfolder (#932) 2023-05-29 19:23:28 +02:00
README.md examples: fix missing checks of return values (#1060) 2024-02-11 15:34:50 +01:00
doc.go doc: update links to release or tagged branch (#1069) 2024-02-13 15:58:31 +01:00
rockpi_adaptor.go i2c/spi: remove offensive terminology (#1071) 2024-02-13 18:16:18 +01:00
rockpi_adaptor_test.go lint(all): fix issues of errorlint etc (#1037) 2023-11-15 20:51:52 +01:00
rockpi_pin_map.go Build(v2): revert move to v2 subfolder (#932) 2023-05-29 19:23:28 +02:00

README.md

Radxa Rock Pi

The Radxa Rock Pi board series are clones of the popular Raspberry Pi Single Board Computers (SBCs) with GPIO/PWM/I2C functionalities built-in.

The Gobot adaptor is currently compatible with:

  • Rock Pi 4
  • Rock Pi 4C+

With the possibility to expand its compatibility into past and future models.

Check out the output of cat /proc/device-tree/model to see which model you have if you're not sure. The 4C+ model has a Rockchip 3399_T SoC, while the regular 4 has the 3399. Both are similar, but have slightly different GPIO pin configurations.

How to Install

Make sure you've installed an official Linux image from Radxa with working drivers. See the ROCK 4 Installation Wiki for your SBC setup.

Some versions or Armbian ISOs do not detect the newer SoC chips.

As for your Gobot development, treat this as a regular Go package. It can be cross-compiled and copied over, or simply compiled on the SBC itself (tested and working with go 1.15.15 on linux/arm64, RockPi4C+).

How to Use

The pin numbering used by your Gobot program should match the way your board is labeled right on the board itself.

That is, follow the colored Pin# numbers in the middle in the GPIO mapping Wiki. These have been translated for you into their corresponding underlying GPIO numbers.

package main

import (
        "time"

        "gobot.io/x/gobot/v2"
        "gobot.io/x/gobot/v2/drivers/gpio"
        "gobot.io/x/gobot/v2/platforms/rockpi"
)

func main() {
        r := rockpi.NewAdaptor()
        led := gpio.NewLedDriver(r, "7")

        work := func() {
                gobot.Every(1*time.Second, func() {
                        if err := led.Toggle(); err != nil {
				fmt.Println(err)
			}
                })
        }

        robot := gobot.NewRobot("blinkBot",
                []gobot.Connection{r},
                []gobot.Device{led},
                work,
        )

        if err := robot.Start(); err != nil {
		panic(err)
	}
}

If you want to use I2C, RockPi4 offers three I2C buses: I2C2 (pins 27, 28), I2C6 (pins 29, 31) and I2C7 (pins 3, 5) of which I2C7 is the default. Changing this is a matter of passing the right bus number using i2c.WithBus:

a := rockpi.NewAdaptor()
adc2 := i2c.NewADS1115Driver(a, i2c.WithBus(6))

There are mapped to /dev/i2c-[bus], just like the Gobot raspi implementation.

What's currently supported?

  • General digital pin GPIO access works, but not through the new character device driver.
  • The I2C buses 2, 6, 7 work
  • SPI buses 1, 2 work

PWM interaction is currently not yet supported.

Please see the official Radxa Rock Pi documentation on how librmaa can be utilized in combination with this module, and how these work.

Compiling

Compile your Gobot program on your workstation like this:

$ GOARCH=arm64 GOOS=linux go build examples/rockpi_blink.go

Rock Pi 4s are ARM64 machines.