gpioset --help
Usage: gpioset [OPTIONS] <line=value>…
Set values of GPIO lines.
Lines are specified by name, or optionally by offset if the chip option
is provided.
Values may be ‘1’ or ‘0’, or equivalently ‘active’/‘inactive’ or ‘on’/‘off’.
The line output state is maintained until the process exits, but after that
is not guaranteed.
Options:
–banner display a banner on successful startup
-b, --bias specify the line bias
Possible values: ‘pull-down’, ‘pull-up’, ‘disabled’.
(default is to leave bias unchanged)
–by-name treat lines as names even if they would parse as an offset
-c, --chip restrict scope to a particular chip
-C, --consumer consumer name applied to requested lines (default is ‘gpioset’)
-d, --drive specify the line drive mode
Possible values: ‘push-pull’, ‘open-drain’, ‘open-source’.
(default is ‘push-pull’)
-h, --help display this help and exit
-i, --interactive set the lines then wait for additional set commands
Use the ‘help’ command at the interactive prompt to get help
for the supported commands.
-l, --active-low treat the line as active low
-p, --hold-period
the minimum time period to hold lines at the requested values
-s, --strict abort if requested line names are not unique
-t, --toggle [,period]…
toggle the line(s) after the specified period(s)
If the last period is non-zero then the sequence repeats.
–unquoted don’t quote line names
-v, --version output version information and exit
-z, --daemonize set values then detach from the controlling terminal
Chips:
A GPIO chip may be identified by number, name, or path.
e.g. ‘0’, ‘gpiochip0’, and ‘/dev/gpiochip0’ all refer to the same chip.
Periods:
Periods are taken as milliseconds unless units are specified. e.g. 10us.
Supported units are ‘s’, ‘ms’, and ‘us’.
Note
The state of a GPIO line controlled over the character device reverts to default
when the last process referencing the file descriptor representing the device file exits.
This means that it’s wrong to run gpioset, have it exit and expect the line to continue
being driven high or low. It may happen if given pin is floating but it must be interpreted
as undefined behavior.
点亮灯,比如我的设备gpio是GPIO2_IO4 先使用gpiodetect
gpiodetect
gpiochip0 [43810000.gpio] (32 lines)
gpiochip1 [43820000.gpio] (32 lines)
gpiochip2 [43830000.gpio] (32 lines)
gpiochip3 [47400000.gpio] (32 lines)
gpiochip4 [1-0022] (24 lines)
gpiochip5 [adp5585-gpio] (10 lines)
可以看出来chip0的地址是4831000
由芯片手册可以看出4381000对应GPIO2_IO4。
所以使用
gpioset -c gpiochip0 4=0
就可以成功点亮开发板上的led灯了