I tried the library on Ubuntu64 no a RPI 3B+. It did not work.
Guess the library is only usable for arm32 only now ?
Thanks a lot for the issue report! It shouldn't, The library should work fine with arm64 architectures but I'm not sure if we've ever tested on Ubuntu64. Which version of the package are you using? I ask because we've made changes since we shipped 1.0.0 that might make it so that it works better on other archs. Also, do you mind explaining a bit more what do you mean by "It did not work"? Can you share exception logs or the output you got that lead you to think that it doesn't work?
Would be useful if you've shared the sample you were trying, your csproj and how did you build so that we can check this looks ok
Hi
Thanks for replying to my post.
My Program is a simple one, just to toggle a pin on the RPI GPIO
using System;
using System.Device.Gpio;
using System.Threading;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
int ledPin1 = 17;
GpioController controller = new GpioController();
controller.OpenPin(ledPin1, PinMode.Output);
while (true)
{
controller.Write(ledPin1, PinValue.High);
Console.WriteLine("High");
Thread.Sleep(500);
controller.Write(ledPin1, PinValue.Low);
Console.WriteLine("Low");
Thread.Sleep(500);
}
}
}
}
Machine ==> RPI 3B+
Machine O/S ==> 64 bit Ubuntu Server 20.04 LTS
dotnet package on RPI side ==> dotnet-sdk-3.1.202-linux-arm64.tar.gz
This is the project file
/>
The program is published with the following settings
Target Framework ==> netcoreapp3.1
Deployment Mode ==> Framework Dependent
Target runtime ==> Portable
This is the error I get when I try running the dll
ubuntu@ubuntu:~/publish$ dotnet TryArm64.dll
Unhandled exception. System.IO.IOException: Error 13 initializing the Gpio
driver.
at System.Device.Gpio.Drivers.RaspberryPi3Driver.Initialize()
at System.Device.Gpio.Drivers.RaspberryPi3Driver.OpenPin(Int32 pinNumber)
at System.Device.Gpio.GpioController.OpenPin(Int32 pinNumber)
at System.Device.Gpio.GpioController.OpenPin(Int32 pinNumber, PinMode
mode)
at ConsoleApplication1.Program.Main() in
C:\Users\smart\Desktop\DC210_Testplan\tryArm64\TryBasicConsole\Program.cs:line
20
Aborted (core dumped)
If I publish with target runtime as 'linux-arm' I will get this error
ubuntu@ubuntu:~/publish$ dotnet TryArm64.dll
Unhandled exception. System.BadImageFormatException: Could not load file or
assembly '/home/ubuntu/publish/TryArm64.dll'. An attempt was made to load a
program with an incorrect format.
On Thu, May 21, 2020 at 1:02 AM Krzysztof Wicher notifications@github.com
wrote:
Would be useful if you've shared the sample you were trying, your csproj
and how did you build so that we can check this looks ok—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/dotnet/iot/issues/1082#issuecomment-631602577, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/ANMUZWG4SPXWIZ2YMT4DUDDRSQEI5ANCNFSM4NF5SNMQ
.
can you replace new GpioController() with new GpioController(PinNumberingScheme.Logical, new LibGpiodDriver()) and see if that fixes the issue? If seeing issue about libgpiod missing just install it.
I suspect the detection logic chose the wrong controller or there is a bug in the auto-detected controller
Error 13 means "permission denied". I can imagine that access to the GPIO ports is not allowed for everyone on Ubuntu.
@Smartcat168 : Can you try to run your application as root (with sudo)?
I think we should add some code translation in the GPIO code (at least for the most common errors)
@krwq : I haven't had time to investigate this fully, but it looks like Win32Exception.GetErrorMessage already does the trick, it even has an unix implementation: https://github.com/dotnet/runtime/blob/master/src/libraries/Microsoft.Win32.Primitives/src/System/ComponentModel/Win32Exception.Unix.cs
Hi
I was able to get the gpio working in Ubuntu 64 bit after issuing the
command below.
sudo chmod 777 /dev/gpiomem
thanks
On Fri, May 22, 2020 at 7:24 PM Patrick Grawehr notifications@github.com
wrote:
@krwq https://github.com/krwq : I haven't had time to investigate this
fully, but it looks like Win32Exception.GetErrorMessage already does the
trick, it even has an unix implementation:
https://github.com/dotnet/runtime/blob/master/src/libraries/Microsoft.Win32.Primitives/src/System/ComponentModel/Win32Exception.Unix.cs—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/dotnet/iot/issues/1082#issuecomment-632642077, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/ANMUZWECRH2U2AYP43CVEZLRSZOG3ANCNFSM4NF5SNMQ
.
@Smartcat168 : Was that change permanent or do you have to redo this after every boot? If so, you might need to add an udev rule. That's a service that manages non-root access to virtual file system entries such as /dev/gpiomem or also /sys/class/* entries (i.e. pwm or i2c access).
Yes I need to issue command to re-enable GPIO after every boot.
Now figuring out what to put in udev to make it persistent after boot.
Thanks for the advise.
On Sun, May 24, 2020 at 10:25 PM Patrick Grawehr notifications@github.com
wrote:
@Smartcat168 https://github.com/Smartcat168 : Was that change permanent
or do you have to redo this after every boot? If so, you might need to add
an udev rule. That's a service that manages non-root access to virtual file
system entries such as /dev/gpiomem or also /sys/class/* entries (i.e. pwm
or i2c access).—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/dotnet/iot/issues/1082#issuecomment-633238963, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/ANMUZWALXJXCGXZDTEHGHTLRTEU6HANCNFSM4NF5SNMQ
.
I need that chmod as well on Raspberry PI OS. @pgrawehr can you elaborate on those udev rules?
@MihaMarkic : On Raspbian, this should not normally be necessary, as it is pre-configured for this to work (with the exception of the PWM driver, which needs an udev rule to work as non-root).
Here's the udev rule I use for pwm: (copy to /etc/udev/rules.d/55-pwm.rules)
SUBSYSTEM=="pwm*", PROGRAM="/bin/sh -c '\
chown -R root:gpio /sys/class/pwm && chmod -R 770 /sys/class/pwm;\
chown -R root:gpio /sys/devices/platform/soc/*.pwm/pwm/pwmchip* && chmod -R 770 /sys/devices/platform/soc/*.pwm/pwm/pwmchip*\
'"
@MihaMarkic Note: Depending on the functions you use (particularly when using interrupt driven triggers) you may need to use a recent development build and not the release version, as we've done a bunch of fixes to properly support udev.
@Smartcat168, I feel like this issue is resolved with the advices from @pgrawehr. I will then close this issue. Feel free to reopen it at any time!