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.
Tool/software:
Hi,
I build project based on enet_l2_multi_channel_am243x-evm_r5fss0-0_freertos_ti-arm-clang in SDK.
The PHY is using 83826 instead of 83869 in the demo.
The issue is that,
1. In the demo project, there is only configuration for 83822 not 83826. I added 83822 in gEnetPhyDrvs and I am not sure if it is OK.
2. For gEnetCpbBoard_am243x_evm_EthPort, I don't know the extended configuration for 83826, so I leave it empty.
3. I searched in the MCU_SDK, there is files named ethphy_dp83826e.c and ethphy_dp83826e.h. I wonder if there is demo for those files, since I only need to connect to the chip.
For the current project
The modified enet_custom_board_config.c
/* * Copyright (C) 2021 Texas Instruments Incorporated * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stdint.h> #include <enet.h> #include <networking/enet/core/include/phy/enetphy.h> #include <networking/enet/core/include/phy/dp83822.h> #include <networking/enet/core/include/phy/dp83867.h> #include <networking/enet/core/include/phy/dp83869.h> #include <networking/enet/utils/include/enet_apputils.h> #include <kernel/dpl/SystemP.h> #include <kernel/dpl/AddrTranslateP.h> #include <networking/enet/core/src/phy/enetphy_priv.h> #include <drivers/gpio.h> #include <board/eeprom.h> #include "ti_board_open_close.h" #include "ti_drivers_config.h" #include "ti_board_config.h" #if (ENETBOARD_SYSCFG_CUSTOM_BOARD == 1) #include <drivers/i2c.h> #define IO_EXPANDER_PORT0_OUTPUT_REG (0x04U) #define IO_EXPANDER_PORT0_DIR_REG (0x0CU) #define IO_EXPANDER_I2C_ADDR (0x22U) #define ENET_BOARD_NUM_MACADDR_MAX (2U) #define I2C_EEPROM_MAC_DATA_OFFSET (0x42) static void EnetBoard_setMacPort2IOExpanderCfg(void); /* PHY drivers */ extern EnetPhy_Drv gEnetPhyDrvGeneric; extern EnetPhy_Drv gEnetPhyDrvDp83822; extern EnetPhy_Drv gEnetPhyDrvDp83867; extern EnetPhy_Drv gEnetPhyDrvDp83869; extern EnetPhy_Drv gEnetPhyDrvVsc8514; /*! \brief All the registered PHY specific drivers. */ static const EnetPhyDrv_Handle gEnetPhyDrvs[] = { &gEnetPhyDrvDp83822, /* DP83867 */ &gEnetPhyDrvDp83867, /* DP83867 */ &gEnetPhyDrvDp83869, /* DP83869 */ &gEnetPhyDrvGeneric, /* Generic PHY - must be last */ }; const EnetPhy_DrvInfoTbl gEnetPhyDrvTbl = { .numHandles = ENET_ARRAYSIZE(gEnetPhyDrvs), .hPhyDrvList = gEnetPhyDrvs, }; /* ========================================================================== */ /* Function Declarations */ /* ========================================================================== */ static const EnetBoard_PortCfg *EnetBoard_getPortCfg(const EnetBoard_EthPort *ethPort); static const EnetBoard_PortCfg *EnetBoard_findPortCfg(const EnetBoard_EthPort *ethPort, const EnetBoard_PortCfg *ethPortCfgs, uint32_t numEthPorts); static void EnetBoard_enableExternalMux(); /* ========================================================================== */ /* Global Variables */ /* ========================================================================== */ /*! * \brief Common Processor Board (CPB) board's DP83867 PHY configuration. */ static const Dp83867_Cfg gEnetCpbBoard_dp83867PhyCfg = { /* The delay values are set based on trial and error and not tuned per port of the evm */ .txClkShiftEn = true, .rxClkShiftEn = true, .txDelayInPs = 250U, /* 0.25 ns */ .rxDelayInPs = 2000U, /* 2.00 ns */ .txFifoDepth = 4U, .impedanceInMilliOhms = 35000, /* 35 ohms */ .idleCntThresh = 4U, /* Improves short cable performance */ .gpio0Mode = DP83867_GPIO0_LED3, .gpio1Mode = DP83867_GPIO1_COL, /* Unused */ .ledMode = { DP83867_LED_LINKED, /* Unused */ DP83867_LED_LINKED_100BTX, DP83867_LED_RXTXACT, DP83867_LED_LINKED_1000BT, }, }; /*! * \brief Common Processor Board (CPB) board's DP83869 PHY configuration. */ static const Dp83869_Cfg gEnetCpbBoard_dp83869PhyCfg = { .txClkShiftEn = false, .rxClkShiftEn = true, .txDelayInPs = 500U, /* Value in pecosec. Refer to DLL_RX_DELAY_CTRL_SL field in ANA_RGMII_DLL_CTRL register of DP83869 PHY datasheet */ .rxDelayInPs = 500U, /* Value in pecosec. Refer to DLL_TX_DELAY_CTRL_SL field in ANA_RGMII_DLL_CTRL register of DP83869 PHY datasheet */ .txFifoDepth = 4U, .impedanceInMilliOhms = 35000, /* 35 ohms */ .idleCntThresh = 4U, /* Improves short cable performance */ .gpio0Mode = DP83869_GPIO0_LED3, .gpio1Mode = DP83869_GPIO1_COL, /* Unused */ .ledMode = { DP83869_LED_LINKED, /* Unused */ DP83869_LED_LINKED_100BTX, DP83869_LED_RXTXACT, DP83869_LED_LINKED_1000BT, }, }; static const Dp83822_Cfg gEnetCpbBoard_dp83826PhyCfg = { }; /* * AM64x board configuration. * * 1 x RGMII PHY connected to am243x-evm CPSW_3G MAC port. */ static const EnetBoard_PortCfg gEnetCpbBoard_am243x_evm_EthPort[] = { { /* "CPSW3G" */ .enetType = ENET_CPSW_3G, .instId = 0U, .macPort = ENET_MAC_PORT_2, .mii = { ENET_MAC_LAYER_MII, ENET_MAC_SUBLAYER_REDUCED }, .phyCfg = { .phyAddr = 3, .isStrapped = false, .skipExtendedCfg = false, .extendedCfg = &gEnetCpbBoard_dp83826PhyCfg, .extendedCfgSize = sizeof(gEnetCpbBoard_dp83826PhyCfg), }, .flags = 0U, }, }; /* ========================================================================== */ /* Function Definitions */ /* ========================================================================== */ static void EnetBoard_enableExternalMux() { /* Enable external MUXes, if any, as per the board design */ uint32_t rgmii1PhyRst = (uint32_t) AddrTranslateP_getLocalAddr(CONFIG_ENET_RGMII_PHY_RST_BASE_ADDR); GPIO_setDirMode(rgmii1PhyRst, CONFIG_ENET_RGMII_PHY_RST_PIN, CONFIG_ENET_RGMII_PHY_RST_DIR); GPIO_pinWriteHigh(rgmii1PhyRst, CONFIG_ENET_RGMII_PHY_RST_PIN); } static const EnetBoard_PortCfg *EnetBoard_getPortCfg(const EnetBoard_EthPort *ethPort) { const EnetBoard_PortCfg *portCfg = NULL; if (ENET_NOT_ZERO(ethPort->boardId & ENETBOARD_CPB_ID)) { portCfg = EnetBoard_findPortCfg(ethPort, gEnetCpbBoard_am243x_evm_EthPort, ENETPHY_ARRAYSIZE(gEnetCpbBoard_am243x_evm_EthPort)); } return portCfg; } static const EnetBoard_PortCfg *EnetBoard_findPortCfg(const EnetBoard_EthPort *ethPort, const EnetBoard_PortCfg *ethPortCfgs, uint32_t numEthPorts) { const EnetBoard_PortCfg *ethPortCfg = NULL; bool found = false; uint32_t i; for (i = 0U; i < numEthPorts; i++) { ethPortCfg = ðPortCfgs[i]; if ((ethPortCfg->enetType == ethPort->enetType) && (ethPortCfg->instId == ethPort->instId) && (ethPortCfg->macPort == ethPort->macPort) && (ethPortCfg->mii.layerType == ethPort->mii.layerType) && (ethPortCfg->mii.sublayerType == ethPort->mii.sublayerType)) { found = true; break; } } return found ? ethPortCfg : NULL; } static void EnetBoard_setMacPort2IOExpanderCfg(void) { // I2C_Transaction i2cTransaction; // uint8_t buffer[2]; // // I2C_Transaction_init(&i2cTransaction); // i2cTransaction.writeBuf = buffer; // i2cTransaction.writeCount = 2U; // i2cTransaction.targetAddress = IO_EXPANDER_I2C_ADDR; // // /* Configure MDIO sel pin */ // /* Set output to high */ // buffer[0] = IO_EXPANDER_PORT0_OUTPUT_REG + 1; /* Port 1 */ // buffer[1] = (0x01 << 4); /* Pin 4 */ // I2C_transfer(I2C_getHandle(CONFIG_I2C1), &i2cTransaction); // // /* set pin to output */ // buffer[0] = IO_EXPANDER_PORT0_DIR_REG + 1; // buffer[1] = ~(0x1 << 4); // I2C_transfer(I2C_getHandle(CONFIG_I2C1), &i2cTransaction); } const EnetBoard_PhyCfg *EnetBoard_getPhyCfg(const EnetBoard_EthPort *ethPort) { const EnetBoard_PortCfg *portCfg; portCfg = EnetBoard_getPortCfg(ethPort); return (portCfg != NULL) ? &portCfg->phyCfg : NULL; } int32_t EnetBoard_setupPorts(EnetBoard_EthPort *ethPorts, uint32_t numEthPorts) { uint32_t i; EnetBoard_enableExternalMux(); /* Nothing else to do */ for (i = 0U; i < numEthPorts; i++) { EnetBoard_EthPort *ethPort = ðPorts[i]; if(ethPort->macPort ==ENET_MAC_PORT_2) { EnetBoard_setMacPort2IOExpanderCfg(); } } return ENET_SOK; } uint8_t u8_local_mac_addr[][ENET_MAC_ADDR_LEN] = {{0x1C, 0x82, 0x59, 0x43, 0x5d, 0x03}, {0x1C, 0x82, 0x59, 0x43, 0x5d, 0x04}}; void EnetBoard_getMacAddrList(uint8_t macAddr[][ENET_MAC_ADDR_LEN], uint32_t maxMacEntries, uint32_t *pAvailMacEntries) { int32_t status = ENET_SOK; uint32_t macAddrCnt; uint32_t i; uint8_t macAddrBuf[ENET_BOARD_NUM_MACADDR_MAX * ENET_MAC_ADDR_LEN]; macAddrCnt = EnetUtils_min(ENET_BOARD_NUM_MACADDR_MAX, maxMacEntries); EnetAppUtils_assert(pAvailMacEntries != NULL); // status = EEPROM_read(gEepromHandle[CONFIG_EEPROM0], I2C_EEPROM_MAC_DATA_OFFSET, macAddrBuf, (macAddrCnt * ENET_MAC_ADDR_LEN)); // EnetAppUtils_assert(status == ENET_SOK); // // /* Save only those required to meet the max number of MAC entries */ // /* TODO Read number of mac addresses from the board eeprom */ // for (i = 0U; i < macAddrCnt; i++) // { // memcpy(macAddr[i], &macAddrBuf[i * ENET_MAC_ADDR_LEN], ENET_MAC_ADDR_LEN); // } memcpy(macAddr[0], u8_local_mac_addr[0], ENET_MAC_ADDR_LEN); *pAvailMacEntries = macAddrCnt; if (macAddrCnt == 0U) { EnetAppUtils_print("EnetBoard_getMacAddrList Failed - IDK not present\n"); EnetAppUtils_assert(false); } } /* * Get ethernet board id */ uint32_t EnetBoard_getId(void) { return ENETBOARD_AM64X_AM243X_EVM; } #endif /* #if (ENETBOARD_SYSCFG_CUSTOM_BOARD == 1) */
System config
For ENET configuration
The log is as follows.
========================== L2 Multi-channel Test ========================== Init all peripheral clocks ---------------------------------------------- Enabling clocks! Create RX tasks ---------------------------------------------- cpsw-3g: Create RX task Open all peripherals ---------------------------------------------- cpsw-3g: Open enet EnetAppUtils_reduceCoreMacAllocation: Reduced Mac Address Allocation for CoreId:1 From 4 To 2 Init all configs ---------------------------------------------- cpsw-3g: init config cpsw-3g: Open port 2 Mdio_normal_ioctl_handler_ENET_MDIO_IOCTL_C22_READ: failed to read PHY 3 C22 reg 1: -1 EnetMod_ioctl: cpsw3g.mdio: Failed to do IOCTL cmd 0x01000605: -1 EnetPhyMdioDflt_readC22: PHY 3: Failed to read C22 reg: -1 EnetPhy_readReg: PHY 3: Failed to read reg 1: -1 PHY 7 is alive EnetMod_ioctl: cpsw3G.macport1: Module is not open Cpsw_registerIoctlHandler: Failed to register IOCTL handler: -1, 1000502, 700A8A91 EnetPer_ioctl: cpsw3g: Failed to do IOCTL cmd 0x01000110: -1 Enet_ioctl: cpsw3g: IOCTL 0x01000110 failed: -1 Failed to set dscp Priority map for Port 1 - -1 Attach core id 1 on all peripherals ---------------------------------------------- cpsw-3g: Attach core EnetMod_ioctl: cpsw3G.macport1: Module is not open Cpsw_registerIoctlHandler: Failed to register IOCTL handler: -1, 1010501, 700A89B1 EnetPer_ioctl: cpsw3g: Failed to do IOCTL cmd 0x01000110: -1 Enet_ioctl: cpsw3g: IOCTL 0x01000110 failed: -1 Assertion @ Line: 280 in ../multi_channel_cfg.c: status == ENET_SOK : failed !!!
Hi Jianyu Wang,
Thanks for your query.
From your logs, looks like communication issue with PHY.
From your logs, looks like communication issue with PHY.
I am assuming you are referring below documentation for your custom PHY integration.
AM64x MCU+ SDK: Ethernet PHY Integration Guide
Let me know which step you are facing problem?
Regards
Ashwani