Sonoffs Zigbee 3.0 USB Dongle Plus Firmware

I’ve had the exact same error –> I’ve finally managed to upgrade the firmware after all.

First I tried to upgrade using the ZigStar addon in HA → didn’t work:

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service banner: starting

-----------------------------------------------------------
 Add-on: ZigStar TI CC2652P/P7 FW Flasher
 ZigStar TI CC2652P/P7 firmware flasher add-on
-----------------------------------------------------------
 Add-on version: 0.4.0
 You are running the latest version of this add-on.
 System: Home Assistant OS 11.4  (amd64 / qemux86-64)
 Home Assistant Core: 2024.1.3
 Home Assistant Supervisor: 2023.12.0
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service banner successfully started
s6-rc: info: service cc2652-flasher: starting
[01:54:19] INFO: Starting CC2652P flasher with Sonoff /dev/ttyUSB0
Setting filename to /root/firmware.hex
sonoff
Opening port /dev/ttyUSB0, baud 500000
Reading data from /root/firmware.hex
Your firmware looks like an Intel Hex file
Connecting to target...
pg_rev = 3, protocols = f, wafer_id = 0xbb41
CC135x PG2.0 (7x7mm): 352KB Flash, 20KB SRAM, CCFG.BL_CONFIG at 0x00057FD8
Primary IEEE Address: 00:12:4B:00:2B:48:1C:69
    Performing mass erase
Erasing all main bank flash sectors
    Erase done
Writing 360448 bytes starting at address 0x00000000
 Write 248 bytes at 0x00000000
 Write 248 bytes at 0x000000F8
// CUT //
Write 248 bytes at 0x00011DC8
 Write 248 bytes at 0x00011EC0
ERROR: No response from target on status request. (Did you disable the bootloader?)
[01:54:23] INFO: cc2652-flasher-up script exited with code 1
s6-rc: warning: unable to start service cc2652-flasher: command exited 1
s6-rc: info: service banner: stopping
s6-rc: info: service banner successfully stopped
s6-rc: info: service legacy-cont-init: stopping
/run/s6/basedir/scripts/rc.init: warning: s6-rc failed to properly bring all the services up! Check your logs (in /run/uncaught-logs/current if you have in-container logging) for more information.
/run/s6/basedir/scripts/rc.init: fatal: stopping the container.
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

Then I decided to skip the “middleman” (being the HA instance) and use the python script directly from Proxmox CLI.

Unfortunately, the 0x24 error appeared:

root@s720proxmox:~/cc2538-bsl-master# python3 cc2538-bsl.py -p /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_74af528edd9ced1185ae7afaa7669f5d-if00-port0 -evw --bootloader-sonoff-usb CC1352P2_CC2652P_launchpad_coordinator_20230507.hex 
sonoff
Opening port /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_74af528edd9ced1185ae7afaa7669f5d-if00-port0, baud 500000
Reading data from CC1352P2_CC2652P_launchpad_coordinator_20230507.hex
Firmware file: Intel Hex
Connecting to target...
CC1350 PG2.0 (7x7mm): 352KB Flash, 20KB SRAM, CCFG.BL_CONFIG at 0x00057FD8
Primary IEEE Address: 00:12:4B:00:2B:48:1C:69
    Performing mass erase
Erasing all main bank flash sectors
    Erase done
Writing 360448 bytes starting at address 0x00000000
ERROR: Timeout waiting for ACK/NACK after 'Send data (0x24)'

Reboot didn’t help. Detaching and reattaching the dongle didn’t help.

What helped? I’m not sure, but I disconnected all USB devices from the PC, so that only the dongle was connected. Then I think it started working. I guess something was interfering.

Conclusion:

  • try directly from Proxmox CLI
  • shut down HA instance just to be sure it isn’t using the port
  • maybe try a different USB port
  • disconnect all other USB devices from the machine
  • good luck!
1 Like

Hi,

I have a SONOFF Zigbee 3.0 USB Dongle Plus connected to /dev/ttyUSB0 on my HomeAssistant machine. That’s an Odroid running Home Assistant OS. I thought it should be possible to run this script right on that machine. I connected via SSH, and stopped HA by running ha core stop. Then I ran the script.

First, I had issues that the script was not able to install some Python packages. I was able to resolve that by using a Python Virtual Environment. But now the actual firmware updater exits with the following output:

sonoff
Opening port /dev/ttyUSB0, baud 500000
Reading data from /root/config/zigbee-firmware/tmp/master/CC1352P2_CC2652P_launchpad_coordinator_20230507.hex
Your firmware looks like an Intel Hex file
Connecting to target...
ERROR: Timeout waiting for ACK/NACK after 'Synch (0x55 0x55)'

I read in this thread that this could have to do with some other process still being connected to the USB port. Could it be that stopping HA with the mentioned command is not enough?

I’d love to hear if someone was able to pull off a firmware update this way. Otherwise, I suppose disconnecting the Zigbee Stick from my HA machine and connecting it to my MacBook would be the next thing to try…

@mmattel thanks for sharing your script!
I copy pasted from my mobile phone into a new file via the HA file editor, used the HA terminal to chmod and make it executable, updated the firmware file name to the latest version, disabled ZHA and then used the HA terminal to execute your script. Worked perfectly and one I reenabled ZHA my Sonoff dongle was good to go and running the latest firmware. I’m trying to fix the IKEA Tradfri remote battery drain issue and I hear the newer firmware fixes it.

For reference these steps worked for me on my Windows VirtualBox instance of HAOS. No reboot or anything else required.

1 Like

@bartkummel not sure if my instructions above help in any way but all I did was Disable ZHA and then run the script with HA terminal. Didn’t disable or stop anything else.

1 Like

Thanks for your reply, @JJW.AU! I tried your approach, with only disabling ZHA and letting HA run. This also doesn’t work for me. Output is slightly different compared to my previous attempt:
</s> <s>Opening port /dev/ttyUSB0, baud 500000</s> <s>Reading data from /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_04630975aec9eb11bf748d4f1d69213e-if00-port0</s> <s>Cannot auto-detect firmware filetype: Assuming .bin</s> <s>Connecting to target...</s> <s>ERROR: device reports readiness to read but returned no data (device disconnected or multiple access on port?)</s> <s>

Scratch that. I made an error editing the script. Your approach actually did work, when I corrected that! Thanks a lot!

For future reference, I’ll try to summarize this thread:

Two different dongles

First of all, it’s important to acknowledge that Sonoff sells two different dongles with almost the same name and almost the same housing. This thread is only about the “P” dongle. Don’t try to update an “E” dongle with the information from this thread! For completeness:

(If you follow any of the two links, the page will have a handy comparison table of both sticks.)

Different update mechanisms

Searching the internet, you’ll find different ways of updating the firmware of the Sonoff P dongle:

  • One involving taking apart the dongle and using specific I/Os to put it in.
  • One involving a GUI tool.
  • One involving some scripts.

All of these method are also referenced in this thread. I did only test the third option, so the remainder of this post will discuss that.

Updating the firmware with scripts

Prerequisites

For this approach, you can leave the dongle attached to your Home Assistant machine. I tested it with Home Assistant OS, I ran the script while logged in to HA OS via SSH. To be able to SSH to your HA machine, you need to install the SSH addon.

To be clear: I tested with a pre-installed image of Home Assistant, I believe this is called a “supervised” installation, but I’m not entirely sure about the right terminology here.

Step 1. Preparing the script

  1. Copy the contents of this file, and paste them into a new file, e.g. in your config directory. For the remainder of the instructions, let’s assume you call that file firmware_sonoff.sh.
  2. Make the script executable, typing the following command in the shell while logged in to your HA machine:
    chmod ug+x firmware_sonoff.sh
    

Step 2. Python virtual environment

  1. Create a Python virtual environment, using the following command:
    python3 -m venv ./venv-for-firmware-update
    
    This will create the virtual environment in a subdirectory of the current directory.
  2. Activate the virtual environment:
    ./venv-for-firmware-update/bin/activate
    
  3. Edit the firmware_sonoff.sh script from step 1 to use the Python version from the virtual environment. To do so:
    • replace all occurences of python with /path/to/venv-for-firmware-update/bin/python. In my case that was /root/config/venv-for-firmware-update/bin/python.
    • replace all occurences of pip with /path/to/venv-for-firmware-update/bin/pip.

Step 3. Disable ZHA

Before running the script, you should disable the ZHA integration, to prevent it from accessing the dongle during the update process.

Step 4. Run the script

Run the script with the right arguments. If you’re not sure about the arguments, run the script without any arguments and it will print a short usage message.

Victory!

A successful run of the script should end with something like this:

Opening port /dev/ttyUSB0, baud 500000
Reading data from /root/config/zigbee-firmware/tmp/master/CC1352P2_CC2652P_launchpad_coordinator_20230507.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: --8<---snip--->8--
    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: 0xe83aa727)

Don’t forget to re-enable the ZHA integration!

I hope this is helpful to anyone. It will at least be helpful to a future me… :wink: Let me know if anything is unclear or if I made an error in my description. (I didn’t make notes when I did all this, so I wrote this up afterwards from the top of my head…)

3 Likes

Could you add a paragraph talking about the requirements for the third method? I suppose you would need a linux machine (any kernal requirements?) and the USB dongle being connected directly to the linux…? Or are we saying all those scripts can be done inside an HAOS…?

Hi @k8gg ,

Thanks for your suggestion! I’ve done this on my HAOS machine directly. I thought I mentioned that, but I’ll see if I can make it more clear.

Best,
Bart

How is the approach if using the pre-configured image from HA for the Raspi?
SSH is limited to that environment as not everything is exposed?

Thanks

@h3rb3rt Using the pre-installed HA image is exactly what I did! You need to install the SSH addon, it will give you the access you need. Will add that to my post, thanks for pointing out this was not clear.

But why no info how to flash Sonoff V2 (E-dongle).
I was experiensing various problems - not working in HA, not working with zigbee2mqtt.

That guy was a lifesavior for me. Hope that will help for the owners of the “E” dongle that is based on a chip from Silabs: EFR32MG21

sorry for the late reply.
I tested it again but struggling with the python3 environment as python3 seems not to be present.
what do I miss ?

image

@h3rb3rt You can probably just use python, without the 3. Verify by executing

python --version

If the version starts with 3, you’re good.

hmm, I’m getting the same as @h3rb3rt with both python and python3

its just says bash: python: command not found

Figured that bit out, you need the SSH and Terminal advanced edition.

However i’m now getting a permissions issue when trying to activate the container

@bartkummel Could you post a copy of your script please, i’m not sure which bits to replace

Not sure if too late to the party but try a recursive chmod on the venv directory if you are getting permission errors:
chmod a+x -R venv-for-firmware-update

The sh script will need to be modified to include the correct firmware location from github as the script has not been updated since 2022 (and you should be checking for the correct firmware anyway)
Correct firmware per device types are listed here:

For example the wget command I had to modify was here:

 # Master branch coordinator as of 5/11/22
      if [ $2 == "coordinator" ]; then
        wget https://github.com/Koenkk/Z-Stack-firmware/raw/Z-Stack_3.x.0_coordinator_20230507/coordinator/Z-Stack_3.x.0/bin/CC1352P2_CC2652P_launchpad_coordinator_20230507.zip

Running the script with arguments is then for example (my sonoff device is at port 0):

firmware_sonoff.sh master coordinator 0

@daan_vb I’d rather not share my script: there are already too many versions of that script floating around the internet. Plus, it’s quite specific to your situation. However, if you follow my instructions carefully, you should be fine. Just replace every occurence of python with /path/to/venv-for-firmware-update/bin/python, where you replace path/to to the actual path. Same for pip. Simply use the “find and replace” function of your favorite text editor. Also, make sure to read @Mattymo s post, it might be helpful.

@bartkummel Thank you for the detailed procedure.
I only have few questions left, not related to the actual flashing.

Why do we need to upgrade firmware?
Is it better for HA than the default one?
And what are the differences with the stock firmware?

I see people flashing their hardware, but I’d like to know why before doing it.

in theory: as with all software existing: to get new features and fix issues/problems

in practise: as with all software existing: shit happens, so better be cautious with updates :wink: