GPIO pins on a Raspberry Pi™ (or any Linux® single-board computer) through
the sysfs interface, /sys/class/gpio, for Jennifer
programs. Pins are keyed by number, with no handle: setup, write, read,
release. It is the gpio module Jennifer bundled up to 0.28.0, moved to a
deck with the same interface.
This deck is part of Skiffyard, small community decks for Jennifer.
Jennifer 0.29.0 drives GPIO only through the /dev/gpiochipN character
device (the gpio library) and no longer bundles the sysfs module. The
kernel deprecates sysfs GPIO, but it is still in use:
| Case | Why sysfs |
|---|---|
| Raspberry Pi kernels | They still enable sysfs GPIO, and existing scripts, udev rules and tutorials use it. |
| Shared pins | A pin that a shell script or another tool exports under /sys/class/gpio can be driven from Jennifer as well. |
| State after exit | An exported output keeps its level after the program ends, so a short script can switch a relay and exit. A character-device line is freed when its process exits. |
jennifer-tiny |
The gpio library is a stub on the TinyGo build; this deck is plain files (fs) and runs on both binaries. |
New code that needs none of these should use the gpio library, the
interface the kernel keeps.
jvc add @skiffyard/gpiosysfsThis vendors the deck to vendor/<scope>/gpiosysfs/. Without jvc, unpack the
src/ subtree of a release archive (<scope>-gpiosysfs-<version>.tar.gz) there.
import "@skiffyard/gpiosysfs/" as gpiosysfs;
gpiosysfs.setup(17, gpiosysfs.OUT); # BCM GPIO 17, header pin 11
gpiosysfs.write(17, 1); # LED on
gpiosysfs.write(17, 0); # LED off
gpiosysfs.release(17);
Change the import line; every call stays as it is:
import "gpio.j" as gpio; # Jennifer up to 0.28.0
import "@skiffyard/gpiosysfs/" as gpio; # this deck
The constants (IN, OUT, AUTO, GLOBAL), the error kind "gpio" and
the environment variables JENNIFER_GPIO_BASE and JENNIFER_GPIO_CHIP_LABEL
are unchanged.
Jennifer 0.28.0 or newer, the default binary or jennifer-tiny. At run time a
Linux host with sysfs GPIO (/sys/class/gpio); a user in the group that owns
the pin files, or root. No capability.
tools/check-all.sh # the full gate, as CI runs it
jennifer test src/gpiosysfs_test.j # the test overlay (a mock sysfs tree)
tools/check-docs.sh # docs against the code
tools/pack.sh dist # build the release archiveLGPL-3.0-only, see LICENSE. Copyright (C) 2026 mplx <mplx@jennifer-lang.dev>.
tools/check-headers.sh checks every source file's SPDX header against
deck.toml.
Raspberry Pi is a trademark of Raspberry Pi Ltd. Linux is a registered trademark of Linus Torvalds. Other product and company names may be trademarks of their respective owners. They are used only to identify the products this deck works with. This deck is an independent project, not affiliated with, sponsored or endorsed by Raspberry Pi Ltd.