nRF5 SDK for Thread and Zigbee v3.0.0
Zigbee stack flash usage configuration

Table of Contents

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:

Amount of memory used

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.
Defined dataset sizes and device types
Note
  • The n_install_codes variable must be equal to OVERALL_NETWORK_SIZE for the coordinator node and to 2 for other devices.
  • The value of n_report_info must be equal to the amount of reportable attributes in your application (see cluster description in the ZCL specification).
  • Use the following formulas to calculate binding_table_size:
    • For end devices: 116 + ZB_APS_BIND_TRANS_TABLE_SIZE + 16 * ((ZB_APS_BIND_TRANS_TABLE_SIZE + 7)/8)
    • For coordinator and routers: 212 + ZB_APS_BIND_TRANS_TABLE_SIZE + 32 * ((ZB_APS_BIND_TRANS_TABLE_SIZE + 7)/8)

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 - -
Flash memory minimum value estimates

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:

Note
  • If the current virtual flash page is filled up with data, every valid dataset must be rewritten into a second page. Because of this, the minimal virtual page size must be greater than the amount of stored data multiplied by 4.
  • Recommended: Use larger virtual pages than calculated for a particular network to reduce the amount of flash erase cycles and extend the device lifetime.

Adjusting persistent data area

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.


Documentation feedback | Developer Zone | Subscribe | Updated