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.

AM437x when using eth0 and eth1 .. Ciclically eth1 is freezing transmission for almost 40seconds and the returns normal

Other Parts Discussed in Thread: SYSBIOS

Hi Everybody,

    When using two ethernet interfaces sometimes the ETH1 stops send UDP packages and then returns normal after few seconds..... there are no error on wireshark and the socket server is normal too.  When it happens "NDK_sendto"    returns error code 64.  

I'm using the last release of all TI packages . It seems to me there is some problem inside the drivers ..

Thanks for any help

Semi

  • Hi Semi,

    A return value of 64 by NDK_sendto() doesn't indicate an error. Did NDK_sento() return -1 and you get 64 by calling fdError()?

    Regards,

    Jianzhong

  • Hi,

        You are sure .. the code is returned for fdError()  when NDK_sendto()  returns -1  ... Do you know way??   

      By the way .. do you have any example of using two ethernet interfaces??  in the pdk examples is always loopback or one interface only...

     Thanks for all

  • We don't have any example of using two ethernet interfaces except the loopback example.

    Are you using the EMAC or the PRU-ICSS?

  • Hi,

        I think  @Marcio Borges uses EMAC driver... I don't know what is PRU-ICSS?   I'm attaching some parrts of  used  source code for you:

    1)

     ethApl.cpp:

    //----------------------------------------------------------------------------
    // Header Files
    //----------------------------------------------------------------------------
    #include <stdio.h>
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Clock.h>
    #include <ti/sysbios/hal/Hwi.h>
    #include <ti/starterware/include/hw/hw_control_am43xx.h>
    #include <ti/starterware/include/hw/am437x.h>
    #include <ti/starterware/include/ethernet.h>
    #include <ti/drv/emac/emac_drv.h>
    #include <ti/drv/emac/soc/emac_soc_v4.h>
    #include <ti/drv/emac/src/v4/emac_drv_v4.h>
    #include <ti/ndk/inc/stkmain.h>
    #include <ti/ndk/inc/netmain.h>

    /*!
    * \brief
    * Physical addresses of the Ethernet transceivers.
    *
    * CED2 has 2 Ethernet transceivers (KSZ9031RNX), one for each EMAC/CPSW port.
    * The address of an Ethernet transceivers is defined by the value of the lines
    * PHYAD[2:0] at power-up.
    * This address is utilized by the EMAC/CPSW driver to select the chip on the MDIO
    * interface, also known as MII Management Interface.
    */
    static const uint32_t EMAC_CPSW_PORT0_PHY_ADDR = 5; ///< Physical address of the transceiver of port 0 (MII1 - U11).
    static const uint32_t EMAC_CPSW_PORT1_PHY_ADDR = 6; ///< Physical address of the transceiver of port 1 (MII2 - U12).

    void Ethernet::Init()
    {
    EMAC_HwAttrs_V4 hwAttrs;

    // Chip configuration MII/RMII selection
    CpswPortMacModeSelect(0, ETHERNET_MAC_TYPE_RGMII);
    CpswPortMacModeSelect(1, ETHERNET_MAC_TYPE_RGMII);

    EMAC_socGetInitCfg(0, &hwAttrs);

    // Note: emac_open, which is called by the NIMU (NIMU_start in cpsw_nimu_eth.c) is
    // in fact EMAC_open_v4 (emac_drv_v4.c). EMAC_open_v4 calls EMAC_setupCpswInitConfig and
    // forces the transceiver to auto-negotiation.
    // Set the configuration mode flags (macModeFlags) not gigabit
    hwAttrs.macModeFlags = EMAC_CPSW_CONFIG_MODEFLG_FULLDUPLEX;

    hwAttrs.numPorts = 2;
    hwAttrs.port[0].phy_addr = EMAC_CPSW_PORT0_PHY_ADDR;
    hwAttrs.port[1].phy_addr = EMAC_CPSW_PORT1_PHY_ADDR;
    EMAC_socSetInitCfg(0, &hwAttrs);

    // Populate the NIMU Device Table to initialize 2 devices (Ethernet interfaces).
    NIMUDeviceTable[0].init = &CpswEmacInit;
    NIMUDeviceTable[1].init = &CpswEmacInit;
    NIMUDeviceTable[2].init = NULL;
    } // Init

    2)

    // main.cpp:

    Int main()
    {
    // Initialize the Memory Management Unit.
    mainMmuInit(applMmuEntries);

    // Initialize the Board module.
    boardInit();

    // Initialize the Watchdog Timer module.
    WtdDrv::Init();

    // Initialize the Debug console module.
    dcInit();

    // Advertise itself.
    AppSwVer::About();

    #ifndef _USE_WDT_
    dcPrint("Watchdog disabled.\n");
    #endif

    // Initialize the Health LED.
    mHealthLed.Config(HEALTH_LED);

    // Initialize the Date and Time module.
    DateTime::Init();

    // Initialize the CPU Load module.
    CpuLoad::Init();

    // Initialize the Network module.
    Ethernet::Init();

    // Initialize the Buffer Descriptor Pool module.
    BdPool::Init();

    // Initialize the Buffer Descriptor Mailbox module.
    BdMail::Init();

    .

    3).

    there is a relation about a .cfg file I think... I don't know much about this subject .. I tried to change it but I can't  find much information if I need it or not .. the part of  this file is showed bellow:

    startup.cfg (this file is originally created at 2018). 

    //----------------------------------------------------------------------------
    // NDK configuration
    //----------------------------------------------------------------------------

    var Global = xdc.useModule('ti.ndk.config.Global');
    var Icmp = xdc.useModule('ti.ndk.config.Icmp');
    var Ip = xdc.useModule('ti.ndk.config.Ip');
    //var Tcp = xdc.useModule('ti.ndk.config.Tcp');
    var Udp = xdc.useModule('ti.ndk.config.Udp');

    // With the autoOpenCloseFD parameter set to true, you do not have to call
    // fdOpenSession in the code (for dynamically created tasks). The downside is
    // that every task in the application will call fdOpenSession as part of a
    // create hook. Even ones that do not use the stack.
    //Global.autoOpenCloseFD = true;

    Global.netSchedulerPri = Global.NC_PRIORITY_HIGH;
    Global.ndkTickPeriod = 100;
    Global.kernTaskPriLevel = 11;
    Global.serviceReportHook = null;
    Global.IPv6 = false;
    Global.debugPrintLevel = Global.DBG_NONE;
    Global.debugAbortLevel = Global.DBG_NONE;

    // IP configuration
    //Ip.socketBufMinTxSize = 1;
    Ip.domainName = "ced2.net";

    // Settings for static IP configuration
    Ip.ResolveIP = false;
    Ip.CallByIP = false;
    Ip.autoIp = false;

    // If initializing without IP.
    Ip.address = "0.0.0.0";
    Ip.mask = "255.255.255.0";
    // If initializing with 2 IPs (Dual MAC mode operation)
    // Configure the second Ethernet interface here and the first interface programatically.
    // For Dual MAC mode operation, configure the second Ethernet interface here and
    // use the Global.stackInitHook to add a hook that performs the IP configuration of
    // the first interface programatically.
    //Ip.address = "192.168.2.34";
    //Ip.gatewayIpAddr = "192.168.2.2";
    //Ip.ifIdx = 2;


    // For Dual MAC mode operation add the hook Global.stackInitHook to perform the
    // IP configuration for the first interface programatically.
    //Global.stackInitHook = "&ethStackInitHook";

    4)

    " I have tried to enable this ifldx for 2 but ethStackInitHook is undefined and I don't know what it  means too.. It seams to me some kind of  initial setup when BIOS is started, isn't it ?

    Thanks for all,

             Semi

  • Hi Semi,

    The AM437x has two Ethernet processing IPs, EMAC and PRU-ICSS. The NDK can use either of them through NIMU, as described here.

    Can you check your BIOS configuration script .cfg file and see if there is something like below:

    var Nimu = xdc.loadPackage('ti.transport.ndk.nimu');

    If there is, can you try to replace it with 

    var Nimu_Icss 	= xdc.loadPackage('ti.transport.ndk.nimu_icss');
    

    This will configure NIMU to use PRU-ICSS instead of EMAC. See if you have the same problem. I'd like to see if your problem is caused by the EMAC driver or the NDK. 

    Thanks and regards,

    Jianzhong

  • Hi, 

     This is the results:

    CHANGES ON STARTUP.CFG:

    // Load the NIMU package

    // SLF 10.15.2021
    // From Texas forum--> Processors forum: AM437x when using eth0 and eth1 .. Ciclically eth1 is freezing transmission for almost 40seconds and the returns normal
    //var Nimu = xdc.loadPackage('ti.transport.ndk.nimu');
    var Nimu_Icss = xdc.loadPackage('ti.transport.ndk.nimu_icss');

    Nimu.Settings.socType = socType;

    Build Results:

    "C:\\ti\\ccs1031\\ccs\\utils\\bin\\gmake" -k -j 3 all -O

    Building file: "../startup.cfg"
    Invoking: XDCtools
    "C:/ti/xdctools_3_55_02_22_core/xs" --xdcpath="C:/ti/bios_6_76_03_01/packages;C:/ti/edma3_lld_2_12_05_30E/packages;C:/ti/ccs1031/ccs/ccs_base;C:/ti/pdk_am437x_1_0_17/packages;C:/ti/ndk_3_61_01_01/packages;" xdc.tools.configuro -o configPkg -t gnu.targets.arm.A9F -p ti.platforms.evmAM437X -r release -c "C:/ti/ccs1031/ccs/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major-win32" "../startup.cfg"
    making package.mak (because of package.bld) ...
    generating interfaces for package configPkg (because package/package.xdc.inc is older than package.xdc) ...
    configuring startup.xa9fg from package/cfg/startup_pa9fg.cfg ...
    subdir_rules.mk:26: recipe for target 'build-2068372575-inproc' failed
    js: "C:/workspace/ced2_v1000/startup.cfg", line 204: ReferenceError: "Nimu" is not defined. (C:/workspace/ced2_v1000/startup.cfg#204)
    "./package/cfg/startup_pa9fg.cfg", line 196
    gmake.exe: *** [package.mak:218: package/cfg/startup_pa9fg.xdl] Error 1
    js: "C:/ti/xdctools_3_55_02_22_core/packages/xdc/tools/Cmdr.xs", line 52: Error: xdc.tools.configuro: configuration failed due to earlier errors (status = 2); 'linker.cmd' deleted.
    gmake[1]: *** [build-2068372575-inproc] Error 1
    gmake: *** No rule to make target 'build-2068372575', needed by 'configPkg/compiler.opt'.
    gmake: *** No rule to make target 'build-2068372575', needed by 'configPkg/linker.cmd'.
    gmake: *** No rule to make target 'build-2068372575', needed by 'configPkg/compiler.opt'.

  • js: "C:/workspace/ced2_v1000/startup.cfg", line 204: ReferenceError: "Nimu" is not defined. (C:/workspace/ced2_v1000/startup.cfg#204)

    Please try this instead:

    var Nimu = xdc.loadPackage('ti.transport.ndk.nimu_icss');

  • I did that ......   socType is not recognized as part of nimu_icss then I comment it :

    // SLF 10.15.2021
    // From Texas forum--> Processors forum: AM437x when using eth0 and eth1 .. Ciclically eth1 is freezing transmission for almost 40seconds and the returns normal
    //var Nimu = xdc.loadPackage('ti.transport.ndk.nimu');
    var Nimu = xdc.loadPackage('ti.transport.ndk.nimu_icss');
    // Nimu.Settings.socType = socType;

    and I have this error:

    making ../src/sysbios/sysbios.aa9fg ...
    gmake[2]: Nothing to be done for 'all'.
    Building target: "ced2.out"
    Invoking: GNU Linker
    "C:/ti/ccs1031/ccs/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major-win32/bin/arm-none-eabi-gcc-7.2.1.exe" -mtune=cortex-a9 -marm -DSOC_AM437x -Dam4376 -D_USE_WDT_ -D_USE_RTC_ -D_USE_FS_ -D_LOG_MSGS_ -Dam4378 -O2 -Wall -faligned-new -mfloat-abi=hard -Wl,-Map,"ced2.map" -nostartfiles -static -Wl,--gc-sections -L"C:/ti/bios_6_76_03_01/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/lib/hard" -Wl,--defsym,STACKSIZE=0x18000 -Wl,--defsym,HEAPSIZE=0x1500 -Wl,--defsym,HEAPSIZE=0x400 --specs=nano.specs -o"ced2.out" "./bacmapl.o" "./bdapl.o" "./bdasciilogapl.o" "./bdbinlogapl.o" "./bdmailapl.o" "./bdpoolapl.o" "./boardapl.o" "./bpposapl.o" "./configapl.o" "./consoleapl.o" "./cpuloadapl.o" "./crcapl.o" "./datetimeapl.o" "./dcapl.o" "./dcpageapl.o" "./ethapl.o" "./eventapl.o" "./exmapl.o" "./fileloggerapl.o" "./filesystemapl.o" "./gpiodrvapl.o" "./ipgateapl.o" "./main.o" "./nimu_osal.o" "./rawosapl.o" "./routerapl.o" "./scigateapl.o" "./spidrvapl.o" "./spigateapl.o" "./sxcrvapl.o" "./uartdrvapl.o" "./udpapl.o" "./versionapl.o" "./wdtdrvapl.o" -Wl,-T"configPkg/linker.cmd" -Wl,--start-group -lnosys -lgcc -lc -lstdc++ -Wl,--end-group
    makefile:178: recipe for target 'ced2.out' failed
    ./ethapl.o: In function `Ethernet::Init()':
    C:\workspace\ced2_v1000\Release/../ethapl.cpp:106: undefined reference to `CpswEmacInit'
    C:\workspace\ced2_v1000\Release/../ethapl.cpp:106: undefined reference to `CpswEmacInit'
    collect2.exe: error: ld returned 1 exit status
    gmake[1]: *** [ced2.out] Error 1
    gmake: *** [all] Error 2
    makefile:174: recipe for target 'all' failed

  • Semi,

    Sorry for my mistake. Changing NIMU to use PRU-ICSS involves much more than BIOS configuration. The application code would need to be rewritten as well.

    Did the problem always happen on ETH1?

    Thanks,

    Jianzhong

  • Hi,

       Don't worry .... 

      Yes, the problem still happen only on Ethernet (Eth1) .. eth0 works pretty welll ...

    I make this change in he source code ...

    // Populate the NIMU Device Table to initialize 2 devices (Ethernet interfaces).
    // SLF 15.10.2021 .. changing fro nimu_iccs
    //NIMUDeviceTable[0].init = &CpswEmacInit;
    //NIMUDeviceTable[1].init = &CpswEmacInit;
    //NIMUDeviceTable[2].init = NULL;

    and the software builds now but I 'm having a error code on run-time console:

    *** Application Software for CED2/AM437x ***
    v2.0.00_beta30 200000.000 NIMUInit: Could not init any NIMU devices.
    00000.000 Shutting down the stack, because NIMUInit could not initialize any devices
    00000.000

    NC_NetStart: WARNING: Boot thread has not completed!

    I  think it's necessary initialize something else ......   Do you know what ??

    Thankssssss

  • Semi,

    More work is needed to change your code to use PRU-ICSS. If you have the Processor SDK for AM437x installed, you can look at NIMU examples inside the PDK: pdk_am437x_1_0_17\packages\ti\transport\ndk\nimu_icss\example\src\main_a9.c. You can also follow instructions in this FAQ to create the PDK example projects and look into NIMU_ICSS_BasicExample_idkAM437x_wSoCLib_armExampleproject.

    Regards,

    Jianzhong

  • Hi,

        I have checked the examples but it was used as a model when the source code was done for the first time.... then there is nothing to change ....   Making some tests I discovered that "emac_poll" is not checking the eth1 link state  .. only eth0 .....  When I disconnect eth0 cable eth1 link state goes down too .... when I disconnect eth1 the eth0 shows link up ..... Do you have any correction of emac_poll service???? Now Im using the last release of all texas packages.... 

    Thanks

  • Please check EMAC LLD documentation: pdk_am437x_1_0_17\packages\ti\drv\emac\docs\EMAC_LLD_SD.pdf