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.

[FAQ] AM263P4: AM263Px: Facing issues with Ethernet MAC PORT IOCTL API.

Part Number: AM263P4


Hi team,

I am using the MCU_PLUS_SDK AM263Px version v11.0 and I am facing issues running ethernet examples. From the logs I suspect issues with MAC Port IOCTL calls. This is causing example failure, failures to read PHY registers and the IOCTL calls to MAC port fail with error codes. 

Can you please help me resolve these errors?

  • Hi,

    Please follow the steps below to solve the MACPORT IOCTL related issues:

    1. Open your MCU_PLUS_SDK and navigate to C:\ti\mcu_plus_sdk_am263px_11_00_00_19\source\networking\enet\core\src\mod\cpsw_macport.c

    2. Replace the "CpswMacPort_ioctl" API with the below updated API:

    int32_t CpswMacPort_ioctl(CpswMacPort_Handle hPort,
                              uint32_t cmd,
                              Enet_IoctlPrms *prms)
    {
        int32_t status = ENET_SOK;
    
        ENETTRACE_VERBOSE("%s: Do IOCTL 0x%08x prms %p\n", hPort->name, cmd, prms);
    
        CSL_Xge_cpswRegs *regs = (CSL_Xge_cpswRegs *)hPort->virtAddr;
    #if ENET_CFG_IS_ON(CPSW_MACPORT_SGMII)
        CSL_CpsgmiiRegs *sgmiiRegs = (CSL_CpsgmiiRegs *)hPort->virtAddr2;
    #endif
        Enet_MacPort macPort = hPort->macPort;
        uint32_t portId = ENET_MACPORT_ID(macPort);
    
        ENETTRACE_VAR(portId);
    #if ENET_CFG_IS_ON(DEV_ERROR)
        /* Validate CPSW MAC port IOCTL parameters */
        if (ENET_IOCTL_GET_PER(cmd) == ENET_IOCTL_PER_CPSW)
        {
            if (ENET_IOCTL_GET_TYPE(cmd) == ENET_IOCTL_TYPE_PUBLIC)
            {
                status = Enet_validateIoctl(cmd, prms,
                                            gCpswMacPort_ioctlValidate,
                                            ENET_ARRAYSIZE(gCpswMacPort_ioctlValidate));
            }
            else
            {
                status = Enet_validateIoctl(cmd, prms,
                                            gCpswMacPort_privIoctlValidate,
                                            ENET_ARRAYSIZE(gCpswMacPort_privIoctlValidate));
            }
    
            ENETTRACE_ERR_IF(status != ENET_SOK, "MAC %u: IOCTL 0x%08x params are not valid\n", portId, cmd);
        }
    #endif
    
        if (status == ENET_SOK)
        {
            CpswMacPortIoctlHandler * ioctlHandlerFxn;
    
            ioctlHandlerFxn = CpswMacPort_getIoctlHandlerFxn(cmd, CpswMacPortIoctlHandlerRegistry, ENET_ARRAYSIZE(CpswMacPortIoctlHandlerRegistry));
            Enet_devAssert(ioctlHandlerFxn != NULL);
            status = ioctlHandlerFxn(hPort, regs,prms);
        }
        else
        {
            ENETTRACE_ERR("%s: IOCTL validation failed for cmd 0x%08x: %d\n", hPort->name, cmd, status);
        }
    
        if (status != ENET_SOK)
        {
            ENETTRACE_ERR("%s: Failed to do IOCTL cmd 0x%08x: %d\n", hPort->name, cmd, status);
        }
    
        return status;
    }

    3. Re-build your enet-cpsw lib using the following command from the MCU_PLUS_SDK directory:

    # FOR RELEASE BUILD
    gmake -sj -f makefile.am263px enet-cpsw_r5f.ti-arm-clang.freertos
    
    # FOR DEBUG BUILD
    gmake -sj -f makefile.am263px enet-cpsw_r5f.ti-arm-clang.freertos PROFILE=debug

    Please note that the library cannot be built from CCS and the example only links these libraries during build. So it is necessary to re-build the library to have the updated driver files with the application.

    The newly built lib will be available at: C:\ti\mcu_plus_sdk_am263px_11_00_00_19\source\networking\enet\lib

    4. Re-build your application and re-test.

    Regards,
    Shaunak

    Checkout other FAQs for AM263x/AM263Px

    Checkout other FAQs for AM261x