acassis opened a new pull request, #3504:
URL: https://github.com/apache/nuttx-apps/pull/3504
## Summary
Add NuttX Init ("NxInit")
This component (abbreviated as "NxInit") is specifically developed for NuttX
and intended for system initialization. While we have adopted the Android Init
Language among various syntax options, this is a brand-new implementation—it is
not a port or variant of Android Init.
Refer to the implementation of Android Init Language, consists of five broad
classes of statements: Actions, Commands, Services, Options, and Imports.
Actions support two types of triggers: event and action. Action triggers
also support runtime triggering. Services support lifecycle management,
including automatic restart (at specified intervals), and starting/stopping
individually or by class. Import supports files or directories, and we may add
a static method in the future. The following are some differences:
The Android Init Language treats lines starting with # as comments,
while we use a preprocessor to handle comments.
For action commands, we can omit "exec" and directly execute built-in
apps or nsh builtins.
Regarding the property service, users can either adapt it by self or
directly use the preset NVS-based properties.
Only part of standard action commands and service options are
implemented currlently.
To enable system/init:
-CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INIT_ENTRYPOINT="init_main"
+CONFIG_SYSTEM_NXINIT=y
## Impact
NuttX will be able to start applications and services without depending NSH
and without using the app as NuttX entrypoint directly.
## Testing
```
[ 0.150000] [ 3] [ 0] init_main: == Dump Services ==
...
[ 0.160000] [ 3] [ 0] init_main: Service 0x40486aa8 name 'telnet' path
'telnetd'
[ 0.160000] [ 3] [ 0] init_main: pid: 0
[ 0.160000] [ 3] [ 0] init_main: arguments:
[ 0.160000] [ 3] [ 0] init_main: [0] 'service'
[ 0.160000] [ 3] [ 0] init_main: [1] 'telnet'
[ 0.160000] [ 3] [ 0] init_main: [2] 'telnetd'
[ 0.160000] [ 3] [ 0] init_main: classes:
[ 0.160000] [ 3] [ 0] init_main: 'test'
[ 0.170000] [ 3] [ 0] init_main: restart_period: 3000
[ 0.170000] [ 3] [ 0] init_main: reboot_on_failure: -1
[ 0.170000] [ 3] [ 0] init_main: flags:
> [ 0.170000] [ 3] [ 0] init_main: 'oneshot'
...
[ 0.370000] [ 3] [ 0] init_main: starting service 'telnet' ...
[ 0.380000] [ 3] [ 0] init_main: service 'telnet' flag 0x2 add 0x4
[ 0.380000] [ 3] [ 0] init_main: +flag 'running'
[ 0.380000] [ 3] [ 0] init_main: service 'telnet' flag 0x6 add 0x8
[ 0.380000] [ 3] [ 0] init_main: -flag 'restarting'
[ 0.380000] [ 3] [ 0] init_main: service 'telnet' flag 0x6 add 0x1
[ 0.380000] [ 3] [ 0] init_main: -flag 'disabled'
[ 0.380000] [ 3] [ 0] init_main: started service 'telnet' pid 9
...
nsh> kill -9 9
nsh> [ 7.350000] [ 3] [ 0] init_main: service 'telnet' flag 0x6 add 0x4
[ 7.350000] [ 3] [ 0] init_main: -flag 'running'
[ 7.350000] [ 3] [ 0] init_main: service 'telnet' flag 0x2 add
0x80000001
[ 7.350000] [ 3] [ 0] init_main: +flag 'disabled'
[ 7.350000] [ 3] [ 0] init_main: +flag 'remove'
[ 7.350000] [ 3] [ 0] init_main: service 'telnet' pid 9 exited status 1
> [ 7.360000] [ 3] [ 0] init_main: removing service 'telnet' ...
``
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]