cancel
Showing results for 
Search instead for 
Did you mean: 

USBH_MSC_ClassRequest looks buggy when using USB host MSC class

yjsbd
Associate II

in usbh_msc.c

if(status == USBH_OK)

   {

      MSC_Handle->max_lun = (MSC_Handle->max_lun > MAX_SUPPORTED_LUN)? MAX_SUPPORTED_LUN : (uint8_t )(MSC_Handle->max_lun) + 1U;

     USBH_UsrLog ("Number of supported LUN: %lu", (int32_t)(MSC_Handle->max_lun));

     for(i = 0U; i < MSC_Handle->max_lun; i++)

     {

       MSC_Handle->unit[i].prev_ready_state = USBH_FAIL;

       MSC_Handle->unit[i].state_changed = 0U;

     }

   }

refer to https://usb.org/sites/default/files/usbmassbulk_10.pdf in page7

Data of GetMaxLun would be 1 byte.

So I think

MSC_Handle->max_lun = (MSC_Handle->max_lun > MAX_SUPPORTED_LUN)? MAX_SUPPORTED_LUN : (uint8_t )(MSC_Handle->max_lun) + 1U;

would be

MSC_Handle->max_lun = ( ((uint8_t)MSC_Handle->max_lun) > MAX_SUPPORTED_LUN)? MAX_SUPPORTED_LUN : (uint8_t )(MSC_Handle->max_lun) + 1U;

Is it right?

11 REPLIES 11

Thank you Imen, indeed fixed in STM32CubeF4 V1.25.0 released a few days ago, I tried this morning.

One year later, fixed ! Whatever, thank you.

You are welcome.

Thank you @yjsbd​, @Community member​  and @Ede S​  for your contribution and enhancement of our STM32 resources.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen