RavenSystem / esp-homekit-devices

Advanced firmware to add native Apple HomeKit and custom configurations, compatible with any SoC based on ESP32, ESP32-S, ESP32-C and ESP8266 series. (Shelly, Sonoff, Electrodragon, Tuya...)
Other
2.73k stars 360 forks source link

Flashing Tasmota device OTA with esp-homekit-devises #683

Closed tonysprenk closed 4 years ago

tonysprenk commented 4 years ago

Is it possible to flash a device that is running Tasmota with esp-HomeKit-devices OTA? When I try to upgrade the firmware with main.bin from HAA I get an error: “ Magic byte is not 0xE9”. Thanks for any help on this!

kueblc commented 4 years ago

@Crazor @Rocket200

Here is a copy with adjusted flash settings

homekit-from-tasmota.zip

Crazor commented 4 years ago

@kueblc Thank you, that worked! Now I have to re-read how to set those beasts up...

i3laze commented 4 years ago

@Crazor @Rocket200

Here is a copy with adjusted flash settings

homekit-from-tasmota.zip

I confirm the latest one worked flawlessly, without power resets (while you're on steady 5V :) Tasmota: .bin upload -> 10 sec -> HAA Setup mode WiFi SSID is online!

Although then after initial JSON and WiFi configuration HAA-Installer flashes both HAA-OTA to 2.2.3 and HAA 1.9.2 itself for 5-10 minutes. Don't you worry guys - it then boot eventually.

i3laze commented 4 years ago

I humbly ask @WizBangCrash to add this Tasmota (and Sonoff DIY) migration path/binary into Wiki.

shanghaix commented 4 years ago

Does that mean we could potentially use the Sonoff DIY mode to flash Tasmota and then once Tasmota is installed flash Ravencore OTA?

i3laze commented 4 years ago

I’m not familiar with Sonoff DIY mode introduced in R3 generation, but looks like now you can flash a vanilla Sonoff device to Tasmota, then to HAA wirelessly, all without a serial cable :)

You might even try skipping the Tasmota part by flashing homekit.bin by kueblc directly to vanilla Sonoff DIY (although be ready for a USB-serial recovery). Please report your success.

allenmehrer commented 4 years ago

I’m not familiar with Sonoff DIY mode introduced in R3 generation, but looks like now you can flash a vanilla Sonoff device to Tasmota, then to HAA wirelessly, all without a serial cable :)

You might even try skipping the Tasmota part by flashing homekit.bin by kueblc directly to vanilla Sonoff DIY (although be ready for a USB-serial recovery). Please report your success.

I'm tempted to give this a try. What is special about the HomeKit.bin by kueblc?

i3laze commented 4 years ago

@allenmehrer,

rebuilt OTA upgrade image using the latest release from @RavenSystem using the process documented here. I've also appended the magic sequence as described here so you should be able to upload this to a device running Tasmota.

allenmehrer commented 4 years ago

@allenmehrer,

rebuilt OTA upgrade image using the latest release from @RavenSystem using the process documented here. I've also appended the magic sequence as described here so you should be able to upload this to a device running Tasmota.

Well bummmer. I flashed the custom bin with the sonoff ota firmware tool and the sonoff mini went dark. No lights. No connection. No custom WiFi ssid to log into.

i3laze commented 4 years ago

@allenmehrer,

rebuilt OTA upgrade image using the latest release from @RavenSystem using the process documented here. I've also appended the magic sequence as described here so you should be able to upload this to a device running Tasmota.

Well bummmer. I flashed the custom bin with the sonoff ota firmware tool and the sonoff mini went dark. No lights. No connection. No custom WiFi ssid to log into.

Bad luck, sorry. Tool? There was also a WebGUI option for that :) Please post a serial output, what’s going on during boot.

alekseyp commented 4 years ago

Here is my issue with sonoff mini.

I can ping it on my wifi, but can't add it to HomeKit, load webpage, or bring it to (emergency) setup mode.

// I'm waiting for new usb ttl

i3laze commented 4 years ago

Something definitely not good with all those Minis. My Shelly.Cloud 1 and 2.5 were flashed OTA from Tasmota 6 just fine.

Have you guys ever flashed a mini manually to HAA via serial cable? It might not be the issue with the OTA, but generally unstable behavior.

Please, hook up a serial cable and give us some serial output to think about.

alekseyp commented 4 years ago

Sorry I didn't get serial output. I got frustrated trying to solder serial cable to mini, so as soon as I got everything soldered I just flashed it again and everything is working like it should. I'll try to 3D print mount for mini so I can easily hook it up and redo OTA flow again.

RavenSystem commented 4 years ago

I think that homekit-from-tasmota.zip file must be updated with last haaboot.bin.

hau21um commented 4 years ago

I’m not familiar with Sonoff DIY mode introduced in R3 generation, but looks like now you can flash a vanilla Sonoff device to Tasmota, then to HAA wirelessly, all without a serial cable :)

Tried direct vanilla sonof mini in DIY over OTA by following https://blog.bilka.sk/how-to-flash-sonoff-mini-in-mac-os/ (but directly with homekit-from-tasmota.bin). But no luck (box remind dark, no SSID visible, no console logs), so had to solder tiny UART, luckily "normal" HAA flash worked.

i3laze commented 4 years ago

@kueblc Could you please refresh the image with latest haaboot.bin one last time?

amitojkapoor commented 4 years ago

Thanks @kueblc for this. I think the flashing part worked for me using your bin, but I might have stupidly messed something up.

I have a Feit smart plug that I initially flashed with Tasmota. I then decided I wanted HomeKit instead so I came here.

Everything worked great for me and I got to the HAA setup screen. I got too excited and entered in the WiFi settings and clicked save without entering anything for the JSON. The device rebooted and connected to my router but obviously I can't do anything with it because nothing is configured. Is there any way I can force it to go back into setup mode or am I out of luck? I tried using the emergency setup mode described here but it just immediately connects to my WiFi.

@i3laze would it be possible for you to see if emergency setup mode works for you? I really hope there is a way to salvage this without having to open it up.

i3laze commented 4 years ago

“Don’t panic” was written on some book cover ;)

@amikapoor Check the Wiki about setup mode: https://github.com/RavenSystem/esp-homekit-devices/wiki/Setup-Mode#entering-setup-mode

amitojkapoor commented 4 years ago

@i3laze thanks for the quick response!

That's actually the exact link I posted in my comment and the first thing I tried. I can't get back in setup mode with the buttons (since I didn't configure the json) or using the emergency setup mode.

amitojkapoor commented 4 years ago

My current state is:

I just wanted to see if emergency setup mode works for anyone else

i3laze commented 4 years ago

So, there are few options: A. You’ve really completed setup and now you can discover the HAA device in Home.app and pair with it. After this it might get emergency working fine. B. You didn’t complete setup (as empty json isn’t valid choice) and you should reset power and search for HAA WiFi again.

Most probable: C. You’ve completed initial setup and now you should calmly wait aprox. 10 min (as I mentioned few times above) for device to download and flash both latest OTA and HAA binaries. Then only it shows up as available for pairing in Home.app and emergency will work. I suggest you reset power and sit tight for a while.

amitojkapoor commented 4 years ago

A. It's been plugged in for about 20 min since I last unplugged it and I just tried to add the accessory and it was not found B. The only reason that I think the setup actually got completed is because it is connected to my router. Also, when I hit save once with the empty json nothing happened. Then I clicked save again and my device disconnected from the HAA network and it did not appear again and I noticed it had connected to my wifi. C. After the behavior described in B, I waited over an hour before touching it again. After that initial hour is when I've been trying to get it back into setup mode after realizing my potential mistake of saving without a configuration. In the last couple hours I have tried multiple resets and let it stay on for 10-20 min each time but it just goes right back on my wifi with no ability to do anything else

amitojkapoor commented 4 years ago

Just figured I’d also mention that I did not select auto update when I was setting it up the first time

tonysprenk commented 4 years ago

@amikapoor in the list of connected devices in your router settings is the device identified as HAA-XXXXXX or as unknown?

If it’s the first one: try emergency setup mode.

If the second one: probably something went wrong during flashing and the device will have to be reflashed by wire.

i3laze commented 4 years ago

@amikapoor, with empty JSON device should boot to setup mode... after OTA downloads all the binaries. Try http://DeviceIP once again.

The next step is serial cable, sorry. This .bin had a disclaimer YMMV :/ You’re welcome to post current serial output before reflashing your smart plug.

amitojkapoor commented 4 years ago

Thanks for the replies guys. I really appreciate your help.

The device name shows up as tasmota. I noticed this from the start but I just figured it was my router just caching the name or something. Using a separate network scanner, I can confirm it says tasmota for sure.

When this all went downhill one of the first things I tried was going back to the tasmota configuration page and it didn’t work and it still isn’t. Sounds like something went wrong with the flashing right? I’m just confused how the HAA installer booted up and now it’s back to saying tasmota. I also wonder if this was caused by the empty json or something else.

I’ve managed to get the device open end it looks like it’s an ESP8285 so I guess my next step will be to order the device I need to flash it, unless I can find some way to reset tasmota.

i3laze commented 4 years ago

Weapon of choice, PL2303 adapter: http://s.aliexpress.com/ji6VjEZ3

Check some local online stores for it. Extra Male<>Male cable might be needed, as most serial inputs are Female (holes)..

amitojkapoor commented 4 years ago

I just realized, I may have a USB to RS-232 cable laying around somewhere from a previous project. Do you have any idea if I could cut that up and use that somehow?

i3laze commented 4 years ago

Although lots of USB-Serial adapters such as yours are built on PL2303 chip, I couldn’t Google a retrofit scheme. It’s a 3$ adapter, used regularly. Just find it nearby and get it delivered)

hau21um commented 4 years ago

So I did next test with new sonoff mini. 1) flash from vanilla mini via [OTA] to tasmota (https://blog.bilka.sk/how-to-flash-sonoff-mini-in-mac-os/) OK 2) flash from tasmota to homekit-from-tasmota.bin (md5 c5f3bea97c7630871ad1e826baed7c38) OK, HAA wifi available 3) on HAA wifi setting my wifi/ssid+pass (no json), saving - OK 4) mini got IP, correctly - can ping it,

STARTING

Get version RavenSystem/haa_ota
NEW CONNECTION LocalPort=e372 DNS IP: 140.82.118.4 local..OK remote..OK SSL..OK set_fd to github.com port 443..OK

GET /RavenSystem/haa_ota/releases/latest HTTP/1.1
Host: github.com

OK

GET /RavenSystem/haa_ota/releases/latest HTTP/1.1
Host: github.com

HTTP returns 302 for Current ROM is 0
Compare
3.0.2 with 2.2.2 = 1
RavenSystem/haa_ota@version:"3.0.2"
Current ROM is 0
Running BOOT
Get hash
DOWNLOADING
GET /RavenSystem/haa_ota/releases/download/3.0.2/main.bin.sig HTTP/1.1
Host: github.com

NEW CONNECTION LocalPort=e373 DNS IP: 140.82.118.4 local..OK remote..OK SSL..OK set_fd to github.com port 443..OK
sent OK
HTTP returns 404
Get file
DOWNLOADING
GET /RavenSystem/haa_ota/releases/download/3.0.2/main.bin HTTP/1.1
Host: github.com

NEW CONNECTION LocalPort=e374 DNS IP: 140.82.118.4 local..OK remote..OK SSL..OK set_fd to github.com port 443..OK
sent OK
HTTP returns 404

But when checking the HAA OTA releases page, resource names should be IMHO rather haaboot.bin and NOT main.bin https://github.com/RavenSystem/haa_ota/releases/download/3.0.2/haaboot.bin So seems will have to solder again.

i3laze commented 4 years ago

@hau21um, great job with troubleshooting. Looks like HAA installer cannot proceed as the .bin is hardcoded wrong.

@kueblc, @RavenSystem how so? what’s next?

amitojkapoor commented 4 years ago

Is this likely the same reason it failed for me?

RavenSystem commented 4 years ago

I added a transition firmware to allow old haaboot to work. Try again.

hau21um commented 4 years ago

Tried just now, but it fails on two bellow files /RavenSystem/haa_ota/releases/download/3.0.2/main.bin.sig /RavenSystem/haa_ota/releases/download/3.0.2/main.bin I see otamain.bin+otamain.bin.sig, so maybe renaming those or adding that two also..?

RavenSystem commented 4 years ago

Ups, sorry. Renamed.

hau21um commented 4 years ago

This is awesome. Good job @RavenSystem, thank you. Now I'm on setup page with HAA 2.1.2/OTA 3.0.2. You saved me from this tiny soldering exercise!!!

amitojkapoor commented 4 years ago

@hau21um when you said “mini got IP, correctly - can ping it“, did the device still show up as a tasmota in your router? I’m just trying to figure out if we have the same problem or not

allenmehrer commented 4 years ago

This is awesome. Good job @RavenSystem, thank you. Now I'm on setup page with HAA 2.1.2/OTA 3.0.2. You saved me from this tiny soldering exercise!!!

Well this is exciting. Care to break down how you did it? I’ve got a six pack of minis in my cart I’d be happy to buy if I can flash them OTA instead of soldering.

hau21um commented 4 years ago

@hau21um when you said “mini got IP, correctly - can ping it“, did the device still show up as a tasmota in your router? I’m just trying to figure out if we have the same problem or not

Well, this I was not checking and also not so long log on my router. I knew my router leas IPs for some time for given MAC, so checked the IP on the router just on the beginning even before any flashing happen.

hau21um commented 4 years ago

@allenmehrer Check my earlier post. Just now, after last RavenSystem's action the step 4 also finish correctly.

amitojkapoor commented 4 years ago

I have some good news from my side also.

I noticed when I plugged in my device, the HAA SSID would show up for like a second before the device would automatically connect to my network automatically. I decided to turn off my router so it wouldn’t be able to connect hoping somehow that would allow me to get into setup mode and it worked!

From here I reset the WiFi configuration and clicked save. It then disconnected me. When I reconnected I put in the JSON, put in the WiFi settings, selected update now, hit save, and now everything works.

I’m not sure if this is all working now because of Raven’s latest change or if I could’ve just done this from the start. Wish I never pried this thing open 😂

Thanks for all your help everyone

i3laze commented 4 years ago

Developer fixed the issue server-side.

Looks like Tasmota.bin was built with haa_ota v2.2.2, which still used main.bin naming. Newest 3.0+ uses haaboot.bin naming, and main.bin was missing for 3.0+ until yesterday: https://github.com/RavenSystem/haa_ota/releases

@RavenSystem will you now duplicate .bin with both names for ages or any workaround can be done here? Was this affecting any device running HAA OTA<3.0 or just custom build from this thread?

RavenSystem commented 4 years ago

Until a new version of a single binary is released, I will keep the workaround to let old version running.

RavenSystem commented 4 years ago

If anyone want to test this, please, give feedback. If it works, I will upload it to releases and I will support it for future versions.

fullhaaboot.bin.zip

MikeDProducer commented 4 years ago

If anyone want to test this, please, give feedback. If it works, I will upload it to releases and I will support it for future versions.

fullhaaboot.bin.zip

Raven, I tested this by logging into the web interface for my Tuya RGBW bulb running tasmota. When I uploaded the zip file I received the following error:

Upload Failed. Magic Byte is not 0xE9.

unscel commented 4 years ago

If anyone want to test this, please, give feedback. If it works, I will upload it to releases and I will support it for future versions.

fullhaaboot.bin.zip

Works like charm for me! Tested on tasmota 8.2.0.6

MikeDProducer commented 4 years ago

If anyone want to test this, please, give feedback. If it works, I will upload it to releases and I will support it for future versions. fullhaaboot.bin.zip

Works like charm for me! Tested on tasmota 8.2.0.6

Did you upload the zip file directly or the bin file within?

Rocket200 commented 4 years ago

If anyone want to test this, please, give feedback. If it works, I will upload it to releases and I will support it for future versions. fullhaaboot.bin.zip

Works like charm for me! Tested on tasmota 8.2.0.6

what HAA Version is here included ? i think i flash my 4 x Gosund with a old HAA Version back to Tuya and than with tuya-convert to Tasmota and than this new File from Ravensystem.

tonysprenk commented 4 years ago

It’s the latest but why not flash HAA straight with tuya convert? And if your going to solder wires anyway why not just flash the latest HAA straight away without tuya convert?

Rocket200 commented 4 years ago

yes i can flash the HAA with wires directly, i forget.

HAA now included in tuya-convert?

i need to flash it again with wires or i can go easy OTA way?

i stuck on HAA 1.4 / 1.7 and can not update (github problem)