USB IN Endpoint handling bug in HAL (and Device Library)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-09-27 4:33 AM
I am developing a complex USB device with several endpoints, I have encountered the following problem: the DataIn class callback was passing the epnum parameter incorrectly, the 0x80 flag - which indicates the endpoint direction - wasn't set. This resulted in faulty operation when I checked against the endpoint number in my callback.
This can be obviously circumvented easily by always setting the 0x80 flag before evaluating the epnum, so it's not a critical bug. However, this flag is otherwise handled everywhere correctly within the HAL library, when using any of the HAL_PCD_EP_<operation>() functions. My argument is that if the USB class calls USBD_LL_Transmit() with a certain epnum value, the DataIn callback signalling the completion of that transfer shall have the same epnum value.
The fix in the HAL libraries is fairly easy, just set the 0x80 flag on the epnum on each occurrence of the DataInStageCallback, like so:
HAL_PCD_DataInStageCallback(hpcd,
0x80 |
epnum);??This alone would break the STM32 USB Device Library, therefore this small change needs to be applied for correctness:
USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev ,uint8_t epnum, uint8_t *pdata)
{ USBD_EndpointTypeDef *pep; if((
epnum
& 0x7F) == 0) {...???????FYI for this and numerous other issues I am currently maintaining my own branch of the STM32 USB Device Library on
https://github.com/IntergatedCircuits/STM32_XPD/tree/master/Middlewares/STM32_USB_Device_Library
.#usb #hal_pcd #stm32_usb_device_library- Labels:
-
STM32Cube MCU Packages
-
USB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-03-13 6:42 PM
Hi Ben,
The githib link appears to be broken. I am experiencing some issues with the library and wondered if your library fixed them already.
Thanks, Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-03-14 6:31 AM
Hi Dave,
Actually I decided to develop a more feature-rich
https://github.com/IntergatedCircuits/USBDevice
. This is able to support pretty much the entire STM32 family. Check the wiki page on how it can be imported to an existing HAL or CMSIS codebase.Nevertheless the source code for the original topic is still available in
https://github.com/IntergatedCircuits/STM32_XPD/releases/tag/v0.1
. We in the forum are also happy to help with any issues you may encounter, just post the detailed problem- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-03-14 7:31 AM
I will take a look, thanks. I also posted a question to the community explaining our issue.
Many thanks, Dave
