-
Notifications
You must be signed in to change notification settings - Fork 181
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
Automatically start BSL mode on Itead Sonoff USB stick #113
Comments
This is the Python script originally provided. It is designed to be run on Windows but can be made generic by deleting the COM suffix attached to the name when selecting the device. |
Thanks for that script @sshaikh . It looks like this is a simple toggle via the RTS and DTS lines.
|
I have no idea how I missed those. I'll assume that works, unless you want a positive confirmation? |
FWIW neither of these options (or any combination of them) enabled BSL:
|
Next step would be to check the schematic of the USB dongle and see how the RTS and DTR lines are connected to make sure they're toggled correctly. Maybe probe them with both scripts and see the difference. |
More information here: https://itead.cc/product/sonoff-zigbee-3-0-usb-dongle-plus/ But shouldn't the script be explicit about what is required? If this is out of the scope of bsl, then I'm happy to use the peculiar uartlog script for my purposes. |
This is the code in their script that enters the bootloader:
So it looks like both pins are active low, and RTS is connected to reset and DTR is connected to the bootloader pin. Which should be the same as in the standard configuration in this script. |
Just in case I've done it incorrectly, I was just adding the |
yes that's the correct way, but it looks like you shouldn't need it. (but still try it, together with I'm guessing the delays are the issue here. You can verify with a scope on the reset and bootloader lines, or just try it with some trial and error. |
Nice with option to automatically try both high and low signals to make Sonoff enter bootloader when Auto BSL is supported: "Auto BSL" will also be supported by upcoming zzhp and zzhp-lite adapters by Electrolama which will all use FT231X by FTDI: https://electrolama.com/radio-docs/bsl/#auto-bsl I have also confirmed that running the attached As a bonus the https://sonoff.tech/wp-content/uploads/2021/09/Zigbee-3.0-USB-dongle-plus-firmware-flashing-1-1.docx Attatched: uartLog.zip PS: ITead/Sonoff originally posted this docx doc here -> https://sonoff.tech/product-review/zigbee-3-0-usb-dongle-plus/ |
@Hedda we're trying to not have to rely on |
I know, only wanted to let you know that I can confirm that the auto BSL feature is supported by the hardware and preflashed firmware, even though it is currently not working in the
No, but I can confirm that So far only tested on Windows OS (Windows 10 operatingsystem):
|
I can confirm Sonoff USB Plus dongle uses Silicon Labs CP2102N (Xpress/USBXpress Family) so at least that is correct in ITead's specifications, (where several other info look to be wrong as if they just copied mix of info from CC2531 and Electrorama's zzh). https://www.silabs.com/documents/public/data-sheets/cp2102n-datasheet.pdf CP2102N should be the same functionality as CP2104 which is end-of-life. (CP2102N are now common in ESP32/ESP8266 boards). For both of those need to use CP210x USB to UART Bridge VCP Drivers if using Windows OS: https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers One wrong is noted that ITead themselves are referring to the wrong device drivers for it on their own page, reviews and docs: https://itead.cc/product/sonoff-zigbee-3-0-usb-dongle-plus/ https://sonoff.tech/product/diy-smart-switch/sonoff-dongle-plus/ https://sonoff.tech/product-review/zigbee-3-0-usb-dongle-plus/ https://sonoff.tech/wp-content/uploads/2021/09/Zigbee-3.0-USB-dongle-plus-firmware-flashing-1-1.docx |
Perhaps not related but noted Silabs posted a few erratas for CP2102N listing bugs and workarounds so they might be relavant: https://www.silabs.com/documents/public/errata/cp2102n-errata.pdf Among other things it list these errata/bug:
|
ESP32/ESP8266 adapters with CP2102N A01 revision chips seem to have had similar issues on Windows OS. Some reports for those ESP devices say the issue is fixed in hardware on new CP2102N A02 revision chips and later VCP drivers for Windows OS. For CP2102N A01 revision chips they worked around these issues by adding more and longer delays as JelmerT suggested. Also, looks like Sonoff might got part of boot mode reset code logic for uartLog.py script from esptool and esp_rfc2217_server: https://github.com/espressif/esptool/blob/master/esp_rfc2217_server.py#L70 https://github.com/espressif/esptool/blob/master/esptool.py#L521 |
@guozi7788 Any chance you could report this issue to relevant personnel at ITead/Sonoff and get them to submit a fix in a patch? Summery, "Auto BSL" is currently not working in the c2538-bsl script on Windows OS (Windows 10) with the SONOFF Zigbee 3.0 USB Dongle Plus by ITead even though its hardware does support "Auto BSL", this is likely due to the CP2102N USB-to-UART chip would need some additional delays added to the script, probably because of bugs in hardware or some issue Microsoft serial interface in Windows. Please inform ITead/Sonoff that c2538-bsl is the most popular firmware upgrade script used by the community for flashing Texas Instruments based Zigbee USB dongles and having "Auto-BSL" (automatic reset and boot to bootloader via software) fully supporting SONOFF Zigbee 3.0 USB Dongle Plus by ITead would make it possible for the script to automatically enter BTL boot mode and perform the firmware upgrade without the need for to open the enclosure which would make the whole firmware upgrade procedure more convenient and user-friendly. That is, having "Auto-BSL" being support in c2538-bsl for the SONOFF Zigbee 3.0 USB Dongle Plus by ITead would make the "uartLog.py" script recommended in ITead/Sonoff's existing firmware upgrade instructions obsolete and make it so much simpler for new users and beginners to upgrade the firmware using this c2538-bsl script as an easier to use tool. Also note that the c2538-bsl is a cross-platform script so it should work on all operating systems. https://sonoff.tech/wp-content/uploads/2021/09/Zigbee-3.0-USB-dongle-plus-firmware-flashing-1-1.docx The current instructions from ITead/Sonoff suggest using the "uartLog.py" script attached in that Word document to enter the bootloader and then use TI's Flash Programmer 2 to flash the firmware, both of which are today only compatible with Microsoft Windows operating system, and that combination is not very convenient or easy to use, so not user-friendly at all. |
@Hedda uartLog.py is only used as a production testing tool to verify whether the dongle enters the boot mode, and it has not been given more uses. As far as I know, the product manager is evaluating your needs,and you can check with your previous contacts for relevant progress. |
@guozi7788 Actually, uartLog.py as a zip file with it is attached to https://sonoff.tech/wp-content/uploads/2021/09/Zigbee-3.0-USB-dongle-plus-firmware-flashing-1-1.docx which is linked to from https://sonoff.tech/product-review/zigbee-3-0-usb-dongle-plus/ so FYI, anyone who bought the Sonoff Plus Dongle who want to upgrade the firmware is currently likely to follow that document and many will thus probably use that uartLog.py script to reset to boot mode rather than having to use a screwdriver to open the enclosure of the dongle, ...and as read it myself too I also posted a quick and dirty guide on how to achieve the wanted result using uartLog.py here at https://community.home-assistant.io/t/itead-sonoff-zigbee-3-0-usb-dongle-plus-adapter-based-on-texas-instruments-cc2652p/340705/105 as well as a copy of that guide here Koenkk/zigbee2mqtt#8840 (comment)_ Quick and dirty guide for how-to upgrade firmware on this Sonoff USB Plus Dongle from Windows OS without opening its enclosure:The main benefit of this method is that don't need to open the dongles enclosure/casing, (this method could also be made to work across Windows, MacOS and Linux platforms if modify 1. Install Silabs CP210x drivers (if not already installed/available, at least needed on Windows). Again, this guide could relatively easily be translated to Linux or Mac OS and be further automated via scripting, (the problem there is that the Tip! cc2538-bsl can be replaced by experimental llama-bsl fork if willing to test it, though it has same "Auto BSL" delay issue with Sonoff USB Plus dongle, but developer of llama-bsl is considering adding several additional features that will make it more user-friendly than cc2538-bsl: https://github.com/electrolama/llama-bsl/issues PS: ITead/Sonoff own developers could of course have made this much simpler if they themselves submitted patches to cc2538-bsl script. |
Could you try the version in this branch: https://github.com/JelmerT/cc2538-bsl/tree/feature/ITead_Sonoff_Zigbee-delay Try it:
if none of those work, try increasing the delay Line 239 in efc9412
|
@Hedda python cc2538-bsl.py -p COM19 -evw CC1352P2_CC2652P_launchpad_coordinator_20210708.bin sonoff I tested it on windows and it looked like it worked correctly, you can try it. https://github.com/guozi7788/cc2538-bsl/blob/master/cc2538-bsl.py |
@JelmerT Have now tested each of those options on my Windows 10 computer increasing the delay in that
|
@guozi7788 I tested and https://github.com/guozi7788/cc2538-bsl/blob/master/cc2538-bsl.py does work with "sonoff" argument. Looks much more complicated than just adding some delay(s) but does indeed work with Sonoff Plus Dongle on Windows 10 OS.
|
also working on mac here:
|
@guozi7788 that's a great temp fix, but I can't pull that into the script of course. It's basically just the 2 separate scripts in the same file. I don't have the hardware, so I can't look further into this. If anyone is willing to send me the HW I should be able to connect it to a logic analyzer or scope and see what's going on. I more than welcome any PRs that integrate the functionality into the script of course. |
That is fully understandable. Hope that ITead/Sonoff will ship you a free dongle so that you can take a deeper look at this issue! PS: I also suspected it and posted a related comment in Zigbee2MQTT discussion in -> Koenkk/zigbee2mqtt#8840 (reply in thread)
|
FYI, according to comment in this discussion on the is a modified version of BSL Scripter that also got BSL working with CP2102: That discussion also links to these other discussions which goes into much deeper details about how that solution works exactly: So apparently this other type of invoke sequence pattern needed is well known by other developers using CP2102N / CP2102 |
@chiakikato read in Koenkk/zigbee2mqtt#8840 you have access to Sonoff Zigbee 3.0 USB Dongle Plus and already done some analyzing of it, any chance you could analyze further to find exact invocation sequence and pattern needed to invoke "Auto BLS"? |
I got my hands on a unit and have implemented the correct sequence to start the bootloader automatically. The new option is now Thanks everyone! |
Nice! Will try to get time to test this weekend. But if and when we know it is working will that "sonoff" parameter still be required?
Could otherwise CP2102 UART-to-USB chip or just USB "description" be detected then automatically use the correct sequence? |
the needed sequence between the "standard" connection (RTS and DTR connected 1 to 1 to reset and the bootloader pin) and the connection in the sonoff stick is quite different. So I don't think we could do them both automatically, I'd need to test with some different hardware though. If we could that'd be great, since then it would be transparent for all hardware. Just detecting the CP2102 would not be a good idea, since many boards use that chip, or could use it in the future, and might not be connected in the same way to the radio being programmed. |
I can now confirm that with PR here #114 with
|
I have reported that before to ITead that it is an issue they are using default VID, PID, and Product Description for CP2102 USB device identification. Important to note is that they are also using the default "product description" from Silabs. Got a reply from them that they plan on changing the Product Description String value field to “Sonoff Zigbee 3.0 USB Dongle Plus” on EEPROM in CP2102N for their next batch in order to at least make "product description" unique so that applications can use "product description" to automatically detected it. USB discovery in Home Assistant can already differ from different Zigbee adapters based solely on "product description" in USB chip EEPROM, (Itead however answered that they will continue using standard VID and PID in future batches as changing those would mean requiring releasing custom device drivers for CP2102). More info about that here -> 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 There are already a few "product description" for known CC2652 adapters in https://github.com/home-assistant/core/blob/dev/homeassistant/components/zha/manifest.json
|
FYI, ITead looks to have their Sonoff branded CC2652P based USB dongles back in stock again for $10.99 (US) at least for now: https://itead.cc/product/sonoff-zigbee-3-0-usb-dongle-plus/ No changelog announcement yet to let us know whether the USB chip in this batch has a unique Product Description String. |
FYI, ITead now posted a program (blob) that should let users themselves update the product description string on already shipped Sonoff dongles to supposedly match the same description already written to CP2102N EEPROM the latest batch of their dongles: https://www.facebook.com/SONOFF.official/posts/2927251720919807 Tested that program myself on a Windows 10 computer and it did not work for me (program just closed without any messages). Sad that ITead did not instead choose to release a CP2102N write tool based on this open-source cp210x-program by VCTLabs: https://github.com/VCTLabs/cp210x-program The point of having a unique custom product description in USB-to-UART chip is to allow USB auto-discovery, like the example in: |
Hello!
Is there another solution to the problem, or has USB become completely brick? |
FYI, I just got new adapters and they show up as |
Yeah should have used the " https://github.com/Koenkk/Z-Stack-firmware/tree/master/coordinator/Z-Stack_3.x.0/bin Did you try removing enclosure and manually hold physical boot-button while plugging into USB-port? https://sonoff.tech/sonoff-zigbee-3-0-usb-dongle-plus-firmware-flashing-2/ If you messed up the bootloader firmware then believe only way to unbrick hardware is to flash with cJTAG, see details on that here: https://electrolama.com/radio-docs/advanced/flash-jtag/ The debug adapter for CC2652/CC1352 needs to support 2-pin cJTAG (a.k.a C-JTAG or c/JTAG) and not just common JTAG SWD as TI CC2652 debug does not use SWD and SWDCLK, etc. but instead only TMS and TCK (cJTAG is not SWD/SWDCLK). Texas Instruments XDS110 JTAG debug probe is a bit expensive but cheap clones of it should work, ex: https://aliexpress.com/item/4000751867419.html The official TMDSEMU110-U XDS110 JTAG Debug Probe from TI also looks to be out-of-stock now too. https://www.ti.com/tool/TMDSEMU110-U Looking at pictures on ITead's product page you see that no SWD and SWDCLK pads are exposed. So will probably need cJTAG debug probe with TMS and TCK like Texas Instruments XDS110 or clone. |
Yeah some partial progress at least. Unfortunately, the script ITead posted that should let users themselves update the product description string on CP2102N for Sonoff dongles already shipped before does not seem to work: https://www.facebook.com/SONOFF.official/posts/2927251720919807 Again sad that ITead did not choose to release a CP2102N write tool based on this open-source cp210x-program by VCTLabs: https://github.com/VCTLabs/cp210x-program That way both new and existing owners of it could utilize an automatic discovery feature if it is added. |
FYI, after updating several times and helping others with different setups I have broken down my tested steps to flash firmware mentioned from #114 into this basic guide for flashing ITead SONOFF Zigbee 3.0 USB Dongle Plus adapter. This guide uses the cc2538-bsl tool from JelmerT's latest "master" branch on GitHub and could easily be made to work on all operating systems. I tested on Windows OS but others have done this on Linux and Mac OS by using different Serial/COM-port addressing as the steps should otherwise be the same.
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 |
I tried making the script work on macOS and also tried the alternative tools, but had no success updating the descriptor or vid pid on mine. Manually selecting the port is not the worst, but it's unfortunate we can't make it happen automagically for those first units that were sent out with the standard descriptors. I'm going to close this issue since the original problem is now pulled into main and works. For auto detecting the sonoff hardware, please open a new issue or even better a PR. Thanks everyone for your contribution. |
@JelmerT Maybe you could look into VCTLabs cp210x-program to change the CP2102N "product description" string? See: https://github.com/VCTLabs/cp210x-program Note! Do not change the VID or PID as then will new a new device driver too, so only change the "product description" string. PS: I will create a new separate issue with a request to auto-detect known dongles based on information provided on USB chip. |
I successfully used this script to flash an "ITead Sonoff Zigbee 3.0 USB Dongle Plus adapter based on Texas Instruments CC2652P", so thank you for the script.
There are two ways to put this model into BSL mode, pressing the button on the board (typically requiring assembly) or running a python script to do it via software.
I don't know if this is a feature of the stick, the UART bridge or the CC2652P, but I've attached the script for your perusal, as it may be useful for cc2538-bsl to do this when appropriate.
The text was updated successfully, but these errors were encountered: