cancel
Showing results for 
Search instead for 
Did you mean: 

big problem with memory

anhhuy0701
Associate II
Posted on March 06, 2014 at 04:44

hello everyone

today I have problem with memory but I cannot solve

I don't know it relate stack and heap or not.

in startupcode file, I

initialize

stack_size : 0x00013000 and heap_size : 0x00006000

because I read on this page

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0203g/Beiddiij.html

when debug, it jump to HardFault_Handler() and display statement: cannot access memory. I record the value of stack pointer register (SP), program counter (PC), Link register (LR)

------START-----

SP: 0x20019258

LR: 0x080002CB

PC: 0x080067D0

-----BEFORE DIED------

SP: 0x20019218

LR: 0x80062F9

PC: 0x08006F92

-----DIED-----

SP: 0x200191B0

LR: 0xFFFFFFE9

PC: 0x0800052A

can anyone help me?

thank in advance!

1 REPLY 1
Posted on March 06, 2014 at 05:01

Try to use a proper Hard Fault Handler (Google: Hard Fault Handler Joseph Yiu)

Understand the processor registers, and the assembler code that is faulting. Then you'll have a clue about what memory it's trying to access, and perhaps why. Add assert() or other sanity checking on variable you are using, and gauge the stack depth and utilization.

The stack size looks ridiculously large, have you made any effort to quantify how much you actually need based on your local/auto usage and call tree?

Make sure malloc() isn't returning NULL pointers, and perhaps wrap the malloc/free so you can understand the usage.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..