Search code examples
mcu

Any reason not to increase .bss or .data section size on MCU?


I'm a little surprised that I couldn't find an answer to this question so I'll just ask it. I have a farely large Look Up Table which is not initialized and hence will be placed in the .bss section of my TI TMS320F280049 MCU. Not surprisingly the bss section is way to small for that.

So I thought of several ways to fix this issue:

  1. Increase the .bss section size
  2. Initialize the LUT (which is not really necessary in my case) and increase the .data size until it fits in there.
  3. Create a dedicated RAM section for this LUT (must be RAM, flash is not sufficient due to slower access time)

Thanks to a lack of experience I cannot really tell which variant would be best. Is there any reason why you shouldn't screw with the section size of .bss and .data?

Thanks in advance for taking the time to answer!


Solution

  • Answer from TI support:

    1) Increase the .bss section size
    

    There is no particular reason why we used only 1 RAM block for allocating bss section. That is just a template and was sufficient for the C2000ware examples. There is no restriction on number of RAMs that is used to map the section

    2) Initialize the LUT (which is not really necessary in my case) and increase the .data size until it fits in there.
    

    The only disadvantage I see in this case is, compiler generates a separate section to store the initial values. This just adds to the total memory size (the initial values are usually loaded to Flash).

    Also, initializing of the globals will consume cycles. But, in case you are using EABI format, even the non-initialized variables will be initialized to 0 by default, hence you wont see a significant difference in cycles. But in case of COFF format, this approach will consume more cycles.

    3) Create a dedicated RAM section for this LUT
    

    This method as well works fine. You can use #pragma DATA_SECTION to make the global go to a user-specified section, instead of the default .bss section. This new section needs to be specified in the cmd file with the RAM mapping. I do not see any advantage or disadvantage of this method over the first one