AnsweredAssumed Answered

Adding an uninitialized data section to a GCC build?

Question asked by van_hooft.frank.001 on Dec 22, 2011
Latest reply on Aug 31, 2014 by meeh.ralf
Perhaps the subject line is a bit cryptic, but does anybody know how to add uninitialized data sections to the linker script? The F4xx has two RAM banks. I want to use the smaller 64 kB as the normal RAM area (.bss etc) and the larger 128 kB RAM as an area for large data buffers, which would be declared using the __attribute__ in the C code. Here's what I've done...

In the linker script:

  RAM_C (xrw) : ORIGIN = 0x10000000, LENGTH = 64K
  RAM_D (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
  FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K

 and also

/* This is the 128 kB RAM, used for data buffers that require DMA access. This RAM is not used by default -
the programmer
must explicitly specify using this RAM by something like: 
uint8_t mybuffer[1024] __attribute__((section(".buffram")));   
   Also, the programmer should NOT assume this RAM will be initialised at boot.   */
  . = ALIGN(4);
    *(.buffram)            /* .buffram section */
  . = ALIGN(4);
} >RAM_D

Then in my C code I do (for example):

volatile uint8_t buff0[16384] __attribute__((section(".buffram")));

It's all great, everything compiles and links OK, no problems in that regards. BUT...

The output hex file is huge. Because it contains a 64 kB section of .buffram section, all zeros.

Put another way, it's kinda like it's treating this new data section as flash, in that it's putting it into the output hex file.

I've been googling and reading LD documentation like crazy, but I'm missing some magic trick here. How do I keep this data section out of my hex file?