如何从OpenWRT构建的UBoot读取GPIO值

问题描述 投票:-1回答:1

我正在尝试在由OpenWRT驱动的电路板上实现恢复模式。我有一个连接到某个GPIO的按钮:GPIO_PL4。

我使用下一个表达式将gpio名称转换为数字表示:

(position of letter in alphabet - 1) * 32 + pin number

所以我得到了PL4 - 356映射。

我试图将下一行添加到u引导环境文件qazxsw poi:

uEnv-default.txt

但在启动过程中收到错误消息:

  if gpio input 356; then
     echo "The button is pressed";
  fi;

然后我尝试使用 gpio: requesting pin 356 failed gpio - query and control gpio pins Usage: gpio <input|set|clear|toggle> <pin> - input/set/clear/toggle the specified pin gpio status [-a] [<bank> | <pin>] - show [all/claimed] GPIOs 获取有关GPIO的信息:

gpio status -a

得到了下一个输出:

gpio status -a (within uEnv-default.txt)

所以问题是:我能否使用PL4 gpio引脚作为当前gpio配置的输入,如果没有,如果可能的话,如何更改此引脚的gpio配置?

我想,我必须在U-Boot上应用一个补丁来制作一个合适的gpio配置,对吗?

linux gpio openwrt u-boot
1个回答
-1
投票

我找到了解决方案。有两个问题:

  1. 至少,对于sunxi-8设备的U-boot(2018.11)不使用上面的表达式将gpio名称转换为数字表示(可以为u-boot Bank PA: ... Bank PL: PL0: func ... PL4: func // does it mean that I'm not able to use it as an input ... PL11: func PL12: input: 0 [ ] PL13: input: 0 [ ] .... 命令键入gpio名称:gpio)。
  2. 默认情况下,端口L在sunxi-8 cpus上是非时钟/无电源的,至少是sun8i-h2-plus-orangepi-zero电路板,所以它必须由gpio input pl4提供时钟/电源。看看prcm_apb0_enable
© www.soinside.com 2019 - 2024. All rights reserved.