HardFault_handler in GUI_Init ()

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • HardFault_handler in GUI_Init ()

    Hi,
    I've just soldered a second PCB with a STM32F429ZIT6. The first PCB runs perfectly, so the code seems correct. I compile, and debug the code. The code is loaded correctly because there is any complain from Keil.
    I've inherited this code from my old colleage which he currently isn't in my company, so I soldered this new board according to the schematic and I’ve resoldered all solders.
    So, I’ve compile the code and load through debug and starts, goes fine untill arrives in GUI_Init which crashes!
    I’ve debug the code and crashes in the last line of GUI_X_Config function:


    C Source Code

    1. void GUI_X_Config(void) {
    2. //
    3. // 32 bit aligned memory area
    4. //
    5. #ifdef GUI_BUFFER_IN_EXT_RAM
    6. static U32 aMemory[GUI_NUMBYTES / 4]__attribute__((at(GUI_BUFFER_ADDRESS)));
    7. #else
    8. static U32 aMemory[GUI_NUMBYTES / 4];
    9. #endif
    10. //
    11. // Assign memory to emWin
    12. //
    13. GUI_ALLOC_AssignMemory(aMemory, GUI_NUMBYTES);
    14. //
    15. // Set default font
    16. //
    17. GUI_SetDefaultFont(GUI_FONT_6X8);
    18. }
    Display All

    I go over to disassembly code and in the line 0x08003C6A BD10 POP {r4,pc} The code goes to HardFault_Handler function.
    The disassembly code is below:

    Source Code

    1. 0x08003CB2 4803 LDR r0,[pc,#12] ; @0x08003CC00x08003CB4 F7FDFF22 BL.W GUI_ALLOC_AssignMemory (0x08001AFC) 104: GUI_SetDefaultFont(GUI_FONT_6X8); 105: 0x08003CB8 4802 LDR r0,[pc,#8] ; @0x08003CC40x08003CBA F7FFFD81 BL.W GUI_SetDefaultFont (0x080037C0) 106: } 0x08003CBE BD10 POP {r4,pc}0x08003CC0 0000 DCW 0x00000x08003CC2 D060 DCW 0xD0600x08003CC4 0D00 DCW 0x0D000x08003CC6 0804 DCW 0x0804


    Is it possible that the code is the problem?
    If, for example, the display is not connect correctly should be the problem?
    What does exactly GUI_Init function? does it check the hardware?
    Thanks!
  • Hi Rapid84,

    Thank you for your help. I use an external sdram.

    By the way do you activate the CRC? I know how I can calculate CRC in interchange data through UART, for example, but I don't understand what do you want to say "activating the CRC".

    Thanks

    The post was edited 1 time, last by hibiscusblau ().

  • Hi,

    I've soldered again the external SDRAM and not works but I'm hangs in other point.

    I debug the code and put a breakpoint i GUI_Init(), then I put a breakpoint at the end of GUI_X_Config (GUIConf.c) and it arrives here correctly, then I put a breakpoint at the end of in LCD_X_Config (LCDConf.c) and arrives ok, and then I'm in:

    C Source Code

    1. void GUI_X_Init(void) {}



    And if I advance step by step, only the Dissassembly code (assembler) advances, so, I can see that the code runs towards correctly:

    - LCD_Init ()
    - LCD_SetClipRectMax
    - LCD_InitColors
    - GUI_DEVICE__GetpDriver
    etc.

    But I can't stop in the C code of these functions. And if I debug "step out" I lost the cursor untill HardFault Handler. Sometimes also goes to UsageFault_Handler and sometimes to DebugMon_Handler. I don't understand anything... it is very strange... What I do wrong?

    Is it possible that I broke the TFT?
  • Hi,

    not sure what causes the HardFault. But you can try to get an idea what causes it using this application note from our embOS guys:
    segger.com/downloads/appnotes/…ngHardFaultsOnCortexM.pdf

    Further there is an generic HardFault handler (this need a valid login to be downloaded) which can be included to your project:
    segger.com/downloads/appnotes/HardFaultHandler.zip

    Both are available on this page:
    segger.com/downloads/appnotes

    Regards,
    Sven
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • hibiscusblau wrote:

    If I try to put you code: generic HardFault handler (https://www.segger.com/downloads/appnote…aultHandler.zip) is generating some errors.


    Dear hibiscusblau,

    Since you are using Keil, I assume the observed errors refer to the preprocessor directives contained in HardFaultHandler.S. This is due to the fact that by default Keil does not preprocess assembly files. To enable preprocessing of assembly files, please add --cpreproc to your assembler options.
    Does this solve the observed errors?

    Best regards,
    Martin
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Martin,

    Yesterday appears 51 errors, currently with your advice, apears 1 error and a warning which say:


    startup_stm32f429xx.s: Warning: A3912W: Option 'c' is deprecated.
    startup_stm32f429xx.s: error: A3900U: Unrecognized option '-preproc'.

    What it mean?

    Thanks
  • HI hibiscusblau,

    It seems the assembler confuses "--cpreproc" (2 hyphens) with "-c" (1 hyphen). Can you please check the number of hyphens on your command line?

    Best regards,
    Martin

    Edit: I just noticed I had the second hyphen missing in my post as well, probably causing this issue in the first place. I have subsequently corrected my post. Please kindly excuse any inconvenience caused!
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Martin,

    Thank you, now it's ok.

    I've obtained the following results but I don't know how I have to interpet these data:

    [img]https://i.imgsafe.org/db4c5b16ff.jpg[/img]

    Do you know what is happening?

    By other hand, I programed the same code in the STM32F429 DISCOVERY board, and works. And searching in google I've found a guy which change the capacitors (so, add 1uF in 100nF). I've tested it and in a one own board (only 1 from 4 own boards) which I've soldered these capacitors works, the rest of the boards there is hardfaulthandler again. (For this reason I'm continuing with this post).