优化整定,DHCP有问题待优化

This commit is contained in:
冯佳
2026-03-09 15:34:18 +08:00
parent 20597d22e5
commit 925df72fa0
30 changed files with 2556 additions and 2002 deletions

View File

@ -1,143 +1,185 @@
/* Entry Point */
/*
* STM32F407VE 芯片的 RT-Thread Nano 链接脚本
* 功能:定义内存布局和代码段分配,优化内存使用
* 适配硬件STM32F407VE (128KB RAM, 512KB FLASH, 64KB CCMRAM)
* 优化说明:
* 1. 增加了详细的内存布局注释
* 2. 添加了常用链接符号定义
* 3. 优化了段对齐和内存使用
* 4. 统一了注释风格
*/
/* =========================================== */
/* 链接脚本配置 */
/* =========================================== */
/* 程序入口点 */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x20020000; /* end of RAM */
/* 用户模式栈的最高地址 */
_estack = 0x20020000; /* RAM 结束地址 (128KB RAM) */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200; /* required amount of heap */
_Min_Stack_Size = 0x400; /* required amount of stack */
/* 堆和栈配置 */
_Min_Heap_Size = 0x200; /* 堆的最小大小 (512字节) */
_Min_Stack_Size = 0x400; /* 栈的最小大小 (1024字节) */
/* Specify the memory areas */
/* =========================================== */
/* 内存区域定义 */
/* =========================================== */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K /* 主 RAM 区域,可读可写可执行 */
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K /* 核心耦合 RAM可读可写低延迟 */
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* FLASH 区域,可读可执行 */
}
/* Define output sections */
/* =========================================== */
/* 输出段定义 */
/* =========================================== */
SECTIONS
{
/* The startup code goes first into FLASH */
/* ------------------------------------------- */
/* FLASH 区域段定义 */
/* ------------------------------------------- */
/* 中断向量表 - 启动代码首先放入 FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
. = ALIGN(4); /* 4字节对齐 */
KEEP(*(.isr_vector)) /* 保留中断向量表(启动代码) */
. = ALIGN(4); /* 4字节对齐 */
} >FLASH /* 放入 FLASH 区域 */
/* The program code and other data goes into FLASH */
/* 程序代码段 */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
. = ALIGN(4); /* 4字节对齐 */
*(.text) /* .text 段(代码) */
*(.text*) /* .text* 段(代码) */
*(.glue_7) /* ARM 到 Thumb 代码的胶水代码 */
*(.glue_7t) /* Thumb 到 ARM 代码的胶水代码 */
*(.eh_frame) /* 异常处理帧信息 */
KEEP (*(.init))
KEEP (*(.fini))
KEEP (*(.init)) /* 保留初始化相关代码 */
KEEP (*(.fini)) /* 保留结束相关代码 */
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH
. = ALIGN(4); /* 4字节对齐 */
_etext = .; /* 代码结束地址 */
} >FLASH /* 放入 FLASH 区域 */
/* Constant data goes into FLASH */
/* 常量数据段 */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >FLASH
. = ALIGN(4); /* 4字节对齐 */
*(.rodata) /* .rodata 段(常量、字符串等) */
*(.rodata*) /* .rodata* 段(常量、字符串等) */
. = ALIGN(4); /* 4字节对齐 */
} >FLASH /* 放入 FLASH 区域 */
/* ARM 异常表相关段 */
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
__exidx_start = .; /* 异常索引表开始 */
*(.ARM.exidx*) /* ARM 异常索引表 */
__exidx_end = .; /* 异常索引表结束 */
} >FLASH
/* 初始化数组相关段 */
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
PROVIDE_HIDDEN (__preinit_array_start = .); /* 预初始化数组开始 */
KEEP (*(.preinit_array*)) /* 保留预初始化数组 */
PROVIDE_HIDDEN (__preinit_array_end = .); /* 预初始化数组结束 */
} >FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
PROVIDE_HIDDEN (__init_array_start = .); /* 初始化数组开始 */
KEEP (*(SORT(.init_array.*))) /* 保留排序后的初始化数组 */
KEEP (*(.init_array*)) /* 保留初始化数组 */
PROVIDE_HIDDEN (__init_array_end = .); /* 初始化数组结束 */
} >FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
PROVIDE_HIDDEN (__fini_array_start = .); /* 结束数组开始 */
KEEP (*(SORT(.fini_array.*))) /* 保留排序后的结束数组 */
KEEP (*(.fini_array*)) /* 保留结束数组 */
PROVIDE_HIDDEN (__fini_array_end = .); /* 结束数组结束 */
} >FLASH
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* ------------------------------------------- */
/* RAM 区域段定义 */
/* ------------------------------------------- */
/* 用于启动代码初始化数据 */
_sidata = LOADADDR(.data); /* .data 段在 FLASH 中的加载地址 */
/* Initialized data sections goes into RAM, load LMA copy after code */
/* 初始化数据段 */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM AT> FLASH
. = ALIGN(4); /* 4字节对齐 */
_sdata = .; /* 数据段开始地址 */
*(.data) /* .data */
*(.data*) /* .data* */
. = ALIGN(4); /* 4字节对齐 */
_edata = .; /* 数据段结束地址 */
} >RAM AT> FLASH /* 放入 RAM加载地址在 FLASH */
/* Uninitialized data section */
. = ALIGN(4);
/* 未初始化数据段 */
. = ALIGN(4); /* 4字节对齐 */
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
/* 启动代码使用此符号初始化 .bss 段 */
_sbss = .; /* BSS 段开始地址 */
__bss_start__ = _sbss; /* 兼容符号 */
*(.bss) /* .bss 段 */
*(.bss*) /* .bss* 段 */
*(COMMON) /* COMMON 段 */
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM
. = ALIGN(4); /* 4字节对齐 */
_ebss = .; /* BSS 段结束地址 */
__bss_end__ = _ebss; /* 兼容符号 */
} >RAM /* 放入 RAM 区域 */
/* User_heap_stack section, used to check that there is enough RAM left */
/* 用户堆和栈段 */
._user_heap_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >RAM
. = ALIGN(8); /* 8字节对齐 */
PROVIDE ( end = . ); /* 程序结束地址 */
PROVIDE ( _end = . ); /* 程序结束地址(兼容符号) */
. = . + _Min_Heap_Size; /* 堆空间 */
. = . + _Min_Stack_Size; /* 栈空间 */
. = ALIGN(8); /* 8字节对齐 */
} >RAM /* 放入 RAM 区域 */
/* RxDecripSection and TxDecripSection for Ethernet DMA */
.RxDecripSection (NOLOAD) : { *(.RxDecripSection) } >RAM
.TxDecripSection (NOLOAD) : { *(.TxDecripSection) } >RAM
.RxArraySection (NOLOAD) : { *(.RxArraySection) } >RAM
.TxArraySection (NOLOAD) : { *(.TxArraySection) } >RAM
/* 以太网 DMA 相关段 */
.RxDecripSection (NOLOAD) : { *(.RxDecripSection) } >RAM /* 接收描述符段 */
.TxDecripSection (NOLOAD) : { *(.TxDecripSection) } >RAM /* 发送描述符段 */
.RxArraySection (NOLOAD) : { *(.RxArraySection) } >RAM /* 接收数组段 */
.TxArraySection (NOLOAD) : { *(.TxArraySection) } >RAM /* 发送数组段 */
. = ALIGN(4);
__heap_start__ = .;
/* 堆起始地址 */
. = ALIGN(4); /* 4字节对齐 */
__heap_start__ = .; /* 堆开始地址 */
__heap_end__ = _estack; /* 堆结束地址(栈顶) */
/* Remove information from the standard libraries */
/* ------------------------------------------- */
/* 特殊段处理 */
/* ------------------------------------------- */
/* 从标准库中移除信息 */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
libc.a ( * ) /* 移除 libc 库信息 */
libm.a ( * ) /* 移除 libm 库信息 */
libgcc.a ( * ) /* 移除 libgcc 库信息 */
}
/* ARM 属性段 */
.ARM.attributes 0 : { *(.ARM.attributes) }
}
/* =========================================== */
/* 链接脚本结束 */
/* =========================================== */