Hello Giselle, although there are two great answers already, which might solve your problem, a third suggestion.
Most EMAC peripherals maintain a list of valid MAC-addresses.
When you call
IPInit(), the MAC-address will be copied to a variable:
#define ipLOCAL_MAC_ADDRESS ( xDefaultPartUDPPacketHeader.ucBytes )
And a function like
xNetworkInterfaceInitialise() will copy that MAC-address to the EMAC, e.g. here:
xETH.Init.MACAddr = ( uint8_t * ) FreeRTOS_GetMACAddress();
and later in stm32fxx_hal_eth.c:
/* Initialize MAC address in ethernet MAC */
ETH_MACAddressConfig( heth, ETH_MAC_ADDRESS0, heth->Init.MACAddr );
Note that this is a hardware filter. It allows the reception of a certain set of MAC-addresses.
The reception of broadcast and multicast packets is often enabled with special configuration bits.
Now when you call:
void FreeRTOS_UpdateMACAddress( const uint8_t ucMACAddress[ ipMAC_ADDRESS_LENGTH_BYTES ] )
/* Copy the MAC address at the start of the default packet header fragment. */
( void ) memcpy( ipLOCAL_MAC_ADDRESS, ucMACAddress, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES );
all you’re updating is a local variable which will be used for outgoing packets. The hardware will still listen to the old MAC-addresses.
What you’ll have to do is copy the new MAC-address to the hardware.
Matt is right: often the old MAC-address is still cached in the OS.
A FreeRTOS+TCP device will send a gratuitous ARP packet about every 20 seconds (see
arpGRATUITOUS_ARP_PERIOD). This packet will inform the devices on the LAN about the (MAC and IP) addresses. When you run WireShark you should see the change in ARP address(!)
What type (brand) of hardware are you using? For STM32xx you might want to call:
/* xETH is declared static in NetworkInterface. */
ETH_MACAddressConfig( &( xETH ), ETH_MAC_ADDRESS0, ucNewMAC );