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.

AM4379: EtherCat Slave SDO upload issue

Part Number: AM4379

Hi,

 I try to debug some SDO upload request (expedited) of specific index at specific slave address that don't work.

Soon we figured out that the address that we send to the PRU and the one on the "wire" was not the same.

As far as I can follow the address, his value is as wanted:

UINT8 MBX_CopyToSendMailbox( TMBX MBXMEM *pMbx )
{
    if ( (nAlStatus & STATE_MASK) == STATE_INIT)
    {
        /* the mailbox is disabled if the slave is in the INIT state */
        return( ERROR_INVALIDSTATE );
    }


    if ( !bMbxRunning )
    {
        /* the mailbox is disabled if the slave is in the INIT state */
        return( ERROR_INVALIDSTATE );
    }

    if ( bSendMbxIsFull )
    {
        /* mailbox service cannot be sent because the send mailbox is still full */
        return MBXERR_NOMOREMEMORY;
    }
    else
    {
        /* the variable mbxSize contains the size of the mailbox data to be sent */
        UINT16 mbxSize = pMbx->MbxHeader.Length;
        PRINTLN("HW_EscWriteMbxMem at addr: 0x%X", pMbx->MbxHeader.Address); /////////////////////////////// output:  HW_EscWriteMbxMem at addr: 0x3EA
        HW_EscWriteMbxMem((MEM_ADDR *)pMbx, u16EscAddrSendMbx, (mbxSize + MBX_HEADER_SIZE));


Wireshark trace:

Frame 964: 71 bytes on wire (568 bits), 71 bytes captured (568 bits) on interface 0
    Interface id: 0 (\Device\NPF_{D1941824-1A2A-45F5-9238-CCAE8E883F8B})
        Interface name: \Device\NPF_{D1941824-1A2A-45F5-9238-CCAE8E883F8B}
    Encapsulation type: Ethernet (1)
    Arrival Time: Aug  6, 2019 14:26:16.629419000 Eastern Daylight Time
    [Time shift for this packet: 0.000000000 seconds]
    Epoch Time: 1565115976.629419000 seconds
    [Time delta from previous captured frame: 0.000008000 seconds]
    [Time delta from previous displayed frame: 0.000000000 seconds]
    [Time since reference or first frame: 1.154025000 seconds]
    Frame Number: 964
    Frame Length: 71 bytes (568 bits)
    Capture Length: 71 bytes (568 bits)
    [Frame is marked: False]
    [Frame is ignored: False]
    [Protocols in frame: eth:ethertype:ecatf:ecat:ecat_mailbox]
Ethernet II, Src: Beckhoff_01:00:00 (01:01:05:01:00:00), Dst: 22:47:47:cc:37:f4 (22:47:47:cc:37:f4)
    Destination: 22:47:47:cc:37:f4 (22:47:47:cc:37:f4)
        Address: 22:47:47:cc:37:f4 (22:47:47:cc:37:f4)
        .... ..1. .... .... .... .... = LG bit: Locally administered address (this is NOT the factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Source: Beckhoff_01:00:00 (01:01:05:01:00:00)
        [Expert Info (Warning/Protocol): Source MAC must not be a group address: IEEE 802.3-2002, Section 3.2.3(b)]
            [Source MAC must not be a group address: IEEE 802.3-2002, Section 3.2.3(b)]
            [Severity level: Warning]
            [Group: Protocol]
        Address: Beckhoff_01:00:00 (01:01:05:01:00:00)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...1 .... .... .... .... = IG bit: Group address (multicast/broadcast)
    Type: EtherCAT frame (0x88a4)
EtherCAT frame header
    .... .000 0011 0111 = Length: 0x037
    .... 0... .... .... = Reserved: Valid (0x0)
    0001 .... .... .... = Type: EtherCAT command (0x1)
EtherCAT datagram(s): 3 Cmds, 'FPRD': len 16, 'FPRD': len 1, 'FPRD': len 2
    EtherCAT datagram: Cmd: 'FPRD' (4), Len: 16, Adp 0x3e9, Ado 0x1080, Cnt 1
        Header
            Cmd        : 4 (Configured address Physical Read)
            Index: 0xaa
            Slave Addr: 0x03e9
            Offset Addr: 0x1080
            Length     : 16 (0x10) - No Roundtrip - More Follows...
                .... .000 0001 0000 = Length: 16
                ..00 0... .... .... = Reserved: Valid (0)
                .0.. .... .... .... = Round trip: Frame is not circulating
                1... .... .... .... = Last indicator: More EtherCAT datagrams will follow
            Interrupt: 0x0000
        EtherCAT Mailbox Protocol:CoE SDO Req : 'Initiate Upload' (2) Idx=0x1001 Sub=0
            Header
                Length: 10
                Address: 0x03e9
                .... ..00 = Priority: 0
                Type: CoE (CANopen over EtherCAT) (3)
                Counter: 2
            CoE
                Number: 0
                Type: SDO Req (2)
                SDO Req : 'Initiate Upload' (2) Idx=0x1001 Sub=0
                    Init Upload: 0x40
                        ...0 .... = Access: Legacy
                Index: 0x1001
                SubIndex: 0x00
        Working Cnt: 1
    EtherCAT datagram: Cmd: 'FPRD' (4), Len: 1, Adp 0x3e9, Ado 0x10ff, Cnt 1
        Header
            Cmd        : 4 (Configured address Physical Read)
            Index: 0x00
            Slave Addr: 0x03e9
            Offset Addr: 0x10ff
            Length     : 1 (0x1) - No Roundtrip - More Follows...
                .... .000 0000 0001 = Length: 1
                ..00 0... .... .... = Reserved: Valid (0)
                .0.. .... .... .... = Round trip: Frame is not circulating
                1... .... .... .... = Last indicator: More EtherCAT datagrams will follow
            Interrupt: 0x0000
        Data: 00
        Working Cnt: 1
    EtherCAT datagram: Cmd: 'FPRD' (4), Len: 2, Adp 0x3eb, Ado 0x1080, Cnt 0
        Header
            Cmd        : 4 (Configured address Physical Read)
            Index: 0x00
            Slave Addr: 0x03eb
            Offset Addr: 0x1080
            Length     : 2 (0x2) - No Roundtrip - Last Sub Command
                .... .000 0000 0010 = Length: 2
                ..00 0... .... .... = Reserved: Valid (0)
                .0.. .... .... .... = Round trip: Frame is not circulating
                0... .... .... .... = Last indicator: Last EtherCAT datagram
            Interrupt: 0x0000
        Data: 0000
        Working Cnt: 0

 

 

 

Version - EtherCAT Slave 01.00.07.02

Board name      : AM43_IDK

Board Revision  : 1.4A

EtherCAT Device

SYS/BIOS EtherCAT Internal application 3.3.0ENETPHY_FindingState: PhyNum: 0

I already tried this:

#define ENABLE_MULTIPLE_SM_ACCESS_IN_SINGLE_DATAGRAM 1

Thank you

Stéphane Germain

  • Hi,

    My previous post was not as clear as in the preview and I got a new "print" more near of the HW.

    That still shows the right byte that we expect to be put on the wire by the PRU are not see as well by Wireshark.

    So I create a new bsp_write (bsp_write_debug) and I call it only in "HW_EscWriteMbxMem" to not be spammed too much.

    void bsp_write_debug(PRUICSS_Handle pruIcssHandle, uint8_t *pdata, uint16_t address, uint16_t len){

        if(0 == bsp_pdi_access_perm_array(address, PDI_PERM_WRITE, len)) {

           ...

        }

        uint8_t *pEsc = (uint8_t *)(((PRUICSS_HwAttrs *)(pruIcssHandle->hwAttrs))->baseAddr + PRU_ICSS_SHARED_RAM);

        tiesc_memcpy(&pEsc[address], pdata, len); //memcpy(dest, src, len)

        PRINTF("bsp_write_debug (len=0x%X): ", len);
        for(int i=0; i< len; i++)
        {
            PRINTF("0x%X ", pdata[i]);
        }
        PRINTLN("");

        ASSERT_DMB();

    }

    Here the result of the print:

    bsp_write_debug (len=0x10): 0xA 0x0 0xEA 0x3 0x0 0x23 0x0 0x20 0x40 0x1 0x10 0x0 0x53 0x54 0x3A 0x75

    Again, here the address in WireShark:

    [...]

    EtherCAT Mailbox Protocol:CoE SDO Req : 'Initiate Upload' (2) Idx=0x1001 Sub=0
    Header
    Length: 10
    Address: 0x03e9
    [...]

    I can confirm that the PRU use in some way or another the address of "itself" because I modify my slave address and the result on the wire change accordingly.

    The end result is, I cannot reach the targeted slave!

    Thanks

    Stéphane Germain

  • Hi Stephane,

    Is it the fixed offset '1' (0x03ea- 0x03e9) between the written address and captured on the wireshark?

    Can you please show a connection topology of your setup including master and slaves? How can this be reproduced in my side?

    Regards,

    Garrett

  • Hi Garrett,

     

    The offset is 1 only because the two slaves are "side by side" with address automatically assigned by the master.

     

    The simplest configuration that can reproduce the bug is:

    Master (TC3 win x86) -> Sitara with full slave EtherCat demo (Addr: 0x03e9) -> OtherSlave / Elmo drive (Addr: 0x03ea)

     

    On the sitara I execute the code to do an  SDO upload request:

       //Slave to slave SDO communication test

       static TINITSDOUPLOADREQMBX MBXMEM *pMbx;

       if(bMbxRunning && s_iMbxTestAtAddr != 0)

       {

           PRINTLN("\r\nSlave to slave SDO communication test At addr: %d", s_iMbxTestAtAddr);

     

           pMbx = (TINITSDOUPLOADREQMBX MBXMEM *) APPL_AllocMailboxBuffer(sizeof(TINITSDOUPLOADREQMBX)); // allocate buffer for the

           if(pMbx)

           {

               HMEMSET(pMbx, 0x00, sizeof(TINITSDOUPLOADREQMBX)); //clear allocated buffer

     

               pMbx->MbxHeader.Length = EXPEDITED_FRAME_SIZE;

               pMbx->MbxHeader.Address = s_iMbxTestAtAddr;

               pMbx->MbxHeader.Flags[MBX_OFFS_TYPE] = (MBX_TYPE_COE << MBX_SHIFT_TYPE);

     

               pMbx->CoeHeader = ((UINT16)COESERVICE_SDOREQUEST) << COEHEADER_COESERVICESHIFT;

     

               pMbx->SdoHeader.Sdo[SDOHEADER_COMMANDOFFSET] = SDOSERVICE_INITIATEUPLOADREQ;

     

               pMbx->SdoHeader.Sdo[SDOHEADER_INDEXHIOFFSET] = MSB8(s_iMbxTestAtIndex);

               pMbx->SdoHeader.Sdo[SDOHEADER_INDEXLOOFFSET] = (LSB8(s_iMbxTestAtIndex) << SDOHEADER_INDEXLOSHIFT);

               pMbx->SdoHeader.Sdo[SDOHEADER_SUBINDEXOFFSET] = (s_iMbxTestAtSubIndex << SDOHEADER_SUBINDEXSHIFT);

     

               int MBX_ret = MBX_MailboxSendReq((TMBX MBXMEM *)pMbx, COE_SERVICE);

               PRINTLN("\r\nMBX_MailboxSendReq return: %d", MBX_ret);

               if (MBX_ret != 0)

               {

                   APPL_FreeMailboxBuffer(pMbx);

               }

     

               s_iMbxTestAtAddr = 0;

           }

       }

     

    With :

    s_iMbxTestAtAddr = 0x3ea;

    s_iMbxTestAtIndex=0x1001;

    s_iMbxTestAtSubIndex = 0;

    You also need to modify the ecatcoe.c to handle reply:

    UINT8 COE_ServiceInd(TCOEMBX MBXMEM *pCoeMbx)

    {

       UINT8 result = 0;

       switch ((pCoeMbx->CoeHeader & COEHEADER_COESERVICEMASK) >> COEHEADER_COESERVICESHIFT)

       {

    ...

       case COESERVICE_SDORESPONSE:

           PRINTF("\r\nCOE_ServiceInd COESERVICE_SDORESPONSE Addr: %d Len: %d ", pCoeMbx->MbxHeader.Address, pCoeMbx->MbxHeader.Length);

           ...

           break;

    ...

     

    You will see:
    1 - No reply / print about COESERVICE_SDORESPONSE

    2- In Wireshark that the address of 0x3ea is replaced by 0x3e9 (the sitara address)


    The bug only append with expedited upload (<= 4 bytes payload reply) but not all.
    Example, Index 0x1000 work well (In fact, is is the only one that I saw work).

    Thanks
    Stéphane Germain

     

     

     

     

     

     

  • Hi Stéphane,

    Where do you put the SDO upload request code? If adding in APPL_Application() with index 0x1001, I am seeing

    MBX_MailboxSendReq return: 0
    Slave to slave SDO communication test At addr: 1002
    COE_ServiceInd COESERVICE_SDORESPONSE Addr: 1002 Len: 10

    Regards,
    Garrett

  • Hi Garrett,

     I also put it in APPL_Application()

    So, you receive a response of your other slave!

    What do you use as slave 2 (at address 1002)?

    I would like to try other kind of slave but I only have Elmo Drive here.

    I will investigate that way.

    Thank you,

    Stéphane Germain

  • Stéphane,

    I don't have an Elmo Drive, so used an AM335x ICEv2 with full EtherCAT stack as the 2nd slave.

    Regards,

    Garrett

  • Hi Garrett,

    Sorry for the delay, the issue is more complicated than expected.

    So as often in complicated issue, it was in fact 2 bugs.

    1) Elmo is sometimes not responding to Slave to Slave SDO and this have been reproduced by other stakeholders.

    2) The "address" issue observed with Wireshake (only with TwinCat 3 master, not Acontis master) is still true.

    The spec is clear, the mailbox header address field should contain the address of the requested device: “Station Address of the source, if a master is client, Station Address of the destination, if a slave is a client” EtherCat group support cannot reproduce this part of the issue!

    So I would like to know if your test have reproduce it?

    Thank you,

    Stéphane Germain

  • Hi Stéphane,

    I used the ecat.adp=0x3ea filter in wireshark and can see it in my capture from netAnalyzer.

    Regards,

    Garrett