cancel
Showing results for 
Search instead for 
Did you mean: 

SRAM after Reset

paulsmitton9
Associate III
Posted on September 23, 2008 at 06:50

SRAM after Reset

15 REPLIES 15
stevemelnikoff9
Associate II
Posted on May 17, 2011 at 12:44

If, most of the time, you're only going to be calling a small section of code which doesn't use any static variables, it may be possible to delay calling __main (the library module which does the initialisation), until you've determined whether the main part of the code needs to be executed.

Bear in mind that I haven't tried this, and, to my knowledge, ST haven't released the source code for this module.

Of course, the disassembly for it accessible from the debugger, so you could hack that to only initialise the parts of the memory you need for this task.

Steve.

lanchon
Associate III
Posted on May 17, 2011 at 12:44

> I was thinking that if everything was volatile, the compiler would not assume anything was zero, even if it thought it had been initalised to zero.

the compiler won't assume any globals are zero unless they are const; volatile doesn't enter into it. in theory a global optimizer could find such things out. in practice compilers work with compilation units and a compiled unit must operate correctly when linked with all possible future compiled units, which means the compiler can't make assumptions now about what yet non-existing units will store or not and where. so globals won't be assumed to have any particular value.

that said, if the compiler did assume a zero, it'd be good for you. if a global should be zero but is not, code that depends on that fact will malfunction; unless the code just assumes the value is zero and doesn't read it, in which case it'll work fine!

(note that global statics are only visible within their compilation unit and current compilers could global-optimize on them. no idea what actual compiler do.)

stevemelnikoff9
Associate II
Posted on May 17, 2011 at 12:44

Hey Lanchon.

Quote:

the compiler won't assume any globals are zero

Are you sure about this? As far as I'm aware, ANSI C requires that all non-automatic variables be set to zero, and embedded compilers tend to implement this.

Steve.

disirio
Associate II
Posted on May 17, 2011 at 12:44

It is more a C runtime requirement than a compiler requirement IMO. Using GCC it is possible to use an uninitialized BSS. It is not the safest thing to do anyway.

Giovanni

---

ChibiOS/RT

http://chibios.sourceforge.net

lanchon
Associate III
Posted on May 17, 2011 at 12:44

steve,

I say bananas are yellow.

you say, are you sure about this? as far as I'm aware carrots are orange.

I can't really answer without repeating myself.

btw, you're right about the carrots.

stevemelnikoff9
Associate II
Posted on May 17, 2011 at 12:44

LOL 🙂

Ah, I see what you mean.

Steve.