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"
    ];

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
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
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
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

We're in Beta

About us Mission Statement