cancel
Showing results for 
Search instead for 
Did you mean: 

USB Host library, MSC Class missing cast in MAXLUN management

DVill
Associate

Hi guys,

I'm porting a firmware bootloader from STM32F4 to STM32F7.

The bootloader firmware manages a timeout of 7" where if usb key is detected, the firmware upgrade happens, otherwise the bootloader jumps to application.

At the end of works I had that sometimes the STM32F7 doesn't recognize some usbkey.

Indeed, the STM32F4 version always recognize them.

After soma hacking I found that the problem stays at line 291 of usbh_msc.c file in STM32_USB_HOST_Library of STM32CubeF7 1.15 (here in bold):

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

So I patched with the missing casting:

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

and the STM32F7 version works as STM32F4 version.

I hope this may help anyone needs.

Best regards.

Davide.

0 REPLIES 0