cancel
Showing results for 
Search instead for 
Did you mean: 

HardFault_Handler() at stm32f0xx_it.c occur when i run a project with RTOS.

Dai Huy
Associate II

Dear STM support team.

My name is Dai. I am working at G-innovation Corporation.
Now I have a project using the STM Chip(STM32F0xx).
I use the STM32CubeMX (version 6.11.0) to create a project using the STM32F091VBT6 with CMIS_RTOS.
this project aims to study all CMSIS-RTOS APIs.
the function of the project include:
- 6 thread: "idle thread" to blink an LED at 0.5Hz.
              "SWI thread: is reserved.

             "dut1 thread" to send counter log to the PC over UART1, "dut2 thread", "dut3 thread" and "dut4 thread" as the same "dut1 thread".

             mutex to protect the "debug_printf" function.
I received a "HardFault_Handler() at stm32f0xx_it.c 0x80033f4" after running it for several milliseconds.
I have attached my project, the UART log, and the Debug log to this post.

everybody helps me to debug and fix this bug.

Regards,


DaiHuy_0-1712886396057.png

 


      

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Dai Huy
Associate II

I discovered that when I increased the size of the Stack of Thread this Problem was resolved.
Everybody tells me how to check the stack's size during run time.
Regards!

View solution in original post

8 REPLIES 8
Dai Huy
Associate II

Can everybody help me?

Dai Huy
Associate II

I discovered that when I increased the size of the Stack of Thread this Problem was resolved.
Everybody tells me how to check the stack's size during run time.
Regards!

Hi,

You can always check the stack usage in the freeRTOS runtime statistics. 

bashira_1-1713351324494.png

 


Secondly, there is also this freeRTOS function that you can consider using: uxTaskGetStackHighWaterMark()

I hope this helps.

 

Dai Huy
Associate II

Hi @bashira 
thanks for your support!

But when I use the STM32CUBEIDE to check the stack usage in the freeRTOS runtime statistic, all parameters in the "Run time(%)" cell show N/A. Please tell me why and how to show it. the SIM32CUBEIDE version on my PC is 1.15.0

DaiHuy_0-1713509588939.png

 

Best Regard!

Hello Dai,

Sorry for the delay.

There are a couple of things you can do. The first step is:

Click the button here.

bashira_0-1713701993602.png

 

Then additionally you can go into freeRTOS settings and enable a few things.
1. Generate Runtime Stats.
2. Check for stack overflow. (This hook has saved me so much headaches over the years)

bashira_1-1713702094342.png


3. Also enable stack high address.

bashira_2-1713702131485.png



Don't ask me about the runtime %. No idea 🙂 Never used it.

EDIT: You need to set a break point somewhere in your code to see the stats being updated.

Thanks for your support, it is helpful for me.
I have a new problem.
the "Build Analysis" windows of the STM32CubeIde show nothing. how do I get information about my build?

DaiHuy_0-1713756729515.png

 


Regards
Dai Huy

Hello,

Please open a new thread for this new question. 
Thank you for your understanding.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Thank you for informing me.