This commit is contained in:
2025-09-28 23:33:51 +08:00
parent ee6f94aae4
commit e369f6c284
15 changed files with 4043 additions and 0 deletions

117
1gpio/cortex-m-generic.ld Normal file
View File

@@ -0,0 +1,117 @@
MEMORY
{
rom (rx) : ORIGIN = 0x08000000, LENGTH = 0x200000 /* Flash 2MB */
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x20000 /* 128 KB */
ram2 (rwx) : ORIGIN = 0x24000000, LENGTH = 0x80000 /* 512 KB */
}
/* Enforce emmition of the vector table. */
EXTERN (vector_table)
/* Define the entry point of the output file. */
ENTRY(reset_handler)
/* Define sections. */
SECTIONS
{
.text : {
*(.vectors) /* Vector table */
*(.text*) /* Program code */
. = ALIGN(4);
*(.rodata*) /* Read-only data */
. = ALIGN(4);
} >rom
/* C++ Static constructors/destructors, also used for __attribute__
* ((constructor)) and the likes */
.preinit_array : {
. = ALIGN(4);
__preinit_array_start = .;
KEEP (*(.preinit_array))
__preinit_array_end = .;
} >rom
.init_array : {
. = ALIGN(4);
__init_array_start = .;
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))
__init_array_end = .;
} >rom
.fini_array : {
. = ALIGN(4);
__fini_array_start = .;
KEEP (*(.fini_array))
KEEP (*(SORT(.fini_array.*)))
__fini_array_end = .;
} >rom
/*
* Another section used by C++ stuff, appears when using newlib with
* 64bit (long long) printf support
*/
.ARM.extab : {
*(.ARM.extab*)
} >rom
.ARM.exidx : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >rom
. = ALIGN(4);
_etext = .;
/* ram, but not cleared on reset, eg boot/app comms */
.noinit (NOLOAD) : {
*(.noinit*)
} >ram
. = ALIGN(4);
.data : {
_data = .;
*(.data*) /* Read-write initialized data */
*(.ramtext*) /* "text" functions to run in ram */
. = ALIGN(4);
_edata = .;
} >ram AT >rom
_data_loadaddr = LOADADDR(.data);
.bss : {
*(.bss*) /* Read-write zero initialized data */
*(COMMON)
. = ALIGN(4);
_ebss = .;
} >ram
/*
* The .eh_frame section appears to be used for C++ exception handling.
* You may need to fix this if you're using C++.
*/
/DISCARD/ : { *(.eh_frame) }
/* Heap 分配到第二块 RAM */
.heap : {
_sheap = .;
. = ORIGIN(ram2) + LENGTH(ram2);
_eheap = .;
} >ram2
/* 第二块 RAM,用于大数组或 heap */
/*
.ext_ram (NOLOAD) : {
_sext_ram = .;
*(.ext_ram*)
*(.bss_ext_ram*)
. = ALIGN(4);
_eext_ram = .;
} > ram2
*/
. = ALIGN(4);
end = .;
}
PROVIDE(_stack = ORIGIN(ram) + LENGTH(ram));
PROVIDE(_sheap = ORIGIN(ram2));
PROVIDE(_eheap = ORIGIN(ram2) + LENGTH(ram2));