Comments (21)
Ok thanks for the debugging, I need to log off now will try to take a look tomorrow to find the root cause.
from periph.
I get the same error if I try to run a simple button press detection code:
package main
import (
"fmt"
"log"
// "periph.io/x/periph/host/rpi"
"periph.io/x/periph/conn/gpio"
"periph.io/x/periph/conn/gpio/gpioreg"
"periph.io/x/periph/host"
)
func main() {
// Load all the drivers:
if _, err := host.Init(); err != nil {
log.Fatal(err)
}
// Lookup a pin by its number:
//p := rpi.P1_26
p := gpioreg.ByName("GPIO7")
if p == nil {
log.Fatal("Failed to find pin 26")
}
fmt.Printf("%s: %s\n", p, p.Function())
// Set it as input, with an internal pull down resistor:
if err := p.In(gpio.PullDown, gpio.BothEdges); err != nil {
log.Fatal(err)
}
// Wait for edges as detected by the hardware, and print the value read:
for {
p.WaitForEdge(-1)
fmt.Printf("-> %s\n", p.Read())
}
}
from periph.
Have you added the host gpiomem device to the container?
ie: docker run --device /dev/gpiomem -d foo
from periph.
@NeuralSpaz I'm not running in a docker container here.
from periph.
additionally ./periph-info
shows:
Drivers failed to load and the error:
- bcm283x-gpio: gpioreg: can't register an alias with no name
from periph.
Seems like a regression on RPi1. I'll find mine and will try to reproduce tomorrow morning.
My hunch is likely this line; https://github.com/google/periph/blob/master/host/bcm283x/gpio.go#L1265
from periph.
@maruel Thanks for the quick reply! Let me know if there's any information I can provide to help.
I'll note that after a "fresh boot", my program takes ~4 seconds to fail the first time, but on subsequent executions, fails almost instantly.
from periph.
I was planing to do a rpi1 with buster later today, I'll see what I can reproduce.
from periph.
Can you try to make RegisterAlias() panic instead?
At https://github.com/google/periph/blob/master/conn/gpio/gpioreg/gpioreg.go#L108
Add:
panic(dest)
Then paste the stack trace here.
from periph.
pi@raspberrypi:~/go/src/button $ ./button
panic: GPIO16
goroutine 17 [running]:
periph.io/x/periph/conn/gpio/gpioreg.RegisterAlias(0x0, 0x0, 0x141323, 0x6, 0x0, 0x0)
/home/pi/go/src/periph.io/x/periph/conn/gpio/gpioreg/gpioreg.go:108 +0x3b8
periph.io/x/periph/host/bcm283x.(*driverGPIO).Init(0x223488, 0x14bac8, 0x2412e60, 0x0)
/home/pi/go/src/periph.io/x/periph/host/bcm283x/gpio.go:1265 +0x36c
periph.io/x/periph.(*stage).loadParallel.func1.1(0x2412e60, 0x24180c0, 0x24181c0, 0x2418140, 0x2418100, 0x14368c, 0xc, 0x166a28, 0x223488)
/home/pi/go/src/periph.io/x/periph/periph_parallel.go:84 +0x48
created by periph.io/x/periph.(*stage).loadParallel.func1
/home/pi/go/src/periph.io/x/periph/periph_parallel.go:82 +0x304
from periph.
Ok so the pin is set to a function between 0 and 2. The ones that are not defined at:
https://github.com/google/periph/blob/master/host/bcm283x/gpio.go#L939
from periph.
https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf page 102:
- 0 is reserved
- 1 is SD8
- 2 is reserved
But the code in Func()
shouldn't return an empty string
It feels like this line triggers but I don't know how;
https://github.com/google/periph/blob/master/host/bcm283x/gpio.go#L292
Can you add panic(f)
?
from periph.
Doesn't look like that line(292) gets hit.
The previous panic was hit first (https://github.com/google/periph/blob/master/conn/gpio/gpioreg/gpioreg.go#L108), so I cleared it, and now I'm back at the original error.
from periph.
I amended https://github.com/google/periph/blob/master/host/bcm283x/gpio.go#L1263 as follows (beginning on line 1263) to include logging as it creates the aliases:
if _, ok := functions[f]; !ok {
functions[f] = struct{}{}
log.Println("Registering Alias: ",string(f),name)
if err := gpioreg.RegisterAlias(string(f), name); err != nil {
log.Println("Error registering alias: ", err)
return true, err
}
}
The output was somewhat unexpected:
pi@raspberrypi:~/go/src/button $ ./button
2019/08/14 02:29:47 Registering Alias: In/High GPIO0
2019/08/14 02:29:47 Registering Alias: Out/Low GPIO5
2019/08/14 02:29:47 Registering Alias: Out/High GPIO6
2019/08/14 02:29:47 Registering Alias: In/Low GPIO9
2019/08/14 02:29:47 Registering Alias: GPIO16
2019/08/14 02:29:47 Error registering alias: gpioreg: can't register an alias with no name
GPIO7: In/High
2019/08/14 02:29:47 bcm283x-gpio (GPIO7): pull cannot be used when subsystem gpiomem not initialized
are the aliases created in a random order?
The output does confirm your statement about https://github.com/google/periph/blob/master/host/bcm283x/gpio.go#L939 being the culprit.
I too am signing off for the evening, Cheers!
from periph.
Same problem I believe. First attempt at using Periph. Raspberry Pi Zero simple button input example.
GPIO22: In/High
2019/08/14 16:25:08 bcm283x-gpio (GPIO22): pull cannot be used when subsystem gpiomem not initialized
from periph.
Sorry for the annoyance. I broke this in v3.2.0. I fixed it, added a smoke test and manually ran the smoketest on a RPi1 and RPiZW. This should be fixed for good. Will try to do a v3.6.1 release next week or so.
from periph.
Thanks for taking care of it
Since I'm a bit of a Go newb, will re-running go get ...
get the latest master
version, or the latest release?
can I get ebc08ac via go get?
from periph.
It depends which Go version you are using and if you enabled GO111MODULE.
If not, a go get -u periph.io/x/periph
should do the trick.
from periph.
confirmed working on rpi1B running buster as non root.
from periph.
Thanks working on raspberry pi zero as non root.
from periph.
🎉 It works for me as well. Thanks!
from periph.
Related Issues (20)
- [Question] How do I set a pin to alt0? HOT 6
- All pins are exported during bcm283x Init HOT 3
- Support for firmata HOT 2
- Go get fetches v3.4.0 if using go modules HOT 3
- Support for BME680 HOT 3
- Halt() does not unblock WaitForEdge() HOT 3
- Feature SSD1322 HOT 5
- mfrc522 constantly returns "IRQ error" after first read HOT 11
- spi to slow HOT 5
- onewire didnot work HOT 9
- Omega2: declare headers HOT 3
- Experimental serial package doesn't export essential func HOT 7
- Unable to set GPIO pin pull on Raspberry Pi 4 HOT 19
- MFRC522 hang on WaitForEdge HOT 2
- HX711: unstable readings and reading before data is ready HOT 2
- spi: rename MISO/MOSI to COPI/CIPO HOT 2
- I2C documentation not clear on read/write operation HOT 2
- MFRC522 - Problem reading Tag HOT 3
- pmem example code incorrect HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from periph.