Skip to content

StreamOut() hangs for ever #74

@stackcoder

Description

@stackcoder

Describe the bug
I wanted to use the gpiomem feature to get at least reasonably correct timings for my gpio.

To Reproduce
Steps to reproduce the behavior:

  1. Take the gpiostream PinOut example code, remove (since it's not implemented) stream and program wrapper
package main

import (
	"log"

	"periph.io/x/conn/v3/gpio/gpioreg"
	"periph.io/x/conn/v3/gpio/gpiostream"
	"periph.io/x/conn/v3/physic"
	"periph.io/x/host/v3"
)

func main() {
	state, err := host.Init()
	if err != nil {
		log.Fatalf("failed to initialize periph: %v", err)
	}

	log.Printf("Drivers failed to load:\n")
	for _, failure := range state.Failed {
		log.Printf("- %s: %v\n", failure.D, failure.Err)
	}

	p := gpioreg.ByName("GPIO24")
	r, ok := p.(gpiostream.PinOut)
	if !ok {
		log.Fatalf("pin streaming is not supported on pin %s", p)
	}
	b := gpiostream.BitStream{
		Freq: 1000 * physic.Hertz,
		Bits: []byte{0b1010_1010, 0b1100_1100},
	}
	if err := r.StreamOut(&b); err != nil {
		log.Fatal(err)
	}
}
  1. Run it.
  2. Process hangs forever
  3. Get stack traces using kill -QUIT
SIGQUIT: quit
PC=0x1274bc m=0 sigcode=0

goroutine 1 gp=0x2002128 m=0 mp=0x2902d8 [running]:
periph.io/x/host/v3/bcm283x.(*dmaChannel).wait(...)
        /go/pkg/mod/github.com/stackcoder/periph-host/v3@v3.0.0-20260302180128-52e941200513/bcm283x/dma.go:563
periph.io/x/host/v3/bcm283x.runIO({0x1c19c4, 0x2012728}, 0x1)
        /go/pkg/mod/github.com/stackcoder/periph-host/v3@v3.0.0-20260302180128-52e941200513/bcm283x/dma.go:668 +0x138 fp=0x20b7e70 sp=0x20b7e28 pc=0x1274bc
periph.io/x/host/v3/bcm283x.dmaWriteStreamEdges(0x28c578, {0x1c1898, 0x205c888})
        /go/pkg/mod/github.com/stackcoder/periph-host/v3@v3.0.0-20260302180128-52e941200513/bcm283x/dma.go:975 +0x670 fp=0x20b7ef8 sp=0x20b7e70 pc=0x1289c4
periph.io/x/host/v3/bcm283x.(*Pin).StreamOut(0x28c578, {0x1c1898, 0x205c888})
        /go/pkg/mod/github.com/stackcoder/periph-host/v3@v3.0.0-20260302180128-52e941200513/bcm283x/gpio.go:734 +0x180 fp=0x20b7f28 sp=0x20b7ef8 pc=0x129a98
main.main()
        /workspaces/test/fail.go:32 +0x2f8 fp=0x20b7fa8 sp=0x20b7f28 pc=0x151c50
runtime.main()
        /usr/local/go/src/runtime/proc.go:285 +0x2f0 fp=0x20b7fec sp=0x20b7fa8 pc=0x5b180
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm.s:877 +0x4 fp=0x20b7fec sp=0x20b7fec pc=0x98180

goroutine 2 gp=0x20026c8 m=nil [force gc (idle)]:
runtime.gopark(0x19ab50, 0x28f628, 0x11, 0xa, 0x1)
        /usr/local/go/src/runtime/proc.go:460 +0x104 fp=0x202cfd4 sp=0x202cfc0 pc=0x92318
runtime.goparkunlock(...)
        /usr/local/go/src/runtime/proc.go:466
runtime.forcegchelper()
        /usr/local/go/src/runtime/proc.go:373 +0xe4 fp=0x202cfec sp=0x202cfd4 pc=0x5b5e4
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm.s:877 +0x4 fp=0x202cfec sp=0x202cfec pc=0x98180
created by runtime.init.6 in goroutine 1
        /usr/local/go/src/runtime/proc.go:361 +0x1c

goroutine 3 gp=0x20027e8 m=nil [GC sweep wait]:
runtime.gopark(0x19ab50, 0x28f788, 0xc, 0x9, 0x1)
        /usr/local/go/src/runtime/proc.go:460 +0x104 fp=0x202d7c4 sp=0x202d7b0 pc=0x92318
runtime.goparkunlock(...)
        /usr/local/go/src/runtime/proc.go:466
runtime.bgsweep(0x204a000)
        /usr/local/go/src/runtime/mgcsweep.go:279 +0xa8 fp=0x202d7e4 sp=0x202d7c4 pc=0x44da0
runtime.gcenable.gowrap1()
        /usr/local/go/src/runtime/mgc.go:212 +0x28 fp=0x202d7ec sp=0x202d7e4 pc=0x346a8
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm.s:877 +0x4 fp=0x202d7ec sp=0x202d7ec pc=0x98180
created by runtime.gcenable in goroutine 1
        /usr/local/go/src/runtime/mgc.go:212 +0x74

goroutine 4 gp=0x2002908 m=nil [GC scavenge wait]:
runtime.gopark(0x19ab50, 0x28f988, 0xd, 0xa, 0x2)
        /usr/local/go/src/runtime/proc.go:460 +0x104 fp=0x202dfb4 sp=0x202dfa0 pc=0x92318
runtime.goparkunlock(...)
        /usr/local/go/src/runtime/proc.go:466
runtime.(*scavengerState).park(0x28f988)
        /usr/local/go/src/runtime/mgcscavenge.go:425 +0x68 fp=0x202dfc8 sp=0x202dfb4 pc=0x421b0
runtime.bgscavenge(0x204a000)
        /usr/local/go/src/runtime/mgcscavenge.go:653 +0x3c fp=0x202dfe4 sp=0x202dfc8 pc=0x428d0
runtime.gcenable.gowrap2()
        /usr/local/go/src/runtime/mgc.go:213 +0x28 fp=0x202dfec sp=0x202dfe4 pc=0x34654
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm.s:877 +0x4 fp=0x202dfec sp=0x202dfec pc=0x98180
created by runtime.gcenable in goroutine 1
        /usr/local/go/src/runtime/mgc.go:213 +0xbc

goroutine 5 gp=0x2002a28 m=nil [GOMAXPROCS updater (idle)]:
runtime.gopark(0x19ab50, 0x28f758, 0x12, 0xa, 0x1)

Expected behavior
Well, I have been warned: "This package is still in flux as development is on-going."
Would wish to find my way to at least reasonably correct gpio timings.

Any ideas how to debug further?

Platform:

Additional context
I needed to patch the library to get as far as that, see: #73

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions