go-rpio
go-rpio copied to clipboard
Hardlock when EdgeDetect is used
I found a small issue with the library. For some reason when rpio is close and EdgeDetect is still enable it will hard lock the rpi. i tested it on both a pi3 and pi4. if i call pin.Detect(rpio.NoEdge) before close nothing locks up and everything is fine. I don't have any logs unfortunately dmsg and the kernel log give no insight.
go version: go1.17 linux/arm64 kernel version (uname-a): Linux XXXX 5.13.0-1013-raspi #15-Ubuntu SMP PREEMPT Fri Jan 7 23:16:57 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux go-rpio version: 4.5.1
这是来自QQ邮箱的假期自动回复邮件。 您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
I have updated to 4.6 and it is still a issue, I had one run where instead of crashing it locked the file system
I can replicate this on v4.6.0 on a Pi Zero W. It hangs if I run as my user (which is a member of group gpio
) but works fine running as root.
Found
WARNING: this might make your Pi unresponsive, if this happens, you should either run the code as root, or add
dtoverlay=gpio-no-irq
to/boot/config.txt
and restart your pi,
in the docs.
It came from https://github.com/stianeikeland/go-rpio/issues/35, of which this bug is likely a dupe.
Thank you ... yes, adding 'dtoverlay=gpio-no-irq to /boot/config.txt' was the solution in my case due to linux kernel bug still present in version 5.10.103-v7+. Maybe it would be useful to add this as part of go-rpio documentation. this was useful : https://www.i-programmer.info/programming/hardware/14114-raspberry-pi-iot-in-c-events-a-interrupts.html?start=1. BTW, Linux doesn't support user-mode interrupts so it works only if run as root user in older Linux kernels.
it seems that in case of the hardlock prevention one can issue a code to disable gpio-no-irq per program run. The code is in C, but it can be easily adopted to golang.
... c code
int txfound = 0;
while (fgets(output, sizeof (output), fp) != NULL) {
printf("%s\n\r", output);
fflush(stdout);
if (strstr(output, "gpio-no-irq") != NULL) {
txfound = 1;
}
}
pclose(fp);
if (txfound == 0) {
fp = popen("sudo dtoverlay gpio-no-irq","r");
if (fp == NULL) {
printf("Failed to run command\n\r");
exit(1);
}
pclose(fp);
}
...