This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

IAR Map File



Hi

IAR map file shows the following:

 68 660 bytes of CODE  memory (+ 446 absolute )
 10 352 bytes of DATA  memory (+ 133 absolute )
 39 306 bytes of CONST memory

Flash consumption is CODE + CONST.
RAM consumption is DATA.

Could you please explain how should I refer to 'absolute' value?
Why is it separated from the other values?
Should I add this value to Flash/RAM usage? 

 

Regards,
Nir

  • I don't know for sure, but comparisons from other projects posted here seem to indicate (and the name fits) that these 'absolute' data bytes refer to data (variables, constants etc.) where the memory location has been explicitely told, so the linker does not relocate them. In case of data memory, these have (in most cases) turned out to be the accesed hardware registers (which are data, read/write, but not in the RAM segment, but on fixed, non-relocatable and therefore absolute addresses).

    For code, it might be any code or constant where you have set a fixed location on flash? Did you use INFO memory? Include a library that uses code at fixed locations? A bootloader? Or stubs generated in lower 64K of the address range to extend to the flash above 64k? Something in the runtime library (it shouldn't be absolute, but well)
    Until now, I have seen this 'absolute' statement only for data, not for code.

    Don't forget the space required for the stack. As the stack grows dynamically, depending on your program flow, local variables etc, it is not included in this table but also resides in RAM.

  • How can I calculate the increase in DATA size (RAM) which is not shown in the MAP file?
    Regards,
    Nir

  • DATA size is always shown in the map file (and the hardware register 'variables' of course do not use any RAM space).

    RAM usage, however, cannot be calculated easily. It fully depends on your program flow.

    If you call a function, it takes 2 bytes on stack, on MSP430X systems (20 bit addresses) it takes 4 bytes. Then any register usind inside the called function must be saved on stack (another 2 bytes each). Local variables are put on the stack too (and removed when teh function exits). Exception are static variables, which take normal DATA space just like global ones, and are handles exactly as these (including initialisation inside the reset function), only that no global reference is generated.

    If an ISR is called, 4 bytes are saved on stack and also all register which are required for the code inside the ISR (2 bytes each).

    Depending on the compiler (each one can handle this differently, I only know of the mspgcc), parameters passed to functions are either passed in a register (the mspgcc uses r12..r15 for up to 4 words or 2 dwords, and these 4 registers are not saved on stack nor restored, but considered clobbered after a function call or hold the return value) or on the stack (on mspgcc, if there are more than 4 byte/word, 2 dword or 1 64bit value). Calling printf requires a LOT of stack space, not only for calling the function and assign hte parameters, but also for the subfunction calls to convert values to text and then for calling the output function.

    If you dynamically allocate ram with malloc(), it also uses ram.

    How much is required cannot be determined by compiler or linker.

    You can try the following: at application startup, fill all memory above the used data area with a guard value (spare the uppermost bytes in case that main() uses them for the local variables) and then let your application run.  (a typical one is 0xaa55, usually used for testing ram integrity, but anything except 0 and 0xffff will do)
    After some time, if you think you have done everything, stop the application with the debugger and check the ram area for how much of the gard values have been overwritten by the stack. So you know that you at least need this much ram for the stack.

    If you do not find your guard value anymore at all, then your stack has already overflown into your data area and overwritten some of your variables.

  • I was looking for the answer to your question:

    "Could you please explain how should I refer to 'absolute' value?"

    I believe that this is the data accesses to hardware registers, which have fixed, i.e. absolute addresses. And this is the reason IAR does not count the data accesses towards the typical, i.e. relative, data memory usage.

    I believe this is true because I see in the Module Summary at the end of the MAP file that all absolute data allocations come from modules with ISRs, which of course access hardware registers. I also confirmed that commenting out a single hardware register write reduced the absolute data usage by 2 bytes.

    I'm not an IAR or MSP430 expert, can anyone else confirm this?

    Update:

    Anders confirmed this in What do Shared and Common Memory Represent in an IAR for MSP430 MAP File? on 11/21/2014.

**Attention** This is a public forum