rpi-ws281x / rpi-ws281x-go

Go library wrapping for the rpi-ws281x library
Apache License 2.0
66 stars 15 forks source link

Failure during Init #2

Closed hermanbanken closed 5 years ago

hermanbanken commented 5 years ago

I am getting this output from rpi-ws281x-go:

2018/12/14 08:30:17 Doing hardware check
*****************************
* rpi_ws281x Hardware Check *
*****************************
Hardware Type    : 1
Hardware Version : 0x00000010
Periph base      : 0x20000000
Video core base  : 0x40000000
Description      : Model B+

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xaf390]

goroutine 7 [running]:
github.com/rpi-ws281x/rpi-ws281x-go.(*WS2811).Init(0x1446400, 0x0, 0x142af88)
    /home/pi/go/pkg/mod/github.com/rpi-ws281x/rpi-ws281x-go@v1.0.3/ws2811_arm.go:117 +0x100

The struct is setup like this:

var option = ws2811.DefaultOptions

func init() {
    option.Channels[0].GpioPin = 10 // SPI
    option.Channels[0].LedCount = 300
    option.Channels[0].Brightness = 64

    ws, err := ws2811.MakeWS2811(&option)
    checkError(err)
    defer ws.Fini()
    checkError(ws.Init()) // <<<< Crash
    leds := ws.Leds(0)

    ...
}

Happening here: https://github.com/rpi-ws281x/rpi-ws281x-go/blob/669a4f9a7e1f167b7e9b5b0b781c1b83e470e6fa/ws2811_arm.go#L113-L117

I don't know how to fix those lines 😢

Getting the exact same error when running examples/color_wipe by the way.

pi@q070-slide-pi:examples/color_wipe $ ./color_wipe
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x90398]

goroutine 1 [running]:
github.com/rpi-ws281x/rpi-ws281x-go.(*WS2811).Init(0x204a140, 0x100, 0x100)
    /home/pi/go/pkg/mod/github.com/rpi-ws281x/rpi-ws281x-go@v1.0.3/ws2811_arm.go:117 +0x100
main.(*colorWipe).setup(0x202c7a4, 0x204a140, 0x0)
    /home/pi/go/pkg/mod/github.com/rpi-ws281x/rpi-ws281x-go@v1.0.3/examples/color_wipe/color_wipe.go:48 +0x28
main.main()
    /home/pi/go/pkg/mod/github.com/rpi-ws281x/rpi-ws281x-go@v1.0.3/examples/color_wipe/color_wipe.go:74 +0xc0
supcik commented 5 years ago

I will check with the latest version of the jgarff/rpi_ws281x library.

hermanbanken commented 5 years ago

(I used a fresh clone)

hermanbanken commented 5 years ago

Above error was using a fresh clone of jgarff/rpi_ws281x

Using the submodule version I get this:

*****************************
* rpi_ws281x Hardware Check *
*****************************
Hardware Type    : 1
Hardware Version : 0x00000010
Periph base      : 0x20000000
Video core base  : 0x40000000
Description      : Model B+

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xaf390]

goroutine 7 [running]:
github.com/rpi-ws281x/rpi-ws281x-go.(*WS2811).Init(0x1846400, 0x0, 0x182af88)
    /home/pi/q070-slide/balena/go-slide/vendor/github.com/rpi-ws281x/rpi-ws281x-go/ws2811_arm.go:117 +0x100
hermanbanken commented 5 years ago

Note: this happens when selecting pin 10 (SPI) for output. If I use the default value (PWM?) it does not crash.

hermanbanken commented 5 years ago

But sudo ./test --width 1 --height 250 --gpio 10 (SPI) just works.