cancel
Showing results for 
Search instead for 
Did you mean: 

SDRAM-based heap initialized as part of ZI-data

cnicolls
Associate
Posted on June 11, 2015 at 04:34

I'm developing an application which requires the heap to be located in a large off-chip SDRAM. I'm using Keil uVision5 and scatter-loading to accomplish this. Functionally, all is good and works as expected.

One quirk I've noticed though is that the heap is linked into ZI-data, which is initialized to 0 in the C runtime. This creates a significant startup delay as the entire 32MB SDRAM is zero'ed. Is there a way to prevent the initialization from taking place? The scatter file I'm using is below... Results after linking...notice the 32MB ZI-data!

Program Size: Code=26176 RO-data=956 RW-data=1512 ZI-data=33561488

Scatter File

#! armcc -E
; -----------------------------------------------------------------------------
; SCATTER 
FILE
; Note: By running armcc above, 
this
file is sent to the C preprocessor
; This allows us to use a file like memory_map.h, which the code uses
; This should prevent mismatches in the code vs. scatter file
; Note: These #includes are done in a very specific order
; -----------------------------------------------------------------------------
#include ''sdram.h''
#include ''memory_map.h''
MAIN_APPLICATION MAIN_CODE_BASE_ADDRESS MAIN_CODE_SIZE
{
ER_RESET_AND_LIBS +0
{
*.o (RESET, +First) ; Locate vector table first
*(InRoot$$Sections) ; All library sections that must be in a root region
.ANY (+RO) ; Any read-only data otherwise unspecified
}
SRAM INTERNAL_SRAM_BASE_ADDRESS SRAM_SIZE
{
.ANY (+RW +ZI)
}
SDRAM_HEAP HEAP_LOCATION UNINIT HEAP_SIZE
{
*(HEAP)
}
}

Relevant Startup Code (for completeness)

; ------------------------------------------------------------------------------
; C Inclusions (requires --cpreproc in assembler command!)
; ------------------------------------------------------------------------------
#include ''sdram.h''
#include ''memory_map.h''
; ------------------------------------------------------------------------------
; Stack Definition
; ------------------------------------------------------------------------------
Stack_Size EQU STACK_SIZE
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; ------------------------------------------------------------------------------
; Heap Definition
; ------------------------------------------------------------------------------
Heap_Size EQU HEAP_SIZE
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit

0 REPLIES 0