Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WaitForEdge Fails on Rasperry Pi Kernel 6.6.16-v8+ #40

Closed
gsexton opened this issue Feb 12, 2024 · 2 comments
Closed

WaitForEdge Fails on Rasperry Pi Kernel 6.6.16-v8+ #40

gsexton opened this issue Feb 12, 2024 · 2 comments

Comments

@gsexton
Copy link
Contributor

gsexton commented Feb 12, 2024

Describe the bug
Using the specified kernel, a call go WaitForEdge immediately unblocks and returns.

To Reproduce
Steps to reproduce the behavior:

  1. Run program
package main

import (
        "log"
        "periph.io/x/conn/v3/driver/driverreg"
        "periph.io/x/conn/v3/gpio"
        "periph.io/x/conn/v3/gpio/gpioreg"
        "periph.io/x/host/v3"
)

func main() {
    _, err:=host.Init()
    if err!=nil {
        panic(err)
    }
    _, err = driverreg.Init()
    if err!=nil {
        panic(err)
    }
    pin := gpioreg.ByName("GPIO19")
    pin.In(gpio.PullUp, gpio.BothEdges)
    for  {
        edgeReceived := pin.WaitForEdge(-1)
        if edgeReceived {
            log.Print("Edge Received., State=", pin.Read())
        } else {
            log.Print("No Edge Received")
        }
    }
}
  1. Run it.
  2. Note the output continuously scrolls "No Edge Received".

Expected behavior
The program should have blocked until the button was pressed.

Platform (please complete the following information):

  • OS: Raspbian Bookworm
  • Board: Pi 4 B 4GB
  • Kernel: 6.6.16-v8+

Additional context
The program has been working for several years. After a kernel update, it stopped working. Experimentation shows that reading the state of the button does work.

I've searched around, and found some references that this might be related to deprecation of /sys/class/gpio?

FWIW, I tried python and RPi.GPIO and it sees the button press as well, but attempt to add event for edge detection fails.

I tried running my test program under strace and got:

...
futex(0x200d00, FUTEX_WAIT_PRIVATE, 0, NULL) = 0
futex(0x200d00, FUTEX_WAIT_PRIVATE, 0, NULL) = -1 EAGAIN (Resource temporarily unavailable)
nanosleep({tv_sec=0, tv_nsec=3000}, NULL) = 0
futex(0x4000100148, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x4000100148, FUTEX_WAKE_PRIVATE, 1) = 1
newfstatat(AT_FDCWD, "/sys/bus/platform/drivers/raspberrypi-firmware", {st_mode=S_IFDIR|0755, st_size=0, ...}, 0) = 0
openat(AT_FDCWD, "/proc/device-tree/system/linux,revision", O_RDONLY|O_CLOEXEC) = 7
fcntl(7, F_GETFL)                       = 0x20000 (flags O_RDONLY|O_LARGEFILE)
fcntl(7, F_SETFL, O_RDONLY|O_NONBLOCK|O_LARGEFILE) = 0
epoll_ctl(4, EPOLL_CTL_ADD, 7, {events=EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, data={u32=223870981, u64=35813851309539333}}) = 0
fstat(7, {st_mode=S_IFREG|0444, st_size=4, ...}) = 0
read(7, "\0\3001\22", 512)              = 4
read(7, "", 508)                        = 0
epoll_ctl(4, EPOLL_CTL_DEL, 7, 0x4000064c80) = 0
close(7)                                = 0
futex(0x4000080148, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x4000100148, FUTEX_WAKE_PRIVATE, 1) = 1
openat(AT_FDCWD, "/etc/localtime", O_RDONLY) = 7
read(7, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\6\0\0\0\6\0\0\0\0"..., 4096) = 2460
read(7, "", 4096)                       = 0
close(7)                                = 0
write(2, "2024/02/12 12:44:38 No Edge Rece"..., 372024/02/12 12:44:38 No Edge Received
) = 37
futex(0x4000100148, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x200d00, FUTEX_WAIT_PRIVATE, 0, NULL) = 0
2024/02/12 12:44:39 No Edge Received

@maruel
Copy link
Member

maruel commented Feb 16, 2024

Dang, sorry to hear. I fear someone will have to do the migration. Since the driver is in host, not in conn, it's tracked at periph/host#39.

@gsexton
Copy link
Contributor Author

gsexton commented Sep 2, 2024

Closing this because periph/host#59 resolves it.

@gsexton gsexton closed this as completed Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants