diff options
| author | HiFiPHile <[email protected]> | 2026-05-10 14:45:21 +0200 |
|---|---|---|
| committer | HiFiPHile <[email protected]> | 2026-05-10 14:45:21 +0200 |
| commit | 7eb806c6073279c4fd791f542a7230aeab582b2c (patch) | |
| tree | a0d67bd0db0468b9ce5aab6b5bc6bce9ac94237b | |
| parent | 5ea1979e290ed80430a5b65b56534373ecbdd56f (diff) | |
use local linker
Signed-off-by: HiFiPHile <[email protected]>
| -rw-r--r-- | hw/bsp/stm32c5/boards/stm32c542nucleo/board.cmake | 4 | ||||
| -rw-r--r-- | hw/bsp/stm32c5/boards/stm32c542nucleo/board.mk | 2 | ||||
| -rw-r--r-- | hw/bsp/stm32c5/linker/stm32c542xc_flash.icf | 46 | ||||
| -rw-r--r-- | hw/bsp/stm32c5/linker/stm32c542xc_flash.ld | 185 |
4 files changed, 234 insertions, 3 deletions
diff --git a/hw/bsp/stm32c5/boards/stm32c542nucleo/board.cmake b/hw/bsp/stm32c5/boards/stm32c542nucleo/board.cmake index 456cf8e79..563a47ba2 100644 --- a/hw/bsp/stm32c5/boards/stm32c542nucleo/board.cmake +++ b/hw/bsp/stm32c5/boards/stm32c542nucleo/board.cmake @@ -1,8 +1,8 @@ set(MCU_VARIANT stm32c542xx) set(JLINK_DEVICE stm32c542rc) -set(LD_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/linker/stm32c542xc_flash.ld) -set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/stm32c542xc_flash.icf) +set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/../../linker/stm32c542xc_flash.ld) +set(LD_FILE_IAR ${CMAKE_CURRENT_LIST_DIR}/../../linker/stm32c542xc_flash.icf) function(update_board TARGET) target_compile_definitions(${TARGET} PUBLIC diff --git a/hw/bsp/stm32c5/boards/stm32c542nucleo/board.mk b/hw/bsp/stm32c5/boards/stm32c542nucleo/board.mk index cea82567b..b3da64713 100644 --- a/hw/bsp/stm32c5/boards/stm32c542nucleo/board.mk +++ b/hw/bsp/stm32c5/boards/stm32c542nucleo/board.mk @@ -6,7 +6,7 @@ CFLAGS += \ -DHSE_STARTUP_TIMEOUT=100 # GCC -LD_FILE = $(ST_CMSIS)/Source/Templates/gcc/linker/stm32c542xc_flash.ld +LD_FILE = $(FAMILY_PATH)/linker/stm32c542xc_flash.ld # For flash-jlink target diff --git a/hw/bsp/stm32c5/linker/stm32c542xc_flash.icf b/hw/bsp/stm32c5/linker/stm32c542xc_flash.icf new file mode 100644 index 000000000..ea826ba8e --- /dev/null +++ b/hw/bsp/stm32c5/linker/stm32c542xc_flash.icf @@ -0,0 +1,46 @@ +/** +****************************************************************************** +* @file stm32c542xc_flash.icf +* @brief Linker File +****************************************************************************** +* @attention +* +* Copyright (c) 2026 STMicroelectronics. +* All rights reserved. +* +* This software is licensed under terms that can be found in the LICENSE file +* in the root directory of this software component. +* If no LICENSE file comes with this software, it is provided AS-IS. +* +****************************************************************************** +*/ + +define memory mem with size = 4G; +define region ROM = mem:[from 0x8000000 size 0x40000]; +define region RAM = mem:[from 0x20000000 size 0x10000]; + +/* define blocks */ +define block HEAP with alignment = 8, size = 0x200 { }; +define block CSTACK with alignment = 8, size = 0x1000 { }; + +/* setup initialization strategies */ +initialize by copy { + readwrite +}; + +do not initialize { + section .noinit +}; + +place at start of ROM { readonly section .intvec } ; + +/* sections placements */ +place in ROM { + readonly +}; + +place in RAM { + readwrite, + block HEAP, + block CSTACK +}; diff --git a/hw/bsp/stm32c5/linker/stm32c542xc_flash.ld b/hw/bsp/stm32c5/linker/stm32c542xc_flash.ld new file mode 100644 index 000000000..34e2bf660 --- /dev/null +++ b/hw/bsp/stm32c5/linker/stm32c542xc_flash.ld @@ -0,0 +1,185 @@ +/** +****************************************************************************** +* @file stm32c542xc_flash.ld +* @brief Linker File +****************************************************************************** +* @attention +* +* Copyright (c) 2026 STMicroelectronics. +* All rights reserved. +* +* This software is licensed under terms that can be found in the LICENSE file +* in the root directory of this software component. +* If no LICENSE file comes with this software, it is provided AS-IS. +* +****************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +HEAP_SIZE = 0x200; +STACK_SIZE = 0x1000; + + +MEMORY +{ + ROM (rx) : org = 0x8000000, len = 0x40000 + RAM (xrw) : org = 0x20000000, len = 0x10000 +} + +SECTIONS +{ + .vectors : + { + . = ALIGN(8); + KEEP(*(.vectors)); + . = ALIGN(8); + } > ROM + + .text : + { + . = ALIGN(8); + *(.text); + *(.text*); + *(.glue_7); + *(.glue_7t); + *(.eh_frame); + KEEP (*(.init)); + KEEP (*(.fini)); + . = ALIGN(8); + _etext = .; + } > ROM + + .rodata : + { + . = ALIGN(8); + *(.rodata); + *(.rodata*); + . = ALIGN(8); + } > ROM + + .ARM.extab : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ + { + . = ALIGN(8); + *(.ARM.extab* .gnu.linkonce.armextab.*) + . = ALIGN(8); + } > ROM + + .ARM : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ + { + . = ALIGN(8); + __exidx_start = .; + *(.ARM.exidx*); + __exidx_end = .; + . = ALIGN(8); + } > ROM + + .preinit_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ + { + . = ALIGN(8); + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)); + PROVIDE_HIDDEN (__preinit_array_end = .); + . = ALIGN(8); + } > ROM + + .init_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ + { + . = ALIGN(8); + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))); + KEEP (*(.init_array*)); + PROVIDE_HIDDEN (__init_array_end = .); + . = ALIGN(8); + } > ROM + + .fini_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ + { + . = ALIGN(8); + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))); + KEEP (*(.fini_array*)); + PROVIDE_HIDDEN (__fini_array_end = .); + . = ALIGN(8); + } > ROM + + .copy.table : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ + { + . = ALIGN(8); + __copy_table_start__ = .; + LONG(LOADADDR(.data)); + LONG (ADDR(.data)); + LONG (SIZEOF(.data) / 4); + __copy_table_end__ = .; + } > ROM + + .zero.table : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ + { + . = ALIGN(8); + __zero_table_start__ = .; + LONG (ADDR(.bss)); + LONG (SIZEOF(.bss) / 4); + __zero_table_end__ = .; + } > ROM + + .data : + { + . = ALIGN(8); + _sidata = LOADADDR(.data); + __data_start__ = .; + _sdata = .; + *(.data); + *(.data*); + . = ALIGN(8); + _edata = .; + } > RAM AT> ROM + + .bss : + { + . = ALIGN(8); + _sbss = .; + __bss_start__ = _sbss; + *(.bss); + *(.bss*); + *(COMMON); + . = ALIGN(8); + _ebss = .; + __bss_end__ = _ebss; + } > RAM + + .heap (NOLOAD) : + { + . = ALIGN(8); + __end__ = .; + PROVIDE (end = .); + _heap_start = .; + . += HEAP_SIZE; + . = ALIGN(8); + _heap_end = .; + __HeapLimit = .; + } > RAM + + .stack (NOLOAD) : + { + . = ALIGN(8); + __StackLimit = .; + . += STACK_SIZE; + . = ALIGN(8); + __StackTop = .; + _estack = .; + __stack = .; + } > RAM + + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : + { + *(.ARM.attributes) + } +} |
