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.

Determining Memory Size

Hi,

 

I am relatively new to the msp.  Currently I am using Code Composer to program a MSP430 am running into issues with memory size.  I have over exceeded the bounds for code size and am alerted that the .bss size is now too large for my particular chip.  I am curious, how can I find out the size of .bss after I have reduced my code?  What sorts of changes to my code affects .bss?  Can I just simply remove lines of code to reduce it?

Any insight on memory size and code size, etc would be greatly appreciated.

 

Thanks!

 

  • Hi Dustin,

    You can monitor your memory usage (both RAM and Flash) with the .map file created when the project builds / links.  Typically the file name will just be the name of the project with the .map extension.  You can find out the file name or change it in the project properties, MSP430 Linker, Basic Options tab.  There you will see a box with the output file name and the .map file ("Input and output sections listed into"... *.map").  Note that on the same tab you can allocate the sizes for the stack and heap used in the project, which will affect the amount of RAM you have available for global and static variables.

    The .map file lists the usage of the different output sections.  Usually your global and static variables will be in the .bss section.  Actual code is usually in the .text output section.  Note that the listing provides the usage by module, so you can figure out which are the big users.  For example, you may have a module that declares a large variable array, which could be using a significant amount of your available RAM.

    Another related file for looking at your memory usage is the Linker Command file.  This will be specific to the MSP430 variant you're using on the project, and describes the memory configuration you have available on the chip.  It includes the system memory map, which lists the available RAM and flash sections.  Then it describes the actual output sections (.bss, .text, ....) and where they will be located (RAM, FLASH, ....).  (You can modify your own linker command file to create new sections to put tables in specific locations, ... )

    Regarding code space usage, during development people like to sometimes use assertions to monitor for abnormal situations (include assert.h), which only really apply if compiling the project for DEBUG (rather than RELEASE).  These can use large amounts of memory for the assertion messages that get printed out.  Similarly, if you're using printf's, you typically need to use a good amount of the available RAM for the heap.

    The compiler has many settings for optimizations (optimize for code space size, optimize for speed, ....). 

    Hope this helps a bit.  Good luck with your project!

    Dave H.

     

     

  • You could use a simple perl command liner like this one:

    @ofd430.exe yourfile.out | $(PERL) -ne '$$b{$$1}+=hex($$2) if /\.(text|text_isr|text2|data|bss|cinit|const|stack|sConst)\s+0x\S+ 0x\S+\s+0x(\S+)/; END { printf("%16d bytes in ROM\n%16d bytes in RAM\n",$$b{text}+$$b{text_isr}+$$b{text2}+$$b{data}+$$b{cinit}+$$b{const}+$$b{sConst}+0x40,$$b{data}+$$b{bss}+$$b{stack}); }'


    The above sections (sConst, text2,...) are from my linker command file.  You have to modify the perl script according to your needs.

    Hardy

  • Dave,

    You are a champ, thanks a lot of the good information, it has helped considerably.  I do have a follow up question.  I have been able to reduce my code size to more manageable levels, however, there is one file that remains rather large and I don't know what exactly I can do to affect it and hopefully make it smaller.  That file is the .cio file.  Do you know what exactly that is and what it is that contributes to it?

     

    Thanks!

  • FYI,

    I am not using printf or any related functions, so I'm not sure why .cio would be so large.  I am using time.h, which seems to be the culprit, however, I'm not sure how...

    Here is the code that uses the time.h header:

    ////////TESTING////////

     time_t t1,t2;

    (void) time(&t1);

                //my code
                read_pyr_adc();            // read SP ADC values
                read_t();                        // read SP temp value
                       
                AppendOutputFile(file_name);

    (void) time(&t2);



    /////////////////////////

  • Dustin,

    I'm assuming you're referring to the .cio section, rather than the .cio file?  I believe the .cio is a RAM section used for variables for C library functions and macros.  In the linker command file, I believe this section is called the "C I/O BUFFER".  There is some mention of the library functions in the Code Composer C Manual (slau132d.pdf).  See 430cio.h.  I don't think people typically modify the library functions as described, but you may just want to take a look at what types of library functions / macros you're including?  I'm sure someone else could help you out here better than myself, but maybe if you're using special math or string or other library functions?  Might be a place to look.

    Dave H.

**Attention** This is a public forum