You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "13627105546 (via GitHub)" <gi...@apache.org> on 2026/01/13 07:57:43 UTC

[PR] netinit: Support the NETINIT_WIFIMAC. [nuttx-apps]

13627105546 opened a new pull request, #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315

   
   *Note: Please adhere to [Contributing Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).*
   
   ## 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.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] netutils/netinit: Support the NETINIT_WIFIMAC. [nuttx-apps]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315#discussion_r2712129835


##########
netutils/netinit/Kconfig:
##########
@@ -488,6 +488,13 @@ config NETINIT_SWMAC
 		With this choice, you can assign a fixed MAC address determined by
 		a NuttX configuration option.
 
+config NETINIT_WIFIMAC

Review Comment:
   NETINIT_MACADDR



##########
netutils/netinit/Kconfig:
##########
@@ -488,6 +488,13 @@ config NETINIT_SWMAC
 		With this choice, you can assign a fixed MAC address determined by
 		a NuttX configuration option.
 
+config NETINIT_WIFIMAC
+	bool "Device Wi-Fi MAC"

Review Comment:
   remove Wi-Fi from the change



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] netutils/netinit: Support the NETINIT_MACADDR. [nuttx-apps]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] netinit: Support the NETINIT_WIFIMAC. [nuttx-apps]

Posted by "simbit18 (via GitHub)" <gi...@apache.org>.
simbit18 commented on PR #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315#issuecomment-3744584609

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] netinit: Support the NETINIT_WIFIMAC. [nuttx-apps]

Posted by "cederom (via GitHub)" <gi...@apache.org>.
cederom commented on code in PR #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315#discussion_r2699201507


##########
netutils/netinit/netinit.c:
##########
@@ -286,7 +286,10 @@ static const uint16_t g_ipv6_netmask[8] =
     defined(HAVE_MAC)
 static void netinit_set_macaddr(void)
 {
-#if defined(CONFIG_NETINIT_UIDMAC)
+#if defined(CONFIG_NETINIT_WIFIMAC)

Review Comment:
   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)
   ..
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] netutils/netinit: Support the NETINIT_WIFIMAC. [nuttx-apps]

Posted by "13627105546 (via GitHub)" <gi...@apache.org>.
13627105546 commented on code in PR #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315#discussion_r2712117941


##########
netutils/netinit/netinit.c:
##########
@@ -286,6 +286,9 @@ static const uint16_t g_ipv6_netmask[8] =
     defined(HAVE_MAC)
 static void netinit_set_macaddr(void)
 {
+#if defined(CONFIG_NETINIT_WIFIMAC)
+  struct boardioc_macaddr_s req;
+#endif
 #if defined(CONFIG_NETINIT_UIDMAC)

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] netutils/netinit: Support the NETINIT_WIFIMAC. [nuttx-apps]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315#discussion_r2711397835


##########
netutils/netinit/netinit.c:
##########
@@ -296,6 +299,14 @@ static void netinit_set_macaddr(void)
 
   /* Many embedded network interfaces must have a software assigned MAC */
 
+#if defined(CONFIG_NETINIT_WIFIMAC)
+  strlcpy((FAR char *)req.ifname, NET_DEVNAME, IFNAMSIZ);

Review Comment:
   remove the cast



##########
netutils/netinit/netinit.c:
##########
@@ -296,6 +299,14 @@ static void netinit_set_macaddr(void)
 
   /* Many embedded network interfaces must have a software assigned MAC */
 
+#if defined(CONFIG_NETINIT_WIFIMAC)
+  strlcpy((FAR char *)req.ifname, NET_DEVNAME, IFNAMSIZ);
+  if (boardctl(BOARDIOC_MACADDR, (uintptr_t)&req) == 0)
+    {
+      netlib_setmacaddr(NET_DEVNAME, req.macaddr);
+    }
+#endif
+
 #if defined(CONFIG_NETINIT_UIDMAC)

Review Comment:
   ```suggestion
   #elif defined(CONFIG_NETINIT_UIDMAC)
   ```



##########
netutils/netinit/netinit.c:
##########
@@ -286,6 +286,9 @@ static const uint16_t g_ipv6_netmask[8] =
     defined(HAVE_MAC)
 static void netinit_set_macaddr(void)
 {
+#if defined(CONFIG_NETINIT_WIFIMAC)
+  struct boardioc_macaddr_s req;
+#endif
 #if defined(CONFIG_NETINIT_UIDMAC)

Review Comment:
   ```suggestion
   #elif defined(CONFIG_NETINIT_UIDMAC)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] netutils/netinit: Support the NETINIT_WIFIMAC. [nuttx-apps]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315#discussion_r2710662809


##########
netutils/netinit/netinit.c:
##########
@@ -296,6 +300,14 @@ static void netinit_set_macaddr(void)
 
   /* Many embedded network interfaces must have a software assigned MAC */
 
+#if defined(CONFIG_NETINIT_WIFIMAC)
+  boardctl(BOARDIOC_MACADDR, (uintptr_t)macstr);
+  if (netlib_ethaddrconv(macstr, wifi_mac))

Review Comment:
   why need convert? the ioctl should return binary mac address directly



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] netinit: Support the NETINIT_WIFIMAC. [nuttx-apps]

Posted by "13627105546 (via GitHub)" <gi...@apache.org>.
13627105546 commented on code in PR #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315#discussion_r2707259510


##########
netutils/netinit/netinit.c:
##########
@@ -296,7 +299,15 @@ static void netinit_set_macaddr(void)
 
   /* Many embedded network interfaces must have a software assigned MAC */
 
-#if defined(CONFIG_NETINIT_UIDMAC)
+#if defined(CONFIG_NETINIT_WIFIMAC)
+  #define BOARDIOC_USER_MAC_WIFI (BOARDIOC_USER + 3)

Review Comment:
   https://github.com/apache/nuttx/pull/18031,I have submitted a commit, which needs to wait for the NuttX commit to be merged first.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] netinit: Support the NETINIT_WIFIMAC. [nuttx-apps]

Posted by "13627105546 (via GitHub)" <gi...@apache.org>.
13627105546 commented on code in PR #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315#discussion_r2707275684


##########
netutils/netinit/netinit.c:
##########
@@ -286,7 +286,10 @@ static const uint16_t g_ipv6_netmask[8] =
     defined(HAVE_MAC)
 static void netinit_set_macaddr(void)
 {
-#if defined(CONFIG_NETINIT_UIDMAC)
+#if defined(CONFIG_NETINIT_WIFIMAC)

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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] netutils/netinit: Support the NETINIT_MACADDR. [nuttx-apps]

Posted by "13627105546 (via GitHub)" <gi...@apache.org>.
13627105546 commented on PR #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315#issuecomment-3815136675

   > Please include a log from your test of this feature.
   
   done


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] netinit: Support the NETINIT_WIFIMAC. [nuttx-apps]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315#discussion_r2686641281


##########
netutils/netinit/netinit.c:
##########
@@ -296,7 +299,15 @@ static void netinit_set_macaddr(void)
 
   /* Many embedded network interfaces must have a software assigned MAC */
 
-#if defined(CONFIG_NETINIT_UIDMAC)
+#if defined(CONFIG_NETINIT_WIFIMAC)
+  #define BOARDIOC_USER_MAC_WIFI (BOARDIOC_USER + 3)

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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] netutils/netinit: Support the NETINIT_WIFIMAC. [nuttx-apps]

Posted by "cederom (via GitHub)" <gi...@apache.org>.
cederom commented on code in PR #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315#discussion_r2710714926


##########
netutils/netinit/netinit.c:
##########
@@ -286,7 +286,10 @@ static const uint16_t g_ipv6_netmask[8] =
     defined(HAVE_MAC)
 static void netinit_set_macaddr(void)
 {
-#if defined(CONFIG_NETINIT_UIDMAC)
+#if defined(CONFIG_NETINIT_WIFIMAC)

Review Comment:
   thanks :-)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] netutils/netinit: Support the NETINIT_WIFIMAC. [nuttx-apps]

Posted by "13627105546 (via GitHub)" <gi...@apache.org>.
13627105546 commented on code in PR #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315#discussion_r2712118624


##########
netutils/netinit/netinit.c:
##########
@@ -296,6 +299,14 @@ static void netinit_set_macaddr(void)
 
   /* Many embedded network interfaces must have a software assigned MAC */
 
+#if defined(CONFIG_NETINIT_WIFIMAC)
+  strlcpy((FAR char *)req.ifname, NET_DEVNAME, IFNAMSIZ);

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] netutils/netinit: Support the NETINIT_WIFIMAC. [nuttx-apps]

Posted by "13627105546 (via GitHub)" <gi...@apache.org>.
13627105546 commented on PR #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315#issuecomment-3775823752

   > @13627105546 this is a new Feature, please add a Documentation to it
   
   I have supplemented the documentation (https://github.com/apache/nuttx/pull/18031) with Documentation/reference/user/13_boardctl.rst


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] netutils/netinit: Support the NETINIT_WIFIMAC. [nuttx-apps]

Posted by "13627105546 (via GitHub)" <gi...@apache.org>.
13627105546 commented on code in PR #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315#discussion_r2707259510


##########
netutils/netinit/netinit.c:
##########
@@ -296,7 +299,15 @@ static void netinit_set_macaddr(void)
 
   /* Many embedded network interfaces must have a software assigned MAC */
 
-#if defined(CONFIG_NETINIT_UIDMAC)
+#if defined(CONFIG_NETINIT_WIFIMAC)
+  #define BOARDIOC_USER_MAC_WIFI (BOARDIOC_USER + 3)

Review Comment:
   https://github.com/apache/nuttx/pull/18031, I have submitted a commit, which needs to wait for the NuttX commit to be merged first.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] netutils/netinit: Support the NETINIT_WIFIMAC. [nuttx-apps]

Posted by "13627105546 (via GitHub)" <gi...@apache.org>.
13627105546 commented on code in PR #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315#discussion_r2712288529


##########
netutils/netinit/Kconfig:
##########
@@ -488,6 +488,13 @@ config NETINIT_SWMAC
 		With this choice, you can assign a fixed MAC address determined by
 		a NuttX configuration option.
 
+config NETINIT_WIFIMAC
+	bool "Device Wi-Fi MAC"

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] netutils/netinit: Support the NETINIT_MACADDR. [nuttx-apps]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #3315:
URL: https://github.com/apache/nuttx-apps/pull/3315#discussion_r2731859314


##########
netutils/netinit/netinit.c:
##########
@@ -286,7 +286,9 @@ static const uint16_t g_ipv6_netmask[8] =
     defined(HAVE_MAC)
 static void netinit_set_macaddr(void)
 {
-#if defined(CONFIG_NETINIT_UIDMAC)
+#if defined(CONFIG_NETINIT_MACADDR) && defined(CONFIG_BOARDCTL_MACADDR)

Review Comment:
   ```suggestion
   #if defined(CONFIG_NETINIT_MACADDR)
   ```



##########
netutils/netinit/netinit.c:
##########
@@ -296,7 +298,14 @@ static void netinit_set_macaddr(void)
 
   /* Many embedded network interfaces must have a software assigned MAC */
 
-#if defined(CONFIG_NETINIT_UIDMAC)
+#if defined(CONFIG_NETINIT_MACADDR) && defined(CONFIG_BOARDCTL_MACADDR)

Review Comment:
   ```suggestion
   #if defined(CONFIG_NETINIT_MACADDR)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org