cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 HAL V1.26.2 USB 2.0 host mode MSC over ULPI phy not stable, some functions must be back-ported to 1.25.2

bernieserver
Associate II

We have found out two stability issues inside the current version of STM32F4 HAL driver.

Chip used:

STM32F429ZI, External ULPI: USB3300, Vbus control using STMPS2151STR, ESD protection, EMI protection.

(see scheme appended)

Compiler: GCC / GNU Arm Embedded Toolchain - 9 2020-q2-update

HAL affected:

STM32F4 HAL V1.26.2

Functions described below backported to version:

STM32F4 HAL V1.25.2

Conclusion

There are two problems which only occur on USB host mode using an USB stick / drive. USB device mode is not affected (tested with CDC communication)

Short term disconnection issue

First of all there is the problem that the USB stick disconnects after insertion and enumeration by the USB host driver. During the mount of the FAT file system after the enumeration an error occurs and the stick shows no more activity and stops blinking.

This could be a power-on problem of the ULPI chipset which does not activate the VBus after enumeration, but only for a short time.

The following two lines must be added from the older HAL version to the new HAL version to fix this problem:

Inside USB_HostInit():

/* Enable VBUS driving */
(void)USB_DriveVbus(USBx, 1U);
HAL_Delay(200U);

Long term disconnection issue (unpredictable)

The second problem is more a long-term stability issue.

On long term file transfers (several megabytes) to or from the USB drive after 10-60 seconds the USB transfer just stopps and returns with an error.

Randomly (but not always) a hardfault might occur.

The behavior can be influenced by changing the compiler optimization. With -O3 the abort of the USB transfer is much faster (after a few seconds) than with -O2. Then the transfers are more stable, but the problem is not completely solved. With -O1 or -O0 no changes can be seen compared to -O2.

After a few days of trial and error, we found that the following features need to be backported to the old HAL versions:

  • USB_HC_Halt()
  • USB_HC_StartXfer()
  • HCD_HC_IN_IRQHandler()
  • HCD_HC_OUT_IRQHandler()
  • HCD_RXQLVL_IRQHandler()

Also the following line must be enhanced to reduce the interrupt load on file transfer:

Heavy interrupt load:

USBx_HC(ch_num)->HCINTMSK &= ~(USB_OTG_HCINTMSK_NYET | USB_OTG_HCINTMSK_ACKM);

to less interrupt load:

USBx_HC(ch_num)->HCINTMSK &= ~(USB_OTG_HCINTMSK_NYET | USB_OTG_HCINTMSK_ACKM | USB_OTG_HCINTMSK_NAKM);

Then file transfers are stable for several hours.

The reason for this stability issue might be a racing condition during interrupt handling as interrupt callbacks are affected.

Are you aware of these errors?

Regards

Bernhard

2 REPLIES 2
bernieserver
Associate II

Any suggestions? Is a fix planned? Does you need further details?

bernieserver
Associate II

Hmm is the forum dead?