Skip to content

qemu-armv8a/fastboot: Add startup script (NxInit init.rc) - #17216

Closed
JianyuWang0623 wants to merge 1 commit into
apache:masterfrom
JianyuWang0623:boards_qemu_fastboot_switch_init
Closed

JianyuWang0623 wants to merge 1 commit into
apache:masterfrom
JianyuWang0623:boards_qemu_fastboot_switch_init

Conversation

@JianyuWang0623

@JianyuWang0623 JianyuWang0623 commented Oct 20, 2025 •

Copy link
Copy Markdown
Contributor

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:

  1. console
  2. fastboot

Related changes:

The impact of NxInit and NSH on ELF size

Typical scenario: High sensitivity to code size, with no requirement for a shell.

Config Changes ELF Size(bytes)
defconfig 7,008,056
+ETC_ROMFS 7,066,048
+INIT 7,127,536
-TELENT 7,127,024
-NSH_LIBRARY
-SYSTEM_NSH
6,509,392

For 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

  • qemu-armv8a:fastboot

Testing

Selftest

LD: nuttx
Memory region         Used Size  Region Size  %age Used
CP: nuttx.hex
CP: nuttx.bin
[    0.010000] parsing /etc/init.d/init.rc
[    0.010000] line   1: 'on init'
[    0.010000] new section (on)
[    0.010000] add action 0x4042a270(init) to manager 0x4042a090
[    0.010000] line   2: '    class_start core'
[    0.010000] add command 0x4042a2d0(class_start) to action 0x4042a270
[    0.010000]   argv[0] 'class_start'
[    0.010000]   argv[1] 'core'
[    0.010000] line   3: 'service console sh'
[    0.010000] new section (service)
[    0.010000] line   4: '    class core'
[    0.010000] apply option[0] 0x40290b68 for class
[    0.010000]   argv[0] 'class'
[    0.010000]   argv[1] 'core'
[    0.020000] line   5: '    restart_period 1000'
[    0.020000] apply option[2] 0x40290b48 for restart_period
[    0.020000]   argv[0] 'restart_period'
[    0.020000]   argv[1] '1000'
[    0.020000] line   6: 'service fastboot fastbootd'
[    0.020000] new section (service)
[    0.020000] line   7: '    class core'
[    0.020000] apply option[0] 0x40290b68 for class
[    0.020000]   argv[0] 'class'
[    0.020000]   argv[1] 'core'
[    0.020000] line   8: '    restart_period 7000'
[    0.020000] apply option[2] 0x40290b48 for restart_period
[    0.020000]   argv[0] 'restart_period'
[    0.020000]   argv[1] '7000'
[    0.020000] == Dump Actions ==
[    0.020000] action 0x4042a270
[    0.020000]   event trigger: 'init'
[    0.020000]   argv[0] 'class_start'
[    0.020000]   argv[1] 'core'
[    0.020000] == Dump Services ==
[    0.020000] Service 0x4042a370 name 'console' path 'sh'
[    0.020000]   pid: 0
[    0.020000]   arguments:
[    0.020000]       [0] 'service'
[    0.020000]       [1] 'console'
[    0.020000]       [2] 'sh'
[    0.020000]   classes:
[    0.020000]     'core'
[    0.020000]   restart_period: 1000
[    0.020000] Service 0x4042a490 name 'fastboot' path 'fastbootd'
[    0.020000]   pid: 0
[    0.020000]   arguments:
[    0.020000]       [0] 'service'
[    0.020000]       [1] 'fastboot'
[    0.020000]       [2] 'fastbootd'
[    0.020000]   classes:
[    0.020000]     'core'
[    0.020000]   restart_period: 7000
[    0.020000] add event [0] 'boot'
[    0.040000] add event [1] 'init'
[    0.040000] add event [2] 'netinit'
[    0.040000] remove event [0] 'boot'
[    0.040000] add ready 0x4042a2d0 class_start
[    0.040000] executing command 'class_start'
[    0.040000] starting service 'console' ...
[    0.040000] service 'console' flag 0x0 add 0x4
[    0.040000]   +flag 'running'
[    0.040000] service 'console' flag 0x4 add 0x8
[    0.040000]   -flag 'restarting'
[    0.040000] service 'console' flag 0x4 add 0x1
[    0.040000]   -flag 'disabled'
[    0.040000] started service 'console' pid 4
[    0.040000] starting service 'fastboot' ...
[    0.040000] service 'fastboot' flag 0x0 add 0x4
[    0.040000]   +flag 'running'
[    0.040000] service 'fastboot' flag 0x4 add 0x8
[    0.040000]   -flag 'restarting'
[    0.040000] service 'fastboot' flag 0x4 add 0x1
[    0.040000]   -flag 'disabled'
[    0.040000] started service 'fastboot' pid 5
[    0.050000] remove event [1] 'init'
[    0.050000] remove event [2] 'netinit'
nsh> ps
  PID  PPID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK            STACK    USED FILLED COMMAND
    0     0     0   0 FIFO     Kthread   - Ready              0000000000000000 0008160 0000928  11.3%  Idle_Task
    1     0     0 192 RR       Kthread   - Waiting  Semaphore 0000000000000000 0008096 0001040  12.8%  hpwork 0x403f5540 0x403f55c0
    2     0     0 100 RR       Kthread   - Waiting  Semaphore 0000000000000000 0008096 0001040  12.8%  lpwork 0x403f5490 0x403f5510
    3     0     3 100 RR       Task      - Waiting  Semaphore 0000000000000000 0008128 0002112  25.9%  init_main
    4     3     4 100 RR       Task      - Running            0000000000000000 0008128 0003344  41.1%  sh
    5     3     5 100 RR       Task      - Waiting  Semaphore 0000000000000000 0008128 0002144  26.3%  fastbootd
nsh>
nsh>

@cederom cederom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a feedback after dev@ mailing list discussion, thank you for understanding / considering @JianyuWang0623 :

  1. 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.
  2. 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 anchao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add new config named fastboot_init?

@JianyuWang0623 JianyuWang0623 Oct 21, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate this commit with defconfig

@JianyuWang0623 JianyuWang0623 changed the title qemu-armv8a/fastboot: Switch from NSH to Init qemu-armv8a/fastboot: Switch init entry point from NSH to Init Oct 21, 2025
@JianyuWang0623

Copy link
Copy Markdown
Contributor Author

Just a feedback after dev@ mailing list discussion, thank you for understanding / considering @JianyuWang0623 :

  1. 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.
  2. 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.

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?

@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.

Config Changes ELF Size(bytes)
defconfig 7,008,056
+ETC_ROMFS 7,066,048
+INIT 7,127,536
-TELENT 7,127,024
-NSH_LIBRARY
-SYSTEM_NSH
6,509,392

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).

@anchao

anchao commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

Just a feedback after dev@ mailing list discussion, thank you for understanding / considering @JianyuWang0623 :

  1. 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.
  2. 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.

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?

@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.

Config Changes ELF Size(bytes)
defconfig 7,008,056
+ETC_ROMFS 7,066,048
+INIT 7,127,536
-TELENT 7,127,024
-NSH_LIBRARY
-SYSTEM_NSH 6,509,392
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.

@JianyuWang0623

This comment was marked as resolved.

@cederom

cederom commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

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 :-)

@anchao

anchao commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

This isn't a fair comparison, and I'm not convinced that nsh could disable more commands to align with init.

@anchao You're right. When making comparisons, the non-essential functions of NSH should be turned off.

A rough estimate shows that after disabling the non-essential functions of NSH (as listed below), the ELF size has decreased by 397,448 bytes. It is estimated that the space required for NSH is approximately 220,184 bytes, and the init component takes up 61,488 bytes.

$ diff defconfig  boards/arm64/qemu/qemu-armv8a/configs/fastboot/defconfig
9d8
< # CONFIG_NSH_CONSOLE is not set
47c46
< CONFIG_INIT_ENTRYPOINT="nsh_main"
---
> CONFIG_INIT_ENTRYPOINT="init_main"
78,135d76
< CONFIG_NSH_DISABLE_ARP=y
< CONFIG_NSH_DISABLE_BASENAME=y
< CONFIG_NSH_DISABLE_CAT=y
< CONFIG_NSH_DISABLE_CD=y
< CONFIG_NSH_DISABLE_CMP=y
< CONFIG_NSH_DISABLE_CP=y
< CONFIG_NSH_DISABLE_DF=y
< CONFIG_NSH_DISABLE_DIRNAME=y
< CONFIG_NSH_DISABLE_DMESG=y
< CONFIG_NSH_DISABLE_ECHO=y
< CONFIG_NSH_DISABLE_ENV=y
< CONFIG_NSH_DISABLE_ERROR_PRINT=y
< CONFIG_NSH_DISABLE_EXEC=y
< CONFIG_NSH_DISABLE_EXIT=y
< CONFIG_NSH_DISABLE_EXPORT=y
< CONFIG_NSH_DISABLE_EXPR=y
< CONFIG_NSH_DISABLE_FDINFO=y
< CONFIG_NSH_DISABLE_FREE=y
< CONFIG_NSH_DISABLE_GET=y
< CONFIG_NSH_DISABLE_HELP=y
< CONFIG_NSH_DISABLE_HEXDUMP=y
< CONFIG_NSH_DISABLE_IFCONFIG=y
< CONFIG_NSH_DISABLE_IFUPDOWN=y
< CONFIG_NSH_DISABLE_KILL=y
< CONFIG_NSH_DISABLE_LOSETUP=y
< CONFIG_NSH_DISABLE_LS=y
< CONFIG_NSH_DISABLE_MD5=y
< CONFIG_NSH_DISABLE_MKDIR=y
< CONFIG_NSH_DISABLE_MKFATFS=y
< CONFIG_NSH_DISABLE_MKFIFO=y
< CONFIG_NSH_DISABLE_MKRD=y
< CONFIG_NSH_DISABLE_MOUNT=y
< CONFIG_NSH_DISABLE_MV=y
< CONFIG_NSH_DISABLE_NFSMOUNT=y
< CONFIG_NSH_DISABLE_NSLOOKUP=y
< CONFIG_NSH_DISABLE_PIDOF=y
< CONFIG_NSH_DISABLE_PKILL=y
< CONFIG_NSH_DISABLE_PRINTF=y
< CONFIG_NSH_DISABLE_PS=y
< CONFIG_NSH_DISABLE_PUT=y
< CONFIG_NSH_DISABLE_PWD=y
< CONFIG_NSH_DISABLE_RM=y
< CONFIG_NSH_DISABLE_RMDIR=y
< CONFIG_NSH_DISABLE_SET=y
< CONFIG_NSH_DISABLE_SLEEP=y
< CONFIG_NSH_DISABLE_SOURCE=y
< CONFIG_NSH_DISABLE_TEST=y
< CONFIG_NSH_DISABLE_TIME=y
< CONFIG_NSH_DISABLE_TRUNCATE=y
< CONFIG_NSH_DISABLE_UMOUNT=y
< CONFIG_NSH_DISABLE_UNAME=y
< CONFIG_NSH_DISABLE_UNSET=y
< CONFIG_NSH_DISABLE_UPTIME=y
< CONFIG_NSH_DISABLE_USLEEP=y
< CONFIG_NSH_DISABLE_WAIT=y
< CONFIG_NSH_DISABLE_WATCH=y
< CONFIG_NSH_DISABLE_WGET=y
< CONFIG_NSH_DISABLE_XD=y

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.

@cederom

cederom commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

@anchao: 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? :-)

@JianyuWang0623

Copy link
Copy Markdown
Contributor Author

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.

@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.

@anchao

anchao commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

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.

@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?

@JianyuWang0623

Copy link
Copy Markdown
Contributor Author

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.

@JianyuWang0623
JianyuWang0623 marked this pull request as draft October 23, 2025 03:28
@xiaoxiang781216

Copy link
Copy Markdown
Contributor

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.

@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?

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:

  1. In many simple case(bootloader, ota), we can enable init, but disable nsh
  2. Implement the different init solution

@7rx8

7rx8 commented Oct 23, 2025

Copy link
Copy Markdown

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.

@JianyuWang0623

Copy link
Copy Markdown
Contributor Author

@7rx8 Thank you so much for your recognition and valuable feedback. Regarding the naming, we are still coordinating :-)

@JianyuWang0623 JianyuWang0623 changed the title qemu-armv8a/fastboot: Switch init entry point from NSH to Init qemu-armv8a/fastboot: Switch init entry point from NSH to NxInit Oct 27, 2025
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]>
@JianyuWang0623
JianyuWang0623 force-pushed the boards_qemu_fastboot_switch_init branch from 2ba9ce6 to 6bac66b Compare October 27, 2025 13:28
@JianyuWang0623 JianyuWang0623 changed the title qemu-armv8a/fastboot: Switch init entry point from NSH to NxInit qemu-armv8a/fastboot: Add startup script Oct 27, 2025
@JianyuWang0623 JianyuWang0623 changed the title qemu-armv8a/fastboot: Add startup script qemu-armv8a/fastboot: Add startup script (NxInit init.rc) Oct 27, 2025
@JianyuWang0623

Copy link
Copy Markdown
Contributor Author

@xiaoxiang781216 @anchao @cederom @7rx8 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:

  1. console
  2. fastboot

@JianyuWang0623
JianyuWang0623 marked this pull request as ready for review October 27, 2025 13:33
@7rx8

7rx8 commented Oct 27, 2025

Copy link
Copy Markdown

Thanks for adding an example. I really want to try this soon.

@anchao

anchao commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

@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.

  1. System monitoring capabilities can also be implemented in nsh, rather than forcing developers to use init if they want enable this feature.
  2. Android's init syntax is only a subset of the shell, with additional syntax keywords to accommodate Android startup requirements. Historically, init syntax has consistently added keywords to improve compatibility with shell, so why not just use the shell? Furthermore, multi-line descriptions are a strange design. Similar to SELinux rule files, we can use semicolons or colon to separate rules, as many systems do.

@anchao

anchao commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

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:

  1. In many simple case(bootloader, ota), we can enable init, but disable nsh
  2. Implement the different init solution

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.

@JianyuWang0623

Copy link
Copy Markdown
Contributor Author

@anchao

  1. System monitoring capabilities can also be implemented in nsh, rather than forcing developers to use init if they want enable this feature.

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).

  1. Android's init syntax is only a subset of the shell, with additional syntax keywords to accommodate Android startup requirements. Historically, init syntax has consistently added keywords to improve compatibility with shell, so why not just use the shell? Furthermore, multi-line descriptions are a strange design. Similar to SELinux rule files, we can use semicolons or colon to separate rules, as many systems do.

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.
As a development and debugging tool, I am very accustomed to using the Shell and quite fond of it. Many people, including myself, are willing to contribute new features to nsh. What concerns me is whether the system monitoring function would deviate from nsh’s core functionalities. For instance, why don’t Linux distributions implement such a function in bash? Instead, they rely on init/systemd (I don’t have a deep understanding of the historical context behind this; I’m merely making a simple reference to the current situation).
I am new to the Android Init Language, but if we are open to adopting it, it will be quite easy to get started with.

@xiaoxiang781216

Copy link
Copy Markdown
Contributor

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:

  1. In many simple case(bootloader, ota), we can enable init, but disable nsh
  2. Implement the different init solution

You are talking about a software requirement, I question how to implement 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?

I don't agree with Android init approach, but I think system monitoring is a valuable capability.

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.

@anchao

anchao commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

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:

  1. In many simple case(bootloader, ota), we can enable init, but disable nsh
  2. Implement the different init solution

You are talking about a software requirement, I question how to implement 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?

I don't agree with Android init approach, but I think system monitoring is a valuable capability.

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?

@JianyuWang0623

Copy link
Copy Markdown
Contributor Author

@anchao

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.

Splitting the initialization function from NSH is a good idea. From what I understand of nsh_consolemain(), it can be assumed that NSH includes the shell (sh) and additionally incorporates system initialization functionality.
However, expanding the shell syntax while ensuring its stability may not be a straightforward task—for instance, how to configure the restart interval of the daemon process? If you already have ideas and are willing to share them, that would be fantastic.

However, the Nuttx kernel now uses 2 different startup script syntaxes: Android init and Nuttx init. Do you think this is a good design?

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.

@xiaoxiang781216

Copy link
Copy Markdown
Contributor

let's close related pr. I don't want to discuss this problem anymore.

@7rx8

7rx8 commented Oct 28, 2025

Copy link
Copy Markdown

In fact there is NO problem and that is the reason why I have been supporting this app from the start

  • NOTHING forces ANYONE. you can still use nsh if you wish.
  • Using a shell to initialize the system brings us back to MULTICS and old systems. In practice in nuttx, it "mixes carrots and cabbage". No shell should run network stack initialization as built in code. This was okay for a while, but now there is a clear possible improvement, which is OPTIONAL.

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.

@xiaoxiang781216

Copy link
Copy Markdown
Contributor

since @anchao reject this feature, we close all related PR and will open source in openvela community: https://github.com/open-vela

@7rx8

7rx8 commented Oct 28, 2025 •

Copy link
Copy Markdown

Since when does a single user has a veto rights?
did he reject something, or just not like it?
I dont know xiaomi, is anchao your boss?

This is a mess.
The "rejection reasons" are invalid. this is just an app.

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.

@7rx8

7rx8 commented Oct 28, 2025 •

Copy link
Copy Markdown

@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.

@cederom

cederom commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

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! :-)

@linguini1

Copy link
Copy Markdown
Contributor

since @anchao reject this feature, we close all related PR and will open source in openvela community: https://github.com/open-vela

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!

@anchao

anchao commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

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:

  1. nxinit will cause the system to support two sets of script syntax: android init and nuttx shell
  2. If developers of nsh want to use the service daemon capability, they need to replace the initialization entry, and the code previously in the nuttx init script cannot be used continuously

Whether to enhance the existing system implementation or create a new set of implementations, the choice is yours.

@7rx8

7rx8 commented Oct 28, 2025

Copy link
Copy Markdown

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.

@anchao

anchao commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

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?

image

@7rx8

7rx8 commented Oct 28, 2025 •

Copy link
Copy Markdown

On my side the impact is : absolutely none.
If you dont want to use the new system, dont.

The presence of rc files in some configurations is not a problem for me.
In additional contributions it is very possible to reorganize board directories to accomodate both systems.

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.

@anchao

anchao commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

On my side the impact is : absolutely none. If you dont want to use the new system, dont.

The presence of rc files in some configurations is not a problem for me. In additional contributions it is very possible to reorganize board directories to accomodate both systems.

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.

@7rx8

7rx8 commented Oct 28, 2025

Copy link
Copy Markdown

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.

@anchao

anchao commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

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

@cederom

cederom commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

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 :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Board: arm64 Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants