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

Table of Contents

You can adjust the usage of the RAM memory at compile time by using one of the following methods:

Each of these methods gives a different granularity to the amount of the RAM memory used by the stack.

Including a predefined header file

The nRF5 SDK for Thread and Zigbee comes with three predefined configuration files that can be included and used with any Zigbee application.

Predefined header files
Configuration file Usage Maximum number of nodes
zb_mem_config_min.h Simple applications and small networks. 16
zb_mem_config_med.h Applications without huge demands on Zigbee features,
for example broadcast transmissions, binding and group membership entries.
32
zb_mem_config_max.h Complex applications and huge networks. 128

Where to include header files

To use any of the header files, include it in your main application file.

The following example shows how to configure medium-sized memory buffers.

#include "zboss_api.h"
#include "zb_mem_config_med.h" /* This file has to be included after zboss_api.h */
...

Effects on RAM usage

The following table shows how the predefined memory configurations affect the RAM usage.

RAM usage by device role (GCC compiler)
Role Minimum [kB] Medium [kB] Maximum [kB]
Router + BLE 29.6 33.1 45.9
ZED + BLE 15.8 18.8 23.9
End device 14.3 17.3 22.4
Coordinator 15.5 19.0 31.7
Router 16.6 20.1 32.8

The values for end device, router and coordinator were calculated based on light control example built with the GCC compiler.

Note
  • You can use different set of settings, depending on the device role. Usually, end devices use much less memory than routers or coordinators. Coordinators have the highest demand on resources.
  • For multiprotocol cases, you can configure the memory used by the Zigbee stack in the same way.

Using macro definitions with properties

You can use macro definitions to configure properties of the Zigbee solution. Each macro definition changes several parameters and is related to one property of the solution.

The following properties are available:

For information about how to set the selected macro definition, see Configuring properties.

For information about the default property values, see Parameter reference table.

Device role

The primary property is the device role. Use one of the following parameters to define it:

Note
  • For end devices, this property is automatically defined in the ZED library and cannot be configured.
  • For routers, this property optimizes the amount of APS link keys that can be stored in the memory.
  • For coordinators (Trust Centers), the value of this property corresponds to the amount of nodes in the network.

The following table shows how much RAM you can save on routers by excluding memory buffers that are used only when the device is working as the Zigbee Trust Center.

Potential RAM savings on routers (GCC compiler)
Router memory configuration Minimum [kb] Medium [kb] Maximum [kb]
ZB_CONFIG_ROLE_ZR 16.9 20.2 27.4
ZB_CONFIG_ROLE_ZC 17.1 20.6 29.2

Application complexity

The application complexity property affects:

You can use the following parameters to define the complexity of the application:

Traffic load

The traffic load property affects:

You can use following parameters to define the estimated traffic load that goes through the device:

Maximum network size

You must define the maximum network size with the ZB_CONFIG_OVERALL_NETWORK_SIZE parameter. The parameter value must be between 2 and 200.

Depending on the device type, set the maximum network size value:

Configuring properties

To configure the properties, follow these steps.

  1. Create a header file for the configuration.
  2. In the file, define one parameter for each property.
  3. At the end of the file, include the following header files:
    • zb_mem_config_common.h – which translates defined symbols into values,
    • zb_mem_config_context.h – which overrides memory buffers used by the stack.

You can use any of the predefined files mentioned in the Including a predefined header file method as reference.

The following example shows the memory configuration for a complex application with the end device role. The application communicates with around 50 nodes and does not expect a huge traffic load.

#ifndef ZB_MEM_CONFIG_CUSTOM_H
#define ZB_MEM_CONFIG_CUSTOM_H 1
#define ZB_CONFIG_ROLE_ZED
#define ZB_CONFIG_OVERALL_NETWORK_SIZE 50
#define ZB_CONFIG_LIGHT_TRAFFIC
#define ZB_CONFIG_APPLICATION_COMPLEX
#include "zb_mem_config_common.h"
#include "zb_mem_config_context.h"
#endif /* ZB_MEM_CONFIG_CUSTOM_H */

Creating a custom memory configuration

This is an advanced method. To use it, create your own header file with memory configuration (see Configuring properties).

If the selected method lacks in memory space for a particular property, redefine the value of the property parameter between the two includes in your header file.

#ifndef ZB_MEM_CONFIG_CUSTOM_H
#define ZB_MEM_CONFIG_CUSTOM_H 1
#define ZB_CONFIG_ROLE_ZED
#define ZB_CONFIG_OVERALL_NETWORK_SIZE 50
#define ZB_CONFIG_LIGHT_TRAFFIC
#define ZB_CONFIG_APPLICATION_COMPLEX
#include "zb_mem_config_common.h"
#undef ZB_CONFIG_SCHEDULER_Q_SIZE
#define ZB_CONFIG_SCHEDULER_Q_SIZE 56
#include "zb_mem_config_context.h"
#endif /* ZB_MEM_CONFIG_CUSTOM_H */

An example of this override is commented out in each of the predefined configuration files (see Including a predefined header file).

The following table shows the parameters that you can adjust with this method.

Customizable parameters
Parameter name Description
ZB_CONFIG_IEEE_ADDR_TABLE_SIZE Address translation table size.
ZB_CONFIG_IOBUF_POOL_SIZE Number of packet buffers in the system.
ZB_CONFIG_APS_BIND_TRANS_TABLE_SIZE Table size for simultaneous transmissions to bound devices.
ZB_CONFIG_APS_DUPS_TABLE_SIZE Incoming APS duplicate detection table size.
ZB_CONFIG_N_APS_KEY_PAIR_ARR_MAX_SIZE Number of APS link-key pairs to store on the device.
ZB_CONFIG_N_APS_RETRANS_ENTRIES Number of parallel outgoing APS TX transactions (packets with ACK req 1).
ZB_CONFIG_NEIGHBOR_TABLE_SIZE Neighbor table size.
ZB_CONFIG_NWK_ROUTING_TABLE_SIZE Number of entries in the routing table.
ZB_SCHEDULER_Q_SIZE Callbacks queue, alarms queue size.
ZB_CONFIG_MAC_PENDING_QUEUE_SIZE Number of entries in the pending TX queue for ZR and ZC.

Parameter reference table

The following table shows the default values of parameters and how the parameters relate to each other.

Parameter
Traffic
Complexity
Role
Network size
Default value
L
M
H
S
M
C
ZED
ZR
ZC
<8
<32
<200
ZB_CONFIG_APS_BIND_TRANS_TABLE_SIZE
(ZB_CONFIG_IOBUF_POOL_SIZE + 15)/16 * 4
ZB_CONFIG_SINGLE_TRANS_INDEX_SIZE
(ZB_CONFIG_APS_BIND_TRANS_TABLE_SIZE + 7) / 8
ZB_CONFIG_APS_DUPS_TABLE_SIZE
x 32
x 16
x 8
ZB_CONFIG_IEEE_ADDR_TABLE_SIZE
x ZB_CONFIG_OVERALL_NETWORK_SIZE + (ZB_CONFIG_OVERALL_NETWORK_SIZE + 15)/16 * 4
x ZB_CONFIG_OVERALL_NETWORK_SIZE + (ZB_CONFIG_OVERALL_NETWORK_SIZE + 15)/16 * 4
x ZB_CONFIG_OVERALL_NETWORK_SIZE
ZB_CONFIG_IOBUF_POOL_SIZE
x 48
x 32
x x 32
x x 24
x x 18
ZB_CONFIG_MAC_PENDING_QUEUE_SIZE
x x x ZB_CONFIG_IOBUF_POOL_SIZE / 4
x x x ZB_CONFIG_IOBUF_POOL_SIZE / 4
x x x ZB_CONFIG_IOBUF_POOL_SIZE / 4
x 0
ZB_CONFIG_N_APS_KEY_PAIR_ARR_MAX_SIZE
x ZB_CONFIG_OVERALL_NETWORK_SIZE
x 4
x 2
ZB_CONFIG_N_APS_RETRANS_ENTRIES
x (ZB_CONFIG_IOBUF_POOL_SIZE + 8)/9 * 3
x (ZB_CONFIG_IOBUF_POOL_SIZE + 8)/9 * 3
x 6
ZB_CONFIG_NEIGHBOR_TABLE_SIZE
x ZB_CONFIG_OVERALL_NETWORK_SIZE
x ZB_CONFIG_OVERALL_NETWORK_SIZE
x x 32
x x 16
x x 8
x MAX(16, x)
ZB_CONFIG_NWK_ROUTING_TABLE_SIZE
x x x ZB_CONFIG_NEIGHBOR_TABLE_SIZE
x x x ZB_CONFIG_NEIGHBOR_TABLE_SIZE
x x x 8
x 0
ZB_SCHEDULER_Q_SIZE
x 48
x x 48
x x x 32
x 20
Note
The "x" sign in different categories represents the logical AND. The "x" sign in the same category represents the logical OR.
Example
Traffic
Application
Role
Network size
L
M
H
S
M
C
ZED
ZR
ZC
<8
<32
<200
(Light traffic) AND (ZR OR ZED) x

x x


Documentation feedback | Developer Zone | Subscribe | Updated