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.

Compiler/CCSTUDIO: CCS compiler generates a very big bin file

Part Number: CCSTUDIO


Tool/software: TI C/C++ Compiler

Hi:

I use CCS8.0.0 with compiler version of  TI v18.1.1.LTS in my daily work. The default initialization model of ARM linker is --rom_model(-c).

I have two projects named "DMC5800" and "DMC5C00" respectively. They are almost all the same except the size of some global variable in "DMC5C00" is a little larger than "DMC5800",such as "double arr[12]" in "DMC5C00" but "double arr[8]" in "DMC5800". My problem is that the size of generated bin file of "DMC5800" is much bigger than that of "DMC5C00" under the identical compiling condition.

I have checked the generated object files which are shown below. I think it's the "Load Addr" of ".cinit" section that causes the problem which making the size of bin file of "DMC5800" reaching 65MB but 2MB with that of "DMC5C00".

My questions are that:

1.the two projects are almost the same, how does such a big difference of location of ".cinit" section come about under the identical compiling condition?

2.The 65MB bin file is too big to flash into ROM of our board, what can I do to handle this problem? 

  • For general background on binary files, please see this forum FAQ.

    Wang Wei said:
    I think it's the "Load Addr" of ".cinit" section that causes the problem

    That looks right.  It is located very far away from all the other initialized sections (i.e. the section type is either CODE or DATA).  

    For both builds, please get the linker command file and map file.  Put them all together in one zip file and attach that to your next post.

    Thanks and regards,

    -George

  • Hi George,

    thanks for your timely reply!

    I have attached the zip file including two map files and one linker command file which used by both builds.

    thanks and best regards!

    map file.rar

  • Thank you for sending the files.

    To anyone reading along on this thread, please understand the changes I'm about to recommend are very specific to the linker command file submitted by the customer. It is unlikely they can be used elsewhere.

    The overall idea is to allocate all of the initialized sections (code and data) close to each other.

    I recommend three changes ...

    1. Explicitly specify the .sysmem section
    2. Create a memory range just for the stack
    3. Add the HIGH location specifier to all the uninitialized sections, except the stack

    The following example is a starting point ...

    /* SPECIFY THE SYSTEM MEMORY MAP */
    
    MEMORY
    {
        DDR_MEM   : org = 0x80000000  len = 0x07FFEFF8 /* RAM */
        FOR_STACK : org = 0x87FFEFF8  len = 0x00001000
    }
    
    /* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY */
    
    SECTIONS
    {
        .init 	 : {
        			system.lib<init.obj> (.text)
        		   } load > 0x80000000
    
        .text    : load > DDR_MEM              /* CODE                          */
        .data    : load > DDR_MEM (HIGH)       /* INITIALIZED GLOBAL AND STATIC VARIABLES */
        .bss     : load > DDR_MEM (HIGH)       /* UNINITIALIZED OR ZERO INITIALIZED */
                                               /* GLOBAL & STATIC VARIABLES */
        				RUN_START(bss_start)
    					RUN_END(bss_end)
        .const   : load > DDR_MEM              /* GLOBAL CONSTANTS              */
        .sysmem  : load > DDR_MEM (HIGH)
        .stack   : load > 0x87FFFFF0           /* SOFTWARE SYSTEM STACK         */
    }
    

    Please understand that I am unable to test these changes.

    The .sysmem section is added so HIGH can be applied to it.

    By creating a memory range just for the stack, it is guaranteed that no other section will use that memory.  The example reserves 0x1000 bytes for the stack.  Feel free to change it.

    Why use the HIGH location specifier?  When allocating a section by default, the linker allocates that section to the lowest address within the given memory range.  The HIGH specifier changes that allocation to the highest address within the given memory range.  By applying HIGH to only the uninitialized sections, the remaining sections are together in the lower addresses, and the uninitialized sections are together in the higher addresses.  Please search the ARM assembly tools manual for the sub-chapter titled Controlling Placement Using The HIGH Location Specifier.

    Thanks and regards,

    -George

  • thanks very much!

    I have cut down the size to less than 1MB with your suggest that using the "HIGH" token.

    best regards!