From 2d60aa101426dffadfd7e2bc82a7aedbbecf9869 Mon Sep 17 00:00:00 2001 From: Ray Morris Date: Mon, 2 Mar 2026 16:09:08 -0600 Subject: [PATCH] =?UTF-8?q?target:=20fix=20STM32F765xG=20linker=20scripts?= =?UTF-8?q?=20=E2=80=94=20correct=20DTCM=20size=20and=20SRAM1=20address?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The three stm32_flash_f765xg*.ld linker scripts were copy-pasted from the STM32F745 linker without updating the memory map for the F765's larger DTCM. STM32F745: DTCM = 64 KB (0x20000000–0x2000FFFF), SRAM1 starts at 0x20010000 STM32F765: DTCM = 128 KB (0x20000000–0x2001FFFF), SRAM1 starts at 0x20020000 The F765xG linker scripts kept the F745 values (TCM = 64 KB, RAM at 0x20010000), which places the RAM region inside the upper half of DTCM on F765 hardware rather than in SRAM1. Fix all three xG variants (normal, bl, for_bl): - Expand DTCM_RAM from 64 KB to 128 KB (the full F765 DTCM) - Move SRAM1 origin from 0x20010000 to 0x20020000 (correct F765 address) - Add SRAM2 region (16 KB at 0x2007C000) matching the xi scripts - Update REGION_ALIAS("RAM") to point to SRAM1 - Update stale file headers that still referenced STM32F745VGTx / 320 KB RAM - Update flash sector comment from "32K on F74x" to "32K on F7xx" The xi variant linker scripts (used by MATEKF765, MATEKF765SE) already had the correct addresses and are not changed. Affected targets: FRSKYPILOT, FRSKYPILOT_LED. --- src/main/target/link/stm32_flash_f765xg.ld | 22 +++++++++++-------- src/main/target/link/stm32_flash_f765xg_bl.ld | 22 +++++++++++-------- .../target/link/stm32_flash_f765xg_for_bl.ld | 22 +++++++++++-------- 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/src/main/target/link/stm32_flash_f765xg.ld b/src/main/target/link/stm32_flash_f765xg.ld index a83374e4e41..ea548ed4ff3 100644 --- a/src/main/target/link/stm32_flash_f765xg.ld +++ b/src/main/target/link/stm32_flash_f765xg.ld @@ -1,10 +1,10 @@ /* ***************************************************************************** ** -** File : stm32_flash_f745.ld +** File : stm32_flash_f765xg.ld ** -** Abstract : Linker script for STM32F745VGTx Device with -** 1024KByte FLASH, 320KByte RAM +** Abstract : Linker script for STM32F765xGTx Device with +** 1024KByte FLASH, 512KByte RAM ** ***************************************************************************** */ @@ -29,7 +29,7 @@ MEMORY { ITCM_RAM (rx) : ORIGIN = 0x00000000, LENGTH = 16K ITCM_FLASH (rx) : ORIGIN = 0x00200000, LENGTH = 32K - /* config occupies the entire flash sector 1 for the ease of erasure, 32K on F74x */ + /* config occupies the entire flash sector 1 for the ease of erasure, 32K on F7xx */ ITCM_FLASH_CONFIG (r) : ORIGIN = 0x00208000, LENGTH = 32K ITCM_FLASH1 (rx) : ORIGIN = 0x00210000, LENGTH = 960K @@ -37,12 +37,16 @@ MEMORY FLASH_CONFIG (r) : ORIGIN = 0x08008000, LENGTH = 32K FLASH1 (rx) : ORIGIN = 0x08010000, LENGTH = 960K - TCM (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - RAM (rwx) : ORIGIN = 0x20010000, LENGTH = 256K + DTCM_RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K + SRAM1 (rwx) : ORIGIN = 0x20020000, LENGTH = 368K + SRAM2 (rwx) : ORIGIN = 0x2007C000, LENGTH = 16K MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K } -/* note CCM could be used for stack */ -REGION_ALIAS("STACKRAM", TCM) -REGION_ALIAS("FASTRAM", TCM) +/* STM32F765 DTCM is 128KB (0x20000000-0x2001FFFF); SRAM1 starts at 0x20020000. + * DMA cannot access DTCM on STM32F7 - all DMA buffers must be in SRAM1 or SRAM2. + * NOTE: F745 DTCM is only 64KB, so F745 SRAM1 starts at 0x20010000 (different!). */ +REGION_ALIAS("STACKRAM", DTCM_RAM) +REGION_ALIAS("FASTRAM", DTCM_RAM) +REGION_ALIAS("RAM", SRAM1) INCLUDE "stm32_flash_f7_split.ld" diff --git a/src/main/target/link/stm32_flash_f765xg_bl.ld b/src/main/target/link/stm32_flash_f765xg_bl.ld index d357aad98d8..92f3d36754b 100644 --- a/src/main/target/link/stm32_flash_f765xg_bl.ld +++ b/src/main/target/link/stm32_flash_f765xg_bl.ld @@ -1,10 +1,10 @@ /* ***************************************************************************** ** -** File : stm32_flash_f745.ld +** File : stm32_flash_f765xg_bl.ld ** -** Abstract : Linker script for STM32F745VGTx Device with -** 1024KByte FLASH, 320KByte RAM +** Abstract : Linker script for STM32F765xGTx Device with +** 1024KByte FLASH, 512KByte RAM (bootloader) ** ***************************************************************************** */ @@ -29,7 +29,7 @@ MEMORY { ITCM_RAM (rx) : ORIGIN = 0x00000000, LENGTH = 16K ITCM_FLASH (rx) : ORIGIN = 0x00200000, LENGTH = 32K - /* config occupies the entire flash sector 1 for the ease of erasure, 32K on F74x */ + /* config occupies the entire flash sector 1 for the ease of erasure, 32K on F7xx */ ITCM_FLASH_CONFIG (r) : ORIGIN = 0x00208000, LENGTH = 32K ITCM_FLASH1 (rx) : ORIGIN = 0x00210000, LENGTH = 928K @@ -37,13 +37,17 @@ MEMORY FIRMWARE (rx) : ORIGIN = 0x08008000, LENGTH = 32K FLASH_CONFIG (r) : ORIGIN = 0x08010000, LENGTH = 32K - TCM (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - RAM (rwx) : ORIGIN = 0x20010000, LENGTH = 256K + DTCM_RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K + SRAM1 (rwx) : ORIGIN = 0x20020000, LENGTH = 368K + SRAM2 (rwx) : ORIGIN = 0x2007C000, LENGTH = 16K MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K } -/* note CCM could be used for stack */ -REGION_ALIAS("STACKRAM", TCM) -REGION_ALIAS("FASTRAM", TCM) +/* STM32F765 DTCM is 128KB (0x20000000-0x2001FFFF); SRAM1 starts at 0x20020000. + * DMA cannot access DTCM on STM32F7 - all DMA buffers must be in SRAM1 or SRAM2. + * NOTE: F745 DTCM is only 64KB, so F745 SRAM1 starts at 0x20010000 (different!). */ +REGION_ALIAS("STACKRAM", DTCM_RAM) +REGION_ALIAS("FASTRAM", DTCM_RAM) +REGION_ALIAS("RAM", SRAM1) __firmware_start = ORIGIN(FIRMWARE); diff --git a/src/main/target/link/stm32_flash_f765xg_for_bl.ld b/src/main/target/link/stm32_flash_f765xg_for_bl.ld index c7667d1dc26..b50247b015d 100644 --- a/src/main/target/link/stm32_flash_f765xg_for_bl.ld +++ b/src/main/target/link/stm32_flash_f765xg_for_bl.ld @@ -1,10 +1,10 @@ /* ***************************************************************************** ** -** File : stm32_flash_f745.ld +** File : stm32_flash_f765xg_for_bl.ld ** -** Abstract : Linker script for STM32F745VGTx Device with -** 1024KByte FLASH, 320KByte RAM +** Abstract : Linker script for STM32F765xGTx Device with +** 1024KByte FLASH, 512KByte RAM (bootloader-aware) ** ***************************************************************************** */ @@ -29,7 +29,7 @@ MEMORY { ITCM_RAM (rx) : ORIGIN = 0x00000000, LENGTH = 16K ITCM_FLASH (rx) : ORIGIN = 0x00200000, LENGTH = 32K - /* config occupies the entire flash sector 1 for the ease of erasure, 32K on F74x */ + /* config occupies the entire flash sector 1 for the ease of erasure, 32K on F7xx */ ITCM_FLASH_CONFIG (r) : ORIGIN = 0x00208000, LENGTH = 32K ITCM_FLASH1 (rx) : ORIGIN = 0x00210000, LENGTH = 960K @@ -37,13 +37,17 @@ MEMORY FLASH_CONFIG (r) : ORIGIN = 0x08010000, LENGTH = 32K FLASH1 (rx) : ORIGIN = 0x08018000, LENGTH = 928K - TCM (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - RAM (rwx) : ORIGIN = 0x20010000, LENGTH = 256K + DTCM_RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K + SRAM1 (rwx) : ORIGIN = 0x20020000, LENGTH = 368K + SRAM2 (rwx) : ORIGIN = 0x2007C000, LENGTH = 16K MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K } -/* note CCM could be used for stack */ -REGION_ALIAS("STACKRAM", TCM) -REGION_ALIAS("FASTRAM", TCM) +/* STM32F765 DTCM is 128KB (0x20000000-0x2001FFFF); SRAM1 starts at 0x20020000. + * DMA cannot access DTCM on STM32F7 - all DMA buffers must be in SRAM1 or SRAM2. + * NOTE: F745 DTCM is only 64KB, so F745 SRAM1 starts at 0x20010000 (different!). */ +REGION_ALIAS("STACKRAM", DTCM_RAM) +REGION_ALIAS("FASTRAM", DTCM_RAM) +REGION_ALIAS("RAM", SRAM1) __firmware_start = ORIGIN(FLASH);