Architecture key moments

Stack architecture key points

  • Cross-platform: use OS and hardware-dependent layer for minimum effort porting;
  • OS-less configuration: ability to run without OS support;
  • Multi-tasking: using internal cooperative multitasking;
  • Application integration: Applications are in the same address space as the stack kernel and use the same multitasking model;
  • Fixed memory footprint: does not use dynamic memory allocation. Predictable memory budgeting.
  • Optimized memory usage: low RAM capacity on target device – special technique in handling data structures;
  • Zero-copy approach: exclude non-necessary data copy operations to support more efficient usage of the CPU;
  • Shared memory usage: use of 'packet buffer' data structure for data exchange and memory allocation;
  • Custom build procedure: stack configuration at compilation time, using C preprocessor;
  • Easy-to-use API: inter-layers API uses primitives similar to the ones defined in the ZigBee® and 802.15 standards;
  • Efficient use in Linux: the stack is implemented in Linux as user-space process with applications inside the stack – stack kernel is implemented as a library (library’s set);
  • Optimized power consumption: for 8051 ZBOSS uses interrupt-driving i/o to improve battery consumption, excluding polling.

Cross-platform support

Cross-platform support is one of the unique features of ZigBee® stack developed in this project. To achieve portability, the following concepts were used:
  • Cross-platform goal was considered from the beginning of the project driving the architectural design and decisions;
  • Hardware-dependent code is located in designated files;
  • Platform-specific logic is localized using macros;
  • Same stack architecture is used for every platform;
  • For platforms that support user-space and kernel-space concept, place maximum logic implementation in user-space to mimic no-OS solution and simplify porting and debug (Linux implementation is user-space except two drivers used for SPI transport and transceiver interrupt);
  • Using standard solutions when possible (spidev driver in linux).

Common architecture picture

The following diagram describes the architecture of ZBOSS v1.0. It completely reflects actual ZBOSS implementation with hardware radio support (TI CC253x and UBEC 24xx). For ZBOSS Linux x86 build with network simulator support the same diagram is accurate, excluding the 802.15.4 transceiver.

  • Main functionality of the stack is the exchange of packets between layers.
  • Packets are passed by callback calls using the scheduler.
  • Scheduler provides cooperative multitasking.
  • I/O for the trace, traffic dump and i/o with scheduler are platform-dependent.
  • An application works in the same schedule loop as the stack kernel.
  • All application logic is implemented in callback functions.
  • Sending packets may be buffered in the out queue in the MAC layer under some condition. The received packets are passed up from the MAC layer immediately after receipt.

OS/Hardware abstraction

OS/HW platform abstraction is necessary to achieve cross-platform support. C preprocessor is used to support the abstraction layer. The main idea is to avoid a large number of “ifdef” constructor usage related to portability in the source code and decrease the number of “ifdef” constructors in the header files not related to the OS abstraction layer. Platform abstraction is implemented as C functions that are placed into OS abstraction layers and platform-dependent global types declaration and definitions are placed into specific header files.

All platform-related stuff is stored in the osif/ directory.
Global definitions and types declaration can be used anywhere – that is why in the architecture picture, the OS abstraction layer is displayed as a global layer.

The following objects are platform-dependent:
  • types definitions for base types (8-bit controller vs 32-bit Linux device);
  • definitions for various 8051 compilers (SDCC and Keil);
  • transceiver i/o (interrupts handling for 8051 vs file i/o in Linux);
  • wait for i/o (device sleep for 8051, wait in select() in Linux);
  • trace i/o (UART for 8051, file in Linux);
  • MAC traffic dump (UART for 8051, file in Linux);
  • Timer (8051 timer at device, select() timeout in Linux).
Note that MAC layer is logically divided into 3 parts:
  • platform-independent MAC logic and API;
  • transceiver-dependent (but platform-independent) part;
  • platform-dependent MAC transport.