-
Notifications
You must be signed in to change notification settings - Fork 585
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
GPIOController (PinChangeEventHandler): Assigning a PinChangeEventHandler callback or Controller.OpenPin() causes "Segmentation Error" #2273
Comments
Also get 'Segmentation Error' calling
Code:
|
The "gpioinfo" command failing isn't a good sign, and it may correlate to your problem. To find the root cause, it's better to begin with a functioning state and make small changes gradually -> note versions of the working .NET Runtime / libgpiod combination -> upgrade to NET8 -> check whether it works -> upgrade libgpiod (see here) -> if all still works the issue probably comes with updating OpenWRT (some Linux driver maybe). |
What is the exact operating system you're running? I've been working with LibGpiod on a Raspberry Pi 4 for years now and never saw such a problem. |
OpenWRT, (muscl-linux-arm64) which is a running on Raspberry Pi Compute Model CM4. Thankyou! I have another RPi CM4 dev board (prev working GPIO OS & Dotnet) here that I will investigate LibGpiod functionally on. But if OK, guess I will wipe and load with all current stable and see if LibGpiod works. |
I have a similar problem when I call Controller.OpenPin() I also get a segmentation fault. This happens with System.Device.Gpio v3.1.0. However if I downgrade it to version 3.0.0 all is working as it should. I'm running a .Net 8 application on a Variscite Dart-6UL module. Which has an NXP iMX6UL ARM Cortex-A7 processor. The OS is Debian 12 (Bookworm), custom build. Last updated on 23 January 2024. Unfortunately I currently don't have the time to investigate it much further. The "gpioinfo" console command does give the listing of all gpio lines. |
One diff between the versions is that dotnet iot explicitly uses libgpiod.so.2 (instead of libgpiod.so that points to whatever latest installed version) and maybe something is off with the libgpiod.so.2 file.
|
Apologies! I have traced this issue to a installed 'gpiod-tools' to help gather info on GPIO Controller Need now to more forward and move on with migrating to the newer System.Device.GPIO library that uses the newer IOCTL LibGpiodDriver and see how go. [I'll report back, as have a hunch I'm going to hit this issue again...] |
[Update]
|
I compiled that libgpio2 test, I did have to downgrade the Libgpiod2 from version "1.6.3-1+b3" to "1.6.2-1" in order to get libgpiod-dev installed to have the required header files. The System.Device.Gpio v3.1.0 still failed with this other libgpio2 version. The test in native compiled C however does work:
|
If the C program works and if it is really linked to ".so.2", it strongly suggests a bug in dotnet iot. It's weird though, because |
When libgpiod is not installed, dotnet iot falls back to the
That depends on what dotnet iot version you are using. dotnet-iot 3.1 supports libgpiod v1.6, latest master of dotnet-iot supports libgpiod v2.1 and lower. |
Strange, the problem seems to be with the pinnumbers. I used to just keep numbering them and just use pin 135 for example. But it no longer supports that and gives me a Segmentation fault. I will have to change my code to actually use chip and pin. So at least for me it seems to be a user error, which was allowed on other versions. |
[Triage] @PRIMETSS @WillThisRun @huesla can you clarify the issue here a bit? Is this a single issue or more than one issue? Can you write what OS and libgpiod versions do you have installed? Are you using 64 or 32bit OS? What do we need to reproduce this? Can you share at minimum:
|
Apologies I should have supplied
` processor : 1 processor : 2 processor : 3 Hardware : BCM2835
|
It is a 32bit cpu therefore it is also a 32bit OS But now I must use the port and pin numbers.
|
@PRIMETSS Yes, this is a known issue, see #1992. When sysfs keeps a pin open, it cannot be accessed trough libgpiod. This shouldn't cause a segfault (but rather some defined exception), but maybe that behavior is OS-dependent or otherwise tied to that specific setup. To avoid this problem, use |
[Triage] As it seems that this is not a real issue we can directly fix and everyone found a workaround as problems were mainly related to the configuration, we will most likely close this issue if no new problem that can be fixed in this repository is open. |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. |
Using Latest stable release v3.1.0 & 3.2.0-prerelease.24077.2 & current repo Main (29/Jan/2024)
Creating a console App with
After moving from a working (older) to latest stable SDK & OpenWRT on RiPi Compute Module 4.
'Segmentation fault' happens when assign the ValueChanged callback.
This project had been running fine with previous version(s) & GPIO buttons were working.
_gpioPinButtonUp.ValueChanged += GpioPinButtonUp_ValueChanged
To replicate I build a simple console app, add dependency
System.Device.Gpio
(v3.1.0, tried right back to 2.2 & above preview versions and current Repo's Main branch) and GPIOController and GPIOPin, assign a callback to Pins ValueChanged event.Build & Run App on RPi CM4 and get "Segmentation fault" after trying to assign the call back.
Have also tried the LibGpiodDriver when building the GPIO controller.
Did a
strace
and get this which might shine some light?Looks for Library OK:
Fault:
Code:
Remark out the Event Callback assign, and runs as expected.
//_Pin.ValueChanged += GpioPinButtonUp_ValueChanged;
Has something change recently with assigning callbacks in dotnet or is it a kernal/linux lib issue?
The text was updated successfully, but these errors were encountered: