GPIOs and libgpiod "outside" of containers

Good morning,
I’ve been playing a bit with Torizon (w/Eval containers) on an imx7d with IRIS carrier board, in particular with GPIOs and some I2C expander boards (see also this post).

Now I would like to address a different issue.
As opposed from the examples here, I would like to have gpio-tools and related libraries available at the Torizon o.s. level, in order to be used by anyone accessing the SBC.
Although I was able to run gpio-tools from within the container, and test onboard and off-board (GPIO expander) i/o pins.

Two questions:

  • is there a Torizon easyinstaller image already available, having libgpiod and related gpio-tools enabled? I tested “Toradex with Multimedia”, it has libgpiod but it’s not “TorizonCore” - no containers.
  • how to customize the Torizon environment, in order to add those binaries and libraries at the o.s. level? I don’t need to make “large production” at the moment, prototyping only. But I need to call gpioset and gpioget from many places (maybe, even other containers).

Any suggestions is welcome,
thanks & regards


Greetings @flavio.f,

Could you describe your use-case. Exactly why do you need GPIO tools outside of the container on the host OS itself?

The only practical way to customize and add packages onto the the base OS of TorizonCore is by creating a custom OS image using Yocto/Openembedded. Which is what we use to build TorizonCore initially.

Best Regards,

Greetings again @jeremias.tx ,
and thank you for your continuous support.
I will try to describe my use case, and give some suggestions about how I would like to proceed in order to have a comment from you about which solution is faster.

I’m developing a datalogger that basically store data and switch on/off attached sensors (mainly RS232 but not only - this was my first post). I need to have something working fastly, minimizing development time in favor of testing activities. That’s why I put some efforts into Node-Red. I managed to solve RS232 issues, now I need to solve with GPIOs - taking into consideration that IRIS does not expose too many I/Os, hence we’re using a MCP23017 I/O expander (that works fine either from “user space”, or even from “kernel space” - i managed to run a TorizonCore dev-tree patched version that “I cooked”).
In order to use I/O, everywhere it’s said to use gpio-tools and libgpiod (see linked examples). gpioset and gpioget from commandline are exactly what I need to exec from NodeRed (via a call to underlying o.s. when “privileged”, or at least “containerized” o.s.)

All in all, I figure out some solutions, but still don’t know how to completely build them; and probably each one has its pros and cons.

  1. start from NodeRed container in TorizonCore (with Portainer and other goodies), and try to make a Dockerfile that includes libgpiod prior to instantiate Nodered. I’m still not good at preparing Dockerfile(s), but maybe there won’t be other caveats this way
  2. start from a Toradex BSP (no TorizonCore) which already has libgpiod and associated commandline tools; try to install a NodeRed on it (I attempted this; I was unable to install nodejs/nodered with opkg… it was not working, package not found). Furthermore, need to delve again into devtree details to allow for MCP23017 driver to work.
  3. same as 2) but trying to install docker, and a containerized Node-Red. Didn’t try yet.

So, what would you suggest? To be honest, since there could be only one or two containers at most, it’s not mandatory to have Docker.
Any suggestions is welcome; hopefully in the next few days I will try to move forward on the 1) and 3) approaches.

Sorry for the long post!
Best Regards,


From what I understand then you simply want libgpiod outside of a container because you believe it’s easier to accomplish? And not for any real technical limitations/requirements?

Currently you have a NodeRed container then correct? Why not just add libgpiod inside that container? NodeRed has instructions on how to extend their container/Dockerfile here: Adding Prerequisites to Docker : Node-RED

If you do option 2 or 3 you’d need to use Yocto to install either NodeRed or Docker in our BSP reference image. Which is far more complex, especially if you don’t have any prior Yocto experience.

Best Regards,

Yes @jeremias.tx ,
you got the point. I need it quickly… :slight_smile: this is why I’m struggling to find the fastest (but robust) way.
I’m currently investigating 1st approach, I’m sure it will get the desired result - and it seems that you are suggesting me the same…

From what I understand then you simply want libgpiod outside of a container because you believe it’s easier to accomplish? And not for any real technical limitations/requirements?

To be honest, being these IoT devices meant to be used for I/O “in the field”; I can’t figure out by myself the reasons why not to bundle libgpiod toghether with the standard Torizon distro. But… you know why; furthermore I’m having the chance to learn from docker and containers. Last but not least device tree customization for letting MCP23017 gpio expander work as expected - I have made lots of improvement since the beginning :wink:

I will go on implementing the desired container image beginning from what you suggest, and thanks again!
Kind Regards


Let us know how this approach works out for you.

Of course @jeremias.tx

Is there a Nodered debian-based available Dockerfile for Torizon imx7? I was wondering if it’s better to start the opposite side, i.e. having a clean image, adding libgpiod, and then adding nodejs and nodered in sequence within the Dockerfile. This would me allow also to choose a different NR release.
But I’ll try what you suggest before.

Thanks, andk best regards

In the article I referenced previously: Adding Prerequisites to Docker : Node-RED

There is an entire section about building a Debian-based Nodered container. There are links in the article to Node-RED’s own sources including Dockerfiles.

Best Regards,

Yes of course,
I started yesterday with experimentation on a new NR 3.0.1 container based on those steps.

I’ll let you know!

Kind regards