This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

What the meaning of Zero Initialized data, ZI Data

Can anyone tell me the meaning of Zero Initialized Data (ZI Data). Do they actually take up RAM maps. It would be best explained in practical point of view, ie is this global or local type of variable. I use Keil and Cortex-M0.

I declared variable within code that point to FLASH region as part of emulated ROM code. However according to the .map, it shown that ZI Data = 1024 Byte which is 8 * 128 = 1024 Byte. This lead to incorrect conclusion about RAM size as .map indicated.

EEEDATA_TYPE EEEFLASH[8] __attribute__((at(0x10007C00U))); //this instruct linker to align data to the specific FLASH location. Keil specfic.

Is there nice tutorial or PDF that explain how to use / meaning if RO, RW and ZI data and how to manage them where necessary.

Parents
  • Of course zero-initialized variables consumes RAM. It's just that their initial value is zero, so the startup code can initialize them with a memset() while normal initialized variables needs that the initial values are stored in the code, and copied into RAM on startup.

    As you should have realized from Andy's Google link, the termi ZI or Zero Initialized Data really are standard concepts. The C standard requires that any global variable must always be given an initial value even if the source code doesn't supply an explicit value.

    Auto variables are stored on the stack, and they do not get any initial value unless you do an initial assign. So they are not part of the ZI memory region.

Reply
  • Of course zero-initialized variables consumes RAM. It's just that their initial value is zero, so the startup code can initialize them with a memset() while normal initialized variables needs that the initial values are stored in the code, and copied into RAM on startup.

    As you should have realized from Andy's Google link, the termi ZI or Zero Initialized Data really are standard concepts. The C standard requires that any global variable must always be given an initial value even if the source code doesn't supply an explicit value.

    Auto variables are stored on the stack, and they do not get any initial value unless you do an initial assign. So they are not part of the ZI memory region.

Children