Skip to content

About

Raspberry Pi GPIO over the sysfs interface (/sys/class/gpio), a drop-in for the gpio module Jennifer 0.29.0 removed

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

@skiffyard/gpiosysfs

test Documentation release

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.

Documentation

Why a sysfs deck

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.

Install

jvc add @skiffyard/gpiosysfs

This vendors the deck to vendor/<scope>/gpiosysfs/. Without jvc, unpack the src/ subtree of a release archive (<scope>-gpiosysfs-<version>.tar.gz) there.

Usage

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);

Moving from the bundled gpio module

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.

Requirements

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.

Development

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 archive

Licence

LGPL-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.

Trademarks

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.

About

Raspberry Pi GPIO over the sysfs interface (/sys/class/gpio), a drop-in for the gpio module Jennifer 0.29.0 removed

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors