Every Zigbee device uses a part of the internal flash memory to store data, which allows to restore its functionality after power cut.
The following data is stored inside the flash memory:
The memory reserved for storing the data is divided into two virtual pages of the same size. By default, the size of both pages is set to 16 kB to address the needs of more demanding Zigbee applications.
The amount of data that is written by the Zigbee device depends on its role inside the network and the complexity of the application. All stored values are organized into datasets that can be updated. This organization affects the flash usage, because if a certain value changes, the whole dataset that contains its value must be updated. The following table contains the list of the defined datasets, their sizes, and the device types for which these datasets are relevant.
Dataset size [bytes] | Dataset name | Device type |
---|---|---|
20 | NVRAM page header. | All devices. |
96 | Common dataset (device configuration, network data). | All devices. |
24 | Counters (NIB, AIB versions). | All devices. |
20 + 16 * ZB_CONFIG_IEEE_ADDR_TABLE_SIZE | EUI64 address map. | All devices. |
20 + 4 * ZB_CONFIG_NEIGHBOR_TABLE_SIZE | Neighbor table. | All devices. |
20 + 28 * ZB_CONFIG_N_APS_KEY_PAIR_ARR_MAX_SIZE | APS link keys (e.g. TC link key). | All devices. |
20 + 28 * n_install_codes | Install codes. | All devices. |
54 | GPPB cluster data. | Coordinator and routers. |
248 | GPPB proxy table. | Coordinator and routers. |
40 | HA dataset (poll control, diagnostic data). | Application-specific. |
116 | APS group table. | Application-specific. |
16 + 24 * n_report_info | Attribute reporting configuration. | Application-specific. |
16 + binding_table_size | Local binding table. | Application-specific. |
n_install_codes
variable must be equal to OVERALL_NETWORK_SIZE
for the coordinator node and to 2
for other devices.n_report_info
must be equal to the amount of reportable attributes in your application (see cluster description in the ZCL specification).binding_table_size:
The following table shows the estimates for the minimum value of flash memory that is written for a Zigbee device. It assumes that the network consists of two nodes.
ZC/ZR Dataset size [bytes] | ZED Dataset size [bytes] | Dataset name | Note |
---|---|---|---|
20 | 20 | NVRAM page header. | Every virtual page starts with a header. |
96 | 96 | Common dataset (device configuration, network data). | - |
24 | 24 | Counters (NIB, AIB versions). | - |
20 + 16 | 20 + 16 | EUI64 address map. | At least one for the parent device. |
20 + 4 | 20 + 4 | Neighbor table. | At least one for the parent device. |
20 + 56 | 20 + 56 | APS link keys (e.g. TC link key). | At least two - provisional and verified. |
20 + 28 | 20 + 28 | Install codes. | If the device uses install codes for commissioning (recommended). |
54 | - | GPPB cluster data. | Mandatory for the coordinator and routers. |
248 | - | GPPB proxy table. | Mandatory for the coordinator and routers. |
40 | 40 | HA dataset (poll control, diagnostic data). | Application-specific. |
116 | 116 | APS group table. | Application allows to use APS groups. |
16 + 0 | 16 + 0 | Attribute reporting configuration. | Application does not have reportable attributes. |
252 | 140 | Local binding table. | Low traffic, low complexity. |
Total: 1050 bytes | Total: 636 bytes | - | - |
To estimate the required amount of flash memory, you can use the value calculated above as the base. Add more entries of the application-specific datasets and, depending on your application:
You can change size of the persistent data area by modifying ZIGBEE_NVRAM_PAGE_SIZE
and ZIGBEE_NVRAM_PAGE_COUNT
configuration options in the SDK configuration header file.
The persistent data is stored close to the end of flash memory, as described in Zigbee stack memory layout.