Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB Sending Report Not Working #25

Open
factoryal opened this issue May 5, 2022 · 5 comments
Open

USB Sending Report Not Working #25

factoryal opened this issue May 5, 2022 · 5 comments
Assignees
Labels
hal HAL-LL driver-related issue or pull-request. usb USB-related (host or device) issue or pull-request

Comments

@factoryal
Copy link

factoryal commented May 5, 2022

Hi.

I'm using STM32L053R8T6 based custom PCB development board and testing USB custom HID.
the code

errno = USBD_CUSTOM_HID_SendReport(&hUsbDeviceFS, usb_send_data, sizeof(usb_send_data));

does not works and returned value errno is 1 which represents USBD_BUSY.
I used USB HID Demonstrator v1.0.2 tool to monitor it's communication status.

I solved this problem with simply downgrade firmware package version from 1.12.1 to 1.12.0 and it works as expected.
USBD_CUSTOM_HID_SendReport() function returns 0(USBD_OK)

Please check this issue.
Thanks.

@factoryal
Copy link
Author

I discovered USB HID keyboard not working properly.
Also can be fixed by downgrade version to 1.12.0

Changing the title to "USB Sending Report not working".

Tested code:

uint8_t test[8] = { 0, };
while(1) {
  test[2] = 0x11;
  USBD_HID_SendReport(&hUsbDeviceFS, (uint8_t *)&test, sizeof(test));
  HAL_Delay(30);
  test[2] = 0x00;
  USBD_HID_SendReport(&hUsbDeviceFS, (uint8_t *)&test, sizeof(test));
  HAL_Delay(1000);
}

@factoryal factoryal changed the title USBD_CUSTOM_HID_SendReport() not working USB Sending Report Not Working May 15, 2022
@ALABSTM ALABSTM self-assigned this May 18, 2022
@ALABSTM ALABSTM added hal HAL-LL driver-related issue or pull-request. usb USB-related (host or device) issue or pull-request labels May 18, 2022
@ch-f
Copy link

ch-f commented Aug 19, 2022

Doing tutorial 09.7_USB HID device - custom device lab - solution.zip (reference video) on firmware 1.12.1 fails, but works on 1.12.0: HID_terminal.exe works two times (sends and recieves data by clicking on Send-Button) but fails reproducible after second time with an error "Operation timed out".

@ch-f
Copy link

ch-f commented Sep 4, 2022

--- a/Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_pcd.c
+++ b/Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_pcd.c
@@ -1851,28 +1851,6 @@ static HAL_StatusTypeDef PCD_EP_ISR_Handler(PCD_HandleTypeDef *hpcd)
         /* clear int flag */
         PCD_CLEAR_TX_EP_CTR(hpcd->Instance, epindex);
 
-        if (ep->type != EP_TYPE_BULK)
-        {
-          ep->xfer_len = 0U;
-
-          if ((wEPVal & USB_EP_DTOG_TX) != 0U)
-          {
-            PCD_SET_EP_DBUF0_CNT(hpcd->Instance, ep->num, ep->is_in, 0U);
-          }
-          else
-          {
-            PCD_SET_EP_DBUF1_CNT(hpcd->Instance, ep->num, ep->is_in, 0U);
-          }
-
-          /* TX COMPLETE */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
-          hpcd->DataInStageCallback(hpcd, ep->num);
-#else
-          HAL_PCD_DataInStageCallback(hpcd, ep->num);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-        }
-        else
-        /* Manage Bulk Single Buffer Transaction */
         if ((ep->type != EP_TYPE_BULK) ||
                              ((ep->type == EP_TYPE_BULK) && ((wEPVal & USB_EP_KIND) == 0U)))
         {

My issue: Only first two HID URBs are getting through, after applying this patch on firmware 1.12.1 it seems to make it work just fine. But I have no clue why. Could you please check on this?

@factoryal
Copy link
Author

@ch-f Thanks for your comment.
Unfortunately, your patch didn't resolved my problem.
It still cannot send any packet to host.

@ch-f
Copy link

ch-f commented Sep 7, 2022

The code there seems obviously wrong, it does:

    if (a) {
    ...
    } else if (a || b) {
     ...
    }

There might be other traps like this or you might need the bottom part after the 'else if' of (ep->type != EP_TYPE_BULK)...

Would be nice if an official from ST could shed light?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hal HAL-LL driver-related issue or pull-request. usb USB-related (host or device) issue or pull-request
Projects
Development

No branches or pull requests

3 participants