ebarker123 wrote:
>Here is the scenario.
>
>I have an MCB2138 eval board. I have a menu talking on a serial port.
>
>Using the menu, I can set and print a variable called 'mytemp'.
>
>I set the value to say, 456, and print that out.
>
>I press reset and the value is changed to 0.
>Where/How is this variable getting changed. My application requires
>that we be able to press reset, and the SRAM contents not change.
>
>
>
Look in your crt0.s file, bss sections are zeroed there. 'bss' data is
data which you declared globally and did not provide a value for. *ALL*
C code systems initialize the bss data section, all, this is a
requirement of the C language.
If you want to create memory which is part of the code but is not
initialized, add a section attribute to it and then place the section
into the linker ld script. For example:
char myString [8] __attribute__((section ("noinit")));
in the linker script, place a new section AFTER the bss. You want to
avoid placing this in front of "__bss_end__ = . ;"!
================= begin LPC2106ROM.ld ===============
/* .bss section which is used for uninitialized data */
.bss (NOLOAD) :
{
__bss_start = . ;
__bss_start__ = . ;
*(.bss)
*(COMMON)
. = ALIGN(4);
} > RAM
. = ALIGN(4);
__bss_end__ = . ;
PROVIDE (__bss_end = .);
.myvars (NOLOAD) :
{
*(noinit)
} > RAM
.stack ALIGN(256) :
{
. += STACK_SIZE;
PROVIDE (_stack = .);
} > RAM
_end = . ;
PROVIDE (end = .);
================== snip ====================
Note the new region called ".myvars" in the script? That is where I
will put the "noinit" section.
To make sure that all is well, look at the symbol file produced by the
linker. In my case it is main2106.sym, in it I look at the memory
location of '__bss_end__' and 'myString'. Here is a snippet of my
symbols file:
============= begin main2106.sym ===============
400092e2 B serial1ParityMode
400092e4 B tx1Buffer
40009ae8 B Words
40009dec B WordCnt
40009df0 A __bss_end__
40009df0 B myString
4000ae00 A end
4000ae00 A _end
4000ae00 B _stack
================= snip =====================
Actually, that is the very end of the symbol file. The variable
myString is placed at the end of the RAM. Adding more data to this new
section is quite easy now, simply assign the same attribute to each:
char myString [8] __attribute__((section ("noinit")));
struct BIG_DATA abort_info __attribute__((section ("noinit")));
int timeAborted __attribute__((section ("noinit")));
...
Hope this helps,
TomW
--
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------------------------------------------Message
Re: [lpc2000] ram initialization at reset
2006-03-07 by Tom Walsh
Attachments
- No local attachments were found for this message.