cancel
Showing results for 
Search instead for 
Did you mean: 

Mass Storage Mode Receive Data From Host Fail Issue!

JLee.64
Associate II

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!

1 ACCEPTED SOLUTION

Accepted Solutions
JLee.64
Associate II

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.

View solution in original post

1 REPLY 1
JLee.64
Associate II

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.