cancel
Showing results for 
Search instead for 
Did you mean: 

USB HOST with MSC is not working on FreeRTOS CMSIS V2

JJhin.1
Senior

Hello Community!

Recently i have started working on USB MSC using RTOS. Im using USB HOST Library version 3.5.2 and latest version of CubeMx.

When im generating the code by selecting FreeRTOS CMSIS V2 and pulging my USB drive to CN13 connector then the Appli_state is always staying at APPLICATION_START state and not not going to APPLICATION_READY state.

but on other hand if im selecting FreeRTOS CMSIS V1 instead of V2 with keeping same configuration then USB Appli_state is changing imidiatly to APPLICATION_READY state when USB is getting connected to CN13 connetor.

Here im using STM32F746 NUCLEO board. if anyone knows what is the issue please reply.

Thank you! 

1 ACCEPTED SOLUTION

Accepted Solutions

Hello  @JJhin.1   @nouirakh

 I am now able to use USB as MSC Host with CMSIS V2. The only change I did was to increase the stack size for USB task to 1024.
I am using STM32CubeIDE Version: 1.15.1 and STM32CubeMX Version 6.11.1


Thankyou once again  for your guidance and support. 

View solution in original post

9 REPLIES 9
pitbull
Associate III

Hello @JJhin.1 

 

Even I am facing the same issue and I did try a lot but unable to get it working with CMSIS-V2. Either the application goes into Hard Fault or is stuck in infinite loop.
Have you successfully implemented it?

Please guide me accordingly.

Thankyou

Hi @pitbull 

In my case MSC host is working fine with FreeRTOS CMSIS V1 ... but when i trying same configuration for  FreeRTOS CMSIS V2 then its Appli_State is not getting changed to READY_STATE.

 

For your case if its going to hardfault then there will be configuration issue.. if its stucking in some loop then debuge the code and try to find where it is getting stucked.

 

I'll recommend you to use lasted versions of MSC hoste library which is 3.5.2 but the latest version of CubeMX is using 3.4 version of library. 

pitbull
Associate III

Hello @JJhin.1 

 

Thankyou for your time and consideration.

I am currently using STM32 Cube IDE 1.13.1 with CubeMX 6.9 and one firmware using CMSIS V1 with working USB MSC Host and another firmware with CMSIS V2 where hardfault or infinite FreeRTOS loop occurs either when USB is connected or  firmware enters first f_open() function.

Same code for USB and other functionalities is used in both the firmwares.
I am updating the IDE to latest version, I am currently using the USB host library provided at the github link https://github.com/STMicroelectronics/stm32_mw_usb_host which is version 3.5.2 as you mentioned.

Will try with the updated IDE and will keep you posted.

 

Thankyou once again.

 

If your code is going to hardfault after f_open() .... then you have to check your file discriptor pointer .... before opening any file ... you must have to check Apli-state should equal to APLICATION_READY state .. after that only you have to maount the drive ... otherwise fault will generate.

 

Make shure new downloaded MSC host library should get copied into your device firmware repository. 

Hello @JJhin.1 

Sorry for the late reply I was on a holiday

Thankyou for your suggestions the USB library is working well in CMSIS V1 in the latest IDE and MX version and I am able to use USB as MSC.
Have not tested yet for CMSIS V2 but will surely try for it. Will keep you posted.
Thankyou again for your time and valuable guidance. It sure does help beginners like me.


Good to know that .. its working with CMSIS V1 =) try with CMSIS v2 ... plz inform me if it will work with CMSIS v2 or you found any solution for CMSIS v2. 

nouirakh
ST Employee

Hello  @JJhin.1 

When you encounter a difference in behavior between different versions of a real-time operating system component, such as FreeRTOS CMSIS V1 versus V2, it can be due to various reasons, including changes in the API, differences in initialization code, or changes in how the middleware interacts with the underlying RTOS.

Here are some steps to troubleshoot the issue:

  • Check the Middleware Initialization Code: Ensure that the middleware initialization code is compatible with CMSIS-RTOS V2. There might be changes in the initialization sequence or configuration structures that need to be addressed when upgrading from V1 to V2.
  • Review the USB Host Configuration: Verify that the USB host configuration is correctly set up for CMSIS-RTOS V2. This includes checking the USB host task priorities, stack sizes, and any other relevant parameters.
  • Compare API Differences: Look for any differences in the USB middleware API between the two versions. CMSIS-RTOS V2 might have introduced changes that affect how the USB middleware should be used.
  • Inspect the State Machine: Review the code responsible for managing the Appli_state. It's possible that the conditions for transitioning to APPLICATION_READY are not being met due to timing issues or changes in the way the USB middleware reports its status.
  • Analyze the USB Interrupts and Callbacks: Check if there are any differences in how interrupts and callbacks are handled between the two versions. Ensure that the USB interrupt priorities are compatible with FreeRTOS and that the callbacks are being set and used correctly.
  • Look for RTOS Kernel Changes: Since CMSIS-RTOS V2 may introduce changes to the RTOS kernel behavior, ensure that these changes are not affecting the USB middleware. This can include task scheduling, interrupt handling, or inter-task communication mechanisms.
  • Debug the Application: Use a debugger to step through the code and observe where the state machine is getting stuck. Pay special attention to any conditional statements that lead to the APPLICATION_READY state.

By systematically going through these steps, you should be able to identify and resolve the issue causing the Appli_state to remain in APPLICATION_START when using FreeRTOS CMSIS V2. If the problem persists, please provide more details on your setting project if possible, attach your .ioc file/configuration.

Thanks @nouirakh  for replaying ...

i tried this with CubeMx 6.10.0 version 2 months before. i'll check again my code with procedures you you have given. 

one thing letme know that, is there any extra settings i have to do for FreeRTOS CMSIS V2 in CubeMx? like you said that i have to check stack size... so how much minimum stack size should be there for CMSIS V2 ?

please check my ioc attached to this massage.

 

thanks & regards!

Hello  @JJhin.1   @nouirakh

 I am now able to use USB as MSC Host with CMSIS V2. The only change I did was to increase the stack size for USB task to 1024.
I am using STM32CubeIDE Version: 1.15.1 and STM32CubeMX Version 6.11.1


Thankyou once again  for your guidance and support.