cancel
Showing results for 
Search instead for 
Did you mean: 

Hardfault error (STM32F746G) when generating project with cubeMx

Zui
Senior

Hello

i'm using STM32F746G with touchGfx and keil for a project. i have a working empty project (a blank screen with a button). but when i regenerate the project with cubeMX checking the option :"generate peripheral initialization as a pair of '.c/.h/' files per peripheral" i get HardFault Handler. My keil caller stack say is caused by: touchgfx_init ->setLanguage ->hardFault_Handler

28 REPLIES 28
Imen.D
ST Employee

Hello @Zui​ ,

Please provide your ioc file with more details about the STM32CubeMX and firmware package versions used.

This will help us to check and analyze your issue.

Best Regards,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Ozone
Lead II

Toolchains are notoriously bad at determining stack sizes.

A quick test would be to try that first. With touchGFX involved, I would guess 1 or 2 kBytes.

Can you elaborate on how to find and change the stack size?

Embedded UI/UX Consulting: cadenza.design

The OP was using Keil, there the stack size is called out in startup_stm32f7xx.s

Seem to recall IAR having something in the .ICF file, whereas GNU/GCC just comingles the heap/stack and hopes they don't plough into each other.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

i tryed both increasing the stack size in startup_stm32f7xx.s and the stack size given to osThreadDef function inside  MX_FREERTOS_Init();  but didn't work.

i tryed both increasing the stack size in startup_stm32f7xx.s and the stack size given to osThreadDef function inside  MX_FREERTOS_Init();  but didn't work.

Martin KJELDSEN
Chief III

Have you enabled CRC? The STM32 CRC check may be failing which results in an intentional hard fault.

Otherwise it could have something to do with QSPI initialization since texts and fonts are placed in external flash by default.

@Martin KJELDSEN​  thanks for your reply.

Yes i have crc enabled. i've tryed disabling it, but nothing changed.

How can it be QSPI initialization since the same empry project generated with cubeMx with "generate peripheral initialization as a pair of '.c/.h/' files per peripheral" doesnt work, but without that option do work. the QSPI initialization is the same.

Need to look at faulting instructions and processor registers to determine the nature of the failure better. Published routines to dump salient details previously.

An access/probe of QSPI memory will fault if the memory is not properly initialized, same with SDRAM.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..