cancel
Showing results for 
Search instead for 
Did you mean: 

usb host fat32 does not work with freeRTOS

Javad
Associate III

I have stm32f429discovery and i used stm32cubeMx to set up usb host with fast32. when I connect flash it works OK. but when I configure freeRTOS it didn't work. when i debug it, I found it go to "HardFault_Handle" loop.

i increase heap and stack size to 0x400 and 0x800 respectively but still I have that problem.

i attach "usb_host.c" and "cub.ioc" files

5 REPLIES 5
Jack Peacock_2
Senior III

Check the return status when you start the FreeRTOS scheduler. An error usually means you don't have enough heap. Your heap size appear to be very small. How many tasks do you allocate?

If you only have 1K of heap but allocate tasks with 2K of stack, how will those stacks fit in the heap?

Jack Peacock

Javad
Associate III

thank you Jack for your reply

I check status, it return "taskSCHEDULER_RUNNING"

i increased heap size while 10K and stack size 20K and allocate task with 5k but still my programm go to "HardFault_Handle" loop

in this program I just have 2 task (one of them is empty. i add it for test) but in my final program I have 5 task. I ran LTDC with wmwin and ADC and Usart. everything work well, after I add OTG task my program hanged so I built new code just for OTG while I can debug it.

thank you Jack for your reply

I check status, it return "taskSCHEDULER_RUNNING"

i increased heap size while 10K and stack size 20K and allocate task with 5k but still my programm go to "HardFault_Handle" loop

in this program I just have 2 task (one of them is empty. i add it for test) but in my final program I have 5 task. I ran LTDC with wmwin and ADC and Usart. everything work well, after I add OTG task my program hanged so I built new code just for OTG while I can debug it.

Javad
Associate III

I saw I made a mistake! I forgot to call "MX_USB_HOST_Process()" function in loop. now my cod don't hang but still not write on flash!

i debugged it and I notice the status is "HOST_USER_CONNECTION". what it mean?

this is my task:

void StartDefaultTask(void const * argument)

{

 /* init code for FATFS */

 MX_FATFS_Init();

 /* init code for USB_HOST */

 MX_USB_HOST_Init();

 /* USER CODE BEGIN 5 */

 /* Infinite loop */

 for(;;)

 {

schedulerstate= xTaskGetSchedulerState();

MX_USB_HOST_Process();

  osDelay(1);

 }

 /* USER CODE END 5 */ 

}

SSeo.17
Associate III

I also have a problem that USBH does not work under freeRTOS.

Does the USB host work well by adding MX_USB_HOST_Process();?

When freeRTOS is enabled, a thread function called USBH_Process_OS() is created, which calls USBH_Process() to make the USB host work, but does not function normally. Did you artificially call MX_USB_HOST_Process() to solve the problem?