From 405935f91808addd7b8a8127bf1093d3f285e7d8 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 28 Oct 2024 13:31:10 -0400 Subject: rp2040: Rename rp2040_link.lds.S to rpxxxx_link.lds.S This is in preparation for rp2350 support. Signed-off-by: Kevin O'Connor --- src/rp2040/Makefile | 4 +- src/rp2040/main.c | 2 +- src/rp2040/rp2040_link.lds.S | 94 -------------------------------------------- src/rp2040/rpxxxx_link.lds.S | 94 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 97 deletions(-) delete mode 100644 src/rp2040/rp2040_link.lds.S create mode 100644 src/rp2040/rpxxxx_link.lds.S diff --git a/src/rp2040/Makefile b/src/rp2040/Makefile index b9ac8e87..bad4151e 100644 --- a/src/rp2040/Makefile +++ b/src/rp2040/Makefile @@ -63,9 +63,9 @@ rptarget-$(CONFIG_RPXXXX_HAVE_BOOTLOADER) := $(OUT)klipper.bin # Set klipper.elf linker rules target-y += $(rptarget-y) CFLAGS_klipper.elf += -nostdlib -lgcc -lc_nano -CFLAGS_klipper.elf += -T $(OUT)src/rp2040/rp2040_link.ld +CFLAGS_klipper.elf += -T $(OUT)src/rp2040/rpxxxx_link.ld OBJS_klipper.elf += $(stage2-y) -$(OUT)klipper.elf: $(stage2-y) $(OUT)src/rp2040/rp2040_link.ld +$(OUT)klipper.elf: $(stage2-y) $(OUT)src/rp2040/rpxxxx_link.ld # Flash rules lib/rp2040_flash/rp2040_flash: diff --git a/src/rp2040/main.c b/src/rp2040/main.c index e7b64e5f..75d8760d 100644 --- a/src/rp2040/main.c +++ b/src/rp2040/main.c @@ -24,7 +24,7 @@ static void enable_ram_vectortable(void) { - // Symbols created by rp2040_link.lds.S linker script + // Symbols created by rpxxxx_link.lds.S linker script extern uint32_t _ram_vectortable_start, _ram_vectortable_end; extern uint32_t _text_vectortable_start; diff --git a/src/rp2040/rp2040_link.lds.S b/src/rp2040/rp2040_link.lds.S deleted file mode 100644 index abc5be6c..00000000 --- a/src/rp2040/rp2040_link.lds.S +++ /dev/null @@ -1,94 +0,0 @@ -// rp2040 linker script (based on armcm_link.lds.S and customized for stage2) -// -// Copyright (C) 2019-2024 Kevin O'Connor -// -// This file may be distributed under the terms of the GNU GPLv3 license. - -#include "autoconf.h" // CONFIG_FLASH_SIZE - -OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") -OUTPUT_ARCH(arm) - -#if CONFIG_RP2040_HAVE_STAGE2 - #define ROM_ORIGIN 0x10000000 -#else - #define ROM_ORIGIN CONFIG_FLASH_APPLICATION_ADDRESS -#endif - -MEMORY -{ - rom (rx) : ORIGIN = ROM_ORIGIN , LENGTH = CONFIG_FLASH_SIZE - ram (rwx) : ORIGIN = CONFIG_RAM_START , LENGTH = CONFIG_RAM_SIZE -} - -// Force flags for each output section to avoid RWX linker warning -PHDRS -{ - text_segment PT_LOAD FLAGS(5); // RX flags - ram_vectortable_segment PT_LOAD FLAGS(6); // RW flags - data_segment PT_LOAD FLAGS(6); // RW flags - bss_segment PT_LOAD FLAGS(6); // RW flags - stack_segment PT_LOAD FLAGS(6); // RW flags -} - -SECTIONS -{ - .text : { - . = ALIGN(4); -#if CONFIG_RP2040_HAVE_STAGE2 - KEEP(*(.boot2)) -#endif - _text_vectortable_start = .; - KEEP(*(.vector_table)) - _text_vectortable_end = .; - *(.text.armcm_boot*) - } > rom :text_segment - - . = ALIGN(4); - _data_flash = .; - - .ram_vectortable (NOLOAD) : { - _ram_vectortable_start = .; - . = . + ( _text_vectortable_end - _text_vectortable_start ) ; - _ram_vectortable_end = .; - } > ram :ram_vectortable_segment - - .data : AT (_data_flash) - { - . = ALIGN(4); - _data_start = .; - *(.text .text.*) - *(.ramfunc .ramfunc.*); - *(.rodata .rodata*) - *(.data .data.*); - . = ALIGN(4); - _data_end = .; - } > ram :data_segment - - .bss (NOLOAD) : - { - . = ALIGN(4); - _bss_start = .; - *(.bss .bss.*) - *(COMMON) - . = ALIGN(4); - _bss_end = .; - } > ram :bss_segment - - _stack_start = CONFIG_RAM_START + CONFIG_RAM_SIZE - CONFIG_STACK_SIZE ; - .stack _stack_start (NOLOAD) : - { - . = . + CONFIG_STACK_SIZE; - _stack_end = .; - } > ram :stack_segment - - /DISCARD/ : { - // The .init/.fini sections are used by __libc_init_array(), but - // that isn't needed so no need to include them in the binary. - *(.init) - *(.fini) - // Don't include exception tables - *(.ARM.extab) - *(.ARM.exidx) - } -} diff --git a/src/rp2040/rpxxxx_link.lds.S b/src/rp2040/rpxxxx_link.lds.S new file mode 100644 index 00000000..abc5be6c --- /dev/null +++ b/src/rp2040/rpxxxx_link.lds.S @@ -0,0 +1,94 @@ +// rp2040 linker script (based on armcm_link.lds.S and customized for stage2) +// +// Copyright (C) 2019-2024 Kevin O'Connor +// +// This file may be distributed under the terms of the GNU GPLv3 license. + +#include "autoconf.h" // CONFIG_FLASH_SIZE + +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) + +#if CONFIG_RP2040_HAVE_STAGE2 + #define ROM_ORIGIN 0x10000000 +#else + #define ROM_ORIGIN CONFIG_FLASH_APPLICATION_ADDRESS +#endif + +MEMORY +{ + rom (rx) : ORIGIN = ROM_ORIGIN , LENGTH = CONFIG_FLASH_SIZE + ram (rwx) : ORIGIN = CONFIG_RAM_START , LENGTH = CONFIG_RAM_SIZE +} + +// Force flags for each output section to avoid RWX linker warning +PHDRS +{ + text_segment PT_LOAD FLAGS(5); // RX flags + ram_vectortable_segment PT_LOAD FLAGS(6); // RW flags + data_segment PT_LOAD FLAGS(6); // RW flags + bss_segment PT_LOAD FLAGS(6); // RW flags + stack_segment PT_LOAD FLAGS(6); // RW flags +} + +SECTIONS +{ + .text : { + . = ALIGN(4); +#if CONFIG_RP2040_HAVE_STAGE2 + KEEP(*(.boot2)) +#endif + _text_vectortable_start = .; + KEEP(*(.vector_table)) + _text_vectortable_end = .; + *(.text.armcm_boot*) + } > rom :text_segment + + . = ALIGN(4); + _data_flash = .; + + .ram_vectortable (NOLOAD) : { + _ram_vectortable_start = .; + . = . + ( _text_vectortable_end - _text_vectortable_start ) ; + _ram_vectortable_end = .; + } > ram :ram_vectortable_segment + + .data : AT (_data_flash) + { + . = ALIGN(4); + _data_start = .; + *(.text .text.*) + *(.ramfunc .ramfunc.*); + *(.rodata .rodata*) + *(.data .data.*); + . = ALIGN(4); + _data_end = .; + } > ram :data_segment + + .bss (NOLOAD) : + { + . = ALIGN(4); + _bss_start = .; + *(.bss .bss.*) + *(COMMON) + . = ALIGN(4); + _bss_end = .; + } > ram :bss_segment + + _stack_start = CONFIG_RAM_START + CONFIG_RAM_SIZE - CONFIG_STACK_SIZE ; + .stack _stack_start (NOLOAD) : + { + . = . + CONFIG_STACK_SIZE; + _stack_end = .; + } > ram :stack_segment + + /DISCARD/ : { + // The .init/.fini sections are used by __libc_init_array(), but + // that isn't needed so no need to include them in the binary. + *(.init) + *(.fini) + // Don't include exception tables + *(.ARM.extab) + *(.ARM.exidx) + } +} -- cgit v1.2.3-70-g09d2