🛠 Faire clignoter une LED sur la broche P8_03 avec libgpiod
Objectives
Control a pin on the P8/P9 headers using the modern libgpiod library: identify the correct GPIO controller (the AI-64 has several), understand that P8_03 corresponds to GPIO0_20 (muxmode 7 according to chapter 7 of the System Reference Manual), and blink an LED in Python.
Hardware
- 1 BeagleBone AI-64 with the official Debian image
- 1 breadboard, 1 LED, 1 330 Ω resistor, connecting wires
- Golden rule: ALL signals on P8/P9 are 3.3 V. Never apply 5 V to a pin, and never inject voltage into the pins when the board is powered off (back-powering through ESD diodes = destroyed processor, voided warranty).
Complete code
sudo apt install python3-gpiod gpiod
gpiodetect # chercher la puce nommée 600000.gpio (contrôleur "main")
gpioinfo 600000.gpio | grep -i P8_03
#!/usr/bin/env python3
# blink.py — libgpiod v2, image Debian AI-64
import gpiod, time
# 4211000.gpio = wkup (petit contrôleur), 600000.gpio = main (broches P8/P9)
with gpiod.Chip("600000.gpio") as chip:
line = chip.get_line(20) # P8_03 == GPIO0_20
line.request(consumer="blink", type=gpiod.line_request.DIRECTION_OUTPUT)
try:
while True:
line.set_value(1); time.sleep(0.5)
line.set_value(0); time.sleep(0.5)
finally:
line.release
Expected verification
The LED blinks at 1 Hz. During execution, gpioinfo shows line 20 of 600000.gpio as "output" with the consumer "blink". The script cleanly releases the pin upon Ctrl+C.
Common errors
- Choosing the wrong gpiochip: the wkup controller (4211000.gpio) does not expose the P8/P9 pins; verify with gpiodetect.
- libgpiod API: on images with gpiod 1.x, the call differs (gpiod.LINE_REQ_DIR_OUT); the code above is for the v2 API.
- Forgetting the resistor: a direct LED connection saturates the pin (respect the 3.3 V limit and pin current).
- Expecting hardware PWM: eHRPWM muxing to the headers is a known documentation blind spot on the AI-64 (issue #19) — for beginners, software PWM via libgpiod is sufficient.
- Wiring while the board is powered on without a common GND: erratic readings.
Other tutorials for this board
- Flasher l'image officielle et démarrer la BeagleBone AI-64
- Surveiller la température et l'alimentation du TDA4VM
- Réseau : Ethernet Gigabit unique et module Wi-Fi en M.2 E-key
- Caméra MIPI CSI et encodage H.264 matériel via GStreamer
- Remoteproc : inventorier et démarrer les co-processeurs R5F et C66x
- Inférence de réseau de neurones sur le C7x+MMA avec edgeai-tidl-tools
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash