Skip to content
Merged
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
10 changes: 10 additions & 0 deletions Documentation/reference/user/13_boardctl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ Board information
which to receive the board unique ID.

:dependencies: Board logic must provide the :c:func:`board_uniqueid` interface.

.. c:macro:: BOARDIOC_MACADDR

Get the network driver MAC address.

:Argument: A pointer to an instance of :c:struct:`boardioc_macaddr_s`.

:configuration: CONFIG_BOARDCTL_MACADDR

:dependencies: Board logic must provide the :c:func:`board_macaddr` interface.

Filesystems
-----------
Expand Down
8 changes: 8 additions & 0 deletions boards/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5322,6 +5322,14 @@ config BOARDCTL_START_CPU
Architecture specific logic must provide the board_start_cpu()
interface.

config BOARDCTL_MACADDR
bool "Get network MAC address"
default n
---help---
Enables support for the BOARDIOC_MACADDR boardctl() command.
Architecture specific logic must provide the board_macaddr()
interface.

config BOARDCTL_IOCTL
bool "Board-specific boardctl() commands"
default n
Expand Down
19 changes: 19 additions & 0 deletions boards/boardctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,25 @@ int boardctl(unsigned int cmd, uintptr_t arg)
break;
#endif

#ifdef CONFIG_BOARDCTL_MACADDR
/* CMD: BOARDIOC_MACADDR
* DESCRIPTION: Get the network driver mac address.
* ARG: A pointer to an instance of struct
* boardioc_macaddr_s.
* CONFIGURATION: CONFIG_BOARDCTL_MACADDR
* DEPENDENCIES: Board logic must provide board_macaddr()
*/

case BOARDIOC_MACADDR:
{
FAR struct boardioc_macaddr_s *req =
(FAR struct boardioc_macaddr_s *)arg;

ret = board_macaddr(req->ifname, req->macaddr);
}
break;
#endif

default:
{
#ifdef CONFIG_BOARDCTL_IOCTL
Expand Down
20 changes: 20 additions & 0 deletions include/nuttx/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,26 @@ void board_autoled_off(int led);
# define board_autoled_off(led)
#endif

/****************************************************************************
* Name: board_macaddr
*
* Description:
* Get the network driver mac address.
*
* Input Parameters:
* ifname - The interface name.
* macaddr - The mac address.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on
* any failure.
*
****************************************************************************/

#ifdef CONFIG_BOARDCTL_MACADDR
int board_macaddr(FAR const char *ifname, FAR uint8_t *macaddr);
#endif

/****************************************************************************
* Name: board_userled_initialize
*
Expand Down
16 changes: 15 additions & 1 deletion include/sys/boardctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
# include <nuttx/spinlock.h>
#endif

#ifdef CONFIG_BOARDCTL_MACADDR
# include <net/if.h>
# include <nuttx/net/netdev.h>
#endif

#ifdef CONFIG_BOARDCTL

/****************************************************************************
Expand Down Expand Up @@ -216,6 +221,7 @@
#define BOARDIOC_RESET_CAUSE _BOARDIOC(0x0015)
#define BOARDIOC_IRQ_AFFINITY _BOARDIOC(0x0016)
#define BOARDIOC_START_CPU _BOARDIOC(0x0017)
#define BOARDIOC_MACADDR _BOARDIOC(0x0018)

/* If CONFIG_BOARDCTL_IOCTL=y, then board-specific commands will be support.
* In this case, all commands not recognized by boardctl() will be forwarded
Expand All @@ -224,7 +230,7 @@
* User defined board commands may begin with this value:
*/

#define BOARDIOC_USER _BOARDIOC(0x0018)
#define BOARDIOC_USER _BOARDIOC(0x0019)

/****************************************************************************
* Public Type Definitions
Expand Down Expand Up @@ -478,6 +484,14 @@ struct boardioc_reset_cause_s
};
#endif

#ifdef CONFIG_BOARDCTL_MACADDR
struct boardioc_macaddr_s
{
char ifname[IFNAMSIZ];
uint8_t macaddr[RADIO_MAX_ADDRLEN];
};
#endif

/****************************************************************************
* Public Data
****************************************************************************/
Expand Down
Loading