🛠 Faire clignoter une LED via le GPIO avec libgpiod

Radxa ROCK 3B (Rockchip RK3568) · debutant · Schéma : IMG-radxa-rock-3b-debutant-1-rock3b-led-gpio.svg — LED et résistance 330 Ω câblées sur une broche GPIO du connecteur 40 broches de la Radxa ROCK 3B

Objectives

Discover the 40-pin connector on the Radxa ROCK 3B (Rockchip RK3568) and blink an LED using libgpiod, the modern Linux GPIO API officially recommended by Radxa — the legacy "gpio export" sysfs mechanism is deprecated. You will learn how to identify the correct chip (gpiochip) and line using gpiofind/gpioinfo, rather than copying numbers inherited from Raspberry Pi tutorials.

Hardware

Complete Code

sudo apt update && sudo apt install -y gpiod
gpiodetect                 # RK3568 : gpiochip0..gpiochip3 (banques GPIO0..GPIO3)
gpiofind PIN_7             # renvoie « gpiochipLigne » pour la broche 7 du connecteur
# Nommage Rockchip : GPIO3_C5 -> gpiochip3, ligne 21 (banque*8 + groupe + index)
sudo gpioset -m signal $(gpiofind PIN_7) 1 &     # reste haut jusqu'au Ctrl-C
sudo gpioget $(gpiofind PIN_11)                  # lire une autre broche
# Clignotage 10 cycles sans compiler :
for i in $(seq 1 10); do sudo gpioset --time=0.2 $(gpiofind PIN_7) 1; sleep 0.3; done

Expected Verification

gpiodetect displays gpiochip0 through gpiochip3. gpiofind PIN_7 returns a chip/line pair; with the correct wiring, the LED lights up for ~0.2 s on each loop iteration. The RGB heartbeat LED (driven by the "heartbeat" trigger in the device tree) already blinks under Linux: you can disable it with echo none | sudo tee /sys/class/leds/*/trigger if it interferes with your measurements.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials