可以解决,但不知道会不会引起其他问题。
项目需要,移植一份W25Q16的底层到280049C中。但是源代码里有一个极大的变量(如下代码),用于保存页的数据。
如果使用默认的cmd文件编译,会产生报错:
error #10099-D: program will not fit into available memory, or the section contains a call site that requires a trampoline that can't be generated for this section. run placement with alignment/blocking fails for section ".bss" size 0x11b4 page 1. Available memory ranges:
RAMLS5 size: 0x800 unused: 0x800 max hole: 0x800
双击报错定位到代码:
是分配到RAMLS5的空间不够。
查看其分配的空间(在同一个cmd文件中往上一点):
PAGE 1 :
BOOT_RSVD : origin = 0x000002, length = 0x0000F1 /* Part of M0, BOOT rom will use this for stack */
RAMM1 : origin = 0x000400, length = 0x0003F8 /* on-chip RAM block M1 */
// RAMM1_RSVD : origin = 0x0007F8, length = 0x000008 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
RAMLS5 : origin = 0x00A800, length = 0x000800
RAMLS6 : origin = 0x00B000, length = 0x000800
RAMLS7 : origin = 0x00B800, length = 0x000800
RAMGS0 : origin = 0x00C000, length = 0x002000
RAMGS1 : origin = 0x00E000, length = 0x002000
RAMGS2 : origin = 0x010000, length = 0x002000
RAMGS3 : origin = 0x012000, length = 0x001FF8
// RAMGS3_RSVD : origin = 0x013FF8, length = 0x000008 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
发现还有RAMLS6、RAMLS7两块空间。
查看Memory Allocation,确认其实RAMLS5、RAMLS6、RAMLS7远远没有用完,所以可以将其合并起来用于存放这个变量。
将代码改为:(去掉下面两个空间,将所有空间合并到RAMLS5中)
RAMLS5 : origin = 0x00A800, length = 0x001800
// RAMLS6 : origin = 0x00B000, length = 0x000800
// RAMLS7 : origin = 0x00B800, length = 0x000800
RAMGS0 : origin = 0x00C000, length = 0x002000
RAMGS1 : origin = 0x00E000, length = 0x002000
RAMGS2 : origin = 0x010000, length = 0x002000
RAMGS3 : origin = 0x012000, length = 0x001FF8
并重新编译,成功通过。
查看Memory Allocation,如下:
可以的话还是尽量避免使用占用太大的变量吧,毕竟单片机资源还是很有限的。