I followed OpenEmbedded Core and generated a console-tdx-image.
Then I tried doing the GPIO on Colibri Aster Board (Basic GPIO usage - Iris Carrier Board - Colibri iMX7) where I was able write on gpio pins but not able to read using the sysfs interface. I used the following pins for in out.
But none of the pins I was able to read correctly.
What has to be done in to successfully read gpios, please provide detailed steps as no clear information i could find on the community posts.
Then I read that sysfs was deprecated. Now I wish to using libgpiod on the build image. I can see /dev/gpiochip interfaces but libgpiod commands are not available.
I want to know how can libgpiod be used/integrated in the linux image so i can use it to read write gpios.
As you have already noticed, sysfs have been deprecated and from BSP 3.0 onwards, we support libgpiod in order to be aligned with the Linux kernel community.
As stated in this link, BSP 3.0 supports libgpiod. But the user space tools and libraries are not already included in the Demo image available in the Toradex Easy Installer, so one might have to do a custom Yocto build to add them. This could be why you don’t see libgpiod commands being available.
For further information, please kindly refer to the following developer articles:
But the user space tools and libraries
are not already included in the Demo
image available in the Toradex Easy
Installer, so one might have to do a
custom Yocto build to add them.
I wish to know, how the user space tools and libraries can be added to the yocto build.
I found out the libgpiod package is located in meta-oe layer (https://layers.openembedded.org/layerindex/recipe/66918/)
I want to know what modifications I need to make in yocto build directory so that this library becomes available in the image I build using bitbake.
I have just done the following and it works for me. I just bit baked the available libgpiod package and installed the .ipk onto my image. And I was readily able to use the libgpiod commands.
Could you tell me what exact image and version you use? And also can you please tell me if you had made any changes to the device tree?
I started experimenting with my iMX7 two days ago and thanks to the great tutorials on the wibside i already bitbaked my own OpenEmbedded console-tdx-image image.
My setup:
Colibri iMX7D512MB with Colibri Evaluation Board V3.2B
Linux colibri-imx7 4.14.170-3.0.4+gbaa6c24240a4 #1 SMP Wed Jun 3 12:37:49 UTC 2020 armv7l GNU/Linux
I added the libgpiod and libgpiod-tools packages to the build.
I connected the following Pins on the Eval Board:
LED1 to X22Pin08 (GPIO4.17; SODIMMPin103)
LED2 to X22Pin10 (GPIO4.19; SODIMMPin097)
LED3 to X22Pin12 (GPIO4.21; SODIMMPin059)
LED4 to X22Pin14 (GPIO4.23; SODIMMPin065)
SW1 to X22Pin07 (GPIO4.16; SODIMMPin101)
SW2 to X22Pin09 (GPIO4.18; SODIMMPin079)
SW3 to X22Pin11 (GPIO4.20; SODIMMPin067)
SW4 to X22Pin13 (GPIO4.22; SODIMMPin085)
To keep it simple i want to read the input from SW1 and i want to set the output to LED1.
I can now use the command line tools (gpioinfo, gpioset, gpioget).
gpioget 4 16 always returns 0 independent of the state of the Switch.
gpioset 4 17=0 or gpioset 4 17=1 cant light the LED.
gpioinfo shows:
gpiochip4 - 32 lines:
line 16: unnamed unused input active-high
line 17: unnamed unused output active-high
line 18: unnamed unused input active-high
line 19: unnamed unused output active-high
line 20: unnamed unused input active-high
line 21: unnamed unused output active-high
line 22: unnamed unused input active-high
line 23: unnamed unused output active-high
The openembedded packages libgpiod and libgpiod-tools packages are deployed starting with the 3.0b3 image. Could you therefore also tell the exact version you use? Probably the output of uname -a?
And can you specify what exact Device tree are you using?
I switched to BSP 5.0 for my colibri imx7 and now i am using a slightly modified tdx-reference-minimal-image. I added some packages to “conf/local.conf”:
I also compiled my own device tree with a different pinconfig.
I can now read and write GPIO Pins over the userspace tools provided by libgpiod.
I can’t use the libgpiod API in Python because it is not provided by default.
Like mentioned here i have to add the PACKAGECONFIG option “python3” to the libgpiod package. I tried to follow the steps on the yoctoproject mega-manual and tried the following:
I created the file “/layers/meta-openembedded/meta-oe/recipes-support/libgpiod/libgpiod_1.4.3.bbappend”:
PACKAGECONFIG_append = " python3"
I also tried to add the following line to “conf/local.conf”:
PACKAGECONFIG_append_libgpiod = " python3"
Both of those did not work.
Can you please help me to get the libgpiod API working with python.
The problem was that i am still new to the yocto project. I assumed that bitbake would automatically add the missing package “libgpiod-python” to the image, if the PACKAGECONFIG option “python3” was set for the libgpiod package. Of course you have to add the package manually after setting the PACKAGECONFIG variable.
To add the libgpiod-python-API you have to add the following variables to the “conf/local.conf” file: