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

Hardlock when EdgeDetect is used #82

Open
jax-b opened this issue Jan 16, 2022 · 5 comments
Open

Hardlock when EdgeDetect is used #82

jax-b opened this issue Jan 16, 2022 · 5 comments

Comments

@jax-b
Copy link

jax-b commented Jan 16, 2022

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

@yzj578492228
Copy link

yzj578492228 commented Jan 16, 2022 via email

@jax-b
Copy link
Author

jax-b commented Jan 16, 2022

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

@rspier
Copy link

rspier commented Jan 5, 2023

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.

@rspier
Copy link

rspier commented Jan 5, 2023

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 #35, of which this bug is likely a dupe.

@peritonow
Copy link

peritonow commented Oct 17, 2023

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);
}
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants