From 062f9063d71c1a89b9d3734f4ba21fed6acf833a Mon Sep 17 00:00:00 2001 From: martha-johnston Date: Fri, 1 Nov 2024 12:11:06 -0400 Subject: [PATCH] add driver code --- README.md | 9 +- go.mod | 5 +- go.sum | 5 ++ jetson/board.go | 30 +++++++ jetson/data.go | 223 +++++++++++++++++++++++++++++++++++++++++++++++ jetson/jetson.go | 0 meta.json | 35 ++++---- 7 files changed, 288 insertions(+), 19 deletions(-) create mode 100644 jetson/board.go create mode 100644 jetson/data.go delete mode 100644 jetson/jetson.go diff --git a/README.md b/README.md index 1545dc4..82f7a50 100644 --- a/README.md +++ b/README.md @@ -1 +1,8 @@ -# nvidia \ No newline at end of file +# nvidia + +# Jetson + +## Setup + +* Follow https://www.jetsonhacks.com/2020/05/16/nvidia-jetson-xavier-nx-developer-kit/ +* Also run `sudo modprobe spidev` or add as a start up script \ No newline at end of file diff --git a/go.mod b/go.mod index a66022f..10732dc 100644 --- a/go.mod +++ b/go.mod @@ -8,10 +8,12 @@ require ( github.com/edaniels/golinters v0.0.5-0.20220906153528-641155550742 github.com/fullstorydev/grpcurl v1.8.6 github.com/golangci/golangci-lint v1.61.0 + github.com/pkg/errors v0.9.1 github.com/rhysd/actionlint v1.6.24 go.viam.com/rdk v0.48.2 go.viam.com/utils v0.1.110 gotest.tools/gotestsum v1.10.0 + periph.io/x/host/v3 v3.8.1-0.20230331112814-9f0d9f7d76db ) require ( @@ -185,6 +187,7 @@ require ( github.com/miekg/dns v1.1.53 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/mkch/gpio v0.0.0-20190919032813-8327cd97d95e // indirect github.com/montanaflynn/stats v0.7.0 // indirect github.com/moricho/tparallel v0.3.2 // indirect github.com/nakabonne/nestif v0.3.1 // indirect @@ -209,7 +212,6 @@ require ( github.com/pion/stun v0.6.1 // indirect github.com/pion/transport/v2 v2.2.10 // indirect github.com/pion/turn/v2 v2.1.6 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/polyfloyd/go-errorlint v1.6.0 // indirect @@ -319,4 +321,5 @@ require ( mvdan.cc/gofumpt v0.7.0 // indirect mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f // indirect nhooyr.io/websocket v1.8.7 // indirect + periph.io/x/conn/v3 v3.7.0 // indirect ) diff --git a/go.sum b/go.sum index 2d19bd2..fe37f92 100644 --- a/go.sum +++ b/go.sum @@ -761,6 +761,8 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jonboulle/clockwork v0.2.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= +github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg= +github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -949,6 +951,8 @@ github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/mkch/asserting v0.0.0-20190916092325-c18221b2f2b2 h1:ZuTZrURK+9dqhtVw11exJ65tjbh3DVXj4L5R1KnFAU8= +github.com/mkch/asserting v0.0.0-20190916092325-c18221b2f2b2/go.mod h1:7QF1TGIJmEibF74aU9YWLLfDOnl4R94hWzpD/zWowbM= github.com/mkch/gpio v0.0.0-20190919032813-8327cd97d95e h1:vSAYdBvTvlYVdoDYYQapVnlPd8Klrk19uHPDy29agsg= github.com/mkch/gpio v0.0.0-20190919032813-8327cd97d95e/go.mod h1:4uOFgu7xPZTSz7NSamkmHD67Y6CdXgK9Lx8Dm0qm1vQ= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -1699,6 +1703,7 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/jetson/board.go b/jetson/board.go new file mode 100644 index 0000000..946dcac --- /dev/null +++ b/jetson/board.go @@ -0,0 +1,30 @@ +// Package jetson implements a jetson-based board. +package jetson + +import ( + "github.com/pkg/errors" + "periph.io/x/host/v3" + + "go.viam.com/rdk/components/board/genericlinux" + "go.viam.com/rdk/logging" + "go.viam.com/rdk/resource" +) + +const modelName = "jetson" + +// Model for viam supported nvidia jetson board. +var Model = resource.NewModel("viam", "nvidia", "jetson") + +func init() { + if _, err := host.Init(); err != nil { + logging.Global().Debugw("error initializing host", "error", err) + } + + gpioMappings, err := genericlinux.GetGPIOBoardMappings(modelName, boardInfoMappings) + var noBoardErr genericlinux.NoBoardFoundError + if errors.As(err, &noBoardErr) { + logging.Global().Debugw("error getting jetson GPIO board mapping", "error", err) + } + + genericlinux.RegisterBoard(modelName, gpioMappings) +} diff --git a/jetson/data.go b/jetson/data.go new file mode 100644 index 0000000..19e5c62 --- /dev/null +++ b/jetson/data.go @@ -0,0 +1,223 @@ +package jetson + +import ( + "go.viam.com/rdk/components/board/genericlinux" +) + +const ( + jetsonTX2 = "jetson_tx2" + jetsonNano = "jetson_nano" + jetsonTX2NX = "jetson_tx2_NX" + jetsonOrinAGX = "jetson_orin_agx" + jetsonOrinNX = "jetson_orin_nx" + jetsonOrinNano = "jetson_orin_nano" +) + +//nolint:dupl // This is not actually a duplicate of jetsonNanoPins despite what the linter thinks +var jetsonTX2NXPins = []genericlinux.PinDefinition{ + {Name: "7", DeviceName: "gpiochip0", LineNumber: 76, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "11", DeviceName: "gpiochip1", LineNumber: 28, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "12", DeviceName: "gpiochip0", LineNumber: 72, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "13", DeviceName: "gpiochip1", LineNumber: 17, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "15", DeviceName: "gpiochip0", LineNumber: 18, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "16", DeviceName: "gpiochip0", LineNumber: 19, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "18", DeviceName: "gpiochip1", LineNumber: 20, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "19", DeviceName: "gpiochip0", LineNumber: 58, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "21", DeviceName: "gpiochip0", LineNumber: 57, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "22", DeviceName: "gpiochip1", LineNumber: 18, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "23", DeviceName: "gpiochip0", LineNumber: 56, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "24", DeviceName: "gpiochip0", LineNumber: 59, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "26", DeviceName: "gpiochip0", LineNumber: 163, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "29", DeviceName: "gpiochip0", LineNumber: 105, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "31", DeviceName: "gpiochip1", LineNumber: 50, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "32", DeviceName: "gpiochip1", LineNumber: 8, PwmChipSysfsDir: "", PwmID: -1}, // "3280000.pwm", PwmID: 0}, + {Name: "33", DeviceName: "gpiochip1", LineNumber: 13, PwmChipSysfsDir: "", PwmID: -1}, // "32a0000.pwm", PwmID: 0}, + {Name: "35", DeviceName: "gpiochip0", LineNumber: 75, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "36", DeviceName: "gpiochip1", LineNumber: 29, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "37", DeviceName: "gpiochip1", LineNumber: 19, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "38", DeviceName: "gpiochip0", LineNumber: 74, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "40", DeviceName: "gpiochip0", LineNumber: 73, PwmChipSysfsDir: "", PwmID: -1}, +} + +// NOTE: The Jetson TX2 (like many of the others defined in this file) has hardware PWM +// capabilities that we are not using. We can add that in, but the board is old enough that very +// few people are likely to use it, so don't bother until someone wants it. +var jetsonTX2Pins = []genericlinux.PinDefinition{ + // There exist other pins on the header (e.g., physical pins 3 and 5), but the spreadsheets at + // the bottom of https://jetsonhacks.com/nvidia-jetson-tx2-j21-header-pinout/ recommend against + // using them for GPIO. + {Name: "7", DeviceName: "gpiochip0", LineNumber: 76, PwmChipSysfsDir: "", PwmID: -1}, + // Output-only (due to base board) + {Name: "11", DeviceName: "gpiochip0", LineNumber: 146, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "12", DeviceName: "gpiochip0", LineNumber: 72, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "13", DeviceName: "gpiochip0", LineNumber: 77, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "15", DeviceName: "gpiochip2", LineNumber: 15, PwmChipSysfsDir: "", PwmID: -1}, + // Input-only (due to module): + {Name: "16", DeviceName: "gpiochip1", LineNumber: 40, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "18", DeviceName: "gpiochip0", LineNumber: 161, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "19", DeviceName: "gpiochip0", LineNumber: 109, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "21", DeviceName: "gpiochip0", LineNumber: 108, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "22", DeviceName: "gpiochip2", LineNumber: 14, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "23", DeviceName: "gpiochip0", LineNumber: 107, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "24", DeviceName: "gpiochip0", LineNumber: 110, PwmChipSysfsDir: "", PwmID: -1}, + // Board pin 26 is not available on this board + {Name: "29", DeviceName: "gpiochip0", LineNumber: 78, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "31", DeviceName: "gpiochip1", LineNumber: 42, PwmChipSysfsDir: "", PwmID: -1}, + // Output-only (due to module): + {Name: "32", DeviceName: "gpiochip1", LineNumber: 41, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "33", DeviceName: "gpiochip0", LineNumber: 69, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "35", DeviceName: "gpiochip0", LineNumber: 75, PwmChipSysfsDir: "", PwmID: -1}, + // Input-only (due to base board) IF NVIDIA debug card NOT plugged in + // Output-only (due to base board) IF NVIDIA debug card plugged in + {Name: "36", DeviceName: "gpiochip0", LineNumber: 147, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "37", DeviceName: "gpiochip0", LineNumber: 68, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "38", DeviceName: "gpiochip0", LineNumber: 74, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "40", DeviceName: "gpiochip0", LineNumber: 73, PwmChipSysfsDir: "", PwmID: -1}, +} + +//nolint:dupl // This is not actually a duplicate of jetsonTX2NXPins despite what the linter thinks +var jetsonNanoPins = []genericlinux.PinDefinition{ + {Name: "7", DeviceName: "gpiochip0", LineNumber: 216, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "11", DeviceName: "gpiochip0", LineNumber: 50, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "12", DeviceName: "gpiochip0", LineNumber: 79, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "13", DeviceName: "gpiochip0", LineNumber: 14, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "15", DeviceName: "gpiochip0", LineNumber: 194, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "16", DeviceName: "gpiochip0", LineNumber: 232, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "18", DeviceName: "gpiochip0", LineNumber: 15, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "19", DeviceName: "gpiochip0", LineNumber: 16, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "21", DeviceName: "gpiochip0", LineNumber: 17, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "22", DeviceName: "gpiochip0", LineNumber: 13, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "23", DeviceName: "gpiochip0", LineNumber: 18, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "24", DeviceName: "gpiochip0", LineNumber: 19, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "26", DeviceName: "gpiochip0", LineNumber: 20, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "29", DeviceName: "gpiochip0", LineNumber: 149, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "31", DeviceName: "gpiochip0", LineNumber: 200, PwmChipSysfsDir: "", PwmID: -1}, + // Older versions of L4T have a DT bug which instantiates a bogus device + // which prevents this library from using this PWM channel. + {Name: "32", DeviceName: "gpiochip0", LineNumber: 168, PwmChipSysfsDir: "", PwmID: -1}, // "7000a000.pwm", PwmID: 0}, + {Name: "33", DeviceName: "gpiochip0", LineNumber: 38, PwmChipSysfsDir: "", PwmID: -1}, // "7000a000.pwm", PwmID: 2}, + {Name: "35", DeviceName: "gpiochip0", LineNumber: 76, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "36", DeviceName: "gpiochip0", LineNumber: 51, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "37", DeviceName: "gpiochip0", LineNumber: 12, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "38", DeviceName: "gpiochip0", LineNumber: 77, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "40", DeviceName: "gpiochip0", LineNumber: 78, PwmChipSysfsDir: "", PwmID: -1}, +} + +// There are 6 pins whose Broadcom SOC channel is -1 (pins 3, 5, 8, 10, 27, and 28). We +// added these pin definitions ourselves because they're not present in +// https://github.com/NVIDIA/jetson-gpio/blob/master/lib/python/Jetson/GPIO/gpio_pin_data.py +// We were unable to find the broadcom channel numbers for these pins, but (as of April +// 2023) Viam doesn't use those values for anything anyway. +var jetsonOrinAGXPins = []genericlinux.PinDefinition{ + {Name: "3", DeviceName: "gpiochip1", LineNumber: 22, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "5", DeviceName: "gpiochip1", LineNumber: 21, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "7", DeviceName: "gpiochip0", LineNumber: 106, PwmChipSysfsDir: "", PwmID: -1}, + // Output-only (due to hardware limitation) + {Name: "8", DeviceName: "gpiochip0", LineNumber: 110, PwmChipSysfsDir: "", PwmID: -1}, + // Input-only (due to hardware limitation) + {Name: "10", DeviceName: "gpiochip0", LineNumber: 111, PwmChipSysfsDir: "", PwmID: -1}, + // Output-only (due to hardware limitation) + {Name: "11", DeviceName: "gpiochip0", LineNumber: 112, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "12", DeviceName: "gpiochip0", LineNumber: 50, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "13", DeviceName: "gpiochip0", LineNumber: 108, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "15", DeviceName: "gpiochip0", LineNumber: 85, PwmChipSysfsDir: "", PwmID: -1}, // "3280000.pwm", PwmID: 0}, + {Name: "16", DeviceName: "gpiochip1", LineNumber: 9, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "18", DeviceName: "gpiochip0", LineNumber: 43, PwmChipSysfsDir: "", PwmID: -1}, // "32c0000.pwm", PwmID: 0}, + {Name: "19", DeviceName: "gpiochip0", LineNumber: 135, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "21", DeviceName: "gpiochip0", LineNumber: 134, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "22", DeviceName: "gpiochip0", LineNumber: 96, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "23", DeviceName: "gpiochip0", LineNumber: 133, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "24", DeviceName: "gpiochip0", LineNumber: 136, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "26", DeviceName: "gpiochip0", LineNumber: 137, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "27", DeviceName: "gpiochip1", LineNumber: 20, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "28", DeviceName: "gpiochip1", LineNumber: 19, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "29", DeviceName: "gpiochip1", LineNumber: 1, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "31", DeviceName: "gpiochip1", LineNumber: 0, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "32", DeviceName: "gpiochip1", LineNumber: 8, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "33", DeviceName: "gpiochip1", LineNumber: 2, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "35", DeviceName: "gpiochip0", LineNumber: 53, PwmChipSysfsDir: "", PwmID: -1}, + // Input-only (due to hardware limitation) + {Name: "36", DeviceName: "gpiochip0", LineNumber: 113, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "37", DeviceName: "gpiochip1", LineNumber: 3, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "38", DeviceName: "gpiochip0", LineNumber: 52, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "40", DeviceName: "gpiochip0", LineNumber: 51, PwmChipSysfsDir: "", PwmID: -1}, +} + +// This pin mapping is used for both the Jetson Orin NX and the Jetson Orin Nano. +// +//nolint:dupl // This is not actually a duplicate of jetsonTX2NXPins despite what the linter thinks +var jetsonOrinNXPins = []genericlinux.PinDefinition{ + {Name: "7", DeviceName: "gpiochip0", LineNumber: 144, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "11", DeviceName: "gpiochip0", LineNumber: 112, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "12", DeviceName: "gpiochip0", LineNumber: 50, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "13", DeviceName: "gpiochip0", LineNumber: 122, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "15", DeviceName: "gpiochip0", LineNumber: 85, PwmChipSysfsDir: "", PwmID: -1}, // "3280000.pwm", PwmID: 0}, + {Name: "16", DeviceName: "gpiochip0", LineNumber: 126, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "18", DeviceName: "gpiochip0", LineNumber: 125, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "19", DeviceName: "gpiochip0", LineNumber: 135, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "21", DeviceName: "gpiochip0", LineNumber: 134, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "22", DeviceName: "gpiochip0", LineNumber: 123, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "23", DeviceName: "gpiochip0", LineNumber: 133, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "24", DeviceName: "gpiochip0", LineNumber: 136, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "26", DeviceName: "gpiochip0", LineNumber: 137, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "29", DeviceName: "gpiochip0", LineNumber: 105, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "31", DeviceName: "gpiochip0", LineNumber: 106, PwmChipSysfsDir: "", PwmID: -1}, + // Pin 32 supposedly has hardware PWM support, but we've been unable to turn it on. + {Name: "32", DeviceName: "gpiochip0", LineNumber: 41, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "33", DeviceName: "gpiochip0", LineNumber: 43, PwmChipSysfsDir: "", PwmID: -1}, // "32c0000.pwm", PwmID: 0}, + {Name: "35", DeviceName: "gpiochip0", LineNumber: 53, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "36", DeviceName: "gpiochip0", LineNumber: 113, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "37", DeviceName: "gpiochip0", LineNumber: 124, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "38", DeviceName: "gpiochip0", LineNumber: 52, PwmChipSysfsDir: "", PwmID: -1}, + {Name: "40", DeviceName: "gpiochip0", LineNumber: 51, PwmChipSysfsDir: "", PwmID: -1}, +} + +var boardInfoMappings = map[string]genericlinux.BoardInformation{ + jetsonTX2NX: { + jetsonTX2NXPins, + []string{ + "nvidia,p3509-0000+p3636-0001", + }, + }, + jetsonTX2: { + jetsonTX2Pins, + []string{ + "nvidia,p2771-0000", + "nvidia,p2771-0888", + "nvidia,p3489-0000", + "nvidia,lightning", + "nvidia,quill", + "nvidia,storm", + }, + }, + jetsonNano: { + jetsonNanoPins, + []string{ + "nvidia,p3450-0000", + "nvidia,p3450-0002", + "nvidia,jetson-nano", + }, + }, + jetsonOrinAGX: { + jetsonOrinAGXPins, + []string{ + "nvidia,p3737-0000+p3701-0000", + "nvidia,p3737-0000+p3701-0004", + }, + }, + jetsonOrinNX: { + jetsonOrinNXPins, + []string{ + "nvidia,p3509-0000+p3767-0000", + }, + }, + jetsonOrinNano: { + jetsonOrinNXPins, // The Jetson Orin Nano has the exact same pinout as the Jetson Orin NX. + []string{ + "nvidia,p3768-0000+p3767-0003", + "nvidia,p3768-0000+p3767-0005", + "nvidia,p3767-0003", + "nvidia,p3767-0005", + }, + }, +} diff --git a/jetson/jetson.go b/jetson/jetson.go deleted file mode 100644 index e69de29..0000000 diff --git a/meta.json b/meta.json index d1e8802..43a2af9 100644 --- a/meta.json +++ b/meta.json @@ -1,18 +1,19 @@ { - "module_id": "viam:nvidia", - "visibility": "public", - "url": "https://github.com/viam-modules/nvidia", - "description": "Go module for nvidia jetson board, compatible with Viam", - "models": [ - { - "api": "rdk:component:board", - "model": "viam:nvidia:jetson" - } - ], - "build": { - "build": "make module", - "path": "bin/module.tar.gz", - "arch" : ["linux/arm64", "linux/amd64", "darwin/arm64"] - }, - "entrypoint": "bin/nvidia" - } \ No newline at end of file + "$schema": "https://dl.viam.dev/module.schema.json", + "module_id": "viam:nvidia", + "visibility": "public", + "url": "https://github.com/viam-modules/nvidia", + "description": "Go module for nvidia jetson board, compatible with Viam", + "models": [ + { + "api": "rdk:component:board", + "model": "viam:nvidia:jetson" + } + ], + "build": { + "build": "make module", + "path": "bin/module.tar.gz", + "arch" : ["linux/arm64", "linux/amd64", "darwin/arm64"] + }, + "entrypoint": "bin/nvidia" +} \ No newline at end of file