Stack placed in RAM2

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

Stack placed in RAM2

1,501 Views
markvanderheijd
Contributor II

My stack is placed at location 0x20080000 on my LPC1766. Thats AHB SRAM - bank 1. I like to have my stack on the On-chip SRAM(0x10000000). my linker script is defined like this:

PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0);

What can be the reason that it still writing in RAM2(bank1)?

Labels (1)
0 Kudos
Reply
4 Replies

1,133 Views
markvanderheijd
Contributor II

Thank you for your reaction, 

I hope you can explain me something.

when i execute this code:

uint8_t test;

printf("test addr %x\r\n",&test);

my debug output says:
test addr 20083fe7

So my thought was that [test] is placed on the stack and with asking the adders of [test] i can figure out where the stack is placed.

my current problem is that the initialization of local variable goes wrong.

void SCR_idle(void){
   Point_t point1 = {.x=120,.y=30}; 

..etc

after executing Point_t point1 = {.x=120,.y=30};  the value of point.x ==0 and point.y == 0.
when i was searching for the problem i found out with printing the location of the variables that its on a different location.

I though that my  memory was build up like:

On-chip SRAM-bottom:

-vtable
-bss

-data

-heap

On-chip SRAM-top:

-stack

RAM2

-bss (large buffers defined by   __BSS(RAM2))

whats wrong with my interpretation?

thank you in advance!

0 Kudos
Reply

1,133 Views
jeremyzhou
NXP Employee
NXP Employee

Hi mark van der Heijden,

Thanks for your reply and I'd like to confirm something wih you.

Whether test is the global value.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,133 Views
markvanderheijd
Contributor II

Hi Jeremyzhou,

Thank you for your reaction.

The variables are local variables.


I moved more buffers to RAM2 and now my code seems to work. But i still don't understand whats happening.
two things are unclear for me.

1. my previous question : wy the  function :
void SCR_idle(void){
   Point_t point1 = {.x=120,.y=30}; 

   printf("debug addr: %x", &point1 )

}

printout a location in the RAM2 segment.

2.in my startup file i write my whole memory(On-chip SRAM) with a pattern 

unsigned int addr;
for(addr = 0x10000000; addr < 0x10007DFF; addr++){
if(addr %2){
*(unsigned int *)addr = 0xde;
}else{
*(unsigned int *)addr = 0xad;
}
}

after the failing initialization of a local variable i checked my memory and i see a lot of DEADDE still in my memory. Wat can be the reason that the initialization is failing.

thank you in advance!

0 Kudos
Reply

1,133 Views
jeremyzhou
NXP Employee
NXP Employee

Hi mark van der Heijden,

The question seems a bit interesting, and I will appreciate if you share the completely testing code.

I'm looking forward to your reply.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply