STMicroelectronics / STM32CubeH7

STM32Cube MCU Full Package for the STM32H7 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
https://www.st.com/en/embedded-software/stm32cubeh7.html
Other
479 stars 298 forks source link

USBH_MSC_BOT_Process: Too much byte are sent with USB_EP_DIR_OUT #267

Closed jbiemar closed 4 months ago

jbiemar commented 1 year ago

Describe the set-up

Describe the bug In the function USBH_MSC_BOT_Process from file Middlewares\ST\STM32_USB_Host_Library\Class\MSC\Src\usbh_msc_bot.c the length of sent data may be too long in some case.

    case BOT_DATA_OUT:
      (void)USBH_BulkSendData(phost, MSC_Handle->hbot.pbuf,
                      MSC_Handle->OutEpSize, MSC_Handle->OutPipe, 1U);

      MSC_Handle->hbot.state  = BOT_DATA_OUT_WAIT;
      break;

With a custom SCSI device, the command is misunderstood and the device never respond because we are sending 64 bytes instead of 36 expected in the variable MSC_Handle->hbot.cbw.field.DataTransferLength.

How To Reproduce Use the USBH_StatusTypeDef USBH_MSC_BOT_Process(USBH_HandleTypeDef *phost, uint8_t lun) function.

Additional context My way to fix this is to modify function to this:

    case BOT_DATA_OUT:
      (void)USBH_BulkSendData(phost, MSC_Handle->hbot.pbuf,
                      (MSC_Handle->hbot.cbw.field.DataTransferLength > MSC_Handle->OutEpSize) ? MSC_Handle->OutEpSize : MSC_Handle->hbot.cbw.field.DataTransferLength,
                      MSC_Handle->OutPipe, 1U);

      MSC_Handle->hbot.state  = BOT_DATA_OUT_WAIT;
      break;
RJMSTM commented 1 year ago

Hello @jbiemar,

Thank you for this report. We will get back to you as soon as we analyze it further. This may take some time. Thank you for your comprehension.

With regards,

ALABSTM commented 4 months ago

Hi @jbiemar,

Please excuse this late reply. Your proposal looks quite interesting. It has been forwarded to our development teams. I'll keep you informed.

With regards,

ALABSTM commented 4 months ago

ST Internal Reference: 175667

ALABSTM commented 4 months ago

Hi @jbiemar,

Back to you about this point. Our development teams acknowledged your proposal and its relevance. However, they reported there is no plan to support such enhancement for the moment.

Please allow me to close this thread. Thank you for your comprehension.

With regards,