From 3c137a31de0a4d9a8129899f9e38fad71981c942 Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Wed, 7 Feb 2024 18:37:28 +0100 Subject: [PATCH] Fixed error in STM32F4 linker scripts causing radio thread lockup Error in linker script definitions made the heap area to start at end of the 64kB CCM RAM, thus effectively allocating memory in an access-protected zone. --- platform/mcu/STM32F4xx/linker_script_MDx.ld | 11 +++++------ platform/mcu/STM32F4xx/linker_script_Mod17.ld | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/platform/mcu/STM32F4xx/linker_script_MDx.ld b/platform/mcu/STM32F4xx/linker_script_MDx.ld index c544c522..9ada73d4 100644 --- a/platform/mcu/STM32F4xx/linker_script_MDx.ld +++ b/platform/mcu/STM32F4xx/linker_script_MDx.ld @@ -164,15 +164,17 @@ SECTIONS } > smallram AT > flash _etext = LOADADDR(.data); - /* Put the display framebuffer in the "large" RAM, explicitly request to not - initialize it */ + /* Secondary bss section, placed in the 128kB RAM and not initialized: here + go the display framebuffer and, immediately after it, the heap area. */ .bss2 (NOLOAD) : { *(.bss.fb) . = ALIGN(8); + _end = .; + PROVIDE(end = .); } > largeram - /* .bss section: uninitialized global variables go to ram */ + /* Primary bss section, placed in the 64kB CCM RAM: uninitialized global variables */ .bss : { _bss_start = .; @@ -182,7 +184,4 @@ SECTIONS . = ALIGN(8); } > smallram _bss_end = .; - - _end = .; - PROVIDE(end = .); } diff --git a/platform/mcu/STM32F4xx/linker_script_Mod17.ld b/platform/mcu/STM32F4xx/linker_script_Mod17.ld index 372fb671..c248321c 100644 --- a/platform/mcu/STM32F4xx/linker_script_Mod17.ld +++ b/platform/mcu/STM32F4xx/linker_script_Mod17.ld @@ -163,15 +163,17 @@ SECTIONS } > smallram AT > flash _etext = LOADADDR(.data); - /* Put the display framebuffer in the "large" RAM, explicitly request to not - initialize it */ + /* Secondary bss section, placed in the 128kB RAM and not initialized: here + go the display framebuffer and, immediately after it, the heap area. */ .bss2 (NOLOAD) : { *(.bss.fb) . = ALIGN(8); + _end = .; + PROVIDE(end = .); } > largeram - /* .bss section: uninitialized global variables go to ram */ + /* Primary bss section, placed in the 64kB CCM RAM: uninitialized global variables */ .bss : { _bss_start = .; @@ -181,7 +183,4 @@ SECTIONS . = ALIGN(8); } > smallram _bss_end = .; - - _end = .; - PROVIDE(end = .); }