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

SONOFF Zigbee 3.0 USB Dongle Plus by ITead do support Auto BSL #328

Closed
wants to merge 1 commit into from

Conversation

Hedda
Copy link
Contributor

@Hedda Hedda commented Nov 9, 2021

UPDATE! Auto BSL works on ITead's Sonoff Zigbee 3.0 USB Dongle Plus using c2538-bsl with patch -> JelmerT/cc2538-bsl#114

The back-story is that several other Home Assistant community members have tested Sonoff provided uartLog.py script which seems to confirm "Auto BSL" is working even if it does not currently work with the current version of cc2538-bsl and llama-bsl.

https://community.home-assistant.io/t/itead-sonoff-zigbee-3-0-usb-dongle-plus-adapter-based-on-texas-instruments-cc2652p/340705/45

https://community.home-assistant.io/t/itead-sonoff-zigbee-3-0-usb-dongle-plus-adapter-based-on-texas-instruments-cc2652p/340705/96

Anyway, I have now also myself confirmed that running the attached uartLog.py script from Sonoff docx part as published in ITead's HOW TO FLASH FIRMWARE TO CC2652P instructions do indeed make ITead's Sonoff Zigbee 3.0 Plus Dongle automatically enter bootloader mode and after running that script just to get into BSL mode I could flash it directly using cc2538-bsl.py and llama-bsl.py scripts without having open the enclosure and pressing the BTL button which of course can be very convenient.

Copy of attached script from ITead/Sonoff: uartLog.zip

This is code in Sonoff provided uartLog.py script that already works to enters the bootloader using Auto-BSL software reset:

def enterBoot(serialPort, delay=False):
    # delay is a workaround for bugs with the most common auto reset
    # circuit and Windows, if the EN pin on the dev board does not have
    # enough capacitance.
    # 如果开发板上EN管脚没有足够电容
    last_error = None

    # issue reset-to-bootloader:
    # RTS = either CH_PD/EN or nRESET (both active low = chip in reset
    # DTR = GPIO0 (active low = boot to flasher)
    #
    # DTR & RTS are active low signals,
    # ie True = pin @ 0V, False = pin @ VCC.
    setDTRState(serialPort, False)  # IO0=HIGH
    # setDTRState(serialPort, True)   # IO0=LOW
    setRTSState(serialPort, True)  # EN=LOW, chip in reset
    time.sleep(0.1)
    if delay:
        # Some chips are more likely to trigger the esp32r0
        # watchdog reset silicon bug if they're held with EN=LOW
        # for a longer period
        time.sleep(1.2)

    setDTRState(serialPort, True)  # IO0=LOW
    setRTSState(serialPort, False)  # EN=HIGH, chip out of reset
    if delay:
        # Sleep longer after reset.
        # This workaround only works on revision 0 ESP32 chips,
        # it exploits a silicon bug spurious watchdog reset.
        time.sleep(0.4)  # allow watchdog reset to occur
    time.sleep(1)

    setDTRState(serialPort, False)  # IO0=HIGH, done
    setRTSState(serialPort, False)
    time.sleep(1)

    return last_error

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.
So the only difference I'm seeing is the extra delays in their script.
Try adding some delays in the same spots, and see if that makes it work.

PS: The probable reason why does not yet work in cc2538-bsl is needed extra delays in the script, see -> JelmerT/cc2538-bsl#113

SONOFF Zigbee 3.0 USB Dongle Plus by ITead does support Auto BSL
@Hedda
Copy link
Contributor Author

Hedda commented Nov 9, 2021

By the way, can probably assume this adapter uses DIO_13 for BSL Trigger Pin since it looks to take most hardware design references from TI LAUNCHXL-CC26xR1 or Slaesh's CC2652RB stick and Electrolama's zzh first-generation of CC2652 adapters?

...and if so it probably also uses DIO_6 for red LED and DIO_7 for green LED?

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

Adapter TI Chip/Module Used Firmware to Flash BSL Trigger Pin (1) Auto-BSL (2) RF Switch Control Pins (3) LED(s) Hardware Flow Control
TI LAUNCHXL-CC26xR1 CC2652R CC2652R_*.zip
DIO_13 No N/A DIO_6 (Red)
DIO_7 (Green)
?
Electrolama zzh CC2652R CC2652R_*.zip DIO_13 No N/A DIO_7 (Pink) ?
Slaesh's CC2652RB stick CC2652RB CC2652RB_*.zip DIO_13 Yes N/A DIO_7 (Blue) ?
SONOFF Zigbee 3.0 USB Dongle Plus by ITead CC2652P CC1352P2_CC2652P_launchpad_*.zip ? No DIO_29: 20dBm PA ? DIO13: TX
DIO12:RC
DIO19: CTS
DIO18: RTS

@JelmerT
Copy link

JelmerT commented Nov 9, 2021

As mentioned in JelmerT/cc2538-bsl#113 if you can figure out how much delay needs to be added in cc2538-bsl you should be able to flash without needing uartlog.py.

Please submit a PR if you do, so we can support more HW in the cc2538-bsl script!

@Hedda
Copy link
Contributor Author

Hedda commented Nov 10, 2021

Hmm, are you saying accepting PR #328 is dependent on cc2538-bsl script by JelmerT supporting this for each dongle or not?

Does a fix for JelmerT/cc2538-bsl#113 have to be merged into cc2538-bsl and working in there for "Auto BSL" to be listed as support by hardware in Koenkk's Z-Stack-firmware repo when the hardware does technically already support automatic BSL?

I thought README.md in Koenkk/Z-Stack-firmware repo only listed different hardware-enabled features for each specific dongle?

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

So what if "Auto-BSL" is now already supported by the hardware and working in another script other than the cc2538-bsl script?

Not listing "Auto-BSL" as a hardware feature for the dongle could simply mean that new developers will ignore it for this dongle.

At least as it stands now this README.md in Koenkk/Z-Stack-firmware repo does not specify that listing "Auto-BSL" support only equals that Auto-BSL is supported in the cc2538-bsl script by JelmerT for that specific dongle. In fact, the independent cc2538-bsl script is currently not mentioned in this repo at all so does that directly dependent connection seem very strange or is that just me?

@Hedda Hedda mentioned this pull request Nov 16, 2021
@Hedda
Copy link
Contributor Author

Hedda commented Dec 6, 2021

FYI, JelmerT got it working however I believe that help may still want in testing firmware upgrade(s) with his pull request patch for ITead’s Sonoff CC2652P USB dongle with JelmerT cc2538-bsl tool using the new option --bootloader-sonoff-usb parameter.

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

Please report firmware upgrade issue with it or confirm it working under which operating system so this might get merged:

JelmerT/cc2538-bsl#114

(Again there is a longer related troubleshooting discussion in JelmerT/cc2538-bsl#114 with some more information on solution).

@Hedda
Copy link
Contributor Author

Hedda commented Dec 21, 2021

Closing as PR #329 by @guozi7788 also contained this change setting Auto-BSL field to Yes value for the Sonoff Plus dongle now.

@Hedda Hedda closed this Dec 21, 2021
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.

3 participants