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.

LoggerSM eraseRecords EventHdr_getLength issue

Other Parts Discussed in Thread: SYSBIOS

Hello everyone

(target C6678, SYSBIOS 6.37, UIA 1.4.00.6, XDC tools 3.25, CCSv6...98)

We have an example application that uses LoggerSM.

Our issue only happens when DECODE = FALSE and OVERWRITE = TRUE.

This application (very simple and minimal) uses 1 SWI.

We have then a swi_post which calls LoggerSM_write4 which calls eraseRecords.

The application then hangs in the WHILE loop inside eraseRecords. It never goes out of it.

Here's the code for eraseRecords

static Void eraseRecords(SizeT numMAUToWrite)
{
    SizeT freeSizeMAU = LoggerSM_getFreeSize();
    SizeT numMAUInEvent = 0;
    Bits32 endPtr = (Bits32)LoggerSM_module->sharedObj->endPtr;
    volatile Char *readPtr = LoggerSM_module->sharedObj->readPtr;

    while (freeSizeMAU <= numMAUToWrite) {
        /*
         *  - Get the size of the event record
         *  - Update the running count
         *  - adjust the temp read pointer
         */
        numMAUInEvent = EventHdr_getLength(*(Int32 *)readPtr);
        freeSizeMAU += numMAUInEvent;
        readPtr = (Ptr)((Bits32)readPtr + numMAUInEvent);

        /* check for wrap condition */
        if ((Bits32)readPtr >= endPtr) {
            readPtr = (Ptr)((Bits32)LoggerSM_module->sharedObj->buffer +
                              ((Bits32)readPtr - endPtr));
        }
    }
    LoggerSM_module->sharedObj->readPtr = readPtr;
}

and here's the code for EventHdr_getLength

 /*  ======== EventHdr_getLength ========
 *  gets the event length (in bytes) from the first word of the event header
 */

#define ti_uia_runtime_EventHdr_getLength(eventWord1)                         \
    ((UInt32)((eventWord1 & EventHdr_LENGTH_MASK) >> EventHdr_LENGTH_BIT_SHIFT))

I'd like to draw attention to this line :

numMAUInEvent = EventHdr_getLength(*(Int32 *)readPtr);

as you can see we expect a number of MAU

but we get a SIZE in BYTES with EventHdr_getLength

I think it could lead to errors on target where 1 MAU is different than 1 byte.

This may not be the cause of my issue.

I think the correct code should be :

numMAUInEvent = BITS8_TO_MAU(EventHdr_getLength(*(Int32 *)readPtr));

Let me know what you think

Thank you

Regards
Clement

  • Hi Clement,

    This does look like a bug, that numMAUInEvent is supposed to be the number of MAUs in the event, while EventHdr_getLength() returns the number of bytes in the event.  On 6678, a MAU is the same size as a byte, though, so I don't think this would be causing the problem.  Can you determine the values of the readPtr, endPtr, numMAUToWrite when you enter eraseRecords() for this condition of not breaking out of the while() loop?

    Is it possible to reproduce this failure with a small LoggerSM buffer that you could post the contents of?

    Thanks,

        Janet

  • Hi Janet,

    Oh my mistake I read the code thinking 1 MAU was equal to 1 bit not 1 byte.

    I corrected my previous post to reflect that.

    By the way in LoggerCircBuf.c, LoggerStopMode.c, LoggerProbePoint.c,  it is used correctly

    numMAUInEvent = BITS8_TO_MAU(EventHdr_getLength(*(Int32 *)tempRdPtr));

    but not in LoggerIdle.c

    lengthInMAU = EventHdr_getLength(*LoggerIdle_module->bufferRead);

    Anyway yes I'll give you the info about the values when I get back to work.

    About the LoggerSM buffer, in the example application "SWI_post" is the first call that triggers a loggerSM_write !

    Regards,
    Clement

  • Yes, that is a problem in LoggerIdle that has been corrected in UIA 2.x.

    Best regards,

        Janet

  • Ok Janet,

    Let's consider this thread closed and continue the discussion about eraseRecords here :

    http://e2e.ti.com/support/embedded/tirtos/f/355/t/373489.aspx

    (I work with Nadim on this)

    Will you file a bug on the EventHdr_getLength issue in LoggerSM.c

    it should be written :
    numMAUInEvent = BITS8_TO_MAU(EventHdr_getLength(*(Int32 *)readPtr));
    (even if it wasn't the bug that's affecting us)
    Clément