ZAP Memory Sections
There are various memory sections of which a programmer must be aware when writing a ZAP.
High Level Memory Sections
At the highest level there are three memory sections:
ZAP Image
- This is where the entire .zap file resides. This includes:
- ZAP executable code
- ZAP image header
- ZentriOS API lookup table
- Settings
- Log strings
- On the AMW004 and AMW106 platforms this is on the device's extended serial flash
- On the NXP-SCCK platform this is on the device's flash bank B ('user' flash)
Code
- This is where the ZAP program code executes
- On the AMW004 and AMW106 platforms this is in a dedicated portion of RAM
- On the NXP-SCCK this is on the device's flash bank B ('user' flash)
Data
- This is where ZAP data structures and other buffers reside
- On all platforms this is in the RAM
Memory Size and Availability by Platform
Memory Optimizations
Since the ZAP code section resides in RAM for the AMW004 and AMW106, numerous optimizations are in place to ensure only essential memory is loaded into RAM.
Note that code optimizations are not required for the NXP-SCCK platform, as the ZAP executes directly from the Code section stored in user flash, is not loaded into RAM and does not consume memory.
Using the application settings feature can save RAM. See Settings and Resources, Memory Saving on AMW004 and AMW106 Platforms.
Parts of the ZAP that are static and rarely used are kept in the ZAP image on extended serial flash and loaded on demand:
Log Strings
Log strings, such as:
ZOS_LOG("This is a log string");
The string is stored in the ZAP image and loaded when the log function is called.
Variables with RO_MEM Attribute
If a global data variable contains this attribute, then the variable's read-only data is stored in the ZAP image and loaded with the API: zn_load_ro_memory()
Example:
RO_MEM uint8_t read_only_buffer[] = { 1, 2, 3, 4 };
zn_load_ro_memory(local_buffer, 4, read_only_buffer, 0);