🛠 LEDs du Lichee RV Dock : LED verte et RGB WS2812 pilotée par le LEDC du D1
Objectives
The Lichee RV Dock has TWO controllable LEDs under mainline Linux: the module's green "status" LED (pin PC1, standard LED class driver) and the Dock's RGB WS2812 (NeoPixel) LED on pin PC0 — a rare feature, it is driven by the D1's hardware LEDC peripheral, declared in the mainline device tree as a multicolor LED (multicolor class), without bit-banging. This tutorial introduces you to /sys/class/leds, triggers (timer, heartbeat), and the multicolor API multi_intensity.
Hardware
- Lichee RV Dock running a mainline image (Buildroot
sipeed_lichee_rv_dock, Ubuntu 24.04 RISC-V, or Armbian D1) — kernel ≥ 6.3 for the board's device tree (merged in v6.3), and a subsequent WS2812/LEDC patch (commit f8ad8bbb8827) required for the RGB LED - No external wiring: both LEDs are onboard
Complete code
# 1) Lister les LED visibles par le noyau
ls /sys/class/leds/
# mainline : « green:status » (PC1, module) + une LED multicolore « status » (PC0, WS2812)
# 2) LED verte PC1 : trigger timer (clignotement 1 Hz)
echo timer | sudo tee '/sys/class/leds/green:status/trigger'
# rythme cardiaque :
echo heartbeat | sudo tee '/sys/class/leds/green:status/trigger'
# contrôle manuel :
echo none | sudo tee '/sys/class/leds/green:status/trigger'
echo 1 | sudo tee '/sys/class/leds/green:status/brightness'
echo 0 | sudo tee '/sys/class/leds/green:status/brightness'
# 3) RGB WS2812 (PC0) via le LEDC — LED multicolore, canaux R G B 0-255
RGB=$(ls -d /sys/class/leds/*status/multi_intensity 2>/dev/null | head -1)
echo "255 0 0" | sudo tee "$RGB" # rouge
echo "0 255 128" | sudo tee "$RGB" # vert menthe
echo 64 | sudo tee "$(dirname $RGB)/brightness" # luminosité globale
# 4) Petit script d'ambiance
while :; do for c in "255 0 0" "0 255 0" "0 0 255"; do
echo "$c" | sudo tee "$RGB" >/dev/null; sleep 1; done; done
Expected verification
ls /sys/class/leds/ lists at least the green LED green:status and, with a sufficiently recent kernel, a multicolor device *::status containing multi_intensity. The timer trigger makes the green LED blink at 1 Hz; echo 1/0 to brightness visibly turns it on and off. The Dock's WS2812 actually changes color with multi_intensity (R G B separated by spaces) — if the multicolor device is missing, your kernel does not yet have the Dock's LEDC node. The cat of trigger shows the active value in brackets.
Common errors
- Forgetting to escape the colon in the name: in the shell, put the path in quotes (
'/sys/class/leds/green:status/trigger') or use Tab completion. echo 1 > brightnesswithout sudo: the redirection is performed by the shell without privilege escalation; usesudo tee.- Looking for the WS2812 under a classic "led0" name: it is a MULTICOLOR LED (
multi_intensity,multi_led), not a single-channel LED; older kernels sometimes expose it as a single-color LED. - Testing under Tina Linux (vendor OpenWrt image): LED names there differ completely from mainline; refer to the Sipeed wiki on the vendor side.
- Confusing it with an external WS2812 strip: here the LEDC drives the onboard LED PC0; for an external strip, you need the
leds-ax20000/pwm driver depending on the kernel.
Other tutorials for this board
- Premier boot du Lichee RV Dock avec Ubuntu 24.04 RISC-V
- Audio sur le Dock : enregistrer au micro numérique et jouer sur le haut-parleur 3 W
- Wi-Fi et Bluetooth du module RTL8723DS sur le Lichee RV Dock
- GPIO, touche utilisateur ADC et PWM sur le connecteur 2×20 du Lichee RV
- Tina Linux : l'OpenWrt vendor d'Allwinner pour le Lichee RV, installation et sysconfig
- Construire une image mainline complète avec Buildroot (defconfig officiel du Dock)
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash