system/nxinit: add property-based action triggers - #3726
Merged
xiaoxiang781216 merged 6 commits intoAug 15, 2026
Conversation
Add the property backend and a setprop builtin so that setting a property can feed action triggers. property_simple.c provides a minimal init_property_*() implementation whose init_property_set() forwards the key/value pair to init_action_trigger_event(), and init.c wires the property poller into the init poll loop. Signed-off-by: fangpeina <fangpeina@xiaomi.com> Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Previously only supported event trigger, now added support for
action triggers (property setting).
Steps to enable action triggers:
- Define all init_property_*() interfaces declared in this file.
- Data structures or functions that will likely be used:
- struct action_trigger_s
- init_action_for_every()
Example
```
on boot
setprop key_test
setprop key_test value_test /* property changed and matched */
trigger event_test
on event_test && property:key_test=value_test
echo "on event_test, property changed!"
on property:key_test=value_test
echo "property changed!"
```
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
init.rc
on boot && property:sys.boot.reason!=bootloader
echo "On boot, the reason is not BL."
Before fixing
init_main: action 0x40436120
init_main: sys.boot.reason!=bootloader
init_main: argv[0] 'echo'
init_main: argv[1] 'On boot, the reason is not BL.'
After fixing
init_main: action 0x40436120
init_main: sys.boot.reason!=bootloader
+ init_main: default==boot
init_main: argv[0] 'echo'
init_main: argv[1] 'On boot, the reason is not BL.'
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Action triggered on any event before this fix (e.g. both opposite actions in
init.rc below triggered when event "boot" triggered).
init.rc
on boot && property:sys.boot.reason=bootloader
echo "On boot, the reason is BL."
on boot && property:sys.boot.reason!=bootloader
echo "On boot, the reason is not BL."
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Decrementing i when it's 0 in "for (; i >= 0; i--)" causes size_t underflow to a huge value. Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
The `on <event>` action re-executed on every property poll because the event pending flag was sticky: event_callback returned the same non-zero pending value whether the event had just changed or had stayed satisfied from an earlier change. init_action_foreach_event could not distinguish an edge from a steady state and re-enqueued the action each round (board_netinit ran 262 times per boot). Introduce a three-state result (EVENT_STATE_UNSATISFIED / SATISFIED / TRIGGERED). event_callback now returns TRIGGERED only on the edge where pending flips false -> true. foreach folds per-event states into a product clamped to TRIGGERED, enqueuing the action only when every event is satisfied AND at least one fired this round. Assisted-by: GitHubCopilot:claude-4.8-opus Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
acassis
approved these changes
Aug 14, 2026
acassis
left a comment
Contributor
There was a problem hiding this comment.
@JianyuWang0623 nice! Please update the Documentation
xiaoxiang781216
approved these changes
Aug 15, 2026
xiaoxiang781216
pushed a commit
to apache/nuttx
that referenced
this pull request
Aug 17, 2026
The Triggers section previously stated that action (property) triggers were not yet implemented; they are supported now, so describe the fnmatch value matching and the edge-triggered semantics of on <event>. The Examples section used the stale CONFIG_SYSTEM_INIT_* prefix and now uses CONFIG_SYSTEM_NXINIT_* together with a property trigger example. This documents the behavior added in apache/nuttx-apps#3726. Assisted-by: GitHubCopilot:claude-opus-4.8 Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: Please adhere to Contributing Guidelines.
Summary
Extend init actions from bare event names to a property-based trigger model:
<event>is a name orproperty:key=value(fnmatch,!=inverts). Adds asetpropbuiltin and a pluggable poller backend (property_simple.c). Barenames map to
default==<name>, so existingon <event>rc files keep working.Includes three fixes to the new parser and matcher: event parsing loss,
multi-event AND semantics, and size_t index underflow.
Impact
on property:...syntax andsetprop; oldon <event>unchanged...._ACTION_MANAGER_EVENT_MAX(32) →..._ACTION_EVENTS_MAX(default 1, range 1..64); configs setting the old symbol must be updated.property_simple.c. No hardware or security impact.Testing
tools/checkpatch.sh -fpasses on all changed files.