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.

Bug in TivaWare \usblib\usbbuffer.c

I'm not sure if this is the appropriate place to post a bug report.

I found a bug in:

TivaWare_C_Series-2.1.0.12573\usblib\usbbuffer.c

in function USBBufferInfoGet()

void
USBBufferInfoGet(const tUSBBuffer *psBuffer, tUSBRingBufObject *psRingBuf)
{
    tUSBBufferVars *psBufVars;

    //
    // Check parameter validity.
    //
    ASSERT(psBuffer && psRingBuf);

    //
    // Get our workspace variables.
    //
    psBufVars = psBuffer->pvWorkspace;

    //
    // Copy the current ring buffer settings to the clients storage.
    //
    psRingBuf->pui8Buf = psBufVars->sRingBuf.pui8Buf;
    psRingBuf->ui32ReadIndex = psBufVars->sRingBuf.ui32ReadIndex;
    psRingBuf->ui32Size = psBufVars->sRingBuf.ui32ReadIndex;
    psRingBuf->ui32WriteIndex = psBufVars->sRingBuf.ui32WriteIndex;
}

Highlighted line should be:

psRingBuf->ui32Size = psBufVars->sRingBuf.ui32Size;

Thank you,

Kevin Taberski

  • Hello Kevin,

    In lack of a better system, this is right place to post a bug as well. I will look into it. It would be good if you could describe how you uncovered it so that we can repeat the same to double check (fix and test).

    Regards

    Amit

  • Amit,

    I was just studying the USB API in a bit of detail.

    To repeat the problem, place:

    DEBUG_PRINT("sTxRing->ui32Size=%d\n", sTxRing.ui32Size);

    in EchoNewDataToHost() in usb_dev_bulk.c.  The result is always '0', but should be 256.  The error is fairly straightforward, it looks like a copy/paste/modify type of error.

    Thank you,

    Kevin

  • Hello Kevin,

    Thanks again, I will run it by the software team as well. I am not sure if this would make it for the next SW release though, but would try so.

    Regards

    Amit

  • Amit,

    I encountered the exact same issue in the latest version of Tivaware 2.1.1.71 before I found this thread.  The problem is very significant as it pretty much renders the USB Ring Buffers inoperable without fixing it.  Here's why:

    The result of calling USBBufferInfoGet() is that the size gets set to 0, instead of the appropriate size (in the case of my code) 256.

    Later on, any calls to UpdateIndexAtomic() will hang the processor in an infinite loop below, because ui32Size = 0.

    while(*pui32Val >= ui32Size)

    {

    *pui32Val -= ui32Size;

    }

     This function is called every time you try to read the buffer, so basically the first time you read the buffer the processor will hang.  What concerns me as that TI has known about this for over a year and has chosen not to fix it.  Does this imply that no one is using ring buffers at all?

    It makes me question the amount of run time the rest of the code has seen.