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.

AM2432: Emac mode SWTICH is not working in SDK the example

Part Number: AM2432

Hi Expert,

When I checked the example code in SDK as a reference for our project feature, I found ICSS switch mode is supporting only one Enet Mac Port. But, according to SDK document, it should support 2 ports(ENET_MAC_PORT1, ENET_MAC_PORT2). Does it not support two ports yet?

The example is "examples\networking\lwip\enet_lwip_icssg\am243x-evm". In this example, EMAC Mode is "DUAL MAC" by default. I tried to change it to SWITCH Mode and set numMacPorts as 2 in the example code as below. FYI, when I changed EMAC Mode to SWITCH in syscfg, it didn't change any generated code in my compilation.

void EnetApp_getEnetInstInfo(Enet_Type *enetType,
                             uint32_t *instId,
                             Enet_MacPort macPortList[],
                             uint8_t *numMacPorts)
{
    *enetType = ENET_ICSSG_SWITCH;
    *instId   = 1;
    *numMacPorts = 2;
    macPortList[0] = ENET_MAC_PORT_1;
    macPortList[1] = ENET_MAC_PORT_2;
}

Please see the code below, Here, assert happened. "source\networking\enet\core\lwipif\src\v1\lwipifcb.c” in SDK.

Could you reproduce this at your end with enet_lwip_icssg using EMAC Mode = SWITCH and clarify the problem?

Regards,

Moonil

  • Hi Moonil,

    I believe you are using ICSSG example. I have assigned this thread to our Enet ICSSG expert. He should come back on this thread. Please drop a ping if you see no response.

    Regards,

    Prasad

  • Hi Moonil,

    Currently the enet icssg lwip example is based on DUAL-MAC use case and that too supported one port at a time(Currently hardcoded to ENET_MAC_PORT1 of ICSSG1).

    To get the example to work in Switch mode, Apart from the Syscfg change and EnetApp_getEnetInstInfo change there were couple of other changes which need to be considered. 

    1) "test_enet.c" file changes

    • Use the required memory pool for switch mode: 
    //extern Icssg_FwPoolMem gEnetSoc_Icssg1_1_FwPoolMem[];
    extern Icssg_FwPoolMem gEnetSoc_Icssg1_Swt_FwPoolMem[];

    Icssg_FwPoolMem* EnetCb_getFwPoolMem(Enet_Type enetType, uint32_t instId)
    {
        EnetAppUtils_assert((ENET_ICSSG_SWITCH == enetType) && (1U == instId));
        return ((Icssg_FwPoolMem*)&gEnetSoc_Icssg1_Swt_FwPoolMem);
    }
    • Use below configurations in EnetApp_initLinkArgs() function:
    #if 0
        ethPort.enetType = ENET_ICSSG_DUALMAC;
        ethPort.instId   = 2;
        ethPort.macPort  = macPort;
    #else
        ethPort.enetType = ENET_ICSSG_SWITCH;
        ethPort.instId   = 1;
        ethPort.macPort  = macPort;
    #endif
    and 
     
    #if 0
            phyCfg->phyAddr     = CONFIG_ENET_ICSS0_PHY1_ADDR;
    #else
            if (macPort == ENET_MAC_PORT_1)
            {
                phyCfg->phyAddr     = CONFIG_ENET_ICSS0_PHY1_ADDR;
            }
            else
            {
                phyCfg->phyAddr     = CONFIG_ENET_ICSS0_PHY2_ADDR;
            }
    #endif

    2) "<MCUSDK>\source\networking\enet\core\lwipif\src\V1\lwipifcb.c"  File changes

    • Comment out the Assert line in "LwipApp_init()" function

    /* Currently we only support one ICSSG port in NIMU */
    //EnetAppUtils_assert(gLwipIfCbObj.numMacPorts == 1U);

    • Add else case like below for switch mode in LwipifEnetAppCb_getHandle() function.

    if (ENET_ICSSG_DUALMAC == gLwipIfCbObj.enetType)
    {
        Enet_IoctlPrms prms;
        IcssgMacPort_SetMacAddressInArgs inArgs;

        memset(&inArgs, 0, sizeof(inArgs));
        memcpy(&inArgs.macAddr[0U], &outArgs->rxInfo.macAddr[0U], sizeof(inArgs.macAddr));
        inArgs.macPort = gLwipIfCbObj.macPortList[0U];

        ENET_IOCTL_SET_IN_ARGS(&prms, &inArgs);
        status = Enet_ioctl(handleInfo.hEnet, coreId, ICSSG_MACPORT_IOCTL_SET_MACADDR, &prms);
        if (status != ENET_SOK)
        {
            EnetAppUtils_print("EnetAppUtils_addHostPortEntry() failed ICSSG_MACPORT_IOCTL_ADD_INTERFACE_MACADDR: %d\r\n",
            status);
        }
        EnetAppUtils_assert(status == ENET_SOK);
    }
    else
    {
        Enet_IoctlPrms prms;
        Icssg_MacAddr addr; // FIXME Icssg_MacAddr type

        /* Set host port's MAC address */
        EnetUtils_copyMacAddr(&addr.macAddr[0U], &outArgs->rxInfo.macAddr[0U]);
        ENET_IOCTL_SET_IN_ARGS(&prms, &addr);

        status = Enet_ioctl(handleInfo.hEnet, coreId, ICSSG_HOSTPORT_IOCTL_SET_MACADDR, &prms);
        if (status != ENET_SOK)
        {
            EnetAppUtils_print("EnetAppUtils_addHostPortEntry() failed ICSSG_HOSTPORT_IOCTL_SET_MACADDR: %d\r\n",
            status);
        }
        EnetAppUtils_assert(status == ENET_SOK);
    }

    Also you can refer to "enet_layer2_icssg" example for switch based layer2 example. This example will be in Switch mode using 2 MAC ports.

    Let us know if you face any issues.

    Regards,

    Mohan.