system/nxinit: add rptun/unlink builtins and service fallback option - #3761
Open
JianyuWang0623 wants to merge 3 commits into
Open
system/nxinit: add rptun/unlink builtins and service fallback option#3761JianyuWang0623 wants to merge 3 commits into
JianyuWang0623 wants to merge 3 commits into
Conversation
JianyuWang0623
force-pushed
the
nxinit-rptun-unlink-fallback
branch
from
August 28, 2026 13:10
4ff5356 to
53217b9
Compare
BL uses init framework (not NSH), so the NSH rptun command is not available. Add rptun as an init builtin command that supports start and stop subcommands. Also add a generic unlink builtin command for removing device nodes. Usage in init.bl.rc: rptun stop /dev/rptun/corecs unlink /dev/rptun/corecs rptun start /dev/rptun/corecs - rptun start/stop: open device, ioctl(RPTUNIOC_START/STOP), close - unlink: generic command to unlink any file/device node Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
JianyuWang0623
force-pushed
the
nxinit-rptun-unlink-fallback
branch
2 times, most recently
from
August 28, 2026 13:24
3daf3bf to
b2288ea
Compare
RPTUNIOC_START returns the (positive) pid of the rptun kernel thread in async mode (CONFIG_RPTUN_START_SYNC unset). The action engine treats any positive builtin return value as the pid of a spawned child and waitpid()s on it (action.c: "if (ret > 0) pid_running = ret"). The rptun thread is a detached kthread, never a child of init, so that wait blocks the whole action queue forever and "on init" / console never run. Normalize a successful start to 0. Assisted-by: OpenCode:claude-sonnet-5 Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
The preset kvdb service defined in parser.c conflicts with user-defined kvdb service in board-level init.rc, causing: Error redefined service 'kvdb' Add SVC_FALLBACK flag and fallback service option. When a service is marked as fallback, it will be silently ignored if another service with the same name already exists. This is the semantic opposite of override: - override: new definition replaces old - fallback: new definition yields to old - old has fallback + new arrives: old yields to new If neither flag is set, duplicate service names still produce EEXIST error as before. Mark the preset kvdb service as fallback so that board-specific init.rc can freely define its own kvdb service without conflict. Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
JianyuWang0623
force-pushed
the
nxinit-rptun-unlink-fallback
branch
from
August 28, 2026 13:29
b2288ea to
7e1e173
Compare
Contributor
Author
|
Note: The |
JianyuWang0623
marked this pull request as ready for review
August 28, 2026 13:41
xiaoxiang781216
approved these changes
Aug 28, 2026
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.
Summary
rptun / unlink builtin commands. Some products drive early bring-up
entirely from
init.rcrather than NSH, so the NSHrptuncommand isnot available there. Add
rptunas an init builtin (guarded byCONFIG_RPTUN) supportingstart/stop, plus a genericunlinkbuiltin (always available) for removing device nodes, e.g.:
RPTUNIOC_STARTreturns the pid of the rptun kernel thread in asyncmode (
CONFIG_RPTUN_START_SYNCunset). That thread is a detachedkthread, never a child of init, so returning a positive value would
make the action engine
waitpid()on it and block the whole actionqueue (and
on init/ console would never run). A successful start isnormalized to 0.
fallbackservice option. Add anSVC_FALLBACKflag and afallbackservice option — the semantic opposite ofoverride— toresolve same-name service conflicts.
overridemakes the newdefinition replace the old;
fallbackmakes the definition markedfallback yield to the other one, so a board-level
init.rccan providea default service that is silently dropped when another
init.rcdefines a service with the same name (and vice versa). If neither flag
is set, duplicate service names still produce
-EEXISTas before.Impact
system/nxinit/{builtin.c,service.c,service.h}. No changeto existing builtins/options; new behavior is opt-in via the new
rptun/unlinkcommands and thefallbackoption.rptunbuiltin is compiled only whenCONFIG_RPTUNis enabled;unlinkandfallbackare always available.Testing
Built and verified locally with the
simtarget (host gcc).nxstyleclean on all three touched files.
fallbackverified at runtime onsim+ nxinit with aninit.rcthatdeclares two services named
console(A/B against the same configwithout the flag):
unlinkis always compiled in andrptuncompiles underCONFIG_RPTUN;both build cleanly. The
simtarget has no rptun device, so the rptunruntime path is not exercised here — the concurrency fix (normalizing a
successful async
RPTUNIOC_STARTto 0 so the action engine does notwaitpid()on the detached rptun kthread) is a targeted one-line changeverified by build + code review.
cc @wyr-7