Closed sh4r1k7 closed 4 months ago
I should probably disable the PWM there because it's unstable. Sorry about that.
Could you elaborate? As I mentioned go-rpio
has a similar implementation and works fine. I'd rather see if I can fix it instead of using a mish-mash of two similar libraries.
I'm also experiencing this issue, and I'd also like to see this fixed rather than disabled. Same hardware, similar crash log.
[signal SIGBUS: bus error code=0x1 addr=0x7f800e2004 pc=0x4fed04]
goroutine 1 [running]:
runtime.throw({0x55afbd?, 0x4421bc?})
/usr/local/go/src/runtime/panic.go:1077 +0x40 fp=0x4000156bb0 sp=0x4000156b80 pc=0x436cf0
runtime.sigpanic()
/usr/local/go/src/runtime/signal_unix.go:858 +0xec fp=0x4000156c10 sp=0x4000156bb0 pc=0x44deac
periph.io/x/host/v3/bcm283x.ReadTime(...)
/home/aliced/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/timer.go:20
periph.io/x/host/v3/bcm283x.Nanospin(0x40000021a0?)
/home/aliced/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/timer.go:25 +0x24 fp=0x4000156c40 sp=0x4000156c20 pc=0x4fed04
periph.io/x/host/v3/bcm283x.(*clock).setRaw(0x7f800e30a0, 0x6, 0x0?)
/home/aliced/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/clock.go:291 +0xdc fp=0x4000156c70 sp=0x4000156c40 pc=0x4f8fdc
periph.io/x/host/v3/bcm283x.(*clock).set(0x7f800e30a0, 0x400003d400?, 0x156ce8?)
/home/aliced/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/clock.go:272 +0x64 fp=0x4000156ca0 sp=0x4000156c70 pc=0x4f8e94
periph.io/x/host/v3/bcm283x.setPWMClockSource()
/home/aliced/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/pwm.go:229 +0x64 fp=0x4000156d50 sp=0x4000156ca0 pc=0x4fe954
periph.io/x/host/v3/bcm283x.(*Pin).PWM(0x6739e0, 0x6?, 0x10?)
/home/aliced/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/gpio.go:656 +0x16c fp=0x4000156de0 sp=0x4000156d50 pc=0x4fc2bc
gitlab.com/queer-computer-club/doorbot/devices.NewWS2811LEDStrip({{0x590d50, 0x4000020210}, 0x0, {0x0, 0x0}, {0x400012e400, 0x21, 0x1f4}, {0x4000020220, 0x1, ...}, ...}, ...)
/home/aliced/doorbot/devices/leds.go:63 +0x330 fp=0x4000156ea0 sp=0x4000156de0 pc=0x514dc0
main.NewDoorbot(0x4000157700, 0x4000130200)
/home/aliced/doorbot/doorbot.go:51 +0x500 fp=0x40001573b0 sp=0x4000156ea0 pc=0x5171f0
main.main()
/home/aliced/doorbot/main.go:44 +0x91c fp=0x4000157f30 sp=0x40001573b0 pc=0x51809c
runtime.main()
/usr/local/go/src/runtime/proc.go:267 +0x2bc fp=0x4000157fd0 sp=0x4000157f30 pc=0x4396ac
runtime.goexit()
/usr/local/go/src/runtime/asm_arm64.s:1197 +0x4 fp=0x4000157fd0 sp=0x4000157fd0 pc=0x469104
I also have this problem only if I access the timer reading code:
func main() {
state, err := host.Init()
if err != nil {
log.Fatal("FAIL: device init", err)
}
// Prints the loaded driver.
fmt.Printf("Using drivers:\n")
for _, driver := range state.Loaded {
fmt.Printf("- %s\n", driver)
}
// Prints the driver that were skipped as irrelevant on the platform.
fmt.Printf("Drivers skipped:\n")
for _, failure := range state.Skipped {
fmt.Printf("- %s: %s\n", failure.D, failure.Err)
}
// Having drivers failing to load may not require process termination. It // is possible to continue to run in partial failure mode.
fmt.Printf("Drivers failed to load:\n")
for _, failure := range state.Failed {
fmt.Printf("- %s: %v\n", failure.D, failure.Err)
}
t := time.Duration(0)
for {
t2 := time.Now()
t = bcm283x.ReadTime()
for bcm283x.ReadTime()-t < 1000 {
}
exp := time.Since(t2).Nanoseconds()
println(exp, t)
time.Sleep(time.Second)
}
}
result:
root@ff:/home/ff/hi-alert/build# /home/ff/dmd/executables-ackUjudeFA/___1go_build_test_rt_linux
Using drivers:
- bcm283x-dma
- bcm283x-gpio
- rpi
- sysfs-gpio
- sysfs-led
- sysfs-spi
- sysfs-thermal
Drivers skipped:
- allwinner-gpio-pl: no A64 CPU detected
- allwinner-gpio: no Allwinner CPU detected
- pine64: pine64 board not detected
- sysfs-i2c: no I²C bus found
Drivers failed to load:
unexpected fault address 0x7f5a939004
fatal error: fault
[signal SIGBUS: bus error code=0x1 addr=0x7f5a939004 pc=0xe174c]
goroutine 1 [running]:
runtime.throw({0x11c98b?, 0x0?})
/home/ff/go/src/runtime/panic.go:1077 +0x40 fp=0x4000064dd0 sp=0x4000064da0 pc=0x43940
runtime.sigpanic()
/home/ff/go/src/runtime/signal_unix.go:858 +0xec fp=0x4000064e30 sp=0x4000064dd0 pc=0x5938c
periph.io/x/host/v3/bcm283x.ReadTime(...)
/home/ff/src/pkg/mod/periph.io/x/host/v3@v3.8.1/bcm283x/timer.go:20
main.main()
/home/ff/dmd/sources-SBRP40wfKR/tool/test_rt/main.go:35 +0x31c fp=0x4000064f30 sp=0x4000064e40 pc=0xe174c
runtime.main()
/home/ff/go/src/runtime/proc.go:267 +0x2bc fp=0x4000064fd0 sp=0x4000064f30 pc=0x4623c
runtime.goexit()
/home/ff/go/src/runtime/asm_arm64.s:1197 +0x4 fp=0x4000064fd0 sp=0x4000064fd0 pc=0x72e04
I see a similar trace running on Raspberry Pi Zero 2 W with 64 bit Pi OS. Linux piz2 6.1.0-rpi8-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.73-1+rpt1 (2024-01-25) aarch64 GNU/Linux
unexpected fault address 0x7f77269004
fatal error: fault
[signal SIGBUS: bus error code=0x1 addr=0x7f77269004 pc=0xf0bf4]
goroutine 1 gp=0x40000021c0 m=4 mp=0x4000080008 [running]:
runtime.throw({0x1431bd?, 0x0?})
/usr/local/go/src/runtime/panic.go:1023 +0x40 fp=0x400015b840 sp=0x400015b810 pc=0x45ed0
runtime.sigpanic()
/usr/local/go/src/runtime/signal_unix.go:878 +0xec fp=0x400015b8a0 sp=0x400015b840 pc=0x5f32c
periph.io/x/host/v3/bcm283x.ReadTime(...)
/home/daniel/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/timer.go:20
periph.io/x/host/v3/bcm283x.Nanospin(0x400000c168?)
/home/daniel/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/timer.go:25 +0x24 fp=0x400015b8d0 sp=0x400015b8b0 pc=0xf0bf4
periph.io/x/host/v3/bcm283x.(*clock).setRaw(0x7f7726a0a0, 0x6, 0x0?)
/home/daniel/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/clock.go:291 +0xdc fp=0x400015b900 sp=0x400015b8d0 pc=0xea98c
periph.io/x/host/v3/bcm283x.(*clock).set(0x7f7726a0a0, 0x0?, 0x77271900?)
/home/daniel/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/clock.go:272 +0x64 fp=0x400015b930 sp=0x400015b900 pc=0xea844
periph.io/x/host/v3/bcm283x.setPWMClockSource()
/home/daniel/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/pwm.go:229 +0x64 fp=0x400015b9e0 sp=0x400015b930 pc=0xf0844
periph.io/x/host/v3/bcm283x.(*Pin).PWM(0x23dee0, 0xc168?, 0x400015ba78?)
/home/daniel/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/gpio.go:656 +0x16c fp=0x400015ba70 sp=0x400015b9e0 pc=0xee17c
periph.io/x/conn/v3/gpio/gpioreg.(*pinAlias).PWM(0x4000070090?, 0x0?, 0x2?)
<autogenerated>:1 +0x30 fp=0x400015baa0 sp=0x400015ba70 pc=0xb7bd0
main.main()
/home/daniel/source/clock/app/main.go:139 +0x76c fp=0x400015bf40 sp=0x400015baa0 pc=0x101e1c
runtime.main()
/usr/local/go/src/runtime/proc.go:271 +0x28c fp=0x400015bfd0 sp=0x400015bf40 pc=0x4888c
runtime.goexit({})
/usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x400015bfd0 sp=0x400015bfd0 pc=0x7ace4
Describe the bug Running a basic PWM test results in a panic.
To Reproduce Steps to reproduce the behavior:
import ( "log" "time"
)
func main() { // Load all the drivers: if _, err := host.Init(); err != nil { log.Fatal(err) }
}
pi@raspberrypi:~/pwm-periph $ sudo go run . unexpected fault address 0x7f39ed5004 fatal error: fault [signal SIGBUS: bus error code=0x1 addr=0x7f39ed5004 pc=0xd5dd4]
goroutine 1 [running]: runtime.throw({0x11ce04?, 0x1d7c0?}) /home/pi/.asdf/installs/golang/1.21.1/go/src/runtime/panic.go:1077 +0x40 fp=0x4000060c80 sp=0x4000060c50 pc=0x43940 runtime.sigpanic() /home/pi/.asdf/installs/golang/1.21.1/go/src/runtime/signal_unix.go:858 +0xec fp=0x4000060ce0 sp=0x4000060c80 pc=0x5938c periph.io/x/host/v3/bcm283x.ReadTime(...) /root/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/timer.go:20 periph.io/x/host/v3/bcm283x.Nanospin(0x4000060d58?) /root/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/timer.go:25 +0x24 fp=0x4000060d10 sp=0x4000060cf0 pc=0xd5dd4 periph.io/x/host/v3/bcm283x.(clock).setRaw(0x7f39ed60a0, 0x6, 0x40?) /root/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/clock.go:291 +0xdc fp=0x4000060d40 sp=0x4000060d10 pc=0xd01cc periph.io/x/host/v3/bcm283x.(clock).set(0x7f39ed60a0, 0x15254?, 0x60da8?) /root/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/clock.go:272 +0x64 fp=0x4000060d70 sp=0x4000060d40 pc=0xd0084 periph.io/x/host/v3/bcm283x.setPWMClockSource() /root/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/pwm.go:229 +0x64 fp=0x4000060e20 sp=0x4000060d70 pc=0xd5a24 periph.io/x/host/v3/bcm283x.(Pin).PWM(0x1fb300, 0xae450?, 0x232d48?) /root/go/pkg/mod/periph.io/x/host/v3@v3.8.2/bcm283x/gpio.go:670 +0x328 fp=0x4000060eb0 sp=0x4000060e20 pc=0xd3548 periph.io/x/conn/v3/gpio/gpioreg.(pinAlias).PWM(0x11d9f7?, 0x8?, 0x60?)