Skip to content

Simplify NuttX initialization #11321

Closed

Description

@acassis

Currently NuttX has many initialization options each one used for some specific case, but at least CONFIG_NSH_ARCHINIT that is used to do drivers initialization when NSH is enabled could be removed in favor of some generic option like BOARD_LATE_INITIALIZATION that will work for all applications (inclusive to NSH itself).

I raised this question some time ago here: #10821 but didn't heard anything from my peers.

But now that @0528Mike came with this PR: #11306 we could fix this issue merging CONFIG_NSH_ARCHINIT and BOARD_LATE_INITIALIZATION to avoid issues like this faced from a NuttX user: #10821 and for many people that want to user their application as ENTRYPOINT on NuttX.

Activity

  1. xiaoxiang781216 commented on Dec 5, 2023

    @xiaoxiang781216
    Contributor

    Yes, I think the suggestion is reasonable.

  2. raiden00pl commented on Dec 7, 2023

    @raiden00pl
    Member

    +1 from me

  3. raiden00pl commented on Jan 6, 2025

    @raiden00pl
    Member

    hi, are we trying to solve this problem? Does anyone have any objections to removing CONFIG_NSH_ARCHINIT ?
    This option is slowly starting to cause problems in the case of PCI devices. Some OS components that have a PCI based virtio backend need to be initialized in the correct order (e.g. coredump with PCI based virtblk device), which is impossible to achieve with CONFIG_NSH_ARCHINIT.

  4. xiaoxiang781216 commented on Jan 6, 2025

    @xiaoxiang781216
    Contributor

    NSH_ARCHINIT can be achieved in board initializiton code, so it could be removed to avoid the confusion.

  5. gregory-nutt commented on Jan 6, 2025

    @gregory-nutt
    Contributor

    NSH_ARCHINIT can be achieved in board initializiton code, so it could be removed to avoid the confusion.

    Agreed. But removing CONFIG_NSH_ARCHINIT will be a very big job because it is used by 1246 board configurations.

    $ find boards -name defconfig | xargs grep CONFIG_NSH_ARCHINIT=y | wc -
       1246    1246  100027 
    

    That would be a LOT of breakage!

  6. raiden00pl commented on Jan 18, 2025

    @raiden00pl
    Member

    Yes, it seems like a lot of work. But it will only get worse over time as new boards come in.

    We can automate most of the work. What we need to do is:

    1. remove all CONFIG_NSH_ARCHINIT from configs
    2. add CONFIG_BOARD_LATE_INITIALIZATION to all modified configs
    3. clean up after removing CONFIG_NSH_ARCHINIT.

    Is there anything more to do ?

    The last step most likely must be done manually. But there are "only" 115 files that need modification:

    $ find . -type f ! -name "defconfig" -exec grep -l "CONFIG_NSH_ARCHINIT" {} + | wc                                                                                                                              
        115     115    6899
    
  7. gregory-nutt commented on Jan 18, 2025

    @gregory-nutt
    Contributor

    Is there anything more to do ?

    I think a proper solution would be the complete remove of the archi-init logic, not just disabling it. I think that would cause a lot of confusion in the future.

    This would require removal the the BOARD_CTRL log, removal of the arch-init entry point to the board initialization logic, and removal of all calls to the removed BOARD_CTRL logic.

  8. raiden00pl commented on Jan 22, 2025

    @raiden00pl
    Member

    It makes sense. Such a change deserve major version increase during release, as this is substantial change for users. Probably this issue is a good milestone for NuttX 13.0.0 release

  9. linguini1 commented on Jan 8, 2026

    @linguini1
    Contributor

    I know that this PR was closed, and it appears there are no plans for the author to continue it, but is there a general agreement that something similar to this init approach would be the preferred change? apache/nuttx-apps#3192

    I am envisioning some pure initializer (like nxinit was) that allows the user to choose 1+ different processes to start after boot time, and also which takes care of some common logic like starting up USB, etc.

    Once such an initializer is accepted by the community, I think we can then move to transform NSH from this "do-all" solution to a pure shell that users can choose to include or not.

  10. 13 remaining items

  11. linguini1 commented on Feb 19, 2026

    @linguini1
    Contributor

    I'm in favor of improving the boot process. Just please remember that 3rd party developers may have private, out-of-tree boards that utilize some of these functions in their initialization. (My boards use board_late_initialize, but others may have done differently.) So whatever approach we take to simplify and clean up the boot process, we need to make sure that developers can have the hooks they need to initialize their stuff properly. And we need to make sure that any changes people will need to make, will be properly documented in the release notes!!!

    I agree. Right now the idea is to gut the BOARDIOC_INIT and NSH_ARCHINIT stuff.
    All users should then be able to choose between two options:

    1. Just enable CONFIG_BOARD_LATE_INITIALIZE and let the NuttX kernel handle the
      initialization (the elegant solution)

    2. For cases like raiden pointed out where app developers really need
      userspace control over initialization, disable CONFIG_BOARD_LATE_INITIALIZE and
      implement a custom board_finalinitialization to call from userspace via
      boardctl(BOARDIOC_FINALINIT).

    As @cederom suggested (I think somewhere on the mailing list) I also plan to include a "quick fix" message in both the PR descriptions and commit messages that indicate to the end user what they need to change in their defconfig/custom board logic/custom app to fix any breakages.

  12. cederom commented on Feb 19, 2026

    @cederom
    Contributor

    @patacongo pointed to older documentation [1] that we may use as reference point, and probably we should update our current documentation :-)

    I like the clear distinction:

    1. Phase A - The hardware-specific power-on reset initialization (ARCH_INIT / INIT_ARCH?)
    2. Phase B - NuttX RTOS initialization (NX_INIT / INIT_NX?)
    3. Phase C - Application Initialization (APP_INIT / INIT_APP? nsh init here?)

    But there is no info about where and how board is initialized (BOARD_INIT / INIT_BOARD?) maybe we could add one (as C before APP, then APP becomes D)? :-)

    @linguini1 added plantuml support for documentation so we can now auto-generate awesome diagrams from simple text :-)

    [1] https://cwiki.apache.org/confluence/display/NUTTX/NuttX+Initialization+Sequence

  13. acassis commented on Feb 19, 2026

    @acassis
    ContributorAuthor

    @linguini1 is the boot process is a mess, there are originally the xxx_boot.c and later xxx_bringup.c. Later xxx_appinit.c and finally there is only one xxx_init.c: avr/avrdx/breadxavr/src/avrdx_init.c
    I think we need some consensus before changing it! For visibility: @raiden00pl @simbit18 @hartmannathan @xiaoxiang781216 @lupyuen @jerpelea @cederom (sorry if I missed another people interested on it)

    Hi all,

    I'm in favor of improving the boot process. Just please remember that 3rd party developers may have private, out-of-tree boards that utilize some of these functions in their initialization. (My boards use board_late_initialize, but others may have done differently.) So whatever approach we take to simplify and clean up the boot process, we need to make sure that developers can have the hooks they need to initialize their stuff properly. And we need to make sure that any changes people will need to make, will be properly documented in the release notes!!!

    @hartmannathan I agree that we need to worry about how people are keeping theirs out of tree boards, but instead of creating hooks, it is better to Document how to change to use board_late_initialize or the other alternatives. If I'm not wrong, there is already a "hook" for board early initialize. If we keep many hooks in the kernel, the chaos will continue. The board initialization on NuttX is already very complex, we need to simplify keeping the most common use cases.

  14. cederom commented on Feb 19, 2026

    @cederom
    Contributor

    Ugh, I just realized this is already on the 13's list :-P

  15. jerpelea commented on Feb 19, 2026

    @jerpelea
    Contributor

    Ugh, I just realized this is already on the 13's list :-P

    @cederom 13.0.0 will be branched out on 1 March

  16. acassis commented on Feb 19, 2026

    @acassis
    ContributorAuthor

    Ugh, I just realized this is already on the 13's list :-P

    @cederom 13.0.0 will be branched out on 1 March

    Alin, let's use it as unstable/testing release only, NuttX 13 will not help to promote NuttX :-D

  17. added this to the v13.0.0 milestone on Feb 24, 2026
  18. added
    breaking change
    Arch: all
    on Feb 24, 2026
  19. cederom commented on May 26, 2026

    @cederom
    Contributor

    @cederom: Ugh, I just realized this is already on the 13's list :-P

    @jerpelea: @cederom 13.0.0 will be branched out on 1 March

    @acassis: Alin, let's use it as unstable/testing release only, NuttX 13 will not help to promote NuttX :-D

    Yeah I would stick to 12 too until all tedious work is done and we are really proud to announce 13 :-)

  20. acassis commented on May 26, 2026

    @acassis
    ContributorAuthor

    @xiaoxiang781216 Ok, let's open a new issue to address the NX Init missing part

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

Metadata

Metadata

Labels

Arch: allbreaking change

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions