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.

RTOS/AM5746: USB Behavior Problem

Guru 10235 points
Part Number: AM5746

Tool/software: TI-RTOS

Hello, TI Experts,

 

Our customer sent us questions about "USB Behavior" with PROCESSOR-SDK-RTOS-AM57X.

They checked USB behavior on TMDSIDK574 and found problem like attached pdf.

 

They also found the related E2E-thread like below.

https://e2e.ti.com/support/processors/f/791/t/737330

But they cannot found how to solve this problem in this thread.

 

We would appreciate if you tell us how to solve this problem.

 

Best regards,

usb_seq.pdf

  • Hi,

    Thanks for the detailed diagram! I need to reproduce your issue. Is that by running the USB_DevBulk_idkAM574x_armExampleProject with a lower task and another task with a higher task?

    Regards, Eric
  • Hi,

    Thank you very much for your kindness.
    I really appreciate your help.

    We understand like below in the diagram;
    - TASK_T0 : lower task
    - TASK_T1 : higher task

    We would appreciate if you reproduce the issue and tell us how to solve this problem.

    Best regards,
  • Hi,

    Thank you very much for your kindness.
    I really appreciate your help.

    They said "it is difficult to provide their project".
    They expect to reproduce the issue and tell us how to solve this problem based on their diagram(pdf).

    Best regards,
  • Hi,

    In the USB_bulkwrite, the state is set to BULK_STATE_WAIT_DATA , then a sem_pend() is added to block code execution. When the write finished, the ISR calls ProcessDataToHost() where the state is set to BULK_STATE_IDLE, then post the semaphore. 

    In your failure case, why the sem_pend() moves to the bottom of the follow? Do you mean there is another sem_post() happens so there is no sem_pend()? Or your issue is that in the bulk_write, it is interrupted by another higher priority task, BEFORE you set the state to BULK_STATE_WAIT_DATA and calling the sem_pend(). In this case, the sem_post() came before sem_pend()?  

    Regards, Eric

  • Hi,

    Assume your case is in the bulk_write, it has 3 functionalities executed in sequence:
    1) bulk write
    2) change state to BULK_STATE_WAIT_DATA
    3) sem_pend()

    After execution of 1), there is a higher priority task came in and your USB task switched out. The USB write completion ISR happened and it changes the state to BULK_STATE_IDLE and post_sem(). Then the original USB task switched back and ran the sequences 2) and 3), this put the state in BULK_STATE_WAIT_DATA again. That is wrong.

    We need to update the USB driver code for this in pdk_am57xx_1_0_13\packages\ti\drv\usb\src\usb_func\device\usbdbulk.c, function USBD_bulkWrite(). The workaround is to change the sequences to 2), 1) and 3).

    if (psInst->eBulkTxState == BULK_STATE_IDLE)
    {
    if ((dataSize <= DATA_IN_EP_MAX_SIZE) && (dataSize > 0))
    {
    psInst->eBulkTxState = BULK_STATE_WAIT_DATA;
    usbSetupEpReq(pGadgetObj,
    psInst->ucINEndpoint, /* IN EP # */
    (uint32_t*)buffer,
    USB_TOKEN_TYPE_IN,
    dataSize,
    USB_TRANSFER_TYPE_BULK);


    usb_osalPendLock(psInst->writeSem, SemaphoreP_WAIT_FOREVER);

    retSize = psInst->usLastTxSize;
    }
    else
    {
    retSize = 0;
    }
    }

    You may try if this unblock you. And I filed a ticket for this.

    Regards, Eric
  • Hi,

    Thank you very much for your kindness.
    I really appreciate your help.

    We understand there is a problem in USB driver code from your comment.
    We would like to send your workaround to the customer.

    And we also wait for the driver update plan.

    Best regards,
  • Hi,

    Status update:
    - ticket was opened in bug tracking system
    - workaround suggested to customer
    - Fix plan is P-SDK 6.0 (2019 Q2). Trying to see if this can be pulled in P-SDK 5.3 (2019 Q1), given we are almost in code freeze

    Regards, Eric
  • Hi,

    Thank you very much for your kindness.
    I really appreciate your help.

    We understand the situation.
    We are waiting for the P-SDK6.0 release.

    Best regards,