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.

RTOS/AM4376: Simple UDP example for NDK

Part Number: AM4376
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hi,
I am looking for a simple UDP communication example, which has the minimum required to configure the RTOS/NDK, create sockets, sends and receive UDP packets.
Thanks,

Installed itens:
CCS 7.2
GCC ARM Compiler 4.9.3
processor_sdk_rtos_am437x  4.00.00.04
am437x PDK v1.0.7
bios 6.46.05.55
xdctools 3.32.02.25_core

Thanks,

  • We're looking into this. Feedback will be posted here.

    Best Regards,
    Yordan
  • Thank you very much Yordan.

    In parallel I am looking to the examples of the NIMU module. I do not understand the initialization of the NIMUDeviceTable. It starts from 1. Does the XDC script initialize the first position of the table?

    NIMUDeviceTable[nimu_device_index++].init =  &CpswEmacInit ;
    NIMUDeviceTable[nimu_device_index].init =  NULL ;

    Is both adapters of the AM437x been initialized?

    Could you example use the both adapters?

    regards,

  • Hi Marcio,

    Please see the post - https://e2e.ti.com/support/arm/sitara_arm/f/791/p/559718/2057521#pi316653=4

    The NIMU example for CPSW only supports one network interface.

    Regards,
    Garrett

  • H Garrett,


    I am a little bit confused. My requirements are the same of the refered post: dual mac mode using the CPSW.

    Are you saying that I cannot have dual mac mode in the CPSW becasue the drivers do not support it? Or are you saying that there no example for dual mac mode using the CPSW?

    regards,

    Marcio.

  • Marcio,

    CPSW driver (pdk\packages\ti\drv\emac) does support the dual MAC code, i.e. you can transfer packets between host port and port 1 or host port and port 2, but not between port 1 and port 2 with the driver. I was saying the upper layer NIMU (and its example) to "is not a dual mac Ethernet implementation for the CPSW at this time" as explained in the last update of that referred post. NIMU layer acts as the interface between the NDK stack and the Ethernet driver.

    You may look into the NIMU's function CpswEmacInit() in pdk\packages\ndk\nimu\src\v4\cpsw_nimu_eth.c
    /* Populate the Network Interface Object. */
    strcpy (ptr_device[0].name, "eth1");

    Regards,
    Garrett
  • Hi Garrett,

    "CPSW driver (pdk\packages\ti\drv\emac) does support the dual MAC code, i.e. you can transfer packets between host port and port 1 or host port and port 2, but not between port 1 and port 2 with the driver. I was saying the upper layer NIMU (and its example) to "is not a dual mac Ethernet implementation for the CPSW at this time" as explained in the last update of that referred post. NIMU layer acts as the interface between the NDK stack and the Ethernet driver."

    Ok. What you have just described matches my requirements: the application requires the ability to send and receive UDP packets on both adapters. The second adapter is required for availability. And each Ethernet adapter must have its own MAC and IP address.


    You may look into the NIMU's function CpswEmacInit() in pdk\packages\ndk\nimu\src\v4\cpsw_nimu_eth.c
    /* Populate the Network Interface Object. */
    strcpy (ptr_device[0].name, "eth1");

    Ok. I understand. I see on line 511:

           /* Populate the Network Interface Object. */

           if (numEmacInterfaces == 0U)

           {

               strcpy (ptr_device[numEmacInterfaces].name, "eth0");

           }

           else

           {

               strcpy (ptr_device[numEmacInterfaces].name, "eth1");

           }

     numEmacInterfaces is static and it is incremented in line 539.

     In the NIMU example, the NIMUDeviceTable is initialized to:

     NIMUDeviceTable[nimu_device_index++].init = &CpswEmacInit ;

    NIMUDeviceTable[nimu_device_index].init = NULL ;

     

    I believe for setup the second adapter I would need to do:

    NIMUDeviceTable[nimu_device_index++].init = &CpswEmacInit;

    NIMUDeviceTable[nimu_device_index++].init = &CpswEmacInit;

    NIMUDeviceTable[nimu_device_index].init = NULL;

     

    Anyway, are you still working on the UDP communication example, (which sends/receives packets through the 2 adapters)?

     

    Many thanks,
    Marcio.

     

     

  • Marcio,

    Your insight to the second adapter setup is correct. Actually there is an dual mac example project for AM572x IDK that you can refer to - NIMU_DualMacExample_idkAM572x_armExampleproject under ti\pdk_am57xx_1_0_7\packages\ti\transport\ndk\nimu\example\am572x\armv7\bios, specifically main_AM57xx.c under ti\transport\ndk\nimu\example\src\ and .cfg file under \ti\transport\ndk\nimu\example\am572x\armv7\bios.

    The NIMU layer for AM437x and AM57xx shares the same code base src\v4\cpsw_nimu_eth.c. I was incidentally looking into pdk_am57xx_1_0_6. The pdk_am572xx_1_0_7 actually has dual mac mode supported in NIMU, and only the example for AM437x doesn't exist.

    I am not working on the UDP communication example due to other tasks recently.

    Regards,
    Garrett
  • Hi Garrett,
    The am437x sdk installed on my PC already has NIMU_DualMacExample_idkAM572x_armExampleproject.txt at c:\ti\pdk_am437x_1_0_7\packages\ti\transport\ndk\nimu\example\am572x\armv7\bios\, but I cannot create the project.

    I´ve downloaded and installed ti-processor-sdk-rtos-am57xx-evm-04.00.00.04-Windows-x86-Install.exe, but I cannot create any am57xx project.

    Here is the console output:


    Detected Test Project: NIMU_DualMacExample_idkAM572x_armExampleproject

    --------------------------------------------------------------------------------

    Creating project 'NIMU_DualMacExample_idkAM572x_armExampleproject'...

      !ERROR: Unknown product-type ID 'com.ti.pdk.am57xx'!
        NOTE: Refer to the following list of available product-type IDs (the display
    -names in square brackets are for reference only):

            com.ti.sdo.edma3 [EDMA3 Low Level Driver]
            com.ti.rtsc.NDK [NDK]
            com.ti.rtsc.SYSBIOS [SYS/BIOS]
            com.ti.pdk.am437x [am437x PDK]

    Copying macro.ini
    The system cannot find the path specified.
            0 file(s) copied.


    This maybe a subject for another thread....

    Anyway, I would appreciate if you send me the relevant source files for NIMU_DualMacExample_idkAM572x_armExampleprojec.

    Regards,
    Marcio.

  • Marcio,

    >>!ERROR: Unknown product-type ID 'com.ti.pdk.am57xx'!

    Have you opened CCS to let it install the PDK package? In the case if you are not installing PDK in the ti\ directory, you might need to add the package from ccs->windows->preference->Code Composer Studio->Products->RTSC.

    The source files for NIMU_DualMacExample_idkAM572x_armExampleproject are in the PDK.

    Regards, Garrett

  • Okay. I have not restarted CCS. I´ve managed to create the projects. Thank you.

    Looking at the example, I´ve noticed the following:

    1) On the main file, the NIMUDeviceTable has 3 entries that will call CpswEmacInit twice. This confirms the previous post.

    2) On the cfg file, “Ip.ifIdx = 2;”. Why?

    3) The cfg file add a hook “Global.stackInitHook = "&stackInitHook"”, and stackInitHook() adds an IP configuration by calling CfgAddEntry, with “Item” (which is the NIMU device object) set to 1. Is it related to 2)?

    4) Could you tell whether the following code also applies to AM437x dual MAC port. Some AM437x examples call CpswPortMacModeSelect() twice.

    #elif defined(__ARM_ARCH_7A__)
    CSL_xbarMpuIrqConfigure(CSL_XBAR_INST_MPU_IRQ_92, CSL_XBAR_GMAC_SW_IRQ_RX_PULSE);
    CSL_xbarMpuIrqConfigure(CSL_XBAR_INST_MPU_IRQ_93, CSL_XBAR_GMAC_SW_IRQ_TX_PULSE);
    #endif
    /* Select RGMII 2 ports GMIIx_SEL = 2 for RGMII*/
    CSL_FINS (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->CONTROL_IO_1,
    CONTROL_CORE_CONTROL_IO_1_GMII1_SEL, 2U);
    CSL_FINS (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->CONTROL_IO_1,
    CONTROL_CORE_CONTROL_IO_1_GMII2_SEL, 2U);

    /*GMAC RESET ISOLATION Enable*/
    CSL_FINS (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->CONTROL_IO_2,
    CONTROL_CORE_CONTROL_IO_2_GMAC_RESET_ISOLATION_ENABLE, 0U);
    CSL_FINS (((CSL_control_coreRegs *) CSL_MPU_CTRL_MODULE_CORE_CORE_REGISTERS_REGS)->CONTROL_IO_2,
    CONTROL_CORE_CONTROL_IO_2_GMAC_RESET_ISOLATION_ENABLE, 1U);

    #ifdef evmAM572x
    EMAC_HwAttrs_V4 cfg;
    EMAC_socGetInitCfg(0, &cfg);
    cfg.port[0].phy_addr = GMAC_PORT1_ETHERNET_PHY_ADRESS;
    cfg.port[1].phy_addr = GMAC_PORT2_ETHERNET_PHY_ADRESS;
    EMAC_socSetInitCfg(0, &cfg);
    #endif


    Regards,
    Marcio.
  • Marcio,

    1) yes.
    2) This is to specify the second network interface with index = 2 (IP address = 192.168.1.4)
    3) This is to add the 1st network interface (192.168.2.4)
    4) Those code is for AM572x, not applicable to AM437x dual mac port.

    Regards,
    Garrett

  • Thank you very much Garrett.