"Zzh!" (short for "Zig-a-zig-ah!") open-source hardware licensed Zigbee USB-stick based on TI CC2652R

I posted links above when backup was mentioned.

NVRAM is the flash storage on your Zigbee adapter where all info on your network is stored.

zigpy-znp is a python script/library that among other things allow you to backup (and restore) NVRAM:

If you erased your NVRAM when updated firmware then you needed your backup to restore after.

If you did not perform a backup then you might have to re-join all your devices.

Update: walthowd has apparently created a docker image here GitHub - walthowd/znp-firmware: Firmware update utility for ZNP radios such as the TI CC2652R which has everything needed for NVRAM backup/restore and firmware flashing of Texas Intruments based Zigbee adapters installed and ready to go.

But the devices are not on the stick? Why do I have a zigbee.db file in my configurations folder?

Also it looks like all my devices are there.

Ass seen when I try to remove and readd a device.

already in use

Your Zigbee network with security/link keys, etc. for pairing information are stored on the Zigbee stick.

https://github.com/zigpy/zigpy/issues/557

I think this is all we need for a network backup:

  • PAN ID and Extended PAN ID***
  • Network update ID***
  • Current channel***
  • Stack version (may not be necessary)***
  • Network key, key update ID, and frame counter***
  • Frame counters and all children (may not be necessary)***
  • Link keys for Zigbee 3.0 devices***
  • More???***

I don´t understand.

If I listen to zha_device I get alot of device offline

{
“event_type”: “zha_event”,
“data”: {
“device_ieee”: “08:6b:d7:ff:fe:09:5a:52”,
“unique_id”: “08:6b:d7:ff:fe:09:5a:52”,
“device_id”: “afa7c4bcd507fb24a30d9339463cdd34”,
“device_event_type”: “device_offline”
},
“origin”: “LOCAL”,
“time_fired”: “2021-02-22T14:02:30.261806+00:00”,
“context”: {
“id”: “e62656645da464db029d6a2c30f11b90”,
“parent_id”: null,
“user_id”: null
}
}

But I guess it would not help.

I will have a pain re pairing ALL devices again. F U C *

HA knows about your device, the stick doesn’t anymore as it’s NVRAM was erased during the update. the good news is that HA should recognized each device when it is re-joins so any custom naming/ entity ids etc would stick.

No seems to not know the names.

Please tell me how to avoid this next time? When I update how do I keep the devices.

Hours now of repairing everything,

the link Hedda Posted. https://github.com/zigpy/zigpy-znp#nvram

back up the stick before the update, and restore the backup afterwards.

Okej

But do u think best practice is to not remove the device when re adding?

I see that it says that this device already exists but it don´t gets the same name.

Sadly what’s happened to Michael_Roxin happened to me as well! I innocently upgraded my Zig-a-zig-ah stick and all my devices stopped working. Nowhere in the doco was it clear to me that a firmware upgrade would nuke my setup entirely.

Is there documented somewhere a clear way to upgrade a Zig-a-zig-ah stick that doesn’t cause this issue?
I even asked Omer about it when it happened to me and his reply was:

"I am a long time zigbee2mqtt user so the answer to the question of where configuration is stored for z2m is definitely not on the stick and in the data folder, I swap out my coordinator (zzh stick) fairly regularly without losing configuration/having to re-pair devices. "

So it sounds to me like ZHA does something different to how zigbee2mqtt works?

Now I’m aware there’s some way to backup the sticks NVRAM I’ll check that out. I’ve bought another Zig-a-Zig-Ah in case something happens to this one, I was under the impression I could just unplug the old and plug the new (based on Omer’s response above) but it seems not, I’ll have to find a way to integrate taking a regular NVRAM dump as part of my backup strategy.

Thanks all for the pointers and information.

I need some assistance in backing up my NVRAM. I’ve flashed my stick with this guide, that was pretty straight forward.

But what do I need to do to backup my NVRAM? I am trying to run the backup commands ( python -m zigpy_znp.tools.nvram_read /dev/serial/by-id/old_radio -o backup.json ) on my Windows PC without any luck. Changed /dev/serial/by-id/old_radio to COM3, also no succes.

The stick is succesfully connected to COM3, as shown in the logs (also in device manager):
cc2538-bsl.py -p COM3
Opening port COM3, baud 500000
Connecting to target...
CC1350 PG2.0 (7x7mm): 352KB Flash, 20KB SRAM, CCFG.BL_CONFIG at 0x00057FD8
Primary IEEE Address: 00:12:4B:00:21:B7:80:A7

I am kinda stuck.

So like 65% done with re pairng the devices. Mostly I have been able to pair them where they are and not have to move them to the stick.

However, the performence is very sluggish and slow. Will this be good once the whole network is up and been able to mesh?

Anf one more thing, whats the easiest way to reset trådfri bulbs. The on/off 6 times is not that perfect.

For philips I use a remote and hold 0 and 1 for like 10 sec, and it works great. Are there anyway to do simular with Trådfri?

Try

python -m zigpy_znp.tools.nvram_read -p COM3 -o backup.json

The serial port is selected using the -p option, like -p /dev/ttyUSB0 (Linux and macOS) or -p COM3 (Windows).

Submitted pull request to zigpy-znp with more beginner oriented instructions for Windows, Linux and macOS → Update README.md with beginner instructions for NVRAM backup and restore by Hedda · Pull Request #66 · zigpy/zigpy-znp · GitHub (review welcomed there)

Update: walthowd has apparently created a docker image here GitHub - walthowd/znp-firmware: Firmware update utility for ZNP radios such as the TI CC2652R which has everything needed for NVRAM backup/restore and firmware flashing of Texas Intruments based Zigbee adapters installed and ready to go.

PS: walthowd has before created a similar docker image for Silicon Labs based EmberZNet NCP Zigbee adapters that is available here GitHub - walthowd/husbzb-firmware: Nortek GoControl HUSBZB-1 / EM3581 Firmware update image

I get the following response:

PS D:\> python -m zigpy_znp.tools.nvram_read -p COM3 -o backup.json
usage: nvram_read.py [-h] [-v] [--output OUTPUT] serial
nvram_read.py: error: unrecognized arguments: -p

When trying the docker route I also get an error (running Docker on Win10)

PS D:\> docker run --rm -v.:/opt/firmware/backup --device=/dev/ttyACM0:/dev/ttyACM0 -it walthowd/znp-firmware bash
docker: Error response from daemon: create .: volume name is too short, names should be at least two alphanumeric characters.
See 'docker run --help'.

Tried some combinations with -p COM3 but non of them seem to work.

*edit
While playing around with the settings I seem to be getting something

PS D:\> python -m zigpy_znp.tools.nvram_read -v COM3 -o backup.json
2021-02-23 21:21:54 pcmark zigpy_znp.uart[18320] DEBUG Connecting to COM3 at 115200 baud
2021-02-23 21:21:54 pcmark zigpy_znp.uart[18320] DEBUG Opened COM3 serial port
2021-02-23 21:21:54 pcmark zigpy_znp.uart[18320] DEBUG Toggling RTS/CTS to skip CC2652R bootloader
2021-02-23 21:21:55 pcmark zigpy_znp.uart[18320] DEBUG Connected to COM3 at 115200 baud
2021-02-23 21:21:55 pcmark zigpy_znp.api[18320] DEBUG Waiting 1s before sending anything
2021-02-23 21:21:56 pcmark zigpy_znp.api[18320] DEBUG Sending bootloader skip byte
2021-02-23 21:21:56 pcmark zigpy_znp.api[18320] DEBUG Waiting 1s or until a reset indication is received
2021-02-23 21:21:57 pcmark zigpy_znp.api[18320] DEBUG Testing connection to COM3
2021-02-23 21:21:57 pcmark zigpy_znp.api[18320] DEBUG Sending request: SYS.Version.Req()
2021-02-23 21:22:12 pcmark zigpy_znp.api[18320] DEBUG Connection to COM3 failed, cleaning up
Traceback (most recent call last):
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\zigpy_znp\api.py", line 507, in request
    response = await response_future
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\zigpy_znp\tools\nvram_read.py", line 95, in <module>
    asyncio.run(main(sys.argv[1:]))  # pragma: no cover
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete
    return future.result()
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\zigpy_znp\tools\nvram_read.py", line 90, in main
    obj = await backup(args.serial)
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\zigpy_znp\tools\nvram_read.py", line 18, in backup
    await znp.connect()
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\zigpy_znp\api.py", line 234, in connect
    self._version = await self.request(c.SYS.Version.Req())
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\zigpy_znp\api.py", line 507, in request
    response = await response_future
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\async_timeout\__init__.py", line 55, in __aexit__
    self._do_exit(exc_type)
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\async_timeout\__init__.py", line 92, in _do_exit
    raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError
PS D:\>
1 Like

I think you were / are pretty close. Try without pressing / holding the BSL button on the board while plugging the device into the host.

Tried it without pressing the BSL button but it gave me the same result. Tried another USB-port (COM4) but also no change there.

Also getting an error if I’m trying to run the Energy scan.

D:\>python -m zigpy_znp.tools.energy_scan -v COM4
2021-02-25 22:31:23 pcmark __main__[17788] INFO Starting up zigpy-znp
2021-02-25 22:31:23 pcmark zigpy_znp.uart[17788] DEBUG Connecting to COM4 at 115200 baud
2021-02-25 22:31:23 pcmark zigpy_znp.uart[17788] DEBUG Opened COM4 serial port
2021-02-25 22:31:23 pcmark zigpy_znp.uart[17788] DEBUG Toggling RTS/CTS to skip CC2652R bootloader
2021-02-25 22:31:23 pcmark zigpy_znp.uart[17788] DEBUG Connected to COM4 at 115200 baud
2021-02-25 22:31:23 pcmark zigpy_znp.api[17788] DEBUG Waiting 1s before sending anything
2021-02-25 22:31:24 pcmark zigpy_znp.api[17788] DEBUG Sending bootloader skip byte
2021-02-25 22:31:24 pcmark zigpy_znp.api[17788] DEBUG Waiting 1s or until a reset indication is received
2021-02-25 22:31:25 pcmark zigpy_znp.api[17788] DEBUG Testing connection to COM4
2021-02-25 22:31:25 pcmark zigpy_znp.api[17788] DEBUG Sending request: SYS.Version.Req()
2021-02-25 22:31:40 pcmark zigpy_znp.api[17788] DEBUG Connection to COM4 failed, cleaning up
2021-02-25 22:31:40 pcmark zigpy.application[17788] ERROR Couldn't start application
Traceback (most recent call last):
  File "C:\Users\mmevi\AppData\Local\Programs\Python\Python39\lib\site-packages\zigpy_znp\api.py", line 507, in request
    response = await response_future
asyncio.exceptions.CancelledError

Finally some success! Tried the same commands in Git Bash and everything seems to work! :smiley:

$ python -m zigpy_znp.tools.nvram_read -v COM4 -o backup.json
2021-02-25 23:12:36 pcmark zigpy_znp.uart[11188] DEBUG Connecting to COM4 at 115200 baud
2021-02-25 23:12:36 pcmark zigpy_znp.uart[11188] DEBUG Opened COM4 serial port
2021-02-25 23:12:36 pcmark zigpy_znp.uart[11188] DEBUG Toggling RTS/CTS to skip CC2652R bootloader
2021-02-25 23:12:36 pcmark zigpy_znp.uart[11188] DEBUG Connected to COM4 at 115200 baud
2021-02-25 23:12:36 pcmark zigpy_znp.api[11188] DEBUG Waiting 1s before sending anything
2021-02-25 23:12:37 pcmark zigpy_znp.api[11188] DEBUG Sending bootloader skip byte
2021-02-25 23:12:37 pcmark zigpy_znp.api[11188] DEBUG Waiting 1s or until a reset indication is received
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Testing connection to COM4
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Sending request: SYS.Ping.Req()
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Received command: SYS.Ping.Rsp(Capabilities=<MTCapabilities.CAP_APP_CNF|CAP_GP|CAP_UTIL|CAP_ZDO|CAP_AF|CAP_SYS: 1625>)
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Sending request: SYS.NVLength.Req(SysId=<NvSysIds.ZSTACK: 1>, ItemId=<ExNvIds.TCLK_TABLE: 4>, SubId=0)
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Received command: SYS.NVLength.Rsp(Length=20)
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Sending request: SYS.NVRead.Req(SysId=<NvSysIds.ZSTACK: 1>, ItemId=<ExNvIds.TCLK_TABLE: 4>, SubId=0, Offset=0, Length=20)
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Received command: SYS.NVRead.Rsp(Status=<Status.SUCCESS: 0>, Value=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\x00\x00\x00')
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Detected Z-Stack 3.3
2021-02-25 23:12:38 pcmark zigpy_znp.api[11188] DEBUG Connected to COM4 at 115200 baud

Did a succesfull NVRAM backup, erased the device firmware, flashed the new firmware and restored the NVRAM backup! Connected the stick to home assistant again and boom, all the devices came back online! :smiley: :ok_hand:

Thank you @Hedda & @balu79 for your support!

3 Likes

FYI, there is a bug in pyserial-asyncio v0.5 release for Windows so need to use pyserial-asyncio v0.4

zigpy-znp is installed via pip should automatically use pyserial-asyncio v0.4 (as it has blacklisted v0.5).

I’ve ordered the CC2652R and should arrived in a few weeks. I will be upgrading from CC2531 to CC2652. I have read through the whole post and did not find a solid how to steps. These are the steps I will be doing. Is this more or less ok? I have 15 devices total connected to HA.

Steps:
shutdown zigbee2mqtt
change the pan_id to a different number
change permit_join to true
Reboot HA
make sure zigbee2mqtt is running
pair each devices one by one

Questions:
Do I need to delete all the devices in mqtt integrations prior to repairing?
I was using Channel 11. Is there a better channel # I should use or it is base on my surrounds to find the best channel?
The port path will still be the same if I use the exact usb port of CC2531? Currently /dev/ttyACM0
During the pairing process, will the friendly name be the same and any automations setup using the devices will work once again?

Your other option is to use this guide to back up your CC2531’s network and restore that to the new stick.

Then you won’t have to change anything else, or re-pair your devices.

1 Like

Ok. I have installed zigpy-znp on a separate rpi. Do I use this cmd to backup the file? What port do I use?

python -m zigpy_znp.tools.network_backup socket://192.168.1.123:4567