Some GPIO pins work as expectation, but some pins don't

Hello,
I am using these device.

For OS, I am using the Yocto Project BSP

I am facing some GPIO issues:

I success to set these default (come with board) GPIO as “output”, below is the result of command “gpioinfo” in terminal

[upload|GxjJGZkbuskTlBVTU+LFTTV4khk=]

Then I try to play with these command :

echo 1 > /sys/class/gpio/gpioPIN/value
echo 0 > /sys/class/gpio/gpioPIN/value

Then I realize it only work for some pins with it turn on/off successfully. For those pin that are fail, it never turn on LED.
Conclusion is some pins work as expectation, but some pins don’t.

My connect is straightforward, I connect pin → LED (with a 330 ohm resistor) → GND

[upload|tSN2vOIJzaD3YkxJVtYzr0jsDf8=]

Everything is normal (success) if we check the status in terminal, the ‘value’ does show it is ‘1’ or ‘0’ for both success and fail pins after command ‘echo’ the value.
[upload|j3b14DRMakjbawP+0k7fgMnA58g=]

Below are the table for pass/fail pin:

[upload|0rPdFihsrJgRy9JEZpsO3Y6Bg8w=]

I need to make all the pins work as expectation, please help me on this, thank you very much.

You need to set up proper pin muxing at Device Tree for pins your are going to use as a GPIO. Please check this article.

Hi @alex.tx , based on the Apalis iMX8X datasheet, it seems like there are supposed to be 8 dedicated GPIO pins, GPIO1 to GPIO8 which correspond to the pins being tested above. Do we need to do additional pin muxing for them to work? As far as I can see, these pins are already configured to be GPIO in the device tree. I can see pinctrl_gpio1 to pinctrl_gpio6 assigned to pinctrl-0 of iomuxc here:

https://git.toradex.com/cgit/linux-toradex.git/tree/arch/arm64/boot/dts/freescale/imx8qxp-apalis.dtsi?h=toradex_5.4-2.1.x-imx

Would appreciate any advice on how to proceed on muxing if those declarations do not enable the pins as GPIO. Thanks!

How can you get that “PIN” numbers at your table?

Apalis  MXM3    iMX8X           Linux 
GPIO	pin	 name	     GPIO
    
    1	1     GPIO3.IO21	gpio-405
    2	3     GPIO3.IO22 	gpio-406
    3	5     GPIO3.IO23	gpio-407
    4	7     GPIO3.IO24	gpio-408
    5	11    GPIO3.IO17	gpio-401
    6	13    GPIO3.IO18	gpio-402
    7	15    GPIO3.IO19	gpio-403
    8	17    GPIO3.IO20	gpio-404

@alex.tx I understand that you obtained those GPIO numeric assignments based on the formula provided in this article? In our case, calculating the GPIO numeric value using the formula

480 - 32 x controller + gpio

as provided in the article did not work for us. Trying to export gpio-405, for example, resulted in a write error. Instead, we used the formula

controller x 32 + gpio
e.g. GPIO3.IO23 => (3 x 32) + 23 = gpio-119

and can confirm that this should be the correct formula to obtain the GPIO numeric values on the Apalis iMX8X (as we managed to correctly toggle GPIOs on MXM3 pins 5, 7 and 11).

This is what happens when I cat /sys/kernel/debug/gpio:

Another article where I have observed some conflict of information is GPIO (Linux), where the provided GPIO numerical value tallies with the ones in the table you provided, but not with the Apalis iMX8X SOMs we are currently working with.

So it rises a question - what is “your case”? Which image are you using?

We’ve built Toradex’s BSP 5 Reference Minimal Image based on the OpenEmbedded (core) guide. The machine name which was specified in local.conf is “apalis-imx8x”, which, according to the guide is meant for Apalis iMX8X V1.1B and newer (which is our case here). We have not made any changes to the device tree.

Hi @alex.tx

I download and tested the the image from :
https://developer.toradex.com/software/toradex-easy-installer

And it works well !

According to linux-toradex.git - Linux kernel for Apalis and Colibri modules
It just added those “fail” pin during 28th-Jan-2021.

2574-8.png

Glad it works. Thank you for an update.