AM6442: Ethercat Beckhoff SSC demo - Application I/O mapping events not triggered

Part Number: AM6442

Tool/software:

I'm trying to make the 'ethercat_slave_beckhoff_ssc_demo' work (Industrial sdk v11.00.00), with a custom board where the ethercat phy is connected to PRU_ICSS0 instead of PRU_ICSS1 as in the example.

I modified tiescsoc.c to use a different PRU_ICSS:

===================================================================
--- tiescsoc.c	(revision 44)
+++ tiescsoc.c	(working copy)
@@ -43,6 +43,7 @@
 #include <kernel/dpl/DebugP.h>
 #include "ti_board_open_close.h"
 #include "ti_drivers_config.h"
+#undef ICSSG0_INSTANCE
 #include <industrial_comms/ethercat_slave/beckhoff_stack/stack_hal/tieschw.h>
 #include "tiesc_eeprom.h" /* header equivalent of ESI bin file */
 #ifdef  MDIO_MANUAL_MODE_ENABLED
@@ -197,8 +198,8 @@
     const PRUICSS_HwAttrs *pruicssHwAttrs;
     uint32_t inEventLatch0, inEventLatch1, outEventLatch0, outEventLatch1;
 
-    pruIcss1Handle = PRUICSS_open(CONFIG_PRU_ICSS1);
-    pruicssHwAttrs = PRUICSS_getAttrs(CONFIG_PRU_ICSS1);
+    pruIcss1Handle = PRUICSS_open(CONFIG_PRU_ICSS0);
+    pruicssHwAttrs = PRUICSS_getAttrs(CONFIG_PRU_ICSS0);
 
     /* Selecting MII-RT mode in GPCFG mux */
     PRUICSS_setGpMuxSelect(pruIcss1Handle, PRUICSS_PRU0, PRUICSS_GP_MUX_SEL_MODE_MII);

 
 void tiesc_getFoeFlashOffset(uint32_t *offset)
@@ -315,7 +316,7 @@
 
 int32_t tiesc_getArmInterruptOffset()
 {
-    PRUICSS_HwAttrs const *pruicssHwAttrs = PRUICSS_getAttrs(CONFIG_PRU_ICSS1);
+    PRUICSS_HwAttrs const *pruicssHwAttrs = PRUICSS_getAttrs(CONFIG_PRU_ICSS0);
     int32_t interruptOffset = 0;

So far, I've been able to initialize the slave with a master, I can read the slave XML info and change state. But if I read/write PDO, the functions APPL_OutputMapping and APPL_InputMapping are not called accordingly. Tracing back, it looks like PDITask is stuck waiting for an event:

void PDItask(void *arg)
{
//    TaskP_sleep(10 * OS_TICKS_IN_MILLI_SEC);
    /*TODO: Check if following is correct*/
    ClockP_usleep(10 * 1000);
#if AL_EVENT_ENABLED
    uint32_t evtOutNum = HOST_AL_EVENT - 20;
    while(1)
    {
        PRUICSS_waitEvent((PRUICSS_Handle)arg, evtOutNum);
        /* ISR processing */
        HW_EcatIsr();
    }
#endif //AL_EVENT_ENABLED
}

Using the memory browser (via debug probe) I see that the PDO data from the master is written in the corresponding registers (0x30017000 for RxPDO entry 0x7000). I also note that PDO_InputMapping is called from the application main loop. Because of this, I can also verify that the TxPDO is transferred correctly to the master.

void MainLoop(void)
{
    
    /*return if initialization not finished */
    if(bInitFinished == FALSE)
    {
        return;
    }



        /* FreeRun-Mode:  bEscIntEnabled = FALSE, bDcSyncActive = FALSE
           Synchron-Mode: bEscIntEnabled = TRUE, bDcSyncActive = FALSE
           DC-Mode:       bEscIntEnabled = TRUE, bDcSyncActive = TRUE */
        if (
            (!bEscIntEnabled || !bEcatFirstOutputsReceived)     /* SM-Synchronous, but not SM-event received */
          && !bDcSyncActive                                               /* DC-Synchronous */
            )
        {
            /* if the application is running in ECAT Synchron Mode the function ECAT_Application is called
               from the ESC interrupt routine,
               in ECAT Synchron Mode it should be additionally checked, if the SM-event is received
               at least once (bEcatFirstOutputsReceived = 1), otherwise no interrupt is generated
               and the function ECAT_Application has to be called here (with interrupts disabled,
               because the SM-event could be generated while executing ECAT_Application) */
            if ( !bEscIntEnabled )
            {
                /* application is running in ECAT FreeRun Mode,
                   first we have to check, if outputs were received */
                UINT16 ALEvent = HW_GetALEventRegister();
                ALEvent = SWAPWORD(ALEvent);

                if ( ALEvent & PROCESS_OUTPUT_EVENT )
                {
                    /* set the flag for the state machine behavior */
                    bEcatFirstOutputsReceived = TRUE;
                    if ( bEcatOutputUpdateRunning )
                    {
                        /* update the outputs */
                        PDO_OutputMapping();
                    }
                }
                else if ( nPdOutputSize == 0 )
                {
                    /* if no outputs are transmitted, the watchdog must be reset, when the inputs were read */
                    if ( ALEvent & PROCESS_INPUT_EVENT )
                    {
                        /* Outputs were updated, set flag for watchdog monitoring */
                        bEcatFirstOutputsReceived = TRUE;
                    }
                }
            }

            DISABLE_ESC_INT();
             ECAT_Application();

/*ECATCHANGE_START(V5.13) ECAT 5*/
             if ( (bEcatInputUpdateRunning  == TRUE) && (nPdInputSize > 0))
/*ECATCHANGE_END(V5.13) ECAT 5*/
             {
                /* EtherCAT slave is at least in SAFE-OPERATIONAL, update inputs */
                PDO_InputMapping();
            }
            ENABLE_ESC_INT();
        }

So, to sum up, I'm able to verify:

- Physical link is established OK

- Master can initialize and get slave info. It can also set it's state

- PDO data is exchanged between master and ESC

What further steps can I take to troubleshoot this? Why is the PDI task hang in PRUICSS_waitEvent?

I've seen a previous thread with a similar issue, but the solution was not published: e2e.ti.com/.../tmds64evm-ethercat-pdo-communication-does-not-work-rx-txpdo-addresses-are-changed

  • Hi Martin,

    Apologies for the delay in response.

    Tracing back, it looks like PDITask is stuck waiting for an event:

    So the task is waiting for the AL Event?

    I've seen a previous thread with a similar issue, but the solution was not published: e2e.ti.com/.../tmds64evm-ethercat-pdo-communication-does-not-work-rx-txpdo-addresses-are-changed

    The solution wasn't public then. Now, it should be available in the latest Industrial Communications SDK (v11.00).

    Can you share the wireshark logs for the communication and also the complete ICSS Memory Dump (0x30000000 to 0x30040000)

    Regards,
    Aaron

  • Hi Aaron

    Sorry for the delay, I'm back to working on this project.

    So the task is waiting for the AL Event?

    Correct. PDItask never resumes after calling PRUICSS_waitEvent()

    Can you share the wireshark logs for the communication and also the complete ICSS Memory Dump (0x30000000 to 0x30040000)

    Wireshark capture: https://drive.proton.me/urls/G046MX09RW#KGsJRvffIenK

    The sequence is:

    1- EC Master start

    2- Application start (around packet #1250)

    3- Application stop (around packet #3600)

    The master application is cyclically reading the full TxPDO, and writing 0x55AA/0xAA55 into every RxPDO entry.

    The connection is direct Master <-> Slave (other than the tap I'm using for capture).

    SM/PDO mapping:

    SM0: PhysAddr 0x1000, DefaultSize  128, ControlRegister 0x26, Enable 1
    SM1: PhysAddr 0x1080, DefaultSize  128, ControlRegister 0x22, Enable 1
    SM2: PhysAddr 0x1100, DefaultSize   52, ControlRegister 0x64, Enable 1
      RxPDO 0x1600 "Dn process data mapping"
        PDO entry 0x7000:01, 16 bit, ""
        PDO entry 0x7000:02, 16 bit, ""
        PDO entry 0x7000:03, 16 bit, ""
        PDO entry 0x7000:04, 16 bit, ""
        PDO entry 0x7000:05, 16 bit, ""
        PDO entry 0x7000:06, 16 bit, ""
        PDO entry 0x7000:07, 16 bit, ""
        PDO entry 0x7000:08, 16 bit, ""
        PDO entry 0x7000:09, 16 bit, ""
        PDO entry 0x7000:0a, 16 bit, ""
        PDO entry 0x7000:0b, 16 bit, ""
        PDO entry 0x7000:0c, 16 bit, ""
        PDO entry 0x7000:0d, 16 bit, ""
        PDO entry 0x7000:0e, 16 bit, ""
        PDO entry 0x7000:0f, 16 bit, ""
        PDO entry 0x7000:10, 16 bit, ""
        PDO entry 0x7000:11, 16 bit, ""
        PDO entry 0x7000:12, 16 bit, ""
        PDO entry 0x7000:13, 16 bit, ""
        PDO entry 0x7000:14, 16 bit, ""
        PDO entry 0x7000:15, 16 bit, ""
        PDO entry 0x7000:16, 16 bit, ""
        PDO entry 0x7000:17, 16 bit, ""
        PDO entry 0x7000:18, 16 bit, ""
        PDO entry 0x7000:19, 16 bit, ""
        PDO entry 0x7000:1a, 16 bit, ""
    SM3: PhysAddr 0x1400, DefaultSize   42, ControlRegister 0x20, Enable 1
      TxPDO 0x1a00 "Up process data mapping"
        PDO entry 0x6000:01, 16 bit, ""
        PDO entry 0x6000:02, 16 bit, ""
        PDO entry 0x6000:03, 16 bit, ""
        PDO entry 0x6000:04, 16 bit, ""
        PDO entry 0x6000:05, 16 bit, ""
        PDO entry 0x6000:06, 16 bit, ""
        PDO entry 0x6000:07, 16 bit, ""
        PDO entry 0x6000:08, 16 bit, ""
        PDO entry 0x6000:09, 16 bit, ""
        PDO entry 0x6000:0a, 16 bit, ""
        PDO entry 0x6000:0b, 16 bit, ""
        PDO entry 0x6000:0c, 16 bit, ""
        PDO entry 0x6000:0d, 16 bit, ""
        PDO entry 0x6000:0e, 32 bit, ""
        PDO entry 0x6000:0f, 32 bit, ""
        PDO entry 0x6000:10, 32 bit, ""
        PDO entry 0x6000:11, 32 bit, ""

    For additional information, this is the EC master log:

    [  446.700397] EtherCAT: Master driver 1.6.3 unknown
    [  446.705677] EtherCAT: 1 master waiting for devices.
    [  446.748187] ec_generic: EtherCAT master generic Ethernet device module 1.6.3 unknown
    [  446.756379] EtherCAT: Accepting 28:B5:E8:CF:E8:25 as main device for master 0.
    [  446.763946] ec_generic: Binding socket to interface 4 (eth0).
    [  446.790111] EtherCAT 0: Starting EtherCAT-IDLE thread.
    [  446.795543] EtherCAT 0: Link state of ecm0 changed to UP.
    [  446.803890] EtherCAT 0: 1 slave(s) responding on main device.
    [  446.811526] EtherCAT 0: Slave states on main device: PREOP.
    [  446.818040] EtherCAT 0: Scanning bus.
    [  446.866700] EtherCAT 0: Bus scanning completed in 52 ms.
    [  446.872052] EtherCAT 0: Using slave 0 as DC reference clock.
    [  452.854273] EtherCAT: Requesting master 0...
    [  452.858724] EtherCAT: Successfully requested master 0.
    [  452.865546] EtherCAT 0: Domain0: Logical address 0x00000000, 94 byte, expected working counter 3.
    [  452.875155] EtherCAT 0:   Datagram domain0-0-main: Logical offset 0x00000000, 94 byte, type LRW.
    [  452.884734] EtherCAT 0: Master thread exited.
    [  452.889193] EtherCAT 0: Starting EtherCAT-OP thread.
    [  453.174104] EtherCAT WARNING 0: No application time received up to now, but master already active.
    [  453.366105] EtherCAT 0: Domain 0: Working counter changed to 3/3.
    [  453.410100] EtherCAT 0: Slave states on main device: OP.
    [  458.270700] EtherCAT 0: Releasing master...
    [  458.275035] EtherCAT 0: Master thread exited.
    [  458.279460] EtherCAT 0: Starting EtherCAT-IDLE thread.
    [  458.284956] EtherCAT 0: Released.
    [  458.298226] EtherCAT 0: Slave states on main device: PREOP.
    [  461.380648] EtherCAT 0: Master thread exited.
    [  461.385323] EtherCAT 0: Releasing main device 28:B5:E8:CF:E8:25.
    [  461.410182] ec_generic: Unloading.
    [  461.457955] EtherCAT: Master module cleaned up.

    ICSS Memory dump: https://drive.proton.me/urls/VQE79D75N8#KZo5xNrmh554

    This is the memory state after the previous sequence. You can see that the registers corresponding to SM2 (0x30011100) are filled with alternating 0x55AA/0xAA55 coming from the master.

  • Hi Martin,

    Thank you for the details. I’ll review this and get back by early next week.

    Regards,
    Aaron

  • Hi Aaron,

    I tried a simple application based on the SOEM library instead of IgH EC Master, and this one worked as expected: the PDItask resumes after waiting on PRUICSS_waitEvent(), and in turn calls the PDO mapping handlers. So it seems like the ESC reacts differently for these 2 master implementations. Switching to SOEM is not an option for this current project, but I hope this can be helpful for troubleshooting.

    I'm attaching the memory dump and wireshark capture for the SOEM test:

    https://drive.proton.me/urls/47PGW853A8#NzDBjC81DfHR

  • Hi Martin, 

    I tried a simple application based on the SOEM library instead of IgH EC Master, and this one worked as expected: the PDItask resumes after waiting on PRUICSS_waitEvent(), and in turn calls the PDO mapping handlers. So it seems like the ESC reacts differently for these 2 master implementations. Switching to SOEM is not an option for this current project, but I hope this can be helpful for troubleshooting.

    Thanks for this update. So issue is specific with IgH handling.

    Is it possible to share the Memory dump and wireshark logs in a zip folder. The above link domain is blocked by the web filter.

    Regards,
    Aaron

  • Hi Aaron,

    I'm attaching the files for both scenarios: with IgH master, and with SOEM:

    Igh_TI.zip

    SOEM_sample_TI.zip