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.

AM2434: EtherCAT Subdevice buffer handling api not functional with 09.01 version

Part Number: AM2434

Hi there,

I tried to switch to industrial communications SDK version 09.01.00.41 from 09.00.00.03, unfortunately the buffer handling API I use is not functional anymore. I use the ethercat_slave_simple_demo_am243x-evm_r5fss0-0_freertos_ti-arm-clang example and I just add the following lines

1) after EC_API_SLV_cbRegisterUserApplicationRun

    /* buffer callbacks */
    EC_API_SLV_cbRegisterPreSeqInputPDBuffer(pAppInstance_p->ptEcSlvApi, pAppInstance_p->ptEcSlvApi, acquireBuffer);
    EC_API_SLV_cbRegisterPostSeqInputPDBuffer(pAppInstance_p->ptEcSlvApi, pAppInstance_p->ptEcSlvApi, releaseBuffer);

2) two simple callbacks just passing a buffer to stack

static uint8_t data[1024]={0};
static void * acquireBuffer(void* pContext_p, uint32_t length_p)
{
    return &data[0];
}

static void releaseBuffer(void* pContext_p, void* pData_p, uint32_t length_p)
{
// just a test nothing to do here
}

As soon as the EtherCAT stack should go into operational state (triggered by TwinCAT Master) the complete core crashes and is stuck in data abort handler. I also had break points in my buffer functions, but they haven't been called

PS: also EtherCAT Slave Stack's documentation is missing, clicking "API Documentation" here leads to nowhere: software-dl.ti.com/.../EXAMPLES_INDUSTRIAL_COMMS_ETHERCAT_SLAVE_DEMOS.html

  • Hi Dominic, thanks for bringing documentation link issue to our attention, I will file a JIRA to fix it.

    In the meantime, you can access EtherCAT Slave API documentation from MCU-SDK docs. Ex: C:/ti/ind_comms_sdk_am243x_09_00_00_03/docs/am243x/ethercat_slave/modules.html 

    From documentation, I don't see any changes done to above APIs from 9.0 to 9.1.

    To replicate the issue where you added callback functions? if you can send me a patch to use on top of 9.1 it would be great.

    On the other hand, just confirming, in 9.1 w/o above modifications, ethercat_slave_simple_demo_am243x-evm_r5fss0-0_freertos_ti-arm-clang works OK, right?

    thank you,

    Paula

  • Hi Paula,

    sorry for the late response, I was not at work for some time.

    Without these changes example is working just fine, that is correct.

    Here is a patch with the changes made to the example.

    diff --git a/ecSlvSimple.c b/ecSlvSimple.c
    index 7670305..7339d74 100644
    --- a/ecSlvSimple.c
    +++ b/ecSlvSimple.c
    @@ -2930,6 +2930,17 @@ static bool EC_SLV_APP_EoE_SS_receiveHandler(void* pContext_p, uint16_t* pData_p
         return true;
     }
    
    +static uint8_t data[1024]={0};
    +
    +static void*acquireBuffer(void* pContext_p, uint32_t length_p)
    +{
    +    return &data[0];
    +}
    +
    +static void releaseBuffer(void* pContext_p, void* pData_p, uint32_t length_p)
    +{
    +}
    +
     /*!
      *  <!-- Description: -->
      *
    @@ -3088,16 +3099,22 @@ void EC_SLV_APP_SS_applicationInit(EC_SLV_APP_SS_Application_t *pAppInstance_p)
         EC_API_SLV_DIAG_enable(pAppInstance_p->ptEcSlvApi);
    
     #if !(defined DPRAM_REMOTE) && !(defined FBTL_REMOTE) && !(defined OSAL_FREERTOS_JACINTO) /* first omit flash */
    -    EC_API_SLV_cbRegisterFlashInit              (pAppInstance_p->ptEcSlvApi, EC_SLV_APP_EEP_initFlash, pAppInstance_p->ptEcSlvApi);
    +    // currently not supported for our custom board
    +
    +    // EC_API_SLV_cbRegisterFlashInit              (pAppInstance_p->ptEcSlvApi, EC_SLV_APP_EEP_initFlash, pAppInstance_p->ptEcSlvApi);
         /* @cppcheck_justify{misra-c2012-11.6} void cast required for signature */
         /* cppcheck-suppress misra-c2012-11.6 */
    -    EC_API_SLV_EEPROM_cbRegisterWrite           (pAppInstance_p->ptEcSlvApi,   EC_SLV_APP_EEP_writeEeprom, OSPIFLASH_APP_STARTMAGIC);
    +    // EC_API_SLV_EEPROM_cbRegisterWrite           (pAppInstance_p->ptEcSlvApi,   EC_SLV_APP_EEP_writeEeprom, OSPIFLASH_APP_STARTMAGIC);
         /* @cppcheck_justify{misra-c2012-11.6} void cast required for signature */
         /* cppcheck-suppress misra-c2012-11.6 */
    -    EC_API_SLV_EEPROM_cbRegisterLoad            (pAppInstance_p->ptEcSlvApi,   EC_SLV_APP_EEP_loadEeprom, OSPIFLASH_APP_STARTMAGIC);
    +    // EC_API_SLV_EEPROM_cbRegisterLoad            (pAppInstance_p->ptEcSlvApi,   EC_SLV_APP_EEP_loadEeprom, OSPIFLASH_APP_STARTMAGIC);
     #endif
         EC_API_SLV_cbRegisterUserApplicationRun     (pAppInstance_p->ptEcSlvApi, EC_SLV_APP_SS_applicationRun, pAppInstance_p);
    
    +    /* buffer callbacks */
    +    EC_API_SLV_cbRegisterPreSeqInputPDBuffer(pAppInstance_p->ptEcSlvApi, pAppInstance_p->ptEcSlvApi, acquireBuffer);
    +    EC_API_SLV_cbRegisterPostSeqInputPDBuffer(pAppInstance_p->ptEcSlvApi, pAppInstance_p->ptEcSlvApi, releaseBuffer);
    +
         error = (EC_API_EError_t)EC_API_SLV_init(pAppInstance_p->ptEcSlvApi);
         if (error != EC_API_eERR_NONE)
         {
    @@ -3350,6 +3367,9 @@ static void EC_SLV_APP_SS_applicationRun(void* pAppCtxt_p)
                 }
    
     #if !(defined FBTL_REMOTE) || (0 == FBTL_REMOTE)
    +#if 0
    +            // I don't use this code, as processdata is updated via callbacks only
    +
                 err = (EC_API_EError_t)EC_API_SLV_PDO_setEntryData(pApplicationInstace->ptEcSlvApi
                         ,pApplicationInstace->ptTxPdo1A00
                         ,1
    @@ -3359,6 +3379,7 @@ static void EC_SLV_APP_SS_applicationRun(void* pAppCtxt_p)
                 {
                     OSAL_printf("Fill Description Object Error code: 0x%08x\r\n", err);
                 }
    +#endif
     #endif
             }
             else
    @@ -3394,6 +3415,9 @@ static void EC_SLV_APP_SS_applicationRun(void* pAppCtxt_p)
                         lastLed = (lastLed << 1u);
                     }
    
    +#if 0
    +                // I don't use this code, as processdata is updated via callbacks only
    +
                     //Write Led data to the process data. It can be seen in OBD in Object 0x2002:2 as well.
                     error = EC_API_SLV_PDO_setEntryData(
                             pApplicationInstace->ptEcSlvApi,
    @@ -3406,6 +3430,7 @@ static void EC_SLV_APP_SS_applicationRun(void* pAppCtxt_p)
                     {
                         OSAL_printf("%s:%d:E=0x%x\r\n", __func__, __LINE__, error);
                     }
    +#endif
                 }
             }
    

  • Hi Dominic, thanks, please allow me some time (a couple of days) to get a setup ready and reproduce.

    thank you,

    Paula

  • Hi Dominic, using your changes in 9.1 didn't work for me either (changes, as you mentioned worked for 9.0). Then I double checked documentation and found:

    EtherCAT Slave: API Changes (ti.com)

    Somehow, I missed this before, my apology.

    thank you,

    Paula

  • Hi Paula,

    thanks for your help! Now I see the problem. I wasn't aware of the API change, but position of callback function and context have been swapped. That's a dangerous change

    I wonder why compiler didn't notice. Nevertheless, I did a quick test by swapping both parameters. Now I do not get any hard fault anymore, so I think the problem is fixed. If there is another problem I will reopen/or open another issue.

    Thanks,

    Dominik