USB MTP driver. Multiple bugs #180
Labels
bug
Something isn't working
internal bug tracker
Issue confirmed and logged into the internal bug tracking system
mw
Middleware-related issue or pull-request.
usb
Universal Serial Bus
Certainly a bug:
STM32CubeF4/Middlewares/ST/STM32_USB_Device_Library/Class/MTP/Src/usbd_mtp_storage.c
Line 463 in 8273819
At the file transfer such statement calculates buffer size in a wrong way. It always 12 bytes since the header is always less than Header+data.
I offer to remove this line and to invoke as
(void)USBD_LL_Transmit(pdev, MTPInEpAdd, buf, len);
Because at file transfer there might be a situation when there is no header and the last packet of data has length 0-12 bytes.
The second bug is on the:
STM32CubeF4/Middlewares/ST/STM32_USB_Device_Library/Class/MTP/Src/usbd_mtp_storage.c
Line 109 in 8273819
It invokes the function that writes into buffer and sets it size.
But at line:
STM32CubeF4/Middlewares/ST/STM32_USB_Device_Library/Class/MTP/Src/usbd_mtp_storage.c
Line 113 in 8273819
We overwrite this buffer with 12 byte header at the start of the file transfer thus corrupts 12 bytes of provided data in the buffer.
I offer to change line 109 with:
(void)((USBD_MTP_ItfTypeDef *)pdev->pUserData[pdev->classId])->ReadData(hmtp->OperationsContainer.Param1, (uint8_t *)data_buff+MTP_CONT_HEADER_SIZE, &MTP_DataLength);
As a result move the pointer by 12 bytes and write buffer in the right section
And it is good to notice in ReadData comments that it should return buffer with size 52 at the first invocation,should return 64 bytes at intermediate, and 0-63bytes meaning the last transfer
The text was updated successfully, but these errors were encountered: