From f4c91cbf6cf03f825b17ab9bdbaeabba785dd664 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Thu, 27 Jun 2024 16:00:46 +0200 Subject: [PATCH] ports/stm32: Update linker script. Add more GC blocks, and separate the main GC heap from main memory. --- src/omv/ports/stm32/stm32fxxx.ld.S | 37 ++++++++++++++++++++++-------- src/uvc/stm32fxxx.ld.S | 3 +-- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/omv/ports/stm32/stm32fxxx.ld.S b/src/omv/ports/stm32/stm32fxxx.ld.S index a1d90d9ce..a13895e61 100755 --- a/src/omv/ports/stm32/stm32fxxx.ld.S +++ b/src/omv/ports/stm32/stm32fxxx.ld.S @@ -76,6 +76,18 @@ _micropy_hw_internal_flash_storage_ram_cache_start = ORIGIN(OMV_FFS_MEMORY) + OM _micropy_hw_internal_flash_storage_ram_cache_end = LENGTH(OMV_FFS_MEMORY); #endif +#define OMV_DEFINE_GC_BLOCK(n) \ + .gc_block##n (NOLOAD) : \ + { \ + . = ALIGN(4); \ + . += OMV_GC_BLOCK##n##_SIZE; \ + . = ALIGN(4); \ + } >OMV_GC_BLOCK##n##_MEMORY \ + +#define OMV_ADD_GC_BLOCK(n) \ + LONG (ADDR(.gc_block##n)) \ + LONG (SIZEOF(.gc_block##n) / 4) + /* Define output sections */ SECTIONS { @@ -105,12 +117,13 @@ SECTIONS _sidata = LOADADDR(.data); #if defined(OMV_GC_BLOCK0_MEMORY) - .gc_block0 (NOLOAD) : - { - . = ALIGN(4); - . += OMV_GC_BLOCK0_SIZE; - . = ALIGN(4); - } >OMV_GC_BLOCK0_MEMORY + OMV_DEFINE_GC_BLOCK(0) + #endif + #if defined(OMV_GC_BLOCK1_MEMORY) + OMV_DEFINE_GC_BLOCK(1) + #endif + #if defined(OMV_GC_BLOCK2_MEMORY) + OMV_DEFINE_GC_BLOCK(2) #endif .gc_blocks_table (READONLY) : @@ -118,8 +131,13 @@ SECTIONS . = ALIGN(4); _gc_blocks_table_start = .; #if defined(OMV_GC_BLOCK0_MEMORY) - LONG (ADDR(.gc_block0)) - LONG (SIZEOF(.gc_block0) / 4) + OMV_ADD_GC_BLOCK(0) + #endif + #if defined(OMV_GC_BLOCK1_MEMORY) + OMV_ADD_GC_BLOCK(1) + #endif + #if defined(OMV_GC_BLOCK2_MEMORY) + OMV_ADD_GC_BLOCK(2) #endif _gc_blocks_table_end = .; . = ALIGN(4); @@ -257,8 +275,7 @@ SECTIONS . = ALIGN(4); _heap_end = .; - - } >OMV_MAIN_MEMORY + } >OMV_HEAP_MEMORY /* Make sure there is enough ram for the stack */ ._stack (NOLOAD) : diff --git a/src/uvc/stm32fxxx.ld.S b/src/uvc/stm32fxxx.ld.S index ce1f82ce7..b332ed7a5 100755 --- a/src/uvc/stm32fxxx.ld.S +++ b/src/uvc/stm32fxxx.ld.S @@ -212,8 +212,7 @@ SECTIONS . = ALIGN(4); _heap_end = .; - - } >OMV_MAIN_MEMORY + } >OMV_HEAP_MEMORY /* Make sure there is enough ram for the stack */ ._stack (NOLOAD) :