[FAQ] PROCESSOR-SDK-AM64X: Integration of custom PHY using MCUSDK

Part Number: PROCESSOR-SDK-AM64X

Tool/software:

Hi,

I am designing my custom board using AM64x/AM243x + MCUSDK. But not using PHY provided on EVM/LP board.

Can you provide guidance how to do this?

Regards

  • Hi,

    AM64x/AM243x-EVM have DP83867IRRGZ and DP83869HMRGZT PHY on board. So MCUSDK out of example are written to work with these 2 PHY only.

    If you want to use some other PHY instead of these 2, you need to follow below steps:

    1. Custom Driver for Custom PHY
    2. Configuring your board to Integrate custom PHY

    Custom Driver for Custom PHY

     The very first step is to create driver (.c, .h) files for specific (custom) PHY. 

    In-case you are using a TI PHY, you can find some RTOS and linux drivers at: https://github.com/TexasInstruments/ti-ethernet-software/blob/main/README.md.

    If you don't find the required driver here, please raise an E2E for the same and TI experts will guide you.

    To integrate your PHY driver follow the steps below:

    1. Add the public header files of PHY driver to the following path: C:\ti\mcu_plus_sdk\source\networking\enet\core\incldue\phy
    2. Add the private header file and the C file to the following path:  C:\ti\mcu_plus_sdk\source\networking\enet\core\src\phy.
    3. In the dp83xxxx.c file, fix the include files paths to point to the correct files according to the MCU_PLUS_SDK/source/networking/enet directory structure. 
    4. In the PHY driver file, define a structure of type EnetPhy_Drv.
      1. This structure holds
        1. Details of the PHY,
        2. Details of the supported functions,
        3. Register details
        4. And function pointers for the PHY. 
    5. In this structure,
      1. if device specific implementations are not needed,
        1. Use Generic PHY driver functions.
        2. The generic PHY driver can be found at: 
          1. C:\ti\mcu_plus_sdk\source\networking\enet\core\src\phy\generic_phy.c
    6. In the makefile at: 
      1. C:\ti\workarea\mcu_plus_sdk\source\networking\enet\makefile.cpsw.am243x.r5f.ti-arm-clang
        1. add the dp83xxxx.c file in the FILES_common array.
    7. Rebuild the enet cpsw library using the following command:
      1. # TO CLEAN
        gmake -s -f makefile.am243x enet-cpsw_r5f.ti-arm-clang_clean
         
        # TO BUILD
        gmake -s -f makefile.am243x enet-cpsw_r5f.ti-arm-clang

     Now the PHY driver for DP83TC812 has been integrated in the enet library to work with CPSW. Please note that not all the features of the PHY are supported.

    Configuring your board to Integrate custom PHY

    1. In your application, open the syscfg,
      1. go to enet (CPSW)
      2. →Board config
      3. → Enable custom board.
      4. This will disable the auto-generation of the generic configuration and custom PHY driver can be used.
    2. You need to write a 'C' file specific to the board.
      1. You can refer the following example file from the SDK
        1. C:\ti\mcu_plus_sdk\examples\networking\enet_layer2_multi_channel\am243x-evm\r5fss0-0_freertos\enet_custom_board_config.c
    3. In this C file,
      1. include the header file for the PHY driver which was step 1 in point 1.
      2. Extern the EnetPhy_Drv which is defined in the above driver files. 
      3. Define a Cfg struct (DP8xxxx_Cfg in this case) for the PHY driver. (refer the phy driver include file for the structure)

      4. Modify the EnetBoard_PortCfg to point to the correct .extendedCfg and .extendedCfgSize for the required ports.
    4. Reference code for points 3-4 is shown below

    #include <networking/enet/core/include/phy/dp83tc812.h>
     
    /* PHY drivers */
    extern EnetPhy_Drv gEnetPhyDrvGeneric;
    extern EnetPhy_Drv gEnetPhyDrvDp83tc812;
     
    /*! \brief All the registered PHY specific drivers. */
    static const EnetPhyDrv_Handle gEnetPhyDrvs[] =
    {
        &gEnetPhyDrvDp83tc812,
        &gEnetPhyDrvGeneric,   /* Generic PHY - must be last */
    };
     
    /* Create a config struct for the PHY */
    /*!
     * \brief Common Processor Board (CPB) board's DP83tc812 PHY configuration.
     */
    static const Dp83tc812_Cfg gEnetCpbBoard_dp83tc812PhyCfg =
    {
        .txClkShiftEn = true,
        .rxClkShiftEn = true,
        .interruptEn = false,
        .sgmiiAutoNegEn = true,
        .MasterSlaveMode = DP83TC812_MASTER_SLAVE_STRAP,
    };
     
    /*
     * AM263x board configuration.
     *
     * 1 x RGMII PHY connected to AM263x CPSW_3G MAC port.
     */
    static const EnetBoard_PortCfg gEnetCpbBoard_am263xEthPort[] =
    {
        {    /* "CPSW3G" */
            .enetType = ENET_CPSW_3G,
            .instId   = 0U,
            .macPort  = ENET_MAC_PORT_1,
            .mii      = { ENET_MAC_LAYER_GMII, ENET_MAC_SUBLAYER_REDUCED },
            .phyCfg   =
            {
                .phyAddr         = 0,
                .isStrapped      = false,
                .skipExtendedCfg = false,
                .extendedCfg     = &gEnetCpbBoard_dp83tc812PhyCfg,
                .extendedCfgSize = sizeof(gEnetCpbBoard_dp83tc812PhyCfg),
            },
            .flags    = 0U,
        },
        {    /* "CPSW3G" */
            .enetType = ENET_CPSW_3G,
            .instId   = 0U,
            .macPort  = ENET_MAC_PORT_2,
            .mii      = { ENET_MAC_LAYER_GMII, ENET_MAC_SUBLAYER_REDUCED },
            .phyCfg   =
            {
                .phyAddr         = 3,
                .isStrapped      = false,
                .skipExtendedCfg = false,
                .extendedCfg     = &gEnetCpbBoard_dp83tc812PhyCfg,
                .extendedCfgSize = sizeof(gEnetCpbBoard_dp83tc812PhyCfg),
            },
            .flags    = 0U,
        },
    };

    Now compile your application with this custom board config file

    Regards

    Ashwani