Skip to content

Commit 37d3e12

Browse files
committed
fix(armbian-leds): strip brightness only for :link / phy*tpt triggers
Previous version stripped brightness for any non-none trigger, which regresses board configs that intentionally dim a triggered LED. The kernel LED ABI treats brightness under an active trigger as a "ceiling" the trigger may scale to (writing non-zero brightness while a trigger is active sets the top brightness for the trigger's output). config/boards/radxa-e52c.conf and radxa-e54c.conf rely on this: `brightness=1` under `trigger=netdev` produces a dimmed link blink. Narrow the strip to triggers whose brightness is genuinely an instantaneous output (link-up/down boolean, tpt blink state): *:link — netdev link state, the original case from PR #7337 (commit 2960ffa). Showed cable-up while unplugged after restore from a saved `brightness=1`. phy*tpt — wifi PHY tx-packet trigger. rtw88 forum case: brightness flapped 0/1 in /etc/armbian-leds.conf on every shutdown. Other triggers keep brightness as legitimate config. The token-safe filter (whole-word match instead of ${PARAMS//brightness/} substring substitution) stays — required either way to avoid corrupting sibling files like max_brightness. Forum thread: https://forum.armbian.com/topic/57284-regular-changes-in-file-etcarmbian-ledsconf-on-odroid-n2/ Assisted-by: Claude:claude-opus-4.7
1 parent 4aa01fe commit 37d3e12

1 file changed

Lines changed: 39 additions & 6 deletions

File tree

packages/bsp/common/usr/lib/armbian/armbian-led-state-save.sh

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function store_led() {
2424
TRIGGER_PATH="$1/trigger"
2525
DESTINATION="$2"
2626

27-
TRIGGER_CONTENT=$(<$TRIGGER_PATH)
27+
TRIGGER_CONTENT=$(< $TRIGGER_PATH)
2828

2929
[[ "$TRIGGER_CONTENT" =~ $REGEX ]]
3030

@@ -40,15 +40,48 @@ function store_led() {
4040
COMMAND_PARAMS="$CMD_FIND $PATH/ -maxdepth 1 -type f ! -iname uevent ! -iname trigger -perm /u+w -printf %f\\n"
4141
PARAMS=$($COMMAND_PARAMS)
4242

43-
# In case trigger is representing link-state for any network, use
44-
# bash substitution to remove the brightness parameter and avoid
45-
# ghost wan/lan/etc (led up while cable unplugged)
46-
[[ "$TRIGGER_VALUE" == *":link" ]] && PARAMS=${PARAMS//"brightness"/}
43+
# brightness semantics depend on the trigger:
44+
# trigger=none → brightness is plain config (static value).
45+
# trigger=netdev/pattern → brightness is a "ceiling" the trigger may
46+
# scale to (kernel LED ABI: writing non-zero
47+
# brightness while a trigger is active sets
48+
# the top brightness for the trigger's
49+
# output). Board configs use this on purpose
50+
# (e.g. radxa-e52c.conf has brightness=1
51+
# under trigger=netdev to dim the blink).
52+
# noisy triggers below → brightness is the trigger's instantaneous
53+
# output (link-up/down boolean, tpt blink
54+
# state). Capturing it on shutdown produces
55+
# ghost-LED bugs on restore (":link" showed
56+
# cable-up while unplugged) and constant
57+
# churn in /etc/armbian-leds.conf (rtw88
58+
# phy0tpt flapped 0/1 every shutdown).
59+
# Strip brightness only for the noisy set; keep it for everything else
60+
# so legitimate dim ceilings survive the save/restore cycle.
61+
# Pattern history: ":link"-only strip was the original workaround in
62+
# commit 2960ffaff; "phy*tpt" extends it to the rtw88 forum case.
63+
# Forum thread: https://forum.armbian.com/topic/57284-regular-changes-in-file-etcarmbian-ledsconf-on-odroid-n2/
64+
#
65+
# Token-safe whole-word filter: the simpler ${PARAMS//brightness/}
66+
# substring substitution would also corrupt sibling files like
67+
# `max_brightness` → `max_`, breaking the read loop below under set -e.
68+
# Bash-only (no `awk` etc.) because store_led() reassigns PATH to the
69+
# sysfs led path, so external commands aren't on PATH here.
70+
case "$TRIGGER_VALUE" in
71+
*:link | phy*tpt)
72+
declare _filtered=""
73+
for _p in $PARAMS; do
74+
[[ "$_p" == "brightness" ]] && continue
75+
_filtered+="$_p"$'\n'
76+
done
77+
PARAMS="$_filtered"
78+
;;
79+
esac
4780

4881
for PARAM in $PARAMS; do
4982

5083
PARAM_PATH="$PATH/$PARAM"
51-
VALUE=$(<$PARAM_PATH)
84+
VALUE=$(< $PARAM_PATH)
5285

5386
# If the variable contains non-printable characters
5487
# suppose it contains binary and skip it

0 commit comments

Comments
 (0)