periph / devices

Go·Hardware·Lean - Device drivers
https://periph.io
Apache License 2.0
83 stars 37 forks source link

Jetson Orin AGX #69

Open notnil opened 5 months ago

notnil commented 5 months ago

What kind of new feature are you looking for? (Keep the one that applies, please describe)

Do you plan to:

The Jetson Orin AGX has the RPi GPIO layout. Does this mean it will just work?

_, err := host.Init()
if err != nil {
    panic(err)
}

outputPin := rpi.P1_13
outputPin.Out(gpio.High)

doesn't work while the equivalent on https://github.com/NVIDIA/jetson-gpio does:

import RPi.GPIO as GPIO
import time

# Pin Definitons:
led_pin = 13  # BOARD pin 13

def main():
    # Pin Setup:
    GPIO.setmode(GPIO.BOARD)  # BOARD pin-numbering scheme
    GPIO.setup(led_pin, GPIO.OUT)  # LED pin set as output

    GPIO.output(led_pin, GPIO.HIGH)

if __name__ == '__main__':
    main()
notnil commented 5 months ago

I get when logging the outputPin.Out error:

panic: bcm283x-gpio (GPIO27): subsystem gpiomem not initialized and sysfs not accessible
maruel commented 5 months ago

What is needed is a detection system, see https://github.com/periph/host/blob/main/rpi/rpi.go#L28 or https://github.com/periph/host/blob/main/beagle/black/black.go#L31 or https://github.com/periph/host/blob/main/orangepi/orangepi.go#L27 for example.

notnil commented 5 months ago

Ok just to confirm it won't work and I'll have to figure out another way to run?

maruel commented 5 months ago

Do not use the rpi package if you are not on a raspberry pi. Instead, use GPIOs as they are named, using the gpioreg package; https://pkg.go.dev/periph.io/x/conn/v3/gpio/gpioreg#ByName

notnil commented 5 months ago
package main

import (
    "os"

    "github.com/rs/zerolog"
    "periph.io/x/conn/v3/driver/driverreg"
    "periph.io/x/conn/v3/gpio/gpioreg"
)

func main() {
    logger := zerolog.New(os.Stdout)
    if _, err := driverreg.Init(); err != nil {
        logger.Fatal().Err(err).Msg("failed to initialize periph.io")
    }
    for _, pin := range gpioreg.All() {
        logger.Info().Interface("pin", pin).Msg("found pin")
    }
        if gpioreg.ByName("16") == nil {
            logger.Fatal().Msg("Failed to find GPI16")
        }
}

Doesn't find anything running on the Jetson AGX Orin. Command is run with sudo.

{"level":"fatal","message":"Failed to find GPI16"}