Skip to main content
Explorer II
April 12, 2024
Solved

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

  • April 12, 2024
  • 3 replies
  • 3096 views

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

 


      

 

 

    This topic has been closed for replies.
    Best answer by Dai Huy

    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!

    3 replies

    Dai HuyAuthor
    Explorer II
    April 15, 2024

    Can everybody help me?

    Dai HuyAuthorAnswer
    Explorer II
    April 17, 2024

    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!

    Explorer
    April 17, 2024

    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 HuyAuthor
    Explorer II
    April 19, 2024

    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!

    Explorer
    April 21, 2024

    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.

    Dai HuyAuthor
    Explorer II
    April 22, 2024

    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