【问题标题】:How to read a GPIO value from UBoot built by OpenWRT如何从 OpenWRT 构建的 UBoot 中读取 GPIO 值
【发布时间】:2019-04-05 08:58:20
【问题描述】:

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

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

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

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

我尝试将下一行添加到 uboot 环境文件 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 status -a 获取有关 GPIO 的信息:

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

得到下一个输出:

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 [ ]
....

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

我想,我必须在 U-Boot 上应用补丁才能进行正确的 gpio 配置,对吗?

【问题讨论】:

    标签: linux gpio openwrt u-boot


    【解决方案1】:

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

    1. sunxi-8 设备的 U-boot (2018.11) 至少不使用上述表达式将 gpio 名称转换为数字表示(可以为 u-boot gpio 命令键入 gpio 名称:gpio input pl4)。
    2. 端口L,在sunxi-8 cpus,至少sun8i-h2-plus-orangepi-zero板上默认是unclocked/unpowered,所以它必须由prcm_apb0_enable进行时钟/powered .看https://forum.armbian.com/topic/10111-orange-pi-zero-u-boot-gpio-access/?tab=comments#comment-76996

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-20
      • 1970-01-01
      • 1970-01-01
      • 2018-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多