HardFault (inconsistent flags and how did I get here?)

Comments

4 comments

  • Avatar
    Michael Johnson

    Stacksize problems usually end up in the hard fault handler.

    0
    Comment actions Permalink
  • Avatar
    Rob Roy

    Thanks Michael for adding to the understanding, but how does one create a stacksize problem?

    Do you have examples or is it simply a nesting overload where the limit of the stack (as set by the compiler? or dictated by flags during the build process?) 

    0
    Comment actions Permalink
  • Avatar
    Michael Johnson

    There's a project property "Stack Size" that you should set - the STM32 project setup defaults to 128 bytes which is easily used up by function calls and local variables.

    0
    Comment actions Permalink
  • Avatar
    Rob Roy

    Ok, Good basic info, but as this is hopefully a helper thread for those struggling with adjusting to ARM, GCC, and your IDE so we should do a thorough job of providing meaningfull answers.

    There are GCC compiler options:
    -fstack-check
    -fstack-usage
    -fcallgraph-info.

    Appear to be used heavily by the Keil (referenced in their documentation for understanding stack and heap issues) as well as other major IDE players that I checked today. The first two can be implemented on the C/C++ compiler options property (did not work for me on the C Only compiler options property).

    I believe the first does not produce and output unless the stack exceeds the default or overridden value.
    The second produces a .su file for each compiled source file.

    An example is:

    //included in main
    core_cm3.h:1014:22:NVIC_SetPriority 16 static
    core_cm3.h:1139:26:SysTick_Config 16 static

    //now main
    main.c:90:5:main 24 static
    main.c:181:6:Test_Config 88 static
    main.c:525:9:readUsartByte 24 static
    main.c:548:9:writeUsartByte 16 static
    main.c:576:6:clearUsart 16 static
    main.c:589:6:USART1_IRQHandler 12 static
    main.c:895:6:USART3_IRQHandler 12 static
    main.c:1242:6:USART2_IRQHandler 12 static
    main.c:1469:6:Test_SysTickConfig 8 static
    main.c:1483:5:is_big_endian 16 static
    main.c:1494:6:_WFE 4 static

     

    I at the moment do not know how to implement the third option (fcallgraph-info), but am looking for help with this.

    I could install doxygen and use vizgraph but I would like to stay within the IDE.

    Is there a way to make those outputs part of my docking windows?

    0
    Comment actions Permalink

Please sign in to leave a comment.