system/nxinit: support compound command and resetcause-based triggers - #3751
system/nxinit: support compound command and resetcause-based triggers#3751JianyuWang0623 wants to merge 5 commits into
Conversation
Example in init.rc: echo "start" && hello && echo "done" ls /missing || echo "not found" echo "A" && echo "B" || echo "fallback" Signed-off-by: fangpeina <fangpeina@xiaomi.com>
Add built-in property sys.boot.reason, which allows action triggers to be
executed on specific reset cause.
For example:
```
on property:sys.boot.reason=cpu_soft_reset(bootloader)
echo "bootloader mode ..."
start fastboot
```
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
init.rc
on init && property:sys.boot.reason=watchdog,4
...
on init && property:sys.boot.reason=bootloader|recovery|thermal
...
Test
cause->cause = BOARDIOC_RESETCAUSE_CPU_RWDT;
cause->flag = 4
init_main: setprop key:sys.boot.reason value:watchdog,4
cause->cause = BOARDIOC_RESETCAUSE_CPU_SOFT;
cause->flag = BOARDIOC_SOFTRESETCAUSE_ENTER_BOOTLOADER;
init_main: setprop key:sys.boot.reason value:bootloader
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Add the missing mapping entries in the resetflag[] array to prevent potential NULL pointer dereference when accessing reset.flag. The resetflag array uses designated initializers and must have entries for all BOARDIOC_SOFTRESETCAUSE_* values to avoid array holes. Reported by: xuchuntian@xiaomi.com Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
CI failure investigationThe Evidence:
Since No code change is needed in this PR. Marking ready for review; CI should pass once the upstream |
|
Very nice! Please fix CI error |
cederom
left a comment
There was a problem hiding this comment.
Very cool thank you @JianyuWang0623 the change is good, but also please fix caught syntax issues as we are here and we have them fixed for future :-)
|
@cederom @fdcavalcanti |
cederom
left a comment
There was a problem hiding this comment.
Thank you @JianyuWang0623 :-)
We may want to wait for fixes from apache/nuttx#19555 or merge if other CI checks pass when in hurry in that case :-)
@cederom Would be nice if we could ignore this false‑positive. Some in‑flight PRs need this PR(#3751) merged first. |
|
@JianyuWang0623 fix typo error: |
codespell flagged this in PR apache#3751 CI: system/nxinit/init.c:119: unkown ==> unknown system/nxinit/init.c:130: unkown ==> unknown Both entries were introduced by the resetcause-for-triggers commit and are unrelated to the earlier nxstyle regression already discussed on the PR. Assisted-by: GitHubCopilot:claude-sonnet-5 Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
eeaf6c4
Summary
&&/||short-circuit semantics), e.g.:sys.boot.reasonso action triggers can fire based on the board's reset cause, e.g.:sys.boot.reasonto allow finer-grained matching, e.g.:"assert"entry in theresetflag[]designated-initializer array that could lead to a NULL pointer dereference when accessingreset.flag.Impact
action.c/action.h:init_action_reap_command()signature gained a second parameter to propagate the command's return value for&&/||short-circuiting.Testing
Build Host: Linux x86_64 (Ubuntu, kernel 6.8.0), gcc (Ubuntu 13.4.0-6ubuntu1
22ppa2) 13.4.0Target: sim:nsh (apps/system/nxinit is architecture-independent; verified via the host simulator since no esp32p4 riscv32 cross toolchain is available on this machine)
Build (excerpt,
CONFIG_SYSTEM_NXINIT=y):Runtime (
./nuttx, actual console output):Style check (
tools/checkpatch.sh -g apache/master..nxinit-action-trigger-enhancements, actual output):The single reported issue (
action.c:117) is pre-existing onapache/master— reproduced by runningnxstyledirectly against the unmodifiedapache/mastercopy ofaction.c, which reports the identical error at the same line. It is not introduced by this change.Not verified: esp32p4/esp32s3 board-level flashing and serial output — this change is architecture-independent apps-layer code, and this machine has no esp32p4 riscv32 cross toolchain installed.