1
0
forked from me/IronOS

Merge pull request #1682 from Ralim/pinecilv2-memory

Adjust how heap and ram sections are allocated
This commit is contained in:
Ben V. Brown
2023-05-16 06:46:13 +10:00
committed by GitHub
4 changed files with 47 additions and 45 deletions

View File

@@ -19,10 +19,11 @@ uint16_t ADCReadings[ADC_NORM_SAMPLES]; // room for 32 lots of the pair of readi
// Heap // Heap
extern uint8_t _heap_start; extern uint8_t __HeapBase;
extern uint8_t _heap_size; // @suppress("Type cannot be resolved") extern uint8_t __HeapLimit; // @suppress("Type cannot be resolved")
const uint32_t _heap_size = ((&__HeapLimit) - (&__HeapBase));
static HeapRegion_t xHeapRegions[] = { static HeapRegion_t xHeapRegions[] = {
{&_heap_start, (unsigned int)&_heap_size}, {&__HeapBase, (unsigned int)_heap_size},
{NULL, 0}, /* Terminates the array. */ {NULL, 0}, /* Terminates the array. */
{NULL, 0} /* Terminates the array. */ {NULL, 0} /* Terminates the array. */
}; };

View File

@@ -41,7 +41,7 @@
/* Std driver attribute macro*/ /* Std driver attribute macro*/
#ifndef BFLB_USE_CUSTOM_LD_SECTIONS #ifndef BFLB_USE_CUSTOM_LD_SECTIONS
//#define ATTR_UNI_SYMBOL // #define ATTR_UNI_SYMBOL
#define ATTR_STRINGIFY(x) #x #define ATTR_STRINGIFY(x) #x
#define ATTR_TOSTRING(x) ATTR_STRINGIFY(x) #define ATTR_TOSTRING(x) ATTR_STRINGIFY(x)
#define ATTR_UNI_SYMBOL __FILE__ ATTR_TOSTRING(__LINE__) #define ATTR_UNI_SYMBOL __FILE__ ATTR_TOSTRING(__LINE__)
@@ -49,7 +49,7 @@
#define ATTR_CLOCK_CONST_SECTION __attribute__((section(".sclock_rlt_const." ATTR_UNI_SYMBOL))) #define ATTR_CLOCK_CONST_SECTION __attribute__((section(".sclock_rlt_const." ATTR_UNI_SYMBOL)))
#define ATTR_TCM_SECTION __attribute__((section(".tcm_code." ATTR_UNI_SYMBOL))) #define ATTR_TCM_SECTION __attribute__((section(".tcm_code." ATTR_UNI_SYMBOL)))
#define ATTR_TCM_CONST_SECTION __attribute__((section(".tcm_const." ATTR_UNI_SYMBOL))) #define ATTR_TCM_CONST_SECTION __attribute__((section(".tcm_const." ATTR_UNI_SYMBOL)))
#define ATTR_DTCM_SECTION __attribute__((section(".tcm_data"))) // #define ATTR_DTCM_SECTION __attribute__((section(".tcm_data")))
#define ATTR_HSRAM_SECTION __attribute__((section(".hsram_code"))) #define ATTR_HSRAM_SECTION __attribute__((section(".hsram_code")))
#define ATTR_DMA_RAM_SECTION __attribute__((section(".system_ram"))) #define ATTR_DMA_RAM_SECTION __attribute__((section(".system_ram")))
#define ATTR_NOCACHE_RAM_SECTION __attribute__((section(".nocache_ram"))) #define ATTR_NOCACHE_RAM_SECTION __attribute__((section(".nocache_ram")))

View File

@@ -18,17 +18,15 @@ OUTPUT_ARCH( "riscv" )
ENTRY(_enter) ENTRY(_enter)
StackSize = 0x800; /* 2KB */ StackSize = 0x800; /* 2KB */
HeapSize = 0x800; /* 2KB */
__EM_SIZE = DEFINED(ble_controller_init) ? 8K : 0K; __EM_SIZE = DEFINED(ble_controller_init) ? 8K : 0K;
MEMORY MEMORY
{ {
xip_memory (rx) : ORIGIN = 0x23000000, LENGTH = 1022K xip_memory (rx) : ORIGIN = 0x23000000, LENGTH = 1022K
itcm_memory (rx) : ORIGIN = 0x22014000, LENGTH = 16K itcm_memory (rx) : ORIGIN = 0x22014000, LENGTH = 12K
dtcm_memory (rx) : ORIGIN = 0x42017000, LENGTH = 4K dtcm_memory (rx) : ORIGIN = 0x42017000, LENGTH = 4K
ram_memory (!rx) : ORIGIN = 0x42018000, LENGTH = 64K ram_memory (!rx) : ORIGIN = 0x42018000, LENGTH = 96K
rsvd_memory (!rx) : ORIGIN = 0x42028000, LENGTH = 1K
ram2_memory (!rx) : ORIGIN = 0x42028400, LENGTH = (31K - __EM_SIZE)
hbn_memory (rx) : ORIGIN = 0x40010000, LENGTH = 0xE00 /* hbn ram 4K used 3.5K*/ hbn_memory (rx) : ORIGIN = 0x40010000, LENGTH = 0xE00 /* hbn ram 4K used 3.5K*/
} }
@@ -211,21 +209,27 @@ SECTIONS
__tcm_data_end__ = .; __tcm_data_end__ = .;
} > dtcm_memory } > dtcm_memory
/* .heap_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of heap sections, and assign /*************************************************************************/
* values to heap symbols later */ /* .stack_dummy section doesn't contains any symbols. It is only
.heap_dummy (NOLOAD): * used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (NOLOAD):
{ {
. = ALIGN(0x4); . = ALIGN(0x4);
. = . + HeapSize; . = . + StackSize;
. = ALIGN(0x4); . = ALIGN(0x4);
} > dtcm_memory } > dtcm_memory
_HeapBase = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory) - StackSize - HeapSize; /* Set stack top to end of RAM, and stack limit move down by
_HeapSize = HeapSize; * size of stack_dummy section */
__StackTop = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory);
PROVIDE( __freertos_irq_stack_top = __StackTop);
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
/* Check if data + heap + stack exceeds RAM limit */ /* Check if data + heap + stack exceeds RAM limit */
ASSERT(_HeapBase >= __tcm_data_end__, "region RAM overflowed with stack") ASSERT(__StackLimit >= __tcm_data_end__, "region RAM overflowed with stack")
/*************************************************************************/
/*************************************************************************/ /*************************************************************************/
/* .stack_dummy section doesn't contains any symbols. It is only /* .stack_dummy section doesn't contains any symbols. It is only
@@ -311,17 +315,16 @@ SECTIONS
. = ALIGN(4); . = ALIGN(4);
__HeapBase = .; __HeapBase = .;
/*__end__ = .;*/
/*end = __end__;*/
KEEP(*(.heap*)) KEEP(*(.heap*))
. = ALIGN(4); . = ALIGN(4);
__HeapLimit = .; __HeapLimit = .;
} > ram_memory } > ram_memory
PROVIDE (__heap_min_size = 0x400);
__HeapLimit = ORIGIN(ram_memory) + LENGTH(ram_memory); __HeapLimit = ORIGIN(ram_memory) + LENGTH(ram_memory);
PROVIDE( _heap_start = ORIGIN(ram2_memory) ); ASSERT((__HeapLimit - __HeapBase ) >= __heap_min_size, "heap size is too short.")
PROVIDE( _heap_size = LENGTH(ram2_memory) );
} }

View File

@@ -591,12 +591,10 @@ $(HEXFILE_DIR)/$(model)_font_compressed_%.elf : \
$(OUT_OBJS): $(OUTPUT_DIR)/%.o : %.c Makefile $(OUT_OBJS): $(OUTPUT_DIR)/%.o : %.c Makefile
@test -d $(@D) || mkdir -p $(@D) @test -d $(@D) || mkdir -p $(@D)
@echo Compiling ${<}
@$(CC) -c $(CFLAGS) $< -o $@ @$(CC) -c $(CFLAGS) $< -o $@
$(OUTPUT_DIR)/%.o : %.cpp Makefile $(OUTPUT_DIR)/%.o : %.cpp Makefile
@test -d $(@D) || mkdir -p $(@D) @test -d $(@D) || mkdir -p $(@D)
@echo Compiling ${<}
@$(CPP) -c $(CXXFLAGS) $< -o $@ @$(CPP) -c $(CXXFLAGS) $< -o $@
$(OUT_OBJS_S): $(OUTPUT_DIR)/%.o: %.S Makefile $(OUT_OBJS_S): $(OUTPUT_DIR)/%.o: %.S Makefile