Hardware Address Configuration
It is important to validate the configuration of the Ethernet interface’s hardware address. The physical hardware address should be configured from within NetDev_Start()
to allow for the proper use of NetIF_Ether_HW_AddrSet()
, hard coded hardware addresses from the device configuration structure, or auto-loading EEPROM's. Changes to the physical address only take effect when the device transitions from the NET_IF_LINK_DOWN
to NET_IF_LINK_UP
state. These states are defined in net_if.h
, and the current state of the controller can be found by calling NetIF_LinkStateGet()
from your application.
The device hardware address is set from one of the data sources below, listed in the order of precedence.
- From the device configuration structure (
NET_DEV_CFG_ETHER
) defined innet_dev_cfg.c
. Configure a valid hardware address (i.e., not null) for.HW_AddrStr[]
inNetDev_Cfg_<device>_<Nbr>
innet_dev_cfg.c
at compilation time. - From a call to
NetIF_Ether_HW_AddrSet()
:The value of
.HW_AddrStr[]
must be set to "00:00:00:00:00:00", or an empty string.NetIF_Ether_HW_AddrSet()
must be called with the desired hardware address before callingNetIF_Start()
. - From Auto-Loading via EEPROM
If
.HW_AddrStr[]
is set to "00:00:00:00:00:00", andNetIF_Ether_HW_AddrSet()
is not called, thenNetDev_Start()
will attempt to configure the hardware address with the network hardware address registers. These registers are the low and high hardware address register from the MAC device registers.Note that this test is not available in NDIT since automatic source code compilation and binary download to the target are not supported by NDIT.
Testing
In order to verify that the three hardware address configuration methods work, there are a few steps that you will have to perform:
- Set the value of
.HW_AddrStr[]
inNetDev_Cfg_<device>_<Nbr>
innet_dev_cfg.c
to a valid unicast MAC address. Then set up Wireshark to capture the ARP and ICMP traffic on the network interface used by your target. Send an ICMP echo request to the IP address of the target and verify that the device responds with the hardware address specified by.HW_AddrStr[]
in the Wireshark trace. - Set the value of
.HW_AddrStr[]
inNetDev_Cfg_<device>_<Nbr>
innet_dev_cfg.c
to "00:00:00:00:00:00", before callingNetIF_Start()
in your application code callNetIF_AddrHW_Set()
with a valid unicast MAC address (i.e., not null) Then set up Wireshark to capture the ARP and ICMP traffic on the network interfece on which your target is connected. Send an ICMP echo request to the IP address of the target and verify that the device responds with the hardware address specified withNetIF_AddrHW_Set()
in the Wireshark trace. - The third method can be tested if the MAC on your device stores the MAC address registers in an EEPROM. If the EEPROM is accessible from the program loader, you can configure the high and low address registers with a valid HW address. Then setup Wireshark to capture the ARP and ICMP traffic on the network interface on which your target is connected. Send an ICMP echo request to the IP address of the target and verify, in the Wireshark trace, that the device responds with the hardware address specified.