cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F446RCT6 with FatFS + HSB Host (USB OTG HS) falls in infinite loop

MarcoM
Associate II

Hello, I have a design with an STM32F446RCT6 where I use the FatFS file system and the USB HS as USB Host in Mass Storage Host Class.

The design is made with STM32CubeIDE 1.8.0 and the firmware package is V1.26.2 / 16-july-2021.

The configuration parameters for both FatFS and USB HS are essentially the defaults.

When I open and read a file from a pendrive, all work without problems while the file size is under about 100Kbyte. If I open and read a bigger file, say 200 Kbyte, the program hangs up into an infinite loop in startup_stm32f446rctx.s. This happens when it is executed a function named USBH_LL_GetURBState().

I have no idea about the reason that makes a difference in reading files of different size. The high level function that starts the reading of a block of data from the file is

ff_result = f_read(&source_file, p_buffer, 8192, &byte_read);

Every time this function reads the file takes only 8192 bytes putting them in a buffer. Then the buffer is processed and the software calls again f_read() for the next block of data. There is not any accumulation of data other than the 8192 bytes buffer.

Notice that I have another similar application on a similar processor (STM32L476RCT6) where I read files from a pendrive whose size is some hundred of Mbytes and the software works well without any problem.

I strongly need an idea or a suggestion about the supposed cause of this problem.

Thank you.

3 REPLIES 3

>>the program hangs up into an infinite loop in startup_stm32f446rctx.s

Like the HardFault_Handler() or Default_Handler() ?

The latter could occur if you're missing an IRQ Handler, the former can output information.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
MarcoM
Associate II

the code of the infinite loop (in startup_stm32f446rctx.s) is this:

/**

 * @brief This is the code that gets called when the processor receives an 

 *     unexpected interrupt. This simply enters an infinite loop, preserving

 *     the system state for examination by a debugger.

 * @param None   

 * @retval None    

*/

  .section .text.Default_Handler,"ax",%progbits

Default_Handler:

Infinite_Loop:

 b Infinite_Loop

 .size Default_Handler, .-Default_Handler

MarcoM
Associate II

It is related to some missing handler, but:

  • reding a 100Kb file I get the correct behaviour
  • I have not configured any IRQ handlers because all the configurations are made by Cube itself