2008-09-22 09:50 PM
SRAM after Reset
2011-05-17 03:44 AM
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.2011-05-17 03:44 AM
> 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.)2011-05-17 03:44 AM
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.2011-05-17 03:44 AM
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/RT2011-05-17 03:44 AM
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.2011-05-17 03:44 AM
LOL :)
Ah, I see what you mean. Steve.