HPM6750 在 SES 中链接文件 flash_sdram_xip.icf 注释说明
* Copyright (c) 2021-2023 HPMicro
* SPDX-License-Identifier: BSD-3-Clause
*/
define memory with size = 4G;
/* Regions */
define region NOR_CFG_OPTION = [ from 0x80000400 size 0x0C00 ];
/* XPI0(即连接的片外串行NOR Flash)的起始位置 bootloader address*/
define region BOOT_HEADER = [ from 0x80001000 size 0x2000 ];
/* XPI0(即连接的片外串行NOR Flash)的起始位置 app address */
define region XPI0 = [from 0x80003000 size (_flash_size - 0x3000) ];
define region XPI0_APP = [from 0x80100000 size (_flash_size - 0x100000) ];
/* 指令本地存储器(ILM)的访问频率与 CPU 相同,支持零等待周期访问.*/
define region ILM = [from 0x00000000 size 256k]; /* ILM */
/* 数据本地存储器(DLM)的访问频率与 CPU 相同,支持零等待周期访问 */
define region DLM = [from 0x00080000 size 256k]; /* DLM */
/* CPU0 指令/数据本地存储器 */
define region CPU0_ILM_SLV = [from 0x01000000 size 256k];
define region CPU0_DLM_SLV = [from 0x01040000 size 256k];
/* 正常 AXI SRAM 地址分配*/
define region AXI_SRAM0 = [from 0x01080000 size 512k];
define region AXI_SRAM1 = [from 0x01100000 size 512k];
/* 默认 AXI SRAM 地址分配*/
define region AXI_SRAM = [from 0x01080000 size 768k]; /* AXI SRAM */
//define region AXI_SRAM = [from 0x01080000 size 512k]; /* AXI SRAM0 */
//define region NONCACHEABLE_RAM = [from 0x01100000 size 256k]; /* AXI SRAM1 */
/* CPU1 指令/数据本地存储器 */
define region CPU1_ILM_SLV = [from 0x01180000 size 256k];
define region CPU1_DLM_SLV = [from 0x011C0000 size 256k];
/* 其他RAM/SRAM 分配 */
define region SHARE_RAM = [from 0x0117C000 size 16k];
define region AHB_SRAM = [from 0xF0300000 size 32k];
define region APB_SRAM = [from 0xF40F0000 size 8k];
/* SDRAM 分配 */
define region SDRAM = [from 0x40000000 size _extram_size - 4M];
define region NONCACHEABLE_RAM = [from 0x40000000 + (_extram_size - 4M) size 4M];
/* Blocks */
define block vectors with fixed order { section .isr_vector, section .vector_table };
define block ctors { section .ctors, section .ctors.*, block with alphabetical order { init_array } };
define block dtors { section .dtors, section .dtors.*, block with reverse alphabetical order { fini_array } };
define block eh_frame { section .eh_frame, section .eh_frame.* };
define block tbss { section .tbss, section .tbss.* };
define block tdata { section .tdata, section .tdata.* };
define block tls with fixed order { block tbss, block tdata };
define block tdata_load { copy of block tdata };
define block heap with size = __HEAPSIZE__, alignment = 8, /* fill =0x00, */ readwrite access { };
define block stack with size = __STACKSIZE__, alignment = 8, /* fill =0xCD, */ readwrite access { };
define block boot_header with fixed order { section .boot_header, section .fw_info_table, section .dc_info };
define block cherryusb_usbh_class_info with alignment = 8 { section .usbh_class_info };
define block framebuffer with alignment = 8 { section .framebuffer }; // framebuffer,通常用作通讯接口的收发数据缓冲,8字节对齐
/* Symbols */
/*
__nor_cfg_option_load_addr__ 区域,用来存放外部串行 NOR flash 的配置信息,在
MCU 启动时 BOOT ROM 会根据此配置信息,来初始化 XPI0 端口,用于后续
进一步与 NOR Flash 通讯.在当前 linker 文件,将 __nor_cfg_option_load_addr__ 区域
指定在地址 0x80000400,即串行总线控制器 XPI0 存储空间映射的 0x400 偏
移位置,对应与 XPI0 连接的串行 NOR Flash 地址偏移 0x400.
*/
define exported symbol __nor_cfg_option_load_addr__ = start of region NOR_CFG_OPTION;
/*
__boot_header_load_addr__ 区域,用来存放用户代码镜像的固件容器头,在 MCU 启
动时 BOOT ROM 会根据固件容器头,进一步执行启动流程.在当前 linker 文
件,将 __boot_header_load_addr__ 区域指定在地址 0x80001000,即串行总线控制器
XPI0 存储空间映射的 0x1000 偏移位置,对应与 XPI0 连接的串行 NOR Flash
地址偏移 0x1000.
*/
define exported symbol __boot_header_load_addr__ = start of region BOOT_HEADER;
/*
__app_load_addr__ 区域,即用户代码镜像的存储位置.在当前 linker 文件,将 __app_load_addr__ 区
域指定在地址 0x80003000,即串行总线控制器 XPI0 存储空间映射的 0x3000
偏移位置,对应与 XPI0 连接的串行 NOR Flash 地址偏移 0x3000.显然,此偏
移之前的区域,保留给了 NOR_CFG_OPTION 区域和 BOOT_HEADER 区域.
*/
define exported symbol __app_load_addr__ = start of region XPI0;
define exported symbol __app_offset__ = __app_load_addr__ - __boot_header_load_addr__;
define exported symbol __boot_header_length__ = size of block boot_header;
define exported symbol __fw_size__ = 0x1000;
define exported symbol __noncacheable_start__ = start of region NONCACHEABLE_RAM;
define exported symbol __noncacheable_end__ = end of region NONCACHEABLE_RAM + 1;
define exported symbol __share_mem_start__ = start of region SHARE_RAM;
define exported symbol __share_mem_end__ = end of region SHARE_RAM + 1;
define exported symbol _stack_safe = end of block stack + 1;
define exported symbol _stack = end of block stack + 1;
define exported symbol __usbh_class_info_start__ = start of block cherryusb_usbh_class_info;
define exported symbol __usbh_class_info_end__ = end of block cherryusb_usbh_class_info + 1;
/* Initialization */
/*
*表示所有的输入文件
所以 .*.non_init 表示从所有的输入文件中获取所有 .non_init section放在一块连续的地址空间
*/
do not initialize { section .noncacheable }; // noncacheable 不需要初始化的 section
do not initialize { section .non_init, section .non_init.*, section .*.non_init, section .*.non_init.* };
do not initialize { section .no_init, section .no_init.*, section .*.no_init, section .*.no_init.* }; // Legacy sections, kept for backwards compatibility
do not initialize { section .noinit, section .noinit.*, section .*.noinit, section .*.noinit.* }; // Legacy sections, used by some SDKs/HALs
do not initialize { section .backup_sram};
initialize by copy with packing=auto { section .noncacheable.init };
// 程序数据段存储,以复制的形式进行初始化
initialize by copy with packing=none { section .data, section .data.*, section .*.data, section .*.data.* }; // Static data sections
initialize by copy with packing=auto { section .sdata, section .sdata.* };
// "RAM Code" sections .fast 为复制到内部 RAM 执行的代码,也在初始化阶段复制到 RAM 中一些对执行性能有要求的代码,可以分配到此 section
// .fast 代码段 放在一块连续的地址空间
initialize by copy with packing=auto { section .fast, section .fast.*, section .*.fast, section .*.fast.*, section .text.*nx* };
initialize by calling __SEGGER_init_heap { block heap }; // Init the heap if there is one
initialize by calling __SEGGER_init_ctors { block ctors }; // Call constructors for global objects which need to be constructed before reaching main (if any). Make sure this is done after setting up heap.
initialize by copy { block vectors };
initialize by copy { block cherryusb_usbh_class_info };
/* Placement */
place in NOR_CFG_OPTION { section .nor_cfg_option };
place in BOOT_HEADER with fixed order { block boot_header };
place at start of XPI0 with fixed order { symbol _start};
/*
vectors: RISC-V CPU 的中断向量表, hpm sdk 默认打开了 RISC-V CPU
的中断向量扩展和中断嵌套扩展,每一个外部中断都在中断向量表中占有一个
32 位长的入口. block vectors 包含的就是中断向量表.
为了便于快速访问,以复制的形式指定到片内 ILM 的镜像地址
*/
place at start of ILM with fixed order { block vectors };
place in XPI0 with minimum size order {
block tdata_load, // Thread-local-storage load image
block ctors, // Constructors block
block dtors, // Destructors block
block eh_frame, // Exception frames placed directly into flash overriding default placement (sections writable)
readonly, // Catch-all for readonly data (e.g. .rodata, .srodata)
readexec // Catch-all for (readonly) executable code (e.g. .text)
};
//
// The GNU compiler creates these exception-related sections as writeable.
// Override the section header flag and make them readonly so they can be
// placed into flash.
//
define access readonly { section .gcc_except_table, section .gcc_except_table.* };
define access readonly { section .eh_frame, section .eh_frame.* };
define access readonly { section .sdata.DW.* };
place in ILM {
section .fast, section .fast.*, section .text.*nx*, // "ramfunc" section
};
place in SDRAM { block cherryusb_usbh_class_info };
place in SDRAM { block framebuffer };
//place in AXI_SRAM { block cherryusb_usbh_class_info };
//place in AXI_SRAM { block framebuffer };
place in AXI_SRAM then SDRAM {
//place in AXI_SRAM {
block tls, // Thread-local-storage block
readwrite, // Catch-all for initialized/uninitialized data sections (e.g. .data, .noinit)
zeroinit // Catch-all for zero-initialized data sections (e.g. .bss)
};
place in NONCACHEABLE_RAM { section .noncacheable, section .noncacheable.init, section .noncacheable.bss }; // Noncacheable
place in SHARE_RAM { section .sh_mem}; // Share memory
place in AHB_SRAM { section .ahb_sram}; // AHB SRAM memory
place in APB_SRAM { section .backup_sram}; // Backup SRAM memory
place in DLM { section .fast_ram}; // Fast access memory
/* heap: block heap 包含了程序的堆, 堆是用于存放进程运行中被动态分
配的内存段,它的大小并不固定,可动态扩张或缩减.当进程调用 malloc 等函
数分配内存时,新分配的内存就被动态添加到堆上(堆被扩张); 当利用free等
函数释放内存时,被释放的内存从堆中被剔除(堆被缩减)
*/
place in SDRAM { block heap }; // Heap reserved block at SDRAM
//place in DLM { block heap }; // Heap reserved block at DLM
/*
stack: block stack 包含了程序的栈, 是用户存放程序临时创建的局部变
量. 除此以外,在函数被调用时,其参数也会被压入发起调用的进程栈中,并
且待到调用结束后,函数的返回值也会被存放回栈中.由于栈的先进先出(FIFO)
特点,所以栈也用来保存/恢复调用现场. 比如 RISC-V CPU 响应中断时,也会
将当前 CPU 内现场数据保存到 stack
*/
place at end of DLM { block stack }; // Stack reserved block
/* Keep */
/* KEEP 强制让链接器保留一些特定的section,防止被优化 */
keep { section .nor_cfg_option, section .boot_header, section .fw_info_table, section .dc_info };
keep { section .usbh_class_info};
`
本文来自博客园,作者:求隐,转载请注明原文链接:https://www.cnblogs.com/duguqiuying/articles/17824180.html

浙公网安备 33010602011771号