GPIOs can be accessed from Linux user space through the sysfs interface, example:
echo 4 >/sys/class/gpio/export
echo out >/sys/class/gpio/gpio4/direction
echo 1 >/sys/class/gpio/gpio4/value
echo 0 >/sys/class/gpio/gpio4/value
Digi Embedded Yocto offers an example application gpio_sysfs_test which can be added to local.conf:
EXTRA_IMAGE_FEATURES += dey-examples
IMAGE_INSTALL_append += dey-examples-gpio-sysfs
Usage: gpio-sysfs-test <gpio_in> [gpio_out]
Where gpio_in is a pushbutton and gpio_out an optional LED
Sources:
<dey-install-folder>/sources/meta-digi/meta-digi-dey/recipes-digi/dey-examples/files/gpio_sysfs_test/gpio_sysfs_test.c.
When using GPIOS from the MCA the base address is gpiochip504.
When using GPIOs on the CC6UL development board i/o-expander, make sure you have firmware loaded for the i/o expander:
# sysinfo
..
|| I/O Expander | HW_VERSION=1 FW_VERSION=0.2
..
if it shows FW_VERSION=?? or you don't have sysinfo and can't access:
cat /sys/bus/i2c/devices/0-006e/fw_version
check: i/o expander not programmedi/o expander not programmed
The base address for the i/o expander is gpiochip465. See:
https://www.digi.com/resources/documentation/digidocs/90001547/#reference/bsp/v4-1_6ul/r_io_expander_gpio.htm
The User LED on the CC6UL SBC is connected to IO23 of the i/o expander, its gpio number is 488 (465 + 23), example:
echo 488 >/sys/class/gpio/export
echo out >/sys/class/gpio/gpio488/direction
cat /sys/class/gpio/gpio488/value
0
echo 1 >/sys/class/gpio/gpio488/value
echo 0 >/sys/class/gpio/gpio488/value
Last updated:
May 27, 2025