GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — [Feature Request] Document NVRAM backup/restore commands in ZBOSS NCP Serial Protocol · Issue #818 · espressif/esp-zigbee-sdk Open DescriptionSummaryRequest to extend the ZBOSS NCP Serial Protocol with documented commands for backing up and restoring the network identity of an ESP-Zigbee NCP coordinator (PAN, ExtPAN, channel, NWK key, frame counter, neighbor table, raw NVRAM). Without these commands, an ESP-Zigbee NCP coordinator cannot survive a flash erase, hardware swap, or NCP firmware downgrade/upgrade without losing all paired devices. Why this matters
Reference: Backup is functionality users implicitly expect from any production coordinator — restoring after coordinator hardware swap, after corrupted NVS, after firmware migration. Without it the ESP-Zigbee NCP path is structurally a non-starter for many users. Why a host-only fix doesn't workThe state lives in the NCP's
Empirically, the only path that preserves end-device pairings across a coordinator wipe is byte-for-byte overwriting Proposed commandsBelow are four commands as implemented and live-verified in
|
| Tag | Name | Length | Source |
|---|---|---|---|
| 0x01 | PAN_ID | 2 | esp_zb_get_pan_id() |
| 0x02 | EXT_PAN_ID | 8 | esp_zb_get_extended_pan_id() |
| 0x03 | CHANNEL | 1 | esp_zb_get_current_channel() |
| 0x04 | NWK_UPDATE_ID | 1 | esp_zb_nwk_get_update_id() |
| 0x05 | COORD_IEEE | 8 | esp_zb_get_long_address() |
| 0x06 | NWK_KEY | 16 | esp_zb_secur_primary_network_key_get() |
| 0x07 | NWK_KEY_SEQ | 1 | key sequence number |
| 0x08 | NWK_FRAME_COUNTER | 4 | esp_zb_nwk_get_frame_counter() |
| 0x10 | DEVICE_TABLE | N×16 | iterate esp_zb_nwk_get_next_neighbor() |
Each DEVICE_TABLE record (16 B): uint64_t ieee; uint16_t short_addr; uint8_t flags; uint8_t reserved[5];.
RESTORE_STRUCTURED_BACKUP (proposed 0x009C)Persists a TLV blob to NVS, schedules esp_restart(). On next boot, the bootstrap applies setters before zboss_start_no_autostart().
Same wire shape as the GET_STRUCTURED_BACKUP response payload, with a uint8_t status response.
Known limitation today: applies only partially because of the SDK setter issues listed above. Useful for "form a new network with these defaults" and for cross-adapter migration; not sufficient as a standalone restore until #445 and the missing channel setter are addressed. The raw GET_NETWORK_BACKUP/RESTORE_NETWORK pair is what actually preserves paired devices today.
tostmann/esp-coordinator — handlers in main/commands_impl.h, NVS bootstrap in main/zb_ncp.cpp::apply_pending_restore(), TLV layout in main/backup_structured.h.tostmann/zigbee2mqtt-esp32 — wire schemas + adapter integration via postinstall (scripts/patch_zboss.js).esptool erase_flash → reflash factory.bin → start Z2M with backup JSON → end-devices reconnect at full link quality without re-pair.esp_zb_set_extended_pan_id only effective in factoryreset statelibzboss_stack.zczr.a parser dropping Tuya Simple_Desc_rsp responseslibzboss_stack.zczr.a zb_address.c:3950x0099–0x009C are acceptable in the vendor-extension range).zigbee-herdsman upstream has a spec source to target — currently the spec is silent on backup/restore, which is what blocks the adapter from removing its throw NOT_SUPPORTED paths.esp_zb_nwk_set_current_channel() so the structured-restore path becomes self-sufficient and the raw-partition fallback is no longer needed.If Espressif prefers a different on-wire shape (different TLV tags, different chunk size, different command groupings, different ID assignments), happy to adapt the reference implementation. The goal is a documented serial protocol the herdsman side can implement upstream.
cc @xieqinan