-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
Updating the firmware trough local API #49
Comments
I haven't heard of anyone doing that, although I do know that at least one person has cracked their device open and directly flashed new firmware onto the board. According to Tuya's docs (scroll/search for section 3.10), it may be possible. If you manage to, let me know. 😃 |
I was fortunate enough to get a device that needed a firmware update and hence captured the traffic from my router between the device and the outside world. Here is a run down of what it did - I have tried to identify my private information by substituting for the device id and <32 bit AES key> for the signing key of the communication between the atop gateway and the device. I have attempted to replicate the ota process by running a local mqtt and webserver and redirecting locally - I have got as far as it downloading the 64 byte header of the Sonoff-Tasmota firmware. MQTT - App Triggered MQTT Publish via Cloud which seems to kick off the OTA update HTTP: HTTP: Response: HTTP: Partial Response: ... must perform some validation of the first 64 bytes of the firmware probably looking for the version number and it contains the sizing and offset for the next request ... offset in hex: 00064D47 (dec: 412999) and size in hex: 00064D14 (825947 [file length] - 412999 [offset] = 412948 [section]) HTTP: Partial Response: MQTT: ... a number of progress MQTT Publish... MQTT: ... tuya device did a reboot ... DNS Query: mq.gw.tuyaeu.com MQTT Connect: DNS Query: a.tuyaeu.com HTTP: Response: {"t":1544007229,"e":false,"success":true} |
This seems to be exactly what I was looking for, so thanks. You didn't happen to dump the original bin file, did you? I'll have a closer look at this the next weeks, since I'm a little busy these days. |
No I didn't dump the original bin file however I have a second device that is still needs to be updated. When I get time I will make an attempt - recently moved and need to find the soldering iron. In the meantime I will continue to see if I can get the firmware header correct. Right now the device is downloading my header multiple times. |
Here's an older version of the firmware http://s3-us-west-2.amazonaws.com/airtake-public-data/smart/firmware/upgrade/201806/1528276183-esp_bsd_jl_plug_America_ug_1.0.5.bin I think mine came with 1.0.0 or 1.0.1, though |
anything new on this ? |
The 1.1.0 firmware linked above has a header that is 51 bytes long and is then followed by the actual firmware image. Esptool reports the following about the firmware:
What might work for OTA updating is replacing the tuya image with a tasmota one. You might also have to update the firmware version number in the header (located at bytes 4 - 8). |
The bad news is I've managed to brick my plug by forcing it to install In other news, it turns out the firmware file actually has 2 different firmwares in it.
|
I can get the tuya plug to download and install the sonoff-basic firmware by constructing a binary using the above format header with 2 copies of the sonoff-basic appended. Unfortunately the plug no longer boots once its installed. I suspect that I'll have to get it to install some interim firmware and then get this to install sonoff-basic. |
I'm on the edge-of-my-seat here 😃 |
The minimal version is the same. At the moment I'm looking at what SonOTA did to see if I can adapt that. |
fwiw, there is also an Espurna core version which is only 299 KB, created to simplify OTA updates. |
**** SUCCESS **** |
can you do a detailed write-up ? |
Will do. |
WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING Files Instructions for Updating Tuya device OTA I did this on a linux machine running openSUSE 15.0 but there is no reason why it shouldn't work on other flavours of linux and should be easily adaptable to windows. Prerequisites
NOTE Setting Everything up Redirecting HTTP requests (the difficult bit) Running the Scripts Installing the Firmware After everything has finished follow the sonoff getting started instructions. Acknowledgements |
Awesome. Will try it with my plugs and let you know. I will also try with
my lightbulbs.
|
This definitely changes things! Have a plug I can flash the Tuya junk back on it and test with. Don't have a full blown Linux build going except my media server but I think a wired raspberry Pi should work with this right since it has Wi-Fi capabilities as well? |
There is no reason a Pi wouldn't work. |
No, that's not me |
|
I feel like I am close.. I saw one plug request firmware with the log from the pl script but on the webserver I am not seeing any requests for the bin file though. I did a wget from that Pi just to make sure the bin was accessible and that works but I just don't see the plug asking for that bin yet. |
@digiblur did you edit line nr 8 in tuyaproxy.pl ? |
If you add: |
@SynAckFin so the Pi running the PL still needs to reach the real a.tuyaus.com? That would be my issue then as my whole network is redirecting. |
ahhh...I added that print and it was doing a ....server:8000// I removed the trailing / from the variable and the URL looks right now. Now to get it to request a firmware again. Patience... |
I tried a couple of the current prebuilt bins but I couldn't get color fully working so I'm back to a custom build of Tasmota |
Sorry I've sat this discussion out so far, but it's not at all because I disagree with the approach being taken here. Fantastic work everyone, especially @kueblc and @SynAckFin. A few questions:
Let me know your thoughts, I'm eager to help in any way I can. |
This walkthrough is for an RPi3, but it may get you started if you're doing
it on a different Linux distribution
https://github.com/SynAckFin/TuyOTA/wiki/Walkthrough
Michael Ingraham
Spartanburg, SC
…On Mon, Jan 21, 2019 at 5:11 PM Max Isom ***@***.***> wrote:
Sorry I've sat this discussion out so far, but it's not at all because I
disagree with the approach being taken here. Fantastic work everyone,
especially @kueblc <https://github.com/kueblc> and @SynAckFin
<https://github.com/SynAckFin>.
A few questions:
1. Is it possible to add a quickstart guide to the README of TuyOTA?
I've never really used Perl before and I don't know if I have to install
packages or do anything else before running it, something other new users
will probably wonder as well.
2. Once this firmware flashing process is perfected, do you see any
reason to continue maintaining TuyAPI? While I would be slightly sad that
my pet project is no longer needed, it sounds like the ready-made firmware
alternatives offer an easier API as well as potentially greater reliability.
Let me know your thoughts, I'm eager to help in any way I can.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#49 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Agv9cjW8wLDVxtDEhZB2_BvnSt0Cjuvgks5vFjrzgaJpZM4V3jA_>
.
|
And thank you @codetheweb (et al) I appreciate all your hard work as well. Huge amount of groundwork covered by this project. I only wish I had found it sooner! Regarding 2, I know the feeling of code obsolescence. I was originally building MockTuyaCloud to sandbox my Tuya bulbs but now, I don't even need to! I'm sure there are still folks out there that can't/don't want to flash custom firmware but still want to integrate with their HA setup. In that way I think tuyapi should remain alive and well. There is a lot out there now that depends on it! |
I do need to add some decent documentation for it. I think you should continue the project. Not everybody is comfortable with flashing custom firmware onto a device so they need a method of control using the built in firmware. Similarly, not every device has been flashed successfully. so those that fail (and are still usable) will find the TuyAPI very useful. |
As it turns out, another group has already implemented firmware flashing using a very similar technique to the one developed here. Check it out at https://github.com/ct-Open-Source/tuya-convert Given these guys have most everything covered, I'm going to recommend this over https://github.com/kueblc/mocktuyacloud for firmware flashing purposes (they do pretty much exactly the same thing, just better organized). Funny how these things work out. |
Looks like they developed their stuff in parallel (time period) as here, though I suspect at this point TuyOTA developed by @SynAckFin beat them in their commit to github by a day. Personally I used TuyOTA since it is basically a way more streamlined mocktuyacloud. @SynAckFin you might want to consider updating the landing page for it? Great work all the same! |
Any clear advantage of one over the other?
On Jan 23, 2019, at 2:12 PM, Aterfax <[email protected]> wrote:
Looks like they developed their stuff in parallel (time period) as here,
though I suspect at this point TuyOTA <https://github.com/SynAckFin/TuyOTA>
developed by @SynAckFin <https://github.com/SynAckFin> beat them in their
commit to github by a day.
Personally I used TuyOTA since it is basically a way more streamlined
mocktuyacloud.
@SynAckFin <https://github.com/SynAckFin> you might want to consider
updating the landing page for it? Great work all the same!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#49 (comment)>,
or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ArYhZIAnfM9zTsHhsoNMMinhOTNSTuaxks5vGLQBgaJpZM4V3jA_>
.
|
Yes. Tuya-Convert uses the Provisioning stage and can offer a device a firmware update - a device I couldn't get mocktuyacloud or tuyota to work with I got to the stage 1 loader. The stage 1 loader allows for the backup of the device firmware and to see if the flash mode is supported hence less likely to brick. |
Thanks for the feedback @SynAckFin and @kueblc; looking forward to seeing how these flashing solutions mature. (By the way, @SynAckFin: I'm totally open to you moving TuyOTA to the TuyAPI Org if you want.) |
Me too, Bricked 3 so far, but still excited to see how this matures. May try coverts firmware to see how it works. I have brought one back to life so far. Haven't really tried the other two. I like the option of making a firmware dump. Maybe that can be added to @Tuyota. |
As far as I know the only apparent difference is the choice in stage 1 firmware? The ability to backup the existing firmware certainly is nice. |
When you guys say that your devices are bricked does that mean that they do absolutely nothing? One of mine was acting oddly after the script attempted to run but I was able to hold the button and pair it back to the app. It wasn't as straight forward as that but the device was definitely showing signs that something was running because the LEDs would flash at different rates |
I have bricked two devices:
|
From my experience some of the smart plugs are relatively easy to open and then if you can solder some have just enough access to allow you to connect without having to remove the main PCB from the mains pins. I've posted some notes and pictures but now we have 4 repos and issues to keep track of so my head is spinning a bit. What plug dies on you, maybe it's one of the ones I have. |
Fortunately or Unfortunate the two I haven't messed with had very little or no glue holding the back together. Since I knew I might want to flash them I left them this way. Two of the three bricks had TYWE3S. I think the initial or second firmware failed. Wonder if it can be modified to work. I have only been dealing with pre compiled firmware. I used ESP8266Flasher.exe 32bit on TYWE3S and before flashing I grabbed some output of the chip using putty with baudrate of 77400. I'll post if if anyone things it would be useful. |
If you think you have a bricked device after using Tuya-Convert you probably do not. The firmware they use is sonoff-classic and when that wants an initial configuration it goes into WPS config mode. So switch the device on and go and push the little black button on your wifi router. |
Nope unfortunately I got in when Tuya-Convert was using sonoff-minimal :( |
@drushbrook Its a Hail Mary but Tasmota also supports config via ESP8266 SmartConfig. I've never tried it but you never know.... |
Thanks @SynAckFin but still no luck. I will replace the bulb (they are only $15 each anyway) and do a serial autopsy on the bricked one but won't use it again - too dangerous in my opinion |
Device SHP-6 REQ: Client closed connection while receiving request: Thanks ! |
@SynAckFin WPS fixed one of my bulbs. THANK YOU!!!! |
Hi all,
in the recent posts i found that this SP22 should work when configured as a BlitzWolf SHP. In my case, it doesn't work, But i got it working (partially) as a Gosund SP1 v23. But no LED no Button. Voltage, Power, on/off is ok. Thanks in advance, Manfred |
I can confirm that Tuya-Convert bricked the Feit Electric BPA800 bulb (Costco Sept 2019). When I removed the ESP8266 module to reflash it over serial port I logged what the poor thing was sending out (before the flashing). It was a loop of: |
That's not bricked, you just didn't have the |
|
As I find it hard to find some information on if sombody managed to update the firmware of a tuya device utilizing any kind of OTA update, I thought this might be the right place to ask.
The text was updated successfully, but these errors were encountered: