water

water

Circuits.gpio.open() errors not found, while linux's gpioset does work

Device is a Glovary Firewall 6l with GPIO (2x5) on the motherboard.
The header is the not so standard dupont pins 2mm
GPIO is over the super I/O chip: iTE IT8613E

PIN 1 : SIO_PD0  (line 0)
PIN 2 : SIO_PD4  (line 38)
PIN 3 : SIO_PD1  (line 3)
PIN 4 : SIO_PD5  (line 39)
PIN 5 : SIO_PD2  (line 10)
PIN 6 : SIO_PD6  (line 40)
PIN 7 : SIO_PD3  (line 41)
PIN 8 : SIO_PD7  (line 9)
PIN 9 : GND
PIN 10 : VCC

not working:

> Circuits.GPIO.open("GPIO41", :output)
{:error, :not_found}

> Circuits.GPIO.open(41, :output)
{:error, :not_found}

> Circuits.GPIO.enumerate()
[]

> Circuits.GPIO.backend_info()
%{name: Circuits.GPIO.CDev, gpio_number_remapping: :none}


linux (toybox):

> sudo gpioset 0  "41=1" # turn on
> sudo gpioset 0  "41=0" # turn off

> gpioset --version
toybox 0.8.11

linux (libgpiod):

> sudo gpioset -t0 -c gpiochip0 "41=1" # turn on
> sudo gpioset -t0 -c gpiochip0 "41=0" # turn off

> gpioset --version
gpioset (libgpiod) v2.2
Copyright (C) 2017-2023 Bartosz Golaszewski
License: GPL-2.0-or-later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Marked As Solved

fhunleth

fhunleth

Co-author of Nerves

Hi @water,

My first thought is that it’s a permissions issue and Circuits.GPIO doesn’t have access to the GPIOs. I see that you ran sudo on gpioset. I’m assuming that you’re not running Elixir as root and that if you removed the sudo that gpioset wouldn’t work either.

If it is a permissions issue and your device is running udev, you can add a udev rule to set the group/permissions on/dev/gpiochip0 so that Elixir can access it without running as root. Create a file like /etc/udev/rules.d/99-gpio.rules file with the following contents:

KERNEL=="gpiochip*", SUBSYSTEM=="gpio", GROUP="gpio", MODE="0660"

Then create the gpio group if you don’t already have one. E.g. sudo addgroup gpio. Also make sure that your user is in the gpio group in /etc/group.

Then reload udev and rerun the rules:

sudo udevadm control --reload-rules
sudo udevadm trigger

If you look at /dev/gpiochip0, it should have the right permissions and Circuits.GPIO should find the GPIOs. You also shouldn’t need to run sudo for gpioset, etc.

Hope this helps!

Also Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Hey @water that’s my bad, I saw Circuits.GPIO and assumed nerves!

water

water

thank you.

nixos configuration

    services.udev.extraRules = ''
      KERNEL=="gpiochip*", SUBSYSTEM=="gpio", GROUP="gpio", MODE="0660"
    '';
    users.groups."gpio" = { };
    users.users.${config.ncfg.primaryUserName}.extraGroups = [
      "gpio"
    ];

Last Post!

water

water

I can’t get gpiomon to work either.

I’ll change the 2 buttons with switches.
Polling them every 500ms should do the trick.

Where Next?

Popular in Questions Top

hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44167 214
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement