Skip to content

Conversation

@13627105546
Copy link
Contributor

Note: Please adhere to Contributing Guidelines.

Summary

  • Why : In some embedded scenarios, the Wi-Fi MAC address is stored in a specific location (e.g., a file like device.info , OTP, or NVM) rather than being generated from a unique ID or fixed at compile time. A mechanism is needed to allow netinit to retrieve this MAC address from the board logic.
  • What : This commit adds a new configuration option CONFIG_NETINIT_WIFIMAC . When enabled, netinit attempts to fetch the MAC address via boardctl(BOARDIOC_USER_MAC_WIFI, ...) (defined as BOARDIOC_USER + 3 ). This allows board-specific logic to provide the correct Wi-Fi MAC address during network initialization.

Impact

  • Users : Users can now select CONFIG_NETINIT_WIFIMAC in Kconfig if their board supports providing a Wi-Fi MAC address via boardctl .
  • Build : Introduces CONFIG_NETINIT_WIFIMAC . No impact on existing builds unless this new option is enabled.
  • Hardware : Requires board-level support for BOARDIOC_USER_MAC_WIFI command in board_ioctl if this feature is enabled.
  • Compatibility : Backward compatible. Existing MAC address initialization methods ( UIDMAC , ETHERNET , etc.) remain unchanged.

Testing

  • Verification :
  • Verified that the code compiles successfully with CONFIG_NETINIT_WIFIMAC enabled.
  • Verified that checkpatch.sh passes for the modified files.
  • Target : Verified on local hardware platform where boardctl is implemented to read MAC address from device storage.

@simbit18
Copy link
Contributor

@13627105546 Please fix

../nuttx/tools/checkpatch.sh -c -u -m -g b0b90ac72886a7d2ee8d9a16e057a4b2c801984e..HEAD
❌ Missing git commit message
Used config files:
    1: .codespellrc
Some checks failed. For contributing guidelines, see:
  https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md
Error: Process completed with exit code 1.


#if defined(CONFIG_NETINIT_UIDMAC)
#if defined(CONFIG_NETINIT_WIFIMAC)
#define BOARDIOC_USER_MAC_WIFI (BOARDIOC_USER + 3)
Copy link
Contributor

Choose a reason for hiding this comment

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

let's define a offical boar ioctl to expose the mac address, @13627105546

Copy link
Contributor Author

@13627105546 13627105546 Jan 20, 2026

Choose a reason for hiding this comment

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

apache/nuttx#18031, I have submitted a commit, which needs to wait for the NuttX commit to be merged first.

@13627105546 13627105546 force-pushed the topic/netinit-wifimac branch from 7cd49c9 to 25bcf5e Compare January 13, 2026 15:10
static void netinit_set_macaddr(void)
{
#if defined(CONFIG_NETINIT_UIDMAC)
#if defined(CONFIG_NETINIT_WIFIMAC)
Copy link
Contributor

Choose a reason for hiding this comment

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

What if both wifi and eth are available? Having wifi defined will discard mac definition, correct?

Shouldn't we

#if defined(CONFIG_NETINIT_WIFIMAC)
  char wifi_mac_str[20];
  uint8_t wifi_mac[IFHWADDRLEN];
#endif
#if defined(CONFIG_NETINIT_UIDMAC)
..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have made the revisions. Could you kindly take another look?

jerpelea
jerpelea previously approved these changes Jan 20, 2026
@jerpelea jerpelea changed the title netinit: Support the NETINIT_WIFIMAC. netutils/netinit: Support the NETINIT_WIFIMAC. Jan 20, 2026
@13627105546 13627105546 force-pushed the topic/netinit-wifimac branch from c710681 to e4972d1 Compare January 20, 2026 09:39
jerpelea
jerpelea previously approved these changes Jan 20, 2026
Support getting MAC from boardctl for Wi-Fi.

Signed-off-by: liqinhui <[email protected]>
@13627105546 13627105546 force-pushed the topic/netinit-wifimac branch from 6020df4 to 0029809 Compare January 20, 2026 10:16
Copy link
Contributor

@acassis acassis left a comment

Choose a reason for hiding this comment

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

@13627105546 this is a new Feature, please add a Documentation to it

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants