【问题标题】:How to toggle LED on-board on Dragonboard 410c running Linux如何在运行 Linux 的 Dragonboard 410c 上切换 LED 板载
【发布时间】:2018-01-03 23:57:45
【问题描述】:

Dragonboard 410c 上有 4 个绿色的小 LED,右边的一个心跳一直在闪烁,如何通过命令行切换其他的。

【问题讨论】:

    标签: shell embedded-linux qualcomm dragonboard


    【解决方案1】:

    首先要注意的是,当前 4 个 LED 中有 3 个是 actively being used,但 LED_4 未使用,可以通过命令行打开

    // turn on
    echo 1 > /sys/class/leds/apq8016-sbc\:green\:user4/brightness
    
    // turn off
    echo 0 > /sys/class/leds/apq8016-sbc\:green\:user4/brightness
    

    【讨论】:

      【解决方案2】:

      首先要注意的是,如何访问位于两个 USB 连接器之间的板载 LED 或用户 LED 以及可供使用的 LED 取决于您使用的操作系统(Android 或 Linux)。

      对于 Android 和 Linux,用户 LED 都列在文件夹 /sys/class/leds 中,因此您可以使用 adb 实用程序远程进入,然后使用 ls 文件夹查看实际的伪文件名。

      对于这两种情况,您将更改位于用户 LED 的伪文件夹中的 brightness 伪文件中的值,以打开 LED,值为 1 或关闭,值为 0。

      还有其他与每个 LED 相关的伪文件,其中一个是 trigger,它允许您设置内核事件以触发 LED。在 Raspberry Pi StackExchange 中查看此答案至How do I control the system LEDs using my software?

      在Android下,查看/sys/class/leds中几个伪目录的几个trigger伪文件,得到boot伪目录的以下输出(用户LED 4用于Android的启动指示灯), led1(用户 LED 1,适用于 Android,但不适用于 Linux)和 wlann(LAN 活动指示灯)。

      root@msm8916_64:/sys/class/leds # cat boot/trigger
      none bkl-trigger [boot-indication] usb-online mmc0 mmc1 battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid wlan-indication-led
      root@msm8916_64:/sys/class/leds # cat led1/trigger
      [none] bkl-trigger boot-indication usb-online mmc0 mmc1 battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid wlan-indication-led
      root@msm8916_64:/sys/class/leds # cat wlan/trigger
      none bkl-trigger boot-indication usb-online mmc0 mmc1 battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid [wlan-indication-led]
      

      注意:为了对伪文件使用文件 I/O,文件权限必须允许您要使用的访问类型(读、写、读/写)。 LED 伪文件的默认值似乎已被读取,因此需要像在 sudo chmod 777 /sys/class/leds/led1/brightness 中一样使用 chmod 命令。

      https://www.96boards.org/documentation/consumer/dragonboard/dragonboard410c/guides/led-connectors.md.html

      位于 USB 端口旁边的是一系列 LED,用于提供 信息给用户。它们的用法定义如下:

      Debian 映像

      安装基于 Debian 的映像时,下表定义 LED 的使用/行为。

      +----------------------+----------------------+--------------------------+
      | LED Board Identifier | Description          | Behavior                 |
      +----------------------+----------------------+--------------------------+
      | User LED 1           | Heartbeat            | Green: This LED is       |
      |                      |                      | should always be         |
      |                      |                      | blinking about once a    |
      |                      |                      | second. If solid off or  |
      |                      |                      | solid on, the board is   |
      |                      |                      | not executing correctly  |
      +----------------------+----------------------+--------------------------+
      | User LED 2           | eMMC                 | Green: This LED blinks   |
      |                      |                      | during accesses to eMMC  |
      +----------------------+----------------------+--------------------------+
      | User LED 3           | SD                   | Green: This LED blinks   |
      |                      |                      | during accesses to SD    |
      |                      |                      | Card                     |
      +----------------------+----------------------+--------------------------+
      | User LED 4           | currently unassigned | N/A                      |
      +----------------------+----------------------+--------------------------+
      | Wifi                 | Wifi                 | Yellow: This LED blinks  |
      |                      |                      | during network accesses  |
      |                      |                      | over Wifi                |
      +----------------------+----------------------+--------------------------+
      | BT                   | Bluetooth            | Yellow: This LED blinks  |
      |                      |                      | when Bluetooth is being  |
      |                      |                      | used                     |
      +----------------------+----------------------+--------------------------+
      

      Android 图片

      安装基于 Android 的图像时,下表定义 LED 的使用/行为。

      +----------------------+----------------------+--------------------------+
      | LED Board Identifier | Description          | Behavior                 |
      +----------------------+----------------------+--------------------------+
      | User LED 1           | currently unassigned | Green:                   |
      +----------------------+----------------------+--------------------------+
      | User LED 2           | currently unassigned | Green:                   |
      |                      |                      |                          |
      +----------------------+----------------------+--------------------------+
      | User LED 3           | currently unassigned | Green:                   |
      |                      |                      |                          |
      |                      |                      |                          |
      +----------------------+----------------------+--------------------------+
      | User LED 4           | Boot                 | This LED illuminates at  |
      |                      |                      | at the start of boot     |
      |                      |                      | and turns of after       |
      |                      |                      | completion of boot.      |
      +----------------------+----------------------+--------------------------+
      | Wifi                 | Wifi                 | Yellow: TDB              |
      +----------------------+----------------------+--------------------------+
      | BT                   | Bluetooth            | Yellow: TBD              |
      +----------------------+----------------------+--------------------------+
      

      对于 Linux,当前 4 个用户 LED 中的 3 个正在被操作系统使用,但用户 LED 4 未使用,可以使用以下命令行打开:

      // turn on user LED 4 on Linux.
      //     use backslash to escape the colon which is part
      //     of the pseudo file name of "apq8016-sbc:green:user4".
      echo 1 > /sys/class/leds/apq8016-sbc\:green\:user4/brightness
      
      // turn off user LED 4 on Linux
      echo 0 > /sys/class/leds/apq8016-sbc\:green\:user4/brightness
      

      对于 Android 5.1,4 个用户 LED 中有 3 个可用。用户 LED 可通过路径 /sys/class/leds 访问,其中存在三个用户 LED 的伪文件:led1led2led3。例如,要打开和关闭用户 LED 1,请使用以下命令行。对于用户 LED 2,将路径中的 led1 替换为 led2,同样对于用户 LED 3,将路径中的 led 替换为 led3

      // turn on LED 1 on Android
      echo 1 > /sys/class/leds/led1/brightness
      
      // turn off LED 1 Android
      echo 0 > /sys/class/leds/led1/brightness
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-10-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-11
        • 1970-01-01
        相关资源
        最近更新 更多