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

fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
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
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 126479 1222
New

We're in Beta

About us Mission Statement