gpioutil

List, read from, write to, and configure GPIOs.

Usage

gpioutil <command> [<name>] [<value>]

Commands

list

gpioutil list

List the known GPIOs.

list returns values like this:

[gpio-0] GPIO_HW_ID_3

The value inside the brackets (gpio-0) is a reference to the pin index. The value after the brackets (GPIO_HW_ID_3) is the <name> value to provide to other gpioutil commands. See GPIO names for more details.

Aliases: l

read

gpioutil read <name>

Read the current value of a GPIO that's configured as OUT.

<name> should be one of the values returned from list.

Possible return values are 0 (LOW) or 1 (HIGH).

Aliases: r

write

gpioutil write <name> <value>

Write a value to a GPIO that's configured as IN.

<name> should be one of the values returned from list.

<value> should be 0 (LOW) or 1 (HIGH).

This command doesn't return a value.

Aliases: w

in

gpioutil in <name> <value>

Configure a GPIO as IN.

<name> should be one of the values returned from list.

<value> is the resistor pull. Accepted values are 0 (GPIO_PULL_DOWN), 1 (GPIO_PULL_UP), or 2 (GPIO_NO_PULL).

This command doesn't return a value.

Aliases: i

out

gpioutil out <name> <value>

Configure a GPIO as OUT.

<name> should be one of the values returned from list.

<value> is the initial OUT value. Accepted values are 0 (LOW) or 1 (HIGH).

This command doesn't return a value.

Aliases: o

drive

gpioutil drive <name> [<value>]

Get or set the drive strength of a GPIO in microamps.

<name> should be one of the values returned from list.

When <value> is omitted, drive returns the current drive strength of the GPIO in microamps.

When <value> is provided, drive updates the drive strength of the GPIO. <value> should be in microamps.

Aliases: d

help

gpioutil help

Print help text.

Aliases: h

Examples

List all known GPIOs

$ gpioutil list
[gpio-0] GPIO_HW_ID_3
[gpio-1] GPIO_SOC_TH_BOOT_MODE_L
...

Read the current value of a GPIO

$ gpioutil read GPIO_HW_ID_3
GPIO Value: 1

Write a LOW value to a GPIO

$ gpioutil write GPIO_HW_ID_3 0

Configure a GPIO as IN with a pull-down resistor

$ gpioutil in GPIO_HW_ID_3 0

Configure a GPIO as OUT with an initial value of HIGH

$ gpioutil out GPIO_HW_ID_3 1

Get the current drive strength of a GPIO in microamps

$ gpioutil drive GPIO_HW_ID_3
Drive Strength: 500 ua

Set the drive strength of a GPIO to 500 microamps

$ gpioutil drive GPIO_HW_ID_3 500
Set drive strength to 500

Notes

Accessing this command

This command is only available on certain diagnostic and testing Fuchsia builds.

This is a device-side command, not a host-side command like fx or ffx. In other words before calling this command you must first access the shell of the Fuchsia device.

To interactively access the Fuchsia device's shell:

ffx component explore <component>

Replace <component> with the name of the component that has access to the command documented on this page.

To call a single command and return the output to the host:

ffx component explore <component> -c "<command>"

Replace <command> with one of the commands documented on this page.

GPIO names

GPIO names are defined in the driver source code and usually match the datasheet's name for the GPIO. See the DECL_GPIO_PIN statements in vim3-gpio.cc for an example.

Source code

Source code for gpioutil: //src/devices/gpio/bin/gpioutil/