cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 Hardfault when DMA is used with Optimization to speed is open

eds
Associate III

I'm working on a project using an STM32H7 series MCU with FreeRTOS. I've customized the .ld file to configure the stack and have set up the internal ADC and DMA to continuously read and store ADC values. I've statically assigned the DMA data registers starting at 0x24000000. Initially, my project worked fine, but I needed to increase the execution speed, so I enabled compiler optimizations for speed.

However, after enabling optimizations, I started experiencing a HardFault error which I've been unable to resolve. The error occurs only after the optimizations are turned on. Here are the settings and configuration details:

  • MCU: STM32H7 series
  • RTOS: FreeRTOS
  • Memory Configuration: Customized .ld file, DMA data registers at 0x24000000
  • Compiler Settings: Optimization for speed enabled

I suspect the issue might be related to memory access or alignment due to the optimizations altering how quickly certain operations are executed. Has anyone faced a similar issue, or can anyone suggest potential fixes or debugging strategies to resolve this HardFault error?

10 REPLIES 10
eds
Associate III

It was half a solution, the project is working now with the change of memory and also I needed to close the memory allocation for optimization which was -fdata-sections