cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F303 Flash size / Hardfault error

laurentwawrzyniak9
Associate II
Posted on October 21, 2013 at 16:10

Hello,

I am using a :

 STM32F303RC (256k FLASK, 32k RAM, 8K CCRAM)

 gcc g++ tool chain with Eclipse. 

At compilation time, my firmware memory are as following:

arm-none-eabi-size  --format=berkeley -t Muster.elf

   text   data    bss    dec    hex filename

 261528   1640  30076 293244  4797c Muster.elf

The flashing is working but when the program starts, i got immediatly a HardFault_Handler() interrupt.

It seems that there are 616 bytes remaining in the flash but this size is not enough to start.

Is someone has an explanation for this behavior ?

#flash-size-hardfault-error
3 REPLIES 3
Posted on October 21, 2013 at 16:15

You only have 616 bytes if you don't have any variables that get initialized. If you are copying stuff to RAM, it has to live somewhere.

Have you stepped through the initialization code to observe where it Hard Faults?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
laurentwawrzyniak9
Associate II
Posted on October 21, 2013 at 17:45

It happens in the startup_stm32f30x.s file  at function LoopCopyDataInit.

After a while it crashes.

CopyDataInit:

ldr r3, =_sidata

ldr r3, [r3, r1]

str r3, [r0, r1]

adds r1, r1, #4

LoopCopyDataInit:

ldr r0, =_sdata

ldr r3, =_edata

adds r2, r0, r1

cmp r2, r3

bcc CopyDataInit

ldr r2, =_sbss

b LoopFillZerobss

Posted on October 21, 2013 at 17:53

Your linker output suggests you're some 1024 bytes OVER your budget, not 616 bytes BELOW it.

Compiled with Keil it might fit, GNU/GCC tends to bulk things up, even with optimization.

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