Variables not getting placed in RAM

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

Variables not getting placed in RAM

716 Views
loosecannon
Contributor II

Variables are not getting correctly placesed. In V8.2.2 for windows building for a LPC11C24, variables are getting placed directly AFTER the RAM section. If I enlarge the RAM section (which is larger than physically on the chip), the variable moves, and if I shrink the section to half the chip RAM, the variable again moves to the memory immediately following the defined RAM section. I am using the NewlibNano nohost. Also, it looks like the memcpy operations in the Chip_UART_SendRB function are wiping out vtables so the next polymorphic function call causes a fault. I stepped through and everything looks correctly written with enough RAM, so have no idea why variables are getting placed outside of RAM and obviously not working. This is a statically located global variable. Does the NewlibNano have problems with C++ or memcpy? Why would variables get placed in RAM outside of the defined RAM segment?

The same code works fine for a Newlib nohost built binary running on an LPC1837.

0 Kudos
2 Replies

422 Views
loosecannon
Contributor II

Thank you for your response.  I found the problem.  I had a bug in my code that was clobbering data.  To look at why I wanted to know the location of the global variable but the debugger would not report it to me, so created another variable which was the address of the first.  The debugger reported the value of the pointer as the first location after RAM wherever that was configured to be.  But when I used the new pointer to print out the value in a console, then the pointer was set to a location correctly in the Ram segment; so the pointer I created to debug my code was probably getting optimized out when it was not directly used and the debugger was not dealing with it that well.  Thank you.

0 Kudos

422 Views
lpcxpresso_supp
NXP Employee
NXP Employee

Sounds rather strange. We have certainly not seen anything similar here. Can you clean and export your project and post it here? https://community.nxp.com/message/630625 

Or if not, could you at least post the .map file generated by the linker in the Debug/Release directory?

Can you also confirm if you are using LPCXpresso IDE's managed linker script mechanism (to automatically create linker scripts), or if you are providing your own? If you are using your own, please also provide these too.

0 Kudos