Linux command
raspi-gpio 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Show all GPIO pin states
raspi-gpio get
Get the state of a specific pin
raspi-gpio get [17]
Configure a pin as output
sudo raspi-gpio set [17] op
Drive a pin high
sudo raspi-gpio set [17] dh
Drive a pin low
sudo raspi-gpio set [17] dl
Set as input with pull-up
sudo raspi-gpio set [18] ip pu
List alternate functions
raspi-gpio funcs [17]
Dump raw register values
sudo raspi-gpio raw
说明
raspi-gpio is a low-level tool for inspecting and manipulating GPIO pins on Raspberry Pi boards. It writes directly to the BCM GPIO controller registers via /dev/gpiomem (or /dev/mem when run as root), bypassing higher-level libraries like libgpiod. The tool is mainly intended for debugging hardware setups, verifying that DT overlays applied the expected pin functions, and one-off scripting. For production use, the kernel gpiod interface (via libgpiod's gpioget/gpioset) is recommended because it integrates with the kernel's GPIO subsystem and respects kernel-claimed lines.
FAQ
What is the raspi-gpio command used for?
raspi-gpio is a low-level tool for inspecting and manipulating GPIO pins on Raspberry Pi boards. It writes directly to the BCM GPIO controller registers via /dev/gpiomem (or /dev/mem when run as root), bypassing higher-level libraries like libgpiod. The tool is mainly intended for debugging hardware setups, verifying that DT overlays applied the expected pin functions, and one-off scripting. For production use, the kernel gpiod interface (via libgpiod's gpioget/gpioset) is recommended because it integrates with the kernel's GPIO subsystem and respects kernel-claimed lines.
How do I run a basic raspi-gpio example?
Run `raspi-gpio get` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
Where can I find more raspi-gpio examples?
This page includes 8 examples for raspi-gpio, plus related commands for nearby Linux tasks.