Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Itead Sonoff CC2652P usb stick bootloader invoke toggle #114

Merged
merged 1 commit into from Jan 19, 2022

Conversation

JelmerT
Copy link
Owner

@JelmerT JelmerT commented Nov 26, 2021

This PR adds support for the Itead Sonoff CC2652P usb dongle (https://itead.cc/product/sonoff-zigbee-3-0-usb-dongle-plus/) with the new option --bootloader-sonoff-usb.
With this new option you don't have to manually start the bootloader with the 2 buttons on the PCB anymore.

This dongle does not have a 1 to 1 connection between RTS DTR and RST IO15, but uses 2 NPN transistors to connect them together with the following truth table:

DTR  RTS  |  RST  IO15
1     1   |   1    1
0     0   |   1    1
1     0   |   0    1
0     1   |   1    0

I'm not aware of any other HW that uses this connection, so I'm naming the option after the specific hardware. In the future this should probably get a more general name like --bootloader-imply-gate or something. (the truth table is an imply and nimply port)

If you have this specific HW, please test and report here.

@Hedda
Copy link
Contributor

Hedda commented Nov 29, 2021

Works great now! I can confirm this is working with 'sonoff' parameter on MS Windows 10 OS (more details in #113 ). Thank you!

https://github.com/JelmerT/cc2538-bsl/tree/feature/ITead_Sonoff_Zigbee-delay

UPDATE! I have updated my step-by-step testing instructions for flashing here to make it easier for others to test this:

Broken down steps taken to flash firmware already mentioned in #113 into a step-by-step guide for flashing Sonoff Plus dongle:

  1. Install Silabs CP210x device drivers (CP2102N USB-to-UART bridge / USB-to-Serial converter chip) needed for Windows OS and Mac OS, (this also required a reboot of my operating-system).
  2. Install Python (in my case I installed and tested with Python for Windows 3.10.1).
  3. Launch command-prompt (cmd.exe) as elevated Administrator. Upgrade pip with python -m pip install --upgrade pip, (if pip is not available then first run python -m ensurepip --upgrade), then pre-install dependencies fro cc2538-bsl from PyPi via pip command: pip install wheel pyserial intelhex python-magic
  4. Optional but recommended: Download and install zigpy-znp via pip/PyPI with pip install zigpy-znp then perform NVRAM backup by following instructions in TOOLS.md (also find more details ZNP radio backup procedure at https://github.com/zigpy/zigpy/wiki/Coordinator-Backup-and-Migration) for Windows backup command should be something like python -m zigpy_znp.tools.nvram_read COM5 -o nvram_backup.json and optionally also backup Zigbee network via python -m zigpy_znp.tools.network_backup COM5 -o network_backup.json.
  5. Download cc2538-bsl on GiHub from its "master" branch, (and not via pip/PyPI), unpact the zip to a folder then launch command-promt (cmd.exe) as elevated Administrator and run its setup.py to install its dependencies (should include "setuptools", "wheel", "pyserial", "intelhex", and "python-magic" packages).
  6. Get latest firmware (I tested latest "CC1352P2_CC2652P_launchpad_*.zip" image available from its "master" branch at this time. Alternatively, you could get the latest "beta" version from the develop branch). Regardless make sure to get the correct image file as should be the one for "launchpad" (and not for "other)"!
  7. Stop any applications or services that might be connected to the Zigbee adapter via serial port (ex. Home Assistant's ZHA integration, Zigbee2MQTT, ioBroker, Jeedom, etc.). In my case, I ran the update on another computer so nothing to stop there.
  8. Run command to flash from command-promt (cmd.exe) launched as elevated Administrator, example with firmware release available at this time: python cc2538-bsl.py -p COM5 -e -v -w --bootloader-sonoff-usb CC1352P2_CC2652P_launchpad_coordinator_20211217.hex

Obviously need to replace number in "COM5" with the port # actually shown used under ports in Device Manager on Windows on your computer as the OS will just assign the next available Serial/COM-port.

Also, if using Linux or Mac OS instead of Microsoft Windows then the COM# serial device path after -p will be different when set the port to use, (like for example /dev/ttyUSB0 or /dev/ttyUSB1) and might need different Silabs CP210x device drivers (CP2102N USB-to-UART bridge / USB-to-Serial converter chip) for your operating system, on Linux might have to run Python with sudo, and read that many on Linux successfully run sudo python cc2538-bsl.py -e -v -w --bootloader-sonoff-usb CC1352P2_CC2652P_launchpad_coordinator_20211217.hex without setting serial device path with -p for port to use.

Copy comment from issue #113

I'm not aware of any other HW that uses this connection, so I'm naming the option after the specific hardware. In the future this should probably get a more general name like --bootloader-imply-gate or something. (the truth table is an imply and nimply port)

Better if cc2538-bsl could detect Sonoff "description" from CP2102N USB-to-UART chip then automatically use correct sequence?

Note! Home Assistant now features USB-discovery for this dongle based on combo of VID, PID and its unique product description:

https://community.home-assistant.io/t/community-help-wanted-to-whitelist-all-compatible-zigbee-and-z-wave-usb-adapters-for-automatic-discovery-in-home-assistant-os/344412

PS: Recommend upgrading to latest firmware from the develop branch as it got a lot of bug-fixes from upstream not in master:

https://github.com/Koenkk/Z-Stack-firmware/tree/develop/coordinator/Z-Stack_3.x.0/bin

@io53
Copy link

io53 commented Dec 6, 2021

I have the device and tested "--bootloader-sonoff-usb" on macOS and Arch Linux, it worked perfectly on both. Thanks!

@Oliv4945
Copy link

Hi, it worked also perfectly fine for me with

python cc2538-bsl.py -e -v -w --bootloader-sonoff-usb ./CC1352P2_CC2652P_launchpad_coordinator_20211207.hex

@Hedda
Copy link
Contributor

Hedda commented Dec 13, 2021

@Oliv4945 for reference; can you specifically state on which exact operating system(s) distro and its version it worked on for you?

@panther-sh
Copy link

Hi, worked also for me on Raspbian Buster (Debian 10)! Therefore it was very easy to flash the sonoff zigbee stick. Thank you very much for this great project!

@Oliv4945
Copy link

@Hedda Linux Debian 11

@digiblur
Copy link

Worked great! I even tested on the Zigstar USB stick and it worked too to my surprise. https://zig-star.com/projects/zigbee-stick-v4/

@foxsam21
Copy link

Worked and installed for first time zigbee user. Linux Mint 19.3 Cinnamon python 3.6.9

@osos
Copy link

osos commented Dec 20, 2021

Flashing worked on Linux Mint 20.2

./cc2538-bsl.py -e -v -w --bootloader-sonoff-usb --ieee-address 00:12:34:56:67:78:9a:bc ../CC1352P2_CC2652P_launchpad_coordinator_20211217.hex

@flatsiedatsie
Copy link

flatsiedatsie commented Dec 21, 2021

It worked for me too.

Here's my full report.

  • running the script on Rasbian Buster on a Pi 3.

First, I had to install the dependencies.

pip3 install pyserial
and
pip3 install IntelHex

Then I tried running the command.

python3 cc2538-bsl.py -e -v -w --bootloader-sonoff-usb ./CC1352P2_CC2652P_launchpad_coordinator_20211217.hex

Which resulted in:

sonoff
Opening port /dev/ttyUSB0, baud 500000
Reading data from ./CC1352P2_CC2652P_launchpad_coordinator_20211217.hex
Your firmware looks like an Intel Hex file
Connecting to target...
ERROR: Timeout waiting for ACK/NACK after 'Get ChipID (0x28)'

I then realised Zigbee2MQTT may still be connected to the stick. So I disabled Zigbee2MQTT and ran the command again. This time it worked.

sonoff
Opening port /dev/ttyUSB1, baud 500000
Reading data from ./CC1352P2_CC2652P_launchpad_coordinator_20211217.hex
Your firmware looks like an Intel Hex file
Connecting to target...
CC1350 PG2.0 (7x7mm): 352KB Flash, 20KB SRAM, CCFG.BL_CONFIG at 0x00057FD8
Primary IEEE Address: XX:XX:XX:XX:XX:XX:XX:XX
    Performing mass erase
Erasing all main bank flash sectors
    Erase done
Writing 360448 bytes starting at address 0x00000000
Write 104 bytes at 0x00057F980
    Write done                                
Verifying by comparing CRC32 calculations.
    Verified (match: 0xba5c19c5)

Some thoughts:

  • Maybe the script could offer the suggestion that something else might be using the stick if it detects that error?
  • I suspect I have to restart the Raspberry Pi now? Or should I unplug the device and plug it back in? Maybe the script could suggest a safe course of action at the end?

@digiblur
Copy link

Covered the new feature in the upgrade/hands on this one too - https://youtu.be/4S_c_m6z-RY Awesome work making this easier!

@ckolumbus
Copy link

Another success story, using a virtualenv on an up-to-date Linux Manjaro installation with python 3.9.9

python -m venv sonoff-pyenv
. sonoff-pyenv/bin/activate
pip install pyserial IntelHex
git clone https://github.com/JelmerT/cc2538-bsl.git
cd cc2538-bsl
git checkout feature/ITead_Sonoff_Zigbee-delay
cd ..
python3 ./cc2538-bsl/cc2538-bsl.py  -e -v -w --bootloader-sonoff-usb ./CC1352P2_CC2652P_launchpad_coordinator_20211217.hex

output

Opening port /dev/ttyUSB0, baud 500000
Reading data from ./CC1352P2_CC2652P_launchpad_coordinator_20211217.hex
Your firmware looks like an Intel Hex file
Connecting to target...
CC1350 PG2.0 (7x7mm): 352KB Flash, 20KB SRAM, CCFG.BL_CONFIG at 0x00057FD8
Primary IEEE Address: 00:12:4B:00:24:C2:90:50
    Performing mass erase
Erasing all main bank flash sectors
    Erase done
Writing 360448 bytes starting at address 0x00000000
Write 104 bytes at 0x00057F980
    Write done                                
Verifying by comparing CRC32 calculations.
    Verified (match: 0xba5c19c5)

Great work! THANKS!

@somebody-somewhere-over-the-rainbow

FYI worked like a charm on Ubuntu 20.04 after running sudo pip install pyserial IntelHex using sudo python3 cc2538-bsl.py -e -v -w --bootloader-sonoff-usb CC1352P2_CC2652P_launchpad_coordinator_20211217.hex

@kdevo
Copy link

kdevo commented Jan 1, 2022

Another confirmation:
My Sonoff Zigbee 3.0 Dongle came with a faulty or outdated ZStack coordinator firmware.
So I could use your script to flash the latest correct firmware under Raspberry Pi OS (Debian 11), even without opening the Aluminium case. Worked flawlessly. Thank you very much!
Do you have a donation/sponsoring option?

@cooperaj
Copy link

cooperaj commented Jan 4, 2022

Worked flawlessly (bar my user not having access to the dialout group) with a Sonoff 3 USB.

@klein0r
Copy link

klein0r commented Jan 4, 2022

Worked! Please merge 😄

@ZetaPhoenix
Copy link

Worked well for me as well:

python cc2538-bsl.py -p COM12 -ewv --bootloader-sonoff-usb .\CC1352P2_CC2652P_launchpad_coordinator_20211217.hex
sonoff
Opening port COM12, baud 500000
Reading data from .\CC1352P2_CC2652P_launchpad_coordinator_20211217.hex
Your firmware looks like an Intel Hex file
Connecting to target...
CC1350 PG2.0 (7x7mm): 352KB Flash, 20KB SRAM, CCFG.BL_CONFIG at 0x00057FD8
Primary IEEE Address: xx:xx:xx:xx:xx:xx:xx:xx
    Performing mass erase
Erasing all main bank flash sectors
    Erase done
Writing 360448 bytes starting at address 0x00000000
Write 104 bytes at 0x00057F980
    Write done
Verifying by comparing CRC32 calculations.
    Verified (match: 0xba5c19c5)
    ```

@Hedda
Copy link
Contributor

Hedda commented Jan 5, 2022

@cooperaj @klein0r @ZetaPhoenix for reference please specify exact OS/distro version and Python version it worked on for you?

@ZetaPhoenix
Copy link

@Hedda Windows 10 and it worked as above.

@cooperaj
Copy link

cooperaj commented Jan 5, 2022

Ubuntu 20.04. I had to install a couple of python things (which I did in a venv) but it was all pretty straight forward.

@flatsiedatsie
Copy link

flatsiedatsie commented Jan 5, 2022

Is it allowed to use this script as part of another open source project? I'm thinking about adding a UI to flash the Sonoff dongle into the Zigbee2MQTT plugin for the Webthings Gateway.

@Solksjaer
Copy link

Solksjaer commented Jan 5, 2022

Is it allowed to use this script as part of another open source project? I'm thinking about adding a UI to flash the Sonoff dongle into the Zigbee2MQTT plugin for the Webthings Gateway.

Maybe you could use this one (or get in touch with him for further development, because current latest changes from this repo, do not include this functionality: see xyzroe/ZigStarGW-MT#2) https://github.com/xyzroe/ZigStarGW-MT

@Nardol
Copy link

Nardol commented Jan 10, 2022

Works perfectly on Armbian 21.08.6 Buster with Linux 5.10.81-meson64 kernel (Odroid N2+) Python version 3.7.3.
I used a python virtualenv as @ckolumbus detailed on this comment.
No root privileges needed as my user is in the "dialout" group.

vogler added a commit to vogler/smart-home that referenced this pull request Jan 12, 2022
…20103

Changed from 5dBm to 9dBm by default (only send, not receive).
Link quality in networkmap improved 20-100% (only two samples).

Flashed directly in rpi3, no need to unplug and press button:
$ python3 cc2538-bsl.py -e -w -v --bootloader-sonoff-usb -p /dev/ttyUSB1 CC1352P2_CC2652P_launchpad_coordinator_20220103.hex

PR: JelmerT/cc2538-bsl#114
Firmware: https://github.com/Koenkk/Z-Stack-firmware/blob/a4fbab342c131e8ec387e02ac9662d5344c48224/coordinator/Z-Stack_3.x.0/bin/CC1352P2_CC2652P_launchpad_coordinator_20220103.zip
@juan11perez
Copy link

Good day I had the following fault:
ERROR: Timeout waiting for ACK/NACK after 'Synch (0x55 0x55)

After adding --bootloader-sonoff-usb to the command I was able to complete flashing as per below.

ERROR: Timeout waiting for ACK/NACK after 'Synch (0x55 0x55)' [juan@archlinux cc2538-bsl-feature-ITead_Sonoff_Zigbee-delay]$ python cc2538-bsl.py -evw -p /dev/ttyUSB0 --bootloader-sonoff-usb CC1352P2_CC2652P_launchpad_router_20210128.hex sonoff Opening port /dev/ttyUSB0, baud 500000 Reading data from CC1352P2_CC2652P_launchpad_router_20210128.hex Your firmware looks like an Intel Hex file Connecting to target... CC1350 PG2.0 (7x7mm): 352KB Flash, 20KB SRAM, CCFG.BL_CONFIG at 0x00057FD8 Primary IEEE Address: 00:12:4B:00:24:C2:42:09 Performing mass erase Erasing all main bank flash sectors Erase done Writing 360448 bytes starting at address 0x00000000 Write 104 bytes at 0x00057F988 Write done Verifying by comparing CRC32 calculations. Verified (match: 0xe0c256fd) [juan@archlinux cc2538-bsl-feature-ITead_Sonoff_Zigbee-delay]$

@Hedda
Copy link
Contributor

Hedda commented Jan 14, 2022

@juan11perez for reference please specify which exact OS/distro inc. the OS/distro version + Python version it worked on for you?

@juan11perez
Copy link

@Hedda
Archlinux
Python 3.10.1

@ChrisLane
Copy link

Another success story, using a virtualenv on an up-to-date Linux Manjaro installation with python 3.9.9

python -m venv sonoff-pyenv
. sonoff-pyenv/bin/activate
pip install pyserial IntelHex
git clone https://github.com/JelmerT/cc2538-bsl.git
cd cc2538-bsl
git checkout feature/ITead_Sonoff_Zigbee-delay
cd ..
python3 ./cc2538-bsl/cc2538-bsl.py  -e -v -w --bootloader-sonoff-usb ./CC1352P2_CC2652P_launchpad_coordinator_20211217.hex

Just had success following these steps on Arch Linux with Python 3.10.1!

@marcelrv
Copy link

marcelrv commented Jan 17, 2022

I also had success with this branch in ubuntu 21.04
Needed the CC1352P2_CC2652P_launchpad_coordinator_20220103 version (only available in the develop branch) to get the device to pair any devices...

python3 ./cc2538-bsl/cc2538-bsl.py -e -v -w --bootloader-sonoff-usb ./CC1352P2_CC2652P_launchpad_coordinator_20220103.hex

@2er0
Copy link

2er0 commented Jan 18, 2022

Another success story, using a virtualenv on an up-to-date Linux Manjaro installation with python 3.9.9

python -m venv sonoff-pyenv
. sonoff-pyenv/bin/activate
pip install pyserial IntelHex
git clone https://github.com/JelmerT/cc2538-bsl.git
cd cc2538-bsl
git checkout feature/ITead_Sonoff_Zigbee-delay
cd ..
python3 ./cc2538-bsl/cc2538-bsl.py  -e -v -w --bootloader-sonoff-usb ./CC1352P2_CC2652P_launchpad_coordinator_20211217.hex

output

Opening port /dev/ttyUSB0, baud 500000
Reading data from ./CC1352P2_CC2652P_launchpad_coordinator_20211217.hex
Your firmware looks like an Intel Hex file
Connecting to target...
CC1350 PG2.0 (7x7mm): 352KB Flash, 20KB SRAM, CCFG.BL_CONFIG at 0x00057FD8
Primary IEEE Address: 00:12:4B:00:24:C2:90:50
    Performing mass erase
Erasing all main bank flash sectors
    Erase done
Writing 360448 bytes starting at address 0x00000000
Write 104 bytes at 0x00057F980
    Write done                                
Verifying by comparing CRC32 calculations.
    Verified (match: 0xba5c19c5)

Great work! THANKS!

I had to set the device. -p /dev/ttyUSB0

python3 ./cc2538-bsl/cc2538-bsl.py -e -v -w -p /dev/ttyUSB0 --bootloader-sonoff-usb ./CC1352P2_CC2652P_launchpad_coordinator_20211217.hex

@TeslaCLT
Copy link

I have zigbee2mqtt running in a LXC on Proxmox and wonder if I can do it from inside the container vs. from the host?

Remember that you regardless will need to first stop any application connected to the serial port before upgrading the firmware.

Worked like a charm. I knew to stop z2m first and running the commands others have shared worked perfectly from within my LXC container.

@ckolumbus
Copy link

@TeslaCLT

@ckolumbus I wanted to verify that you ran this from inside a virtual environment with the dongle passed through? I have zigbee2mqtt running in a LXC on Proxmox and wonder if I can do it from inside the container vs. from the host?

sorry for the late reply: python virtualenv are not related to "system virtualization". it is a python construct to isolate installed libraries for individual projects. so no USB pass through is needed as the execution context is still on the host.

@JelmerT JelmerT merged commit 7995271 into master Jan 19, 2022
@JelmerT
Copy link
Owner Author

JelmerT commented Jan 19, 2022

Looks like this is working.

Thanks everyone for testing!

@JelmerT
Copy link
Owner Author

JelmerT commented Jan 19, 2022

Is it allowed to use this script as part of another open source project? I'm thinking about adding a UI to flash the Sonoff dongle into the Zigbee2MQTT plugin for the Webthings Gateway.

@flatsiedatsie It's not only allowed, it's encouraged!

@Hedda
Copy link
Contributor

Hedda commented Jan 20, 2022

Is it allowed to use this script as part of another open source project? I'm thinking about adding a UI to flash the Sonoff dongle into the Zigbee2MQTT plugin for the Webthings Gateway.

@flatsiedatsie It's not only allowed, it's encouraged!

@JelmerT Then pretty please check out the license discussion here -> #59

@Hedda
Copy link
Contributor

Hedda commented Jan 20, 2022

Looks like this is working.

Thanks everyone for testing!

Thank YOU JelmerT!

Can we now please request that you push a new release for PyPI using the old or new name?

#89

https://github.com/JelmerT/cc2538-bsl/releases

Also suggest that you use releases with release version in addition to tags:

https://github.blog/2013-07-02-release-your-software/

Plus make use of the PyPI publish GitHub Action

https://github.com/marketplace/actions/pypi-publish

Not sure if project cc2538 there is still the primary as only @sieben is listed as maintainer there?

https://pypi.org/project/cc2538/

@JelmerT
Copy link
Owner Author

JelmerT commented Jan 20, 2022

Currently pretty busy, but I'll try to bump the version and do the name conversion in the next week somewhere. I'm not the maintainer of the pypi but I'll check if we can also auto publish new versions there.

Hedda added a commit to Hedda/cc2538-bsl that referenced this pull request Jan 27, 2022
Update README.md documenting new `--bootloader-sonoff-usb` option from JelmerT#114

Note that was mentioned in JelmerT#114 that this option might be renamed in the future.
@TeslaCLT
Copy link

TeslaCLT commented Jan 28, 2022

I have zigbee2mqtt running in a LXC on Proxmox and wonder if I can do it from inside the container vs. from the host?

Remember that you regardless will need to first stop any application connected to the serial port before upgrading the firmware.

Worked like a charm. I knew to stop z2m first and running the commands others have shared worked perfectly from within my LXC container.

Odd, I got an email that someone made a comment here referencing my post, but I don't see it in the posts here. Basically, the person asked if I would share my Proxmox LXC config that made this happen.

Basically, I created a udev rule in the Proxmox host to statically name the dongle.
SUBSYSTEMS=="usb", ATTRS{product}=="Sonoff Zigbee 3.0 USB Dongle Plus", ATTRS{serial}=="xxxx", SYMLINK+="ttyACMZigbee", MODE="0666"

I then included the static name as a passed through device in the LXC config. I had to add this manually vs. using the GUI.
lxc.mount.entry = /dev/ttyACMZigbee dev/ttyACMZigbee none bind,optional,create=file

From there, I could do what I want (assuming I shut down any user of the device first, such as z2m).

@denevecon
Copy link

Thanks for your explanation. It was me asking this info. Not very experienced in using GitHub and accidentally deleted the reply / question. One final question; which OS did you use in the LXC?

@TeslaCLT
Copy link

TeslaCLT commented Feb 2, 2022

Thanks for your explanation. It was me asking this info. Not very experienced in using GitHub and accidentally deleted the reply / question. One final question; which OS did you use in the LXC?

Debian Bullseye

mannes added a commit to mannes/zigbee that referenced this pull request Aug 2, 2022
feature branch is merged to master JelmerT/cc2538-bsl#114, might as well point to a current version
@dinhchinh82
Copy link

dinhchinh82 commented Apr 25, 2023

hello @Hedda and @JelmerT

Could you share the schematic of this Sonoff Zigbee 3.0 Dongle Plus (P)?
I’d like to understand the way they did to make this dongle could be flashed automatically without pushing any boot button.

Thank you very much.

@Hedda
Copy link
Contributor

Hedda commented Apr 25, 2023

Auto-BSL usage is in the readme but note that ITead/Sonoff have not implemented it in the standard Texas Instruments way:

https://github.com/JelmerT/cc2538-bsl/blob/master/README.md#cc26xx-and-cc13xx

Please otherwise see the code of read previous discussions

#113

#63

You can also see open-source hardware and firmware asAuto-BSL (Pin 2) is a feature most Texas Instruments CC dongles support:

https://github.com/Koenkk/Z-Stack-firmware/blob/master/coordinator/Z-Stack_3.x.0/bin/README.md

You can also see open-source hardware and firmware as this is a feature that most Texas Instruments CC dongles support:

https://github.com/Koenkk/Z-Stack-firmware/blob/master/coordinator/Z-Stack_3.x.0/bin/README.md

https://github.com/Koenkk/Z-Stack-firmware/tree/master/coordinator/Z-Stack_3.x.0

https://www.zigbee2mqtt.io/guide/adapters/

If want more info you might be best of asking the same question in https://github.com/Koenkk/Z-Stack-firmware/discussions and/or https://github.com/Koenkk/zigbee2mqtt/discussions are those are larger community for TI CC hardware and firmware enthusiasts.

But if you want hardware schematic then you have to ask ITead/Sonoff :

https://itead.cc/contact/

https://github.com/itead

PS: Please understand that I (and @JelmerT) am only an hobbyist/and have no official affiliation with ITead/Sonoff.

@Hedda
Copy link
Contributor

Hedda commented Apr 25, 2023

@dinhchinh82 FYI, see Electrolama's flow chart and see zig-a-zig-ah (zzh) adapter which is open source hardware:

https://electrolama.com/radio-docs/bsl/

https://github.com/electrolama/zig-a-zig-ah

Another open source hardware is ZigStar:

https://github.com/mercenaruss/zigstar_gateways

@MattWeiler
Copy link

Works great now! I can confirm this is working with 'sonoff' parameter on MS Windows 10 OS (more details in #113 ). Thank you!

https://github.com/JelmerT/cc2538-bsl/tree/feature/ITead_Sonoff_Zigbee-delay

UPDATE! I have updated my step-by-step testing instructions for flashing here to make it easier for others to test this:

Broken down steps taken to flash firmware already mentioned in #113 into a step-by-step guide for flashing Sonoff Plus dongle:

  1. Install Silabs CP210x device drivers (CP2102N USB-to-UART bridge / USB-to-Serial converter chip) needed for Windows OS and Mac OS, (this also required a reboot of my operating-system).
  2. Install Python (in my case I installed and tested with Python for Windows 3.10.1).
  3. Launch command-prompt (cmd.exe) as elevated Administrator. Upgrade pip with python -m pip install --upgrade pip, (if pip is not available then first run python -m ensurepip --upgrade), then pre-install dependencies fro cc2538-bsl from PyPi via pip command: pip install wheel pyserial intelhex python-magic
  4. Optional but recommended: Download and install zigpy-znp via pip/PyPI with pip install zigpy-znp then perform NVRAM backup by following instructions in TOOLS.md (also find more details ZNP radio backup procedure at https://github.com/zigpy/zigpy/wiki/Coordinator-Backup-and-Migration) for Windows backup command should be something like python -m zigpy_znp.tools.nvram_read COM5 -o nvram_backup.json and optionally also backup Zigbee network via python -m zigpy_znp.tools.network_backup COM5 -o network_backup.json.
  5. Download cc2538-bsl on GiHub from its "master" branch, (and not via pip/PyPI), unpact the zip to a folder then launch command-promt (cmd.exe) as elevated Administrator and run its setup.py to install its dependencies (should include "setuptools", "wheel", "pyserial", "intelhex", and "python-magic" packages).
  6. Get latest firmware (I tested latest "CC1352P2_CC2652P_launchpad_*.zip" image available from its "master" branch at this time. Alternatively, you could get the latest "beta" version from the develop branch). Regardless make sure to get the correct image file as should be the one for "launchpad" (and not for "other)"!
  7. Stop any applications or services that might be connected to the Zigbee adapter via serial port (ex. Home Assistant's ZHA integration, Zigbee2MQTT, ioBroker, Jeedom, etc.). In my case, I ran the update on another computer so nothing to stop there.
  8. Run command to flash from command-promt (cmd.exe) launched as elevated Administrator, example with firmware release available at this time: python cc2538-bsl.py -p COM5 -e -v -w --bootloader-sonoff-usb CC1352P2_CC2652P_launchpad_coordinator_20211217.hex

Obviously need to replace number in "COM5" with the port # actually shown used under ports in Device Manager on Windows on your computer as the OS will just assign the next available Serial/COM-port.

Also, if using Linux or Mac OS instead of Microsoft Windows then the COM# serial device path after -p will be different when set the port to use, (like for example /dev/ttyUSB0 or /dev/ttyUSB1) and might need different Silabs CP210x device drivers (CP2102N USB-to-UART bridge / USB-to-Serial converter chip) for your operating system, on Linux might have to run Python with sudo, and read that many on Linux successfully run sudo python cc2538-bsl.py -e -v -w --bootloader-sonoff-usb CC1352P2_CC2652P_launchpad_coordinator_20211217.hex without setting serial device path with -p for port to use.

Copy comment from issue #113

I'm not aware of any other HW that uses this connection, so I'm naming the option after the specific hardware. In the future this should probably get a more general name like --bootloader-imply-gate or something. (the truth table is an imply and nimply port)

Better if cc2538-bsl could detect Sonoff "description" from CP2102N USB-to-UART chip then automatically use correct sequence?

Note! Home Assistant now features USB-discovery for this dongle based on combo of VID, PID and its unique product description:

https://community.home-assistant.io/t/community-help-wanted-to-whitelist-all-compatible-zigbee-and-z-wave-usb-adapters-for-automatic-discovery-in-home-assistant-os/344412

PS: Recommend upgrading to latest firmware from the develop branch as it got a lot of bug-fixes from upstream not in master:

https://github.com/Koenkk/Z-Stack-firmware/tree/develop/coordinator/Z-Stack_3.x.0/bin

Thank you so much for the detailed steps.
You saved my ass :)

I had issues flashing using the methods described elsewhere but following you steps worked.
I'm glad that I did, since none of the other people online provided the details for backing-up the Zigbee network and that would have been a PITA if I had to re-add my 40+ devices :p

2 caveats:
I had to use the "feature/ITead_Sonoff_Zigbee-delay" branch for the tool:
https://github.com/JelmerT/cc2538-bsl/tree/feature/ITead_Sonoff_Zigbee-delay

I had to restore my Zigbee network after the flashing completed using the below command:
python -m zigpy_znp.tools.network_restore COM5 -i network_backup.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet