AnsweredAssumed Answered

External Memory - Hardfault on startup

Question asked by melamud.michael on Feb 19, 2013
Latest reply on Feb 20, 2013 by melamud.michael

Hi,

I am having problem with the external memory.
Not so long ago my program used both the internal memory and the external, but I managed to move both the heap and the stack to the external memory (2 megabyte) ,and for now I am not using the internal memory anymore.

Everything worked great until now, I added a memory pool (taken from the freeRTOS source code). when I define my array (that will be used for the allocations) to 1 mb (or even less than that),I receive a hard-fault on startup, i managed to pin-point the problem :

LoopFillZerobss:

  ldr  r3, = _ebss

  cmp  r2, r3

  bcc  FillZerobss

/* Call static constructors */

  bl __libc_init_array // <- Here is the problem


I know that this function initializes the static variables , i also managed to find the exact location in the assembly on where it happens :

0804a490: __libc_init_array+40   b.n 0x804a49a <__libc_init_array+50>

0804a492: __libc_init_array+42   ldr.w r3, [r5],#4

0804a496: __libc_init_array+46   blx r3 //<- here is the problem

0804a498: __libc_init_array+48   adds r4,#1

0804a49a: __libc_init_array+50   cmp r4, r6

0804a49c: __libc_init_array+52   bne.n 0x804a492 <__libc_init_array+42>

 

My guess that it's trying to go to an invalid address, but why does it happens?

Also here is the output from the hard fault trace :

R0 = 0

R1 = 2000032C

R2 = 0

R3 = 64000240

R12 = 31

LR [R14] = 804F36B  subroutine call returnaddress //don't thing that it matters but its address of a function called "wctob"

PC [R15] = 0  program counter

PSR = 60000000

BFAR = E000ED38

CFSR = 20000

HFSR = 40000000

DFSR = 1

AFSR = 0

SCB_SHCSR = 0


The program counter is 0 , so for sure a reset happened .
I also attached my linker script and the startup file for you to look at.

(btw, when I am allocating a really small array for the memory pool (like 100k) ,it works fine.

Any help will be mostly appreciated

Thanks
Michael

Outcomes