Unable to set GPIO High with Sysfs on IMX7ULPEVK

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unable to set GPIO High with Sysfs on IMX7ULPEVK

Jump to solution
501 Views
LegoBox
Contributor II

Hi all,

I'm trying to set a pin high using my IMX7ULPEVK board. Using Kernel V5.15.7 (imx-image-multimedia-imx7ulpevk.wic)

I'm trying to get PTF11 high. (Arduino header D9).

In my interpretation, PTF is the 3th GPIOPort from the sources.

 

aliases {
	gpio0 = &gpio_ptc;
	gpio1 = &gpio_ptd;
	gpio2 = &gpio_pte;
	gpio3 = &gpio_ptf;
}

 

So for PTF11 i need to have have to calculate.

 

(port x 32) + pin =
(3 x 32) + 11 = 107

 

 

Running the following command to check if i can export the GPIO using sysfs.

 

echo 107 > /sys/class/gpio/export

 

Results in:

 

root@imx7ulpevk:~# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/40ae0000.gpio, 40ae0000.gpio:
 gpio-0   (                    |regulators:regulator) out lo 
 gpio-10  (                    |cd                  ) in  lo IRQ ACTIVE LOW
 gpio-19  (                    |?                   ) out hi 

gpiochip1: GPIOs 32-63, parent: platform/40af0000.gpio, 40af0000.gpio:
 gpio-32  (                    |regulators:regulator) out hi 

gpiochip2: GPIOs 64-95, parent: platform/40b00000.gpio, 40b00000.gpio:

gpiochip3: GPIOs 96-127, parent: platform/40b10000.gpio, 40b10000.gpio:
 gpio-96  (                    |fts_irq_gpio        ) in  hi IRQ 
 gpio-97  (                    |fts_reset_gpio      ) out hi 
 gpio-107 (                    |sysfs               ) in  lo 

gpiochip4: GPIOs 128-159, parent: platform/rpmsg-gpio0, imx-rpmsg-gpio-0:
 gpio-142 (                    |reset               ) out hi ACTIVE LOW
 gpio-143 (                    |?                   ) out hi 

gpiochip5: GPIOs 160-191, parent: platform/rpmsg-gpio1, imx-rpmsg-gpio-1:

 

So far so good, sysfs claimed the GPIO-107 on the correct bus, assuming my calculation is right.

When i try to get the pin to output the trouble begins...

 

root@imx7ulpevk:~# echo out > /sys/class/gpio/gpio107/direction
-sh: echo: write error: Invalid argumen

 

I'm unable to write out or "out" to the direction, so i'm unable to change this pin to output.

 

What could be wrong here? It does not seems that something is using the pin, my lsmod output is the following:

 

root@imx7ulpevk:~# lsmod
Module                  Size  Used by
caam_jr               159744  0
caamkeyblob_desc       16384  1 caam_jr
caamhash_desc          16384  1 caam_jr
caamalg_desc           53248  1 caam_jr
crypto_engine          20480  1 caam_jr
authenc                16384  1 caam_jr
libdes                 28672  1 caam_jr
rpmsg_iio_pedometer    16384  0
ath10k_sdio            32768  0
ath10k_core           372736  1 ath10k_sdio
ath                    32768  1 ath10k_core
caam                   20480  1 caam_jr
error                  20480  5 caamkeyblob_desc,caamalg_desc,caamhash_desc,caam_jr,caam

 

 

 

Thanks in advance.

 

 

Labels (2)
0 Kudos
Reply
1 Solution
449 Views
Chavira
NXP TechSupport
NXP TechSupport

Hi @LegoBox!
Thank you for contacting NXP Support!

This is the old way to set the gpios on the board.

You have to declare the gpio on the device tree to be used on Linux.

Please check this guide:

https://www.thegoodpenguin.co.uk/blog/stop-using-sys-class-gpio-its-deprecated/


Best Regards!
Chavira

View solution in original post

1 Reply
450 Views
Chavira
NXP TechSupport
NXP TechSupport

Hi @LegoBox!
Thank you for contacting NXP Support!

This is the old way to set the gpios on the board.

You have to declare the gpio on the device tree to be used on Linux.

Please check this guide:

https://www.thegoodpenguin.co.uk/blog/stop-using-sys-class-gpio-its-deprecated/


Best Regards!
Chavira