Repository navigation
qemu-armv8a/fastboot: Add startup script (NxInit init.rc) - #17216
JianyuWang0623 wants to merge 1 commit into
Conversation
cederom
left a comment
There was a problem hiding this comment.
Just a feedback after dev@ mailing list discussion, thank you for understanding / considering @JianyuWang0623 :
- We clearly need to use "Android System Init" naming here and update all kconfig/global variables names to clearly distinguish from current NuttX Init, Android System Init, and SystemV Init (there is sill a change it will show up here one day), maybe others. "system_system" or "system_init" or "init_main" is really confusing and not self-explanatory, does not even point to "android_system_init". I know this is a bit longer but will provide important context and clear separation between completely different functionalities / implementations.
- We need better documentation for this "Android System Init" as well as "Fastboot". These functionalities are welcome, people want to use it, but users / developers ask questions like: Why do we need another init system? What should happen with the previous ones? What does this new init system solve? How this relates to Fastboot? When, why, and how can I use it? What are best use cases with some examples? Please consider approach like explaining and convincing someone who wants to use it but has zero knowledge about the solution.
anchao
left a comment
There was a problem hiding this comment.
Is there any advantage to using Android init? Besides the service look-aside, I don't see any other benefits. Why is Android necessarily the right path?
| CONFIG_DRIVERS_VIRTIO_RNG=y | ||
| CONFIG_DRIVERS_VIRTIO_SERIAL=y | ||
| CONFIG_DRIVERS_VIRTIO_SOUND=y | ||
| CONFIG_ETC_ROMFS=y |
There was a problem hiding this comment.
add new config named fastboot_init?
There was a problem hiding this comment.
@anchao Sorry for the overly brief PR title(updated). Fastboot has no direct connection with init. The modification of this PR is to switch the init entry point of the configuration "qemu-armv8a:fastboot" from nsh_main to init_main; For the function of "qemu-armv8a:fastboot", this modification may not be mandatory, and it is more of an example for the newly added Init component(apache/nuttx-apps#3192).
| endif() | ||
|
|
||
| if(CONFIG_FS_ROMFS) | ||
| list(APPEND RCSRCS etc/init.d/init.rc) |
There was a problem hiding this comment.
Separate this commit with defconfig
@anchao As the data above , NSH, when used as an initialization program, may seem relatively bloated in scenarios where code size is a major concern. NSH and Init can coexist, allowing users to choose based on their own needs. Init addresses issues such as the excessive code size of NSH when used as an initialization program, and its lack of management (e.g., restarting) for daemons.
For the ELF file, Init requires 61,488 bytes, while NSH and NSH_LIBRARY together require 617,632 bytes. Switching from NSH to Init can save a significant amount of space(556,144 bytes). |
This isn't a fair comparison, and I'm not convinced that nsh could disable more commands to align with init. |
This comment was marked as resolved.
This comment was marked as resolved.
|
Okay now I see this update is also a showcase for both Android System Init and Fastboot and this it was created for this reason :-) Lets sort out the naming stuff (gh and dev@) and we will be ready to go :-) Thank you @JianyuWang0623 amazing work :-) |
So nsh still has room for improvement, right? If it's just a size issue, why can't nsh be optimized to support Android init syntax, rather than making a drastic change like replacing the initialization path? My other question is, why is Android's approach the right one? Is it because apple IOS isn't open source? If functionality is aligned with Android, I don't think it's necessary. Each operating system has its own unique characteristics. I like implementations that are superior to Nuttx/Android systems. |
This PR is only dedicated to changing configuration. I think source PR apache/nuttx-apps#3192 would be better place for general discussion about the solution. Best place would be the dev@ mailing list as some folks are not on GH and does not follow specific PRs. Can you please switch to dev@ mailing list so we have better community coverage and awareness? :-) |
@anchao Beyond code size, also take into account the monitoring and management of daemons. As a shell, NSH may already have sufficiently rich functions; however, much of the work in system initialization is irrelevant to the core responsibilities of the shell. Separating and organizing them may make the overall logic clearer. |
So you're also going to provide capabilities similar to Android's Zygote/SystemServer/Firmware Manager, right? So if an app using NSH wants to use these capabilities, it must use Android Init, right? Why this strange design? Is it difficult for NSH to implement these capabilities? |
@anchao The management of daemons/services does not refer to complex functions like Zygote/SystemServer, but rather the status monitoring of daemons such as sh and telnetd. For example, monitoring their exit and then restarting them with a specified interval, configuring the signal sent when stopping the daemons, and determining whether the entire system needs to restart if the daemons encounter exceptions. |
It's more strange to couple the initialization into shell, do you see any other POSIX OS implement in this way? From the concept, init must be one instance and never exit, but shell may be lunched many times(telnet, ssh, adb shell...) or killed. @JianyuWang0623 's work is the right direction to decouple the initialization from nsh from the architecture. But, it's also has other benefit too:
|
|
This is a very good init system, thank you for contributing it. I also see required improvements in nuttx for netinit all our programs have an independent network monitor daemon to manage plug and unplug of cable and manage link up/down and async DHCP and stuff. Having this init system means we can put this net daemon in this init system instead of having weird nsh shell scripts to do it. let' s remember that scripting in nsh is weirdly linked to some automount code that is absolutely not flexible and that we re always patching out to mount our filesystems in our board code. this init system provides a clean solution for all of this, including fs mounts. Has any consensual decision been made on the naming side of things? PS: If you know or guessed who I am please keep it for youself. |
|
@7rx8 Thank you so much for your recognition and valuable feedback. Regarding the naming, we are still coordinating :-) |
Currently, fastbootd does not start automatically.
Compared with NSH, the newly added component NxInit("NuttX Init")
has been selected because it supports restarting the daemon process
when it exits abnormally.
The script of NxInit (init.rc) launch the necessary services:
a. console
b. fastboot
Signed-off-by: wangjianyu3 <[email protected]>
2ba9ce6 to
6bac66b
Compare
|
@xiaoxiang781216 @anchao @cederom @7rx8 Currently, fastbootd does not start automatically. The script of NxInit (init.rc) launch the necessary services:
|
|
Thanks for adding an example. I really want to try this soon. |
|
You are talking about a software requirement, I question how to implement it. I don't agree with Android init approach, but I think system monitoring is a valuable capability. |
Functionally, this can be achieved. However, it seems that common shells do not directly provide system monitoring capabilities. As I understand it, the usual approach is to use a combination of shell + init/systemd; please correct me if this is not accurate. If implemented in a new component, system monitoring and the shell would be independent of each other, giving users more flexibility in their choices (for example, there are scenarios where no shell is needed).
There are indeed various options when it comes to choosing a syntax, and I am not sure if there exists a syntax that everyone likes. Our primary consideration is to select an Init Language that is relatively widely used and reasonably designed, and then achieve compatibility with it. |
I just said that shell isn't a right place to implement the system init and monitor functionality. So do you agree that init/monitor should be decouple from shell?
There are many init system for POSIX OS: https://en.wikipedia.org/wiki/Init @JianyuWang0623 just provide one of implementation. Anyway, you can still use nsh or provide your own implementation. |
Nuttx already supports init scripts, which follow shell syntax. The shell is initialized after the script is initialized. If you believe that init should be separated from nsh, the correct approach would be to improve nsh into 2-stage init/shell system while still providing support for legacy scripts within init. However, the Nuttx kernel now uses 2 different startup script syntaxes: Android init and Nuttx init. Do you think this is a good design? |
Splitting the initialization function from NSH is a good idea. From what I understand of
Regarding the perspective of having multiple Init Languages coexist, could we maintain an open attitude toward their coexistence? For system initialization components that are relatively universal, independent, and optional, can we offer users an extra choice? I don’t see any downside to this. If there is anything wrong with what I’ve said, please feel free to correct me. Thank you. |
|
let's close related pr. I don't want to discuss this problem anymore. |
|
In fact there is NO problem and that is the reason why I have been supporting this app from the start
Again, this is JUST ONE APP and you are free to init nuttx on your board as you please. This code is not even in the main OS repository, So there is no point in criticizing the design intent of this new app. |
|
since @anchao reject this feature, we close all related PR and will open source in openvela community: https://github.com/open-vela |
|
Since when does a single user has a veto rights? This is a mess. I have compassion for your messed up feelings, but I see no reason to cancel this entirely for such a mundane reason. More context could help and I hope you reconsider this question at a calmer moment. |
|
@anchao please provide actual rejection reasons. your current design concerns are irrelevant. This is just one additional app. Since when do you get full control of nuttx contributions? That is not right. We need a community vote to decide this. |
|
Guys, we have a thread on the mailing list about this NXINIT functionality, please join the discussion on the mailing list! We already agreed over there this functionality is welcome, useful, we even invented and agreed on the NXINIT naming convention (in place of system init or android system init). I mentioned before, this PR is only related to NXINIT and the PR where NXINIT is introduced should be used to discuss the details of the NXINIT. This PR is for a specific configuration change. If you don't agree on this particular configuration change, please create a new configuration so both choices are possible. ONCE AGAIN PLEASE USE DEV@ MAILING LIST TO BE PART OF THE COMMUNITY AND ACTIVELY DISCUSS CHANGES AND PLANS WITH THE NUTTX COMMUNITY THIS IS OUR MAIN COMMUNICATION CHANNEL! :-) |
Please please please reopen this PR. The nxinit method would be very useful for a lot of users. If anchao rejects this PR but the community overwhelmingly votes for a merge, then it can be merged! As the saying goes "talk is cheap, send patches". This patch fixes a lot of issues with NuttX initialization. If someone wants NSH to be two-stage and implement all these great features, they should send their own patch. For now, this patch exists, has been worked on heavily, and is overwhelmingly supported. Please consider reopening it! |
|
I am not denying nxinit, so I have not added any comments in the apps repository. All my comments here are about discussing how nxinit should be implemented, rather than rejecting the merging of this PR. I don't understand why there was such an intense reaction during the discussion, even to the extent of closing the PR. nxinit provides system service monitoring capabilities, which were missing from the previous startup scripts. However, I believe we need to be cautious if nxinit is to be integrated into the nuttx kernel, for the following 2 reasons:
Whether to enhance the existing system implementation or create a new set of implementations, the choice is yours. |
|
I think that you are keeping a misunderstanding: this init system does NOT go in the nuttx kernel AT ALL. I would be very interested to understand why you believe such thing. It is AN APP that you can choose to use as user space entry point, or not. It does NOT replace nsh, it comes before. nsh could be started by nxinit, if you wish to do so, but other apps could be started instead. Just like in a linux PC where the init program is systemd, not bash. I agree that no discussion deserve closing a pr prematurely, but I think @xiaoxiang781216 was a bit fed up trying to explain something while you believe something else. |
When you reply to the comments, you'd better understand what these rcS/rc.sysinit in the nuttx kernel are used for. If a new type of initialization script is added, they use different syntax, what negative impact will it have on the operating system?
|
|
On my side the impact is : absolutely none. The presence of rc files in some configurations is not a problem for me. btw, the etc subdirectory of the "src" folders is probably not a good place to store romfs entries. In my private boards, I have a romfs folder alongside src and include. So I am thankful that you have identified these points that will need work (True, I missed them), but it does not seem blocking at this point, we need a first step, and that may be integrating the app, so we can use it and fix board configurations in a way that please a majority. I think we need a dev discussion about how to organize rom startup files for different init systems, which is... a new feature, so it's normal that things are not yet fixed. Again I thank you for raising this interesting point. It looks like it's time to support different romfs images in board directories. |
So you are looking at this matter from the perspective of a developer. If you are the maintainer of nuttx, you need to be responsible for other developers, then your perspective on this matter will change. |
|
I cant deny it. Maintaining is harder. You have some insight. You might see my point of view changing while writing the previous message :) In retrospect it is obvious that having a new scripted init system requires new sets of init scripts. Do you agree that we can work this out a bit later in the board dirs? We should discuss it separately. |
As I said I have no objection to nxinit, you don't need to ask me for my opinion, if everyone wants it to be merged, then just merge it, I will complete the optimization work of nsh if free |
|
Good catch @anchao !! We all missed that sorry!! o_O Lets solve things out on the dev@ mailing list before this PR is updated and merged so we have good and coherent solution right from start :-) |

Summary
Currently, fastbootd does not start automatically.
Compared with NSH, the newly added component NxInit("NuttX Init") has been selected because it supports restarting the daemon process when it exits abnormally.
The script of NxInit (init.rc) launch the necessary services:
Related changes:
The impact of NxInit and NSH on ELF size
Typical scenario: High sensitivity to code size, with no requirement for a shell.
+ETC_ROMFS+INIT-TELENT-NSH_LIBRARY-SYSTEM_NSHFor the ELF file, Init requires 61,488 bytes, while NSH and NSH_LIBRARY together require 617,632 bytes(without non-essential functions: 220,184 bytes). Switching from NSH to NxInit can save a significant amount of space. (updated)
Depends on apache/nuttx-apps#3192
Impact
Testing
Selftest