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.

  1. From the device configuration structure (NET_DEV_CFG_ETHER) defined in net_dev_cfg.c. Configure a valid hardware address (i.e., not null) for .HW_AddrStr[] in NetDev_Cfg_<device>_<Nbr> in net_dev_cfg.c at compilation time.
  2. 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 calling NetIF_Start().

  3. From Auto-Loading via EEPROM

    If .HW_AddrStr[] is set to "00:00:00:00:00:00", and NetIF_Ether_HW_AddrSet() is not called, then NetDev_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:

  1. Set the value of .HW_AddrStr[] in NetDev_Cfg_<device>_<Nbr> in net_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.
  2. Set the value of .HW_AddrStr[] in NetDev_Cfg_<device>_<Nbr> in net_dev_cfg.c to "00:00:00:00:00:00", before calling NetIF_Start() in your application code call NetIF_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 with NetIF_AddrHW_Set() in the Wireshark trace.
  3. 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.