Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions include/netutils/netinit.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@
# define CONFIG_NETINIT_DNSIPADDR CONFIG_NETINIT_DRIPADDR
#endif

#ifndef CONFIG_NETINIT_MACADDR
# define CONFIG_NETINIT_MACADDR 0x00e0deadbeef
#endif

#if !defined(CONFIG_NETINIT_THREAD) || !defined(CONFIG_ARCH_PHY_INTERRUPT) || \
!defined(CONFIG_NETDEV_PHY_IOCTL) || !defined(CONFIG_NET_UDP)
# undef CONFIG_NETINIT_MONITOR
Expand Down
7 changes: 7 additions & 0 deletions netutils/netinit/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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_MACADDR
bool "Device MAC address"
depends on BOARDCTL_MACADDR
---help---
With this choice, you can assign a fixed MAC address in the file
device.info (DEVICE_INFO_PATH) defined by user.

endchoice # MAC address selection

config NETINIT_MACADDR_1
Expand Down
13 changes: 11 additions & 2 deletions netutils/netinit/netinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
struct boardioc_macaddr_s req;
#elif defined(CONFIG_NETINIT_UIDMAC)
uint8_t uid[CONFIG_BOARDCTL_UNIQUEID_SIZE];
#elif defined(CONFIG_NET_ETHERNET)
uint8_t mac[IFHWADDRLEN];
Expand All @@ -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)
strlcpy(req.ifname, NET_DEVNAME, IFNAMSIZ);
if (boardctl(BOARDIOC_MACADDR, (uintptr_t)&req) == 0)
{
netlib_setmacaddr(NET_DEVNAME, req.macaddr);
}

#elif defined(CONFIG_NETINIT_UIDMAC)
boardctl(BOARDIOC_UNIQUEID, (uintptr_t)&uid);
uid[0] = (uid[0] & 0b11110000) | 2; /* Locally Administered MAC */
netlib_setmacaddr(NET_DEVNAME, uid);
Expand Down
Loading