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.

Generated .bin file blows up to size of heap

Genius 5820 points

Hi,

currently I'm using following linker command file to get a heap size of 64 MBytes and to do some code and data relocation as shown in BeagleBone demo:

-stack  0x00000008                         /* SOFTWARE STACK SIZE           */
-heap   0x04000000                         /* HEAP AREA SIZE 64 MBytes      */
-e Entry
--diag_suppress=10063

MEMORY
{
        DDR_MEM        : org = 0x80000000  len = 0x7FFFFFF           /* RAM */
       IRAM_MEM        : org = 0x40300000  len = 0x000FFFF           /* RAM */
}

SECTIONS
{
    // for relocation
    GROUP
    {
         IRAM_CODE : { }
         IRAM_DATA : { }
    }load=DDR_MEM, run=IRAM_MEM, START(iram_start), SIZE(iram_size), RUN_START(relocstart)

   GROUP: load = 0x80000000
   {
      .text:Entry :
      .text    :                             /* CODE                          */
      .data    :                             /* INITIALIZED GLOBAL AND STATIC VARIABLES */
      .const   :                             /* GLOBAL CONSTANTS              */
   }

   .bss:    load > DDR_MEM                    /* UNINITIALIZED OR ZERO INITIALIZED */
             RUN_START(bss_start)
             RUN_END(bss_end)
   .sysmem: load > DDR_MEM
   .stack   : load > 0x87FFFFF0           /* SOFTWARE SYSTEM STACK         */
}

Within my code I'm doing relocation this way:

extern unsigned int iram_start;
extern unsigned int iram_size;
extern unsigned int relocstart;
extern unsigned int relocend;
...
memcpy((void *)(&relocstart), (const void *)(&iram_start),(unsigned int)(&iram_size));

My problem: as soon as I use some statements like

#pragma CODE_SECTION(DMTimerIsr,     "IRAM_CODE")
#pragma DATA_SECTION(setStandbyFreq, "IRAM_DATA")

to specify which variables or functions have to be relocated, the resulting .bin file blows up to a size of about 64 MBytes. When I reduce the heap size defined in linker command file the size of the .bin file is reduced too.

When I remove the  DATA_SECTION or CODE_SECTION statements the size goes down to the real code size of about 120 kBytes.

So...any ideas why the whole heap becomes part of the .bin file?

  • With some trial and error I found a linker command syntax where the .bin file does not blow up and where code relocation works fine:

    -stack  0x00000008                         /* SOFTWARE STACK SIZE           */
    -heap   0x04000000                         /* HEAP AREA SIZE 64 MBytes      */
    -e Entry
    --diag_suppress=10063
    
    MEMORY
    {
            DDR_MEM        : org = 0x80000000  len = 0x7FFFFFF           /* RAM */
           IRAM_MEM        : org = 0x40300000  len = 0x000FFFF           /* RAM */
    }
    
    SECTIONS
    {
        GROUP
        {
             IRAM_CODE : { }
             IRAM_DATA : { }
        }load=DDR_MEM, run=IRAM_MEM, START(iram_start), SIZE(iram_size), RUN_START(relocstart)
    
    
       GROUP: load = 0x80000000
       {
          .text:Entry :
          .text    :                             /* CODE                          */
          .data    :                             /* INITIALIZED GLOBAL AND STATIC VARIABLES */
          .const   :                             /* GLOBAL CONSTANTS              */
       }
    
       .bss:    load > DDR_MEM                    /* UNINITIALIZED OR ZERO INITIALIZED */
                        RUN_START(bss_start)
                        RUN_END(bss_end)
        .const   : load > DDR_MEM              /* GLOBAL CONSTANTS              */
        .stack   : load > 0x87FFFFF0           /* SOFTWARE SYSTEM STACK         */
    }
    

    So...can anybody explain why this .cmd file behaves in correct way?

    And an other question: using this file I get a warning

    warning #10247-D: creating output section ".sysmem" without a SECTIONS specification

    How can I fix this? When I add a ".sysmem" section like in previous command file the resulting code is still unneccesarily huge.

  • since this is more of compiler query, i am moving this to Compiler forum.