This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM6422: RTOS MAC addr

Part Number: AM6422


Tool/software:

Hello,

    We have a use case where after the Ethernet connection is already up and running normally, we modify the IP and MAC addresses by changing parameters. After modifying the MAC address, we found that it didn't take effect and the device became unpingable. We need to know how to properly modify the MAC address.

	sys_lock_tcpip_core();
	netif_set_down(g_pNetif[0]);

	netif_set_ipaddr(g_pNetif[0], &ip4_ipaddr);

	netif_set_netmask(g_pNetif[0], &ip4_maskaddr);

	netif_set_gw(g_pNetif[0], &ip4_gwaddr);
    
    tempMacAddr[0] = MACADDR0;
	tempMacAddr[1] = MACADDR1;
	tempMacAddr[2] = MACADDR2;
	tempMacAddr[3] = macAddr3;
	tempMacAddr[4] = macAddr4;
	tempMacAddr[5] = macAddr5;

    if(NULL != g_pNetif[0])
    {
		for(i=0; i<6; i++)
			g_pNetif[0]->hwaddr[i] = tempMacAddr[i];
	}	
	netif_set_up(g_pNetif[0]);
	sys_unlock_tcpip_core();

  • HI Wangli,

    Which SDK are you using ? LInux or MCU+SDK?

  • We use SDK8.6 ,MCU+SDK,and it is not linux .

  • Ok. Thanks for the information. i will direct your query to our MCU+SDK Ethernet expert.

  • Hi,

    For your Ethernet application - what SoC are you using? Are you working with a custom board?

    Also, what Ethernet subsystem are you using - is it CPSW or ICSS?

    Regards
    Archit 

  • Hello,

        We are using AM6422 with Ethernet in CPSW (Common Platform Software) mode and employing custom hardware. Upon power-on initialization, there is a default MAC address, but we intend to modify it based on our own configuration file. I have already submitted the relevant code for the modification method when raising the question, yet this approach hasn't taken effect. We would greatly appreciate your support and suggestions. Thank you very much!

  • Hi Wanglili,

    Updating the MAC address in the netif would only change the MAC address the LwIP stack associates with the given netif. But for the device to receive the packets, we have to update the Host port MAC address as well, as the host port would be only accepting the packets directed to host (along with broadcast and multicast packets).

    The Host Port MAC address can be updated by using the Enet Utils function EnetAppUtils_addHostPortEntry(). Doing this will enable receiving from the new MAC address. We also recommend to remove the entry of previous Host MAC address using EnetAppUtils_delAddrEntry() to avoid receiving packets destined for the original MAC address.

    Please let us know if you have any further queries.

    Thanks and Regards,
    Teja.

  • Hello,

        I hope you can provide specific example programs for usage. Can the two functions you mentioned be added to the code I submitted above?Regarding the parameters of these two functions, particularly the 

    void EnetAppUtils_addHostPortEntry(Enet_Handle hEnet, uint32_t coreId, uint8_t *macAddr) 

    function, the first parameter is defined in ti_enet_open_close.c as a static structure variable, which I cannot directly use in my application. I hope you can provide a specific example, similar to the netif_set_ipaddr function.

  • Hi Wanglili,

    You can get the hEnet info by using the API Enet_getHandle(Enet_Type enetType, uint32_t instId). enetType and instId are available widely across applications. These are fixed values in given application of cpsw instance. So, you can fetch these values from app_main.c

    Regards,
    Teja.

  • Hello,

        Thank you for your advice。I might not have explained my question clearly enough. We are developing with the MCU+SDK version based on SDK 8.6, utilizing CPSW Ethernet as two independent Ethernet interfaces, each with its own MAC address. They have default initial addresses upon power-on, and we want to modify their respective MAC addresses during runtime by receiving configuration files. Previously, we only modified the MAC at the LwIP layer, but based on the method you provided, how can we map it to the two Ethernet interfaces of CPSW?

  • Hi Wanglili,

    If I understand correctly, you would like to change the MAC addresses of both of your interfaces in runtime based on the information received from network. This can be done by above mentioned method. I am interested to understand this usecase, as assigning MAC addresses based on the network is not how we generally suggest to maintain the network.

    Regards,
    Teja.

  • Hello,

        You are correct. We may need to reconfigure the network parameters during the operation, so this function is necessary.

  • Hi,

    For your requirement, the above mentioned method should work. It will remove the old entry as hostport address, and update new MAC address into the lookup table. You would have to update the MAC address in both Hardware(lookup tables) and in Software (in Netif hwaddr).

    Regards,
    Teja.

  • Hello,

        According to your advice,I modify it and it works well. Thanks very much!

  • Hi Wanglili,

    Thanks for the response. Please mark the corresponding response as "solved your Issue" so other users can also benefit from it.

    Thanks and regards,
    Teja.