_asm_startmeup: problem on MCF52233 with ___SP_INIT addres...

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

_asm_startmeup: problem on MCF52233 with ___SP_INIT addres...

2,485 Views
osanz
Contributor I
Hello;
 
I have a problem with ___SP_INIT addres when is set inside _asm_startmeup: function...
 
I don't know why, but after my last complilation the software has not worked anymore.
After many times trying to start the debugger on the codewarrior, i had the same exception error about vector address.
 
Then in order to see where the problem can be, i have compiled and run another program using the codewarrior debuger without problems.
 
After this, i have searched for the diffrences between both codes, the new one that is not working, and the old one that has worked perfectly....
 
Finaly i have found the difference:
-On the old code, the ___SP_INIT addres is filled with 0x20008000 on the _asm_startmeup:, ->OK THIS IS WORKING
 
-On the new code, the ___SP_INIT addres is filled with 0x20008EE0 and application crashes when arrives to 'SYSTEM_SysInit' function.
 
I have manually set the ___SP_INIT value to 0x20008000 on this new code and HAS WORKED!!!!!
 
MY QUESTION IS:
Where is the ___SP_INIT value configured on my code????
 
 
 
Labels (1)
0 Kudos
5 Replies

569 Views
RichTestardi
Senior Contributor II

Hi,

> MY QUESTION IS:
> Where is the ___SP_INIT value configured on my code????

Is it in your .lcf file, under Linker Files?

Or maybe you're asking something else...

-- Rich

 

0 Kudos

569 Views
osanz
Contributor I
Hi again.
 
Let me explain better...
I know this value is set on the linker configuration file:
Code:
....
# Heap and Stack sizes definition
 ___heap_size   = 0x1000;
 ___stack_size     = 0x1000;
....
 .custom : {  ___HEAP_START = .;  ___heap_addr = ___HEAP_START;  ___HEAP_END  = ___HEAP_START + ___heap_size;  ___SP_END  = ___HEAP_END;  ___SP_INIT  = ___SP_END + ___stack_size;  . = ALIGN (0x4); } >> userram

 So as far as i can understand ___SP_INIT = '.'  + ___heap_size + ___stack_size.
So, SP_INIT is in my case '.' + 0x2000.
 
Ok. My problem is this file configures the SP_INIT value at 0x20008EE0, and the program crashes on the start up.
 
By comparing with other programs, i have seen thath the SP_INIT value is set at 0x20008000, and if I set manually this value on the code of the first program it works.
 
My questiona are:
Which value should be on SP_INIT?
Why the linker file value ( 0x20008EE0 ) is not valid? ( application crashes on startup )
How can I avoid this problem?
 
Thanks...
0 Kudos

569 Views
RichTestardi
Senior Contributor II
Hi again,
 
My guess is you have just run out of RAM as your program grew...
 
Have you looked at your xMAP (in the "bin" directory) file to see where your RAM is being used?
 
You'll see an overview of the memory map at the end of the file, like:
 
# Memory map:
  v_addr   p_addr   size     name
  00000000 00000000 00000400 .vectors   vectorrom
  00000400 00000400 00000018 .cfmprotect cfmprotrom
  00000500 00000500 00000000 .code      code
  00000500 00000500 00002EB4 .text      code
  20000000 20000000 00000000 .vectorram vectorram
  20000400 20000400 00000000 .userram   userram
  20000400 000033B4 0000001C .data      userram
  2000041C 2000041C 000003EC .bss       userram
  20000808 20000808 00000000 .custom    userram
  20000808 000033D0 00000018 .romp      userram
 
And then your stack is in your custom section, like:
 
# .custom
#>20000808          ___HEAP_START (linker command file)
#>20000808          ___heap_addr (linker command file)
#>20001808          ___HEAP_END (linker command file)
#>20001808          ___SP_END (linker command file)
#>20002808          ___SP_INIT (linker command file)
#>20000000          ___VECTOR_RAM (linker command file)
#>20002808          __SP_INIT (linker command file)
#>000033D0          _romp_at (linker command file)
 
I'm running a part with only 16kB of memoy, starting at 0x20000000, so you can see in this example my stack is within my legal range of 0x20000000 to 0x20004000.
 
-- Rich
 
0 Kudos

569 Views
osanz
Contributor I
Dear Rich, you're rigth again!!!!
 
I'm out of RAM ( a lot!!!! ).
 
I have checked and due i have included a ETHERNET stack to my code, some buffer sizes are too big to fit on this MCF52233.
 
Thanks a lot, really.
0 Kudos

569 Views
Arev
Contributor III
Hello,
 
I always put the stack at the end of the RAM and Unused RAM is dedicated to the Heap.
SP Address depends only of SP_SIZE.
 
Example of SP at the end of SRAM. 

Code:
 
    ___SRAM             = ADDR(.RAM_SRAM);
    ___SRAM_SIZE    = 0x00010000;
    ___SP_SIZE          = 0x2000;
 
    .custom :    {        . = ALIGN(0x40);        ___HEAP_START   = .;        ___HEAP_END     = ___SRAM + ___SRAM_SIZE - ___SP_SIZE;        ___SP_END       = ___HEAP_END;        ___SP_INIT      = ___SP_END + ___SP_SIZE;        ___heap_addr    = ___HEAP_START;        ___heap_size    = ___HEAP_END - ___HEAP_START ;        __SP_INIT       = ___SP_INIT;        . = ALIGN (0x40);    } >> RAM_ProgSector

 
I Hope this helps..

Bye
 
<< Freescale MCF5234/35 with CodeWarrior 6.2 >>
0 Kudos