fix(armbian-leds): strip brightness only for :link / phy*tpt triggers#9800
fix(armbian-leds): strip brightness only for :link / phy*tpt triggers#9800iav wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughNormalize input-redirection whitespace when reading trigger and parameter files; implement trigger-aware filtering that removes ChangesLED Brightness Parameter Filtering
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/bsp/common/usr/lib/armbian/armbian-led-state-save.sh (1)
53-58:⚠️ Potential issue | 🟠 Major | ⚡ Quick winUse token-safe filtering for
brightness(current replacement corrupts other param names).Line 53 does a substring replacement, so
max_brightnessbecomesmax_. That yields invalid paths in Line 57/58 and can abort persistence when reads fail.Suggested fix
- [[ "$TRIGGER_VALUE" != "none" ]] && PARAMS=${PARAMS//"brightness"/} + if [[ "$TRIGGER_VALUE" != "none" ]]; then + # Remove only the exact filename token, keep e.g. max_brightness intact + PARAMS="$(printf '%s\n' "$PARAMS" | awk '$0 != "brightness"')" + fiBased on learnings: In the Armbian build framework, scripts run with
set -e, so non-zero failures should be treated as abort paths unless explicitly handled.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bsp/common/usr/lib/armbian/armbian-led-state-save.sh` around lines 53 - 58, The current substring replacement on PARAMS corrupts tokens like max_brightness (so PARAM_PATH="$PATH/$PARAM" fails); instead filter tokens safely before the loop by removing only the exact token "brightness" (e.g., rebuild PARAMS to exclude any word equal to "brightness") so PARAM remains intact; change the logic around TRIGGER_VALUE/PARAMS (the lines manipulating TRIGGER_VALUE, PARAMS and the for PARAM in $PARAMS loop and uses of PATH and PARAM_PATH) to skip the brightness token rather than using ${PARAMS//"brightness"/}, ensuring no invalid paths are produced and the script won't abort under set -e when reading PARAM_PATH.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/bsp/common/usr/lib/armbian/armbian-led-state-save.sh`:
- Around line 53-58: The current substring replacement on PARAMS corrupts tokens
like max_brightness (so PARAM_PATH="$PATH/$PARAM" fails); instead filter tokens
safely before the loop by removing only the exact token "brightness" (e.g.,
rebuild PARAMS to exclude any word equal to "brightness") so PARAM remains
intact; change the logic around TRIGGER_VALUE/PARAMS (the lines manipulating
TRIGGER_VALUE, PARAMS and the for PARAM in $PARAMS loop and uses of PATH and
PARAM_PATH) to skip the brightness token rather than using
${PARAMS//"brightness"/}, ensuring no invalid paths are produced and the script
won't abort under set -e when reading PARAM_PATH.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d16e0681-e0b1-4eb5-8822-bbda7d2dd0e4
📒 Files selected for processing (1)
packages/bsp/common/usr/lib/armbian/armbian-led-state-save.sh
22b938f to
2748c57
Compare
2748c57 to
16a21ae
Compare
|
Adopted, see commit 11f05650. |
16a21ae to
3ea4eb5
Compare
3ea4eb5 to
493aa3f
Compare
|
I suppose I didn't notice that LED was PHY related. That's an icky side effect. I'm certainly in favor of this fix. |
|
This PR contains unrelated changes to interactive.sh? |
493aa3f to
1464394
Compare
You're right, I dragged it out by mistake. I've already removed it. |
1464394 to
56a978b
Compare
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
56a978b to
37d3e12
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/bsp/common/usr/lib/armbian/armbian-led-state-save.sh`:
- Around line 70-79: The current case branch filters out "brightness" only for
TRIGGER_VALUE matching "*:link" or "phy*tpt", but we need to drop brightness for
any active trigger; update the logic in the case block that inspects
TRIGGER_VALUE so that whenever TRIGGER_VALUE denotes an active trigger (e.g. not
"none" or empty), you iterate over PARAMS and remove any "brightness" entries
(same filtering loop using _filtered and _p). Keep using the same variable names
(TRIGGER_VALUE, PARAMS, _filtered, _p) and preserve existing behavior for
specific link/phy patterns while broadening the condition to cover all non-none
triggers.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0ad49e99-8ef2-42ee-881c-39c9b941655f
📒 Files selected for processing (1)
packages/bsp/common/usr/lib/armbian/armbian-led-state-save.sh
Summary
armbian-led-state-save.shsaves LED state on shutdown for restore at boot.For two narrow trigger families,
brightnessfrom sysfs is not configbut the trigger's instantaneous output (link-up/down boolean, tpt blink
state). Capturing it on shutdown and replaying it at boot produces:
:linktriggers showed cable-up whileunplugged after restoring a saved
brightness=1(PR armbian-led-state: avoid binary parameters, other minor cleanups #7337's case)/etc/armbian-leds.confon every shutdown — visibleto anyone with
etckeeper/ etc-diff alerts (rtw88phy0tptflapped0/1; the forum-thread case)
Fix: strip
brightnessonly for the noisy set:Everything else keeps
brightnessas legitimate config — including thekernel LED ABI "ceiling" semantics (writing non-zero brightness while a
trigger is active sets the top brightness for the trigger's output),
which
config/boards/radxa-e52c.confandradxa-e54c.confrely on withbrightness=1undertrigger=netdevfor a dimmed link blink.The token-safe whole-word filter (instead of
${PARAMS//brightness/}substring substitution) is required either way to avoid corrupting
sibling files like
max_brightness→max_.History
Pattern grew incrementally from existing point-fixes for the same root cause:
:link-only strip in PR armbian-led-state: avoid binary parameters, other minor cleanups #7337 (commit2960ffaff) — original ghost-LED casephy*tptextension here — covers the rtw88 forum-thread case[[ $VALUE -eq 0 ]] && continueguard inarmbian-led-state-restore.sh— independent guard against writing 0(which would kick trigger back to
none); kept untouchedA previous version of this PR (commit
56a978bd4) blanket-strippedbrightness for any non-
nonetrigger, but that regressed legitimate dimceilings (radxa-e52c case above). Narrowed to the explicit blacklist on
review feedback.
Forum reference
Documented in detail (with diff samples and root-cause analysis by
@tparys) on the Armbian forum:
Regular changes in file /etc/armbian-leds.conf on ODroid-N2
Test plan
Standalone scaffold (
.tmp/test-led-state-save.sh) mocks/sys/class/leds/and runs the save script:trigger=eth0:link, savedbrightness=1→brightnessstrippedtrigger=phy0tpt, savedbrightness=0→brightnessstrippedtrigger=netdev, savedbrightness=1(radxa dim case) → preservedtrigger=heartbeat, savedbrightness=42→ preservedtrigger=disk-activity, savedbrightness=255→ preservedtrigger=none, savedbrightness=128→ preserveddelay_on=100,link=1,tx=0,rx=1)preserved on every LED
max_brightnessnot corrupted by token-safe filter (was${PARAMS//brightness/}→max_substring bug)