SysFs interface. I can't export gpio pins in a Xilinx's Board (Zybo and other)

老子叫甜甜 提交于 2020-01-14 02:30:26

问题


Using a linux-kernel compiled as it is described here, I'm trying to make a led blinking following this wiki: Linux GPIO Driver. I'm working with a Zybo-board of Xilinx.

I enabled the kernel options:

CONFIG_GPIO_SYSFS=y
CONFIG_SYSFS=y
CONFIG_GPIO_XILINX=y

I checked that I have mounted in /sys the SysFs

I want to configure the pin 7 of the MIO port because it is attached to the led LD4 in the board. So I used this expression:

echo 7 > /sys/class/gpio/export

And I always obtain this error:

export_store: invalid GPIO 7
ash: write error: Invalid argument

I have also tried to export the values 145 (138+7) because of the explanation I found here: forum_link and 86 because this guy got the things working basic_example. But I always obtained the same error.

Could you give me some help? Maybe a I have to use other offset? Or is it more related with permission configuration??


回答1:


I faced the same problem. The solution is to add 906 as a "base" of the "address-gpio". For example, if you want to manage the pin of the PS connected to MIO 7, you should do something like this:

zynq> echo 913 > /sys/class/gpio/export
zynq> echo out > /sys/class/gpio/gpio913/direction
zynq> echo 1 > /sys/class/gpio/gpio913/value

(where 906+7=913 of course).

Or, if you want to switch it off:

 zynq> echo 0 > /sys/class/gpio/gpio913/value

How do I find this value? Well, in my case I was just lucky: if you have a look in

ls /sys/class/gpio

you can see that it already exists gpiochip906. Go inside this directory and have a look inside the file base (using "less" for example): there is only the value 906 of course



来源:https://stackoverflow.com/questions/40131771/sysfs-interface-i-cant-export-gpio-pins-in-a-xilinxs-board-zybo-and-other

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!