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.

MCU-PLUS-SDK-AM243X: CPSW RMII mode unavailable for AM234x (only RGMII)

Part Number: MCU-PLUS-SDK-AM243X
Other Parts Discussed in Thread: AM2434

I am working with mcu_plus_sdk_am243x_08_02_00_31 and I would like to run the LwIP CPSW example on our custom board based on AM2434.

I found that the register ENET1_CTRL (0x43004044) is always set to 2, that means RGMII mode.

Anyway, we have a PHY working in RMII mode and we expect the SoC being configured in the same mode.

Here is how I have changed the ethernet initialization code in test_enet.c

/* Setup board for requested Ethernet port */
ethPort.enetType = ENET_CPSW_2G; /*! CPSW_2G: 1 host port + 1 MAC port */
ethPort.instId   = 0U;
ethPort.macPort  = macPort;
//ethPort.boardId  = ENETBOARD_AM64X_AM243X_EVM;
ethPort.mii.layerType      = ENET_MAC_LAYER_MII;
ethPort.mii.sublayerType   = ENET_MAC_SUBLAYER_REDUCED;
ethPort.mii.variantType    = ENET_MAC_VARIANT_NONE;

At function EnetBoard_setupPorts(&ethPort, 1U) there is a check if the SoC port is configured in the same way as desired and it fails in CpswMacPort_open (line 466)

/* Save peripheral info to use it later to query SoC parameters */
    hPort->enetType = enetType;
    hPort->instId = instId;

    /* Check if SoC settings (if any) matches the requested MII config */
    status = CpswMacPort_checkSocCfg(enetType, instId, macPort, mii);
    ENETTRACE_ERR_IF(status != ENET_SOK, "MAC %u: MII mismatch with SoC settings\n", portId);

The point where the register ENET1_CTRL (0x43004044) should be configured is at source/networking/enet/utils/V3/enet_appboardutils.c

static void EnetBoard_setMcuEnetControl(uint32_t modeSel)
{
    CSL_main_ctrl_mmr_cfg0Regs *mcuRegs;
    EnetAppUtils_MmrLockState prevLockState;

    mcuRegs = (CSL_main_ctrl_mmr_cfg0Regs *)(uintptr_t)CSL_CTRL_MMR0_CFG0_BASE;
    prevLockState = EnetAppUtils_mcuMmrCtrl(ENETAPPUTILS_MMR_LOCK1, ENETAPPUTILS_UNLOCK_MMR);
    CSL_REG32_FINS(&mcuRegs->ENET1_CTRL,
                   MAIN_CTRL_MMR_CFG0_ENET1_CTRL_PORT_MODE_SEL,
                   modeSel);
    if (prevLockState == ENETAPPUTILS_LOCK_MMR)
    {
        EnetAppUtils_mcuMmrCtrl(ENETAPPUTILS_MMR_LOCK1, ENETAPPUTILS_LOCK_MMR);
    }
}

void EnetBoard_setEnetControl(Enet_Type enetType,
                                      uint32_t instId,
                                      Enet_MacPort portNum,
                                      uint32_t modeSel)
{
    EnetAppUtils_assert(portNum == ENET_MAC_PORT_1);
    EnetAppUtils_assert(enetType == ENET_CPSW_3G);
    EnetAppUtils_assert(((modeSel == RMII) || (modeSel == RGMII)));
    EnetBoard_setMcuEnetControl(modeSel);
}

Anyway the execution never reaches such point because in source/networking/enet/utils/V3/enet_board_cfg.c the definition of EnetBoard_setEnetControl is overwritten !!

int32_t EnetBoard_setupPorts(EnetBoard_EthPort *ethPorts,
                             uint32_t numEthPorts)
{
    uint32_t i;

    /* Nothing else to do */
    for (i = 0U; i < numEthPorts; i++)
    {
        EnetBoard_EthPort *ethPort = &ethPorts[i];
        /* Override the ENET control set by board lib */
        EnetBoard_setEnetControl(ethPort->enetType, ethPort->macPort, &ethPort->mii);

    }
    return ENET_SOK;
}

//Board_STATUS Board_unlockMMR(void);
static void EnetBoard_setEnetControl(Enet_Type enetType,
                                     Enet_MacPort macPort,
                                     EnetMacPort_Interface *mii)
{
    uint32_t modeSel = 0U;
    int32_t status = ENET_SOK;

    ....

Is it possible to configure register ENET1_CTRL (0x43004044) in the proper way in order to use RMII mode ?

May be with EnetBoard_setMcuEnetControl in source/networking/enet/utils/V3/enet_appboardutils.c ?

Looking forward

   Andrea

  • Here is how I have successfully changed the Enet initialization to force RMII mode instead of RGMII.

    In source/networking/enet/utils/V3/enet_board_cfg.c:

    • I changed EnetBoard_setEnetControl with EnetBoard_setEnetType in order to don't overwrite the EnetBoard_setEnetControl from library
    • in EnetBoard_setupPorts I call EnetBoard_setEnetType instead of EnetBoard_setEnetControl, passing also instId
    • at the end of EnetBoard_setEnetType (same as EnetBoard_setEnetControl) I call EnetBoard_setEnetControl from library

    int32_t EnetBoard_setupPorts(EnetBoard_EthPort *ethPorts,
                                 uint32_t numEthPorts)
    {
        uint32_t i;
    
        /* Nothing else to do */
        for (i = 0U; i < numEthPorts; i++)
        {
            EnetBoard_EthPort *ethPort = &ethPorts[i];
            /* Override the ENET control set by board lib */
            //EnetBoard_setEnetControl(ethPort->enetType, ethPort->macPort, &ethPort->mii);
            EnetBoard_setEnetType(ethPort->enetType, ethPort->instId, ethPort->macPort, &ethPort->mii);
    
        }
        return ENET_SOK;
    }
    
    //Board_STATUS Board_unlockMMR(void);
    static void EnetBoard_setEnetType(Enet_Type enetType,
                                      uint32_t instId,
                                      Enet_MacPort macPort,
                                      EnetMacPort_Interface *mii)
    {
        uint32_t modeSel = 0U;
        int32_t status = ENET_SOK;
    
        if (EnetMacPort_isRmii(mii))
        {
            modeSel = RMII;
        }
        else if (EnetMacPort_isRgmii(mii))
        {
            modeSel = RGMII;
        }
        else if (EnetMacPort_isMii(mii))
        {
            //modeSel = MII;
        }
        else
        {
            EnetAppUtils_print("Invalid MII type: layer %u suyblayer %u\n", mii->layerType, mii->sublayerType);
            EnetAppUtils_assert(false);
        }
    
        switch (enetType)
        {
            case ENET_CPSW_3G:
                break;
    
            case ENET_ICSSG_DUALMAC:
            case ENET_ICSSG_SWITCH:
                break;
    
            default:
                break;
        }
    
        EnetBoard_setEnetControl(enetType,
                                 instId,
                                 macPort,
                                 modeSel);
    
        EnetAppUtils_assert(status == ENET_SOK);
    }