Skip to main content
JLee.64
Associate
January 11, 2022
Solved

Mass Storage Mode Receive Data From Host Fail Issue!

  • January 11, 2022
  • 1 reply
  • 1047 views

Hi All,

I am working on a SCSI device read/write project.

(Base on STM32CubeMX V6.4, Chip STM32F103)

Now the windows can recognized this device as a pen driver and I can send data

from Device to Host just like send data for read capacity.

EX

int8_t SCSI_ProcessCmd(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *cmd)

{

       USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *) pdev->pClassData;

       switch (cmd[0])

       {

               ….

          case 0xF7:

                    USBD_MSC_BOT_HandleTypeDef *hmsc =                     (USBD_MSC_BOT_HandleTypeDef *) pdev->pClassData;

   

                       if (hmsc->bot_state == USBD_BOT_IDLE) /* Idle */

                       {

                                    /* Device To Host */

                                     if ((hmsc->cbw.bmFlags & 0x80U) == 0x80U)

                                     {

                                                   hmsc->bot_data[0] = 0x00U;

                                                   hmsc->bot_data[1] = 0x01U;

                                                   hmsc->bot_data[2] = 0x02U;

                                                   hmsc->bot_data[3] = 0x03U;

                                                   hmsc->bot_data_length = 4U;        

                                      }

                                     else/* Host To Device */

                                     {

                                                   USBD_LL_PrepareReceive(pdev,                                                   MSC_EPOUT_ADDR, hmsc->bot_data, 4);     

                                     }

                       }        

                    break;

          …

}

          return 0;

}

And it working well as picture1.

Now I try to send data(4 Bytes) from host to device.

And the device fail(stall) to receive data from host.

Please check picture2.

According to the soft- Analyzer the data is receive OK, but fail on next test unit ready.

Please help me and give me some advices, thanks!

This topic has been closed for replies.
Best answer by JLee.64

I found the reason.

when hmsc->bot_state = USBD_BOT_DATA_OUT

Directly get data in hmsc->bot_data[] and USBD_CSW_CMD_PASSED.

The data can properly get from host and no error.

1 reply

JLee.64
JLee.64AuthorBest answer
Associate
January 12, 2022

I found the reason.

when hmsc->bot_state = USBD_BOT_DATA_OUT

Directly get data in hmsc->bot_data[] and USBD_CSW_CMD_PASSED.

The data can properly get from host and no error.