RO,RW,ZI概念

RO:
RO=read-only
RW:
RW=read-write
ZI:
ZI=zero-initialized

各部分在空间上的分配结构如下图:
在这里插入图片描述
When you compile a standalone firmware for a microcontroller (as opposed to a user-mode program to be run in an OS), in the end you usually get a single monolithic image that will be flashed into the flash ROM and executed in-place. This is fine for code which usually is not modified, or read-only (const) data, but not so great for writable data. That’s where RW and ZI regions come in. The compiler inserts a small bootstrap code which takes a chunk with initial values of initialized data from the ROM image and copies it into RAM (this is the RW region). It then zeroes out the rest of the used RAM (ZI region). Then the control is transferred to the actual code written by the programmer.
当你编译一个独立的应用程序时,编译完后生成一个整体的image,然后烧录到flash并且执行,对于代码(code)和只读常数(read-only const data)是可行的,但对要求读写的数据(writable data)就不太好了.所以才需要RW和ZI区的加入.编译器插入一段代码用于从ROM复制一大块初始数据到RAM(RW区),然后清零剩下的RAM(ZI区).

Thus, to calculate the used ROM (flash) space, you need to add up code, RO-data and RW-data. Used RAM will be the sum of RW-data and ZI-data. So, for your case, it’s 1264+16+0=1280 bytes of flash and 0+1384=1384 bytes of RAM.
因此,ROM空间你需要把code,RO-data和RW-data区加起来,RAM空间要把RW-data和ZI-data区加起来.即
Total RO Size (Code + RO Data)
Total RW Size (RW Data + ZI Data)
Total ROM Size (Code + RO Data + RW Data)

参考链接ROM and RAM in ARM

猜你喜欢

转载自blog.csdn.net/qq_36412526/article/details/83118561