🛠 LEDs du Lichee RV Dock : LED verte et RGB WS2812 pilotée par le LEDC du D1

Sipeed Lichee RV Dock (Allwinner D1 / T-Head XuanTie C906) · debutant · Schéma : IMG-sipeed-lichee-rv-dock-debutant-1-licheerv-leds-ws2812.svg — Lichee RV Dock avec la LED verte du module sur la broche PC1 et la LED RGB WS2812 du Dock sur PC0 reliée au contrôleur matériel LEDC du SoC D1, plus la LED d'alimentation

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

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

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials