Skip to content

Documentation/netutils: add comprehensive guide for netinit - #20578

Merged
michallenc merged 1 commit into
apache:masterfrom
Swatantra-66:doc/netinit-guide
Oct 12, 2026
Merged

michallenc merged 1 commit into
apache:masterfrom
Swatantra-66:doc/netinit-guide

Conversation

@Swatantra-66

Copy link
Copy Markdown
Contributor

Summary

Provide a comprehensive documentation guide for the netinit (Network Initialization) subsystem in Documentation/applications/netutils/netinit/index.rst, replacing the previous 4-line placeholder stub.

Addresses #11081.

Key Additions:

  1. Architecture & Execution Models:
    • Details synchronous foreground bring-up (!CONFIG_NETINIT_THREAD) vs. asynchronous background thread execution (CONFIG_NETINIT_THREAD, priority 80, stack sizing), preventing boot freezes during PHY auto-negotiation or DHCP delays.
    • Documents split local-only configuration (CONFIG_NETINIT_NETLOCAL) for staged multi-phase boot, captive portals, and interactive Wi-Fi onboarding.
    • Comprehensive ASCII architectural lifecycle diagram depicting Phase 1 (Local Device Setup) and Phase 2 (Network Bring-Up).
  2. Autonomous Link State Monitor Daemon:
    • Documents CONFIG_NETINIT_MONITOR event-driven lifecycle: signal registration (CONFIG_NETINIT_SIGNO), MII PHY carrier interrupt notifications (SIOCMIINOTIFY), register status evaluation (MII_MSR_LINKSTATUS), automatic link down / UP state toggling, and configurable retry periods (CONFIG_NETINIT_RETRYMSEC).
  3. Primary Device Selection Precedence:
    • Complete reference table mapping link-layer configuration flags to compile-time interface names (wlan0 → eth0 → wpan0 → bnep0 → sl0 → tun0 → lo → can0).
  4. MAC Address Provisioning Strategies:
    • Documents CONFIG_NETINIT_NOMAC options: board silicon unique ID (CONFIG_NETINIT_UIDMAC) derived as an IEEE Locally Administered Address (LAA) with truncation caveats noted, device calibration files (CONFIG_NETINIT_MACADDR via BOARDIOC_MACADDR), and fixed software MACs (CONFIG_NETINIT_SWMAC).
  5. IP Addressing & Protocols:
    • IPv4: Dynamic DHCP client (:rfc:2131), static IP configuration, and dynamic runtime file configuration (CONFIG_FSUTILS_IPCFG via /etc/net.cfg) with filesystem mount retry delays (CONFIG_NETINIT_RETRY_MOUNTPATH).
    • IPv6: Stateless Address Autoconfiguration (SLAAC, :rfc:4862) vs. static IPv6 addressing, accurately documenting the effective Kconfig default netmask (ffff:ffff:ffff:ffff:ffff:ffff:ffff:0, /112).
    • Default DNS nameserver registration via netlib_set_ipv4dnsaddr().
  6. Wi-Fi Association (WAPI Integration):
    • Walkthrough of netinit_associate() using Wireless Extensions (WEXT) ioctls, covering station modes (Infrastructure, Ad-hoc, Mesh), WPA/WPA2-Personal, CCMP/AES and TKIP ciphers, and SSID/passphrase credentials.
  7. Auxiliary Daemons (NTP Client):
    • Automated startup of Network Time Protocol synchronization via ntpc_start() as soon as interface link state transitions to UP.
  8. Configuration & Public C API Reference:
    • Comprehensive Kconfig table detailing 23 major configuration symbols.
    • Complete C API signatures, parameter lists, and return semantics for netinit_bringup() and netinit_associate().
  9. Practical Integration Scenarios & Troubleshooting:
    • Ready-to-use configuration and code walkthroughs: Standard Ethernet with DHCP, Industrial static IP node with UID MAC, and Wi-Fi IoT auto-association.
    • Dedicated unit debug tracing via CONFIG_NETINIT_DEBUG=y to prevent system-wide DEBUG_NET console flooding.
    • Troubleshooting guide resolving boot freezes, MAC collisions, missing PHY interrupts, and Wi-Fi association mismatches.

Impact

  • Documentation: Fills a core network blank documentation page identified in Documentation: blank pages in documentation #11081.
  • Architecture: Explains the critical distinction between foreground blocking bring-up and background threaded initialization, preventing boot lockups on disconnected embedded targets.
  • Developer Experience: Eliminates confusion surrounding hardware MAC provisioning from silicon UIDs, effective IPv6 subnet masks, and Wi-Fi WAPI auto-association parameters.
  • Build / ABI: Documentation-only change. No functional code or ABI alterations to existing NuttX libraries or apps.

Testing

  • Verified reStructuredText syntax, section underline lengths, and directive syntax with docutils and Sphinx parsers (0 errors, 0 warnings).
  • Verified pure LF line endings and 0 trailing whitespaces (git diff --check).
  • Cross-referenced all public C API signatures and headers against apps/include/netutils/netinit.h.
  • Cross-referenced all operational logic, ioctls, and defaults against apps/netutils/netinit/netinit.c, netinit_associate.c, and apps/netutils/netinit/Kconfig.

@github-actions github-actions Bot added Area: Documentation Improvements or additions to documentation Size: L The size of the change in this PR is large labels Oct 10, 2026

@michallenc michallenc 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 minor note here, other than that thanks for the detailed description.

Provide a complete documentation guide for the netinit (network initialization)
subsystem in Documentation/applications/netutils/netinit/index.rst, replacing
the previous 4-line placeholder stub.

Includes:
- Architectural overview and execution modes (synchronous sequential, asynchronous background pthread, and split local-only configuration via CONFIG_NETINIT_NETLOCAL)
- Autonomous MII PHY link monitoring daemon (CONFIG_NETINIT_MONITOR) with carrier detection, MII ioctl polling, and signal-driven reconnection
- Primary network device selection hierarchy (wlan0, eth0, wpan0, bnep0, sl0, tun0, lo, can0)
- Software MAC address provisioning strategies (CONFIG_NETINIT_NOMAC via UID-derived IEEE LAA, device calibration file, and fixed software MAC)
- IPv4 static configuration, dynamic DHCP client (RFC 2131), and runtime IP configuration file (fsutils/ipcfg via CONFIG_IPCFG_PATH, ASCII and binary formats)
- IPv6 static addressing and ICMPv6 Stateless Address Autoconfiguration (SLAAC, RFC 4862), with effective /112 Kconfig netmask default
- DNS nameserver registration and automated NTP client daemon startup (ntpclient)
- Wi-Fi association via WAPI (wpa_driver_wext_associate) with WPA2-PSK and infrastructure/ad-hoc modes
- Complete Kconfig options reference table
- Public C API reference (netinit_bringup, netinit_associate)
- Practical configuration and usage scenarios (Ethernet with DHCP, static IP industrial node with silicon UID MAC, and Wi-Fi IoT auto-association)
- Troubleshooting and diagnostics guide (CONFIG_NETINIT_DEBUG, boot freezes, link monitor PHY interrupts, and Wi-Fi association)

Addresses apache#11081

Assisted-by: Google Gemini
Signed-off-by: Swatantra Yadav <[email protected]>
@michallenc
michallenc merged commit 49cb472 into apache:master Oct 12, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Documentation Improvements or additions to documentation Size: L The size of the change in this PR is large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants