Closed simonckenyon closed 3 years ago
Hm! The modules aren't very good at proving feedback about what is going on.
I have experienced "Empty reply from server" but I have had some problems with the virus / web protection software on my laptop, so I wasn't sure if it was related to that (it intercepts all TCP/HTTP connections). However resetting the module/starting again did fix it. The OTA Unlock step is very fast - takes less than a second - so you shouldn't have to wait.
Have you put the module into DIY mode?
12345678
.There are a couple of things I should do:
I haven't tried flashing a module with firmware 3.6.0 (only version 3.5.0). So I should try upgrading my test module and then try my script on it.
I should document the full beginning-to-end steps for OTA flashing and put instructions in the README
thank you for your quick response. i really regret updating the firmware to 3.6.0. the device had been sitting in the box for about a year. my bad.
what was/is not clear to me was:
i put it into diy mode (once). does the device fall out of DIY mode once power has been removed? the fact that a) i could make the web service calls and b) the itead app says that my device is not online sort of led me to believe that it remained in diy mode after power off.
can you do the 5 seconds/5 seconds shuffle more that once? i was not able to.
does the device make any calls to itead as part of the ota_unlock web service. i have seen some reports that this is the case. i modified my dhcp server so that it uses 8.8.8.8 for dns (i normally use pi-hole). that did not make any difference (apart from a awful of adverts on web pages while i was doing this).
I think I need to go through this again to double-check, but I think once you have configured the module with your home Wifi, it stays in DIY mode.
I did have to keep having to reset it while I was experimenting/writing the script. Some HTTP requests seem to cause it to crash and I had to power-cycle it to get it back. Pressing the button for 5 seconds is described as "Factory Reset"- so I would have thought it should be possible to do it multiple times.
I am not sure if it calls home or not during the ota_unlock request. When I try doing it again, I will do a packet capture and see if there are any requests out to the Internet.
I have just tried installing the eWeLink software on my phone for the first time but I can't get it to setup my module :-( It is possible I have done something to to the module so that original firmware won't work on it anymore 😞
I think the backup of my Sonoff Mini is from just after I configured it to access my home Wifi. When I do a restore, it goes back to that state just before I called ota_unlock
.
I managed to do a packet capture during unlocking and it is indeed calling home:
This is what the HTTP request looks like:
POST /api/device/otaFlash HTTP/1.1
Host: api.coolkit.cn:8081
Content-Type: application/json
Authorization: Sign 8a62a48e34cfe4e4f5f0a8810267b2af34574396f227b575839310b14ec9a67d
Connection: close
Content-Length: 52
{"deviceid":"1000e4c17c","sequence":"4058031471168"}
HTTP/1.1 200 OK
Server: openresty
Date: Tue, 02 Feb 2021 00:31:26 GMT
Content-Type: application/json
Content-Length: 13
Connection: close
{"error":422}
Weirdly unlocking worked fine, despite the error code in the response.
When I lookup api.coolkit.cn
using my local resolver in the UK:
$ host api.coolkit.cn
api.coolkit.cn is an alias for api.coolkit.cc.
api.coolkit.cc is an alias for eu-api.coolkit.cc.
eu-api.coolkit.cc has address 52.57.118.192
I get the same result when resolving using using 8.8.8.8
and 1.1.1.1
.
It looks like Coolkit is the people who make eWeLink.
Good news, I have successfully managed to OTA a flash a Sonoff Mini running firmware version 3.6.0. Although I had real trouble getting it into DIY mode. I quit everything on my Mac apart from Safari. Went to Wifi settings and told it to forget about the ITEAD wireless network. Then after holding down the button for 5 seconds to factory reset, then holding it down for 5 seconds again to put it into "Compatibility AP" mode, I was able to connect to the Wifi network, then connect to 10.10.7.1 and set my home Wifi network name and password. It then successfully joined my home network.
Once in DIY mode, it seemed to stay in DIY mode between power cycles.
Running the bash script then worked as expected:
./sonoff-ota-flash.sh
Checking new firmware file exists
OK
Looking up sha256sum for firmware
OK
Searching for Sonoff module on network...
Found module on network.
Hostname: eWeLink_1000e4c17c
IPv4 Address: 192.168.1.104
Getting Module Info...
{
"seq":3,
"error":0,
"data":
{
"switch":"off",
"startup":"off",
"pulse":"off",
"pulseWidth":500,
"ssid":"test",
"otaUnlock":true,
"fwVersion":"3.6.0",
"deviceid":"1000e4c17c",
"bssid":"b4:fb:e4:77:7f:aa",
"signalStrength":-47
}
}
Unlocking for OTA flashing...
{
"seq":3,
"error":0
}
Proceed with flashing? [N/y] y
Requesting OTA flashing...
{
"seq":4,
"error":0
}
Please wait for your device to finish flashing.
Packet capture on my router showed it phoning home again.
Again it got an 422
error response back in the JSON endpoint, which it didn't seem to mind.
@simonckenyon did you have any success with this?
I can just say I have managed to flash 5 Sonoff Minis flawlessly.
Just for the record I've managed to flash Sonoff Basic R3 (newer version without jumper for DIY mode) with firmware v3.6.0. The only issue was that avahi was not able to find the IP of the device but I put it with the -i parameter.
Thanks a lot for this script.
I recently bought some more Sonoff Mini R2s, that came with firmware v3.6.0.
I have updated the README with more detailed instructions.
All worked fine, so closing this issue now.
I keep getting "connection reset by peer". Any idea why?
edit: I disabled the router firewall and it worked. I got it flashed with v3.6.0
when i run your most excellent script it just sits there:
./sonoff-ota-flash.sh -i 192.168.20.13 tasmota-9.2.0-lite.bin Checking new firmware file exists OK
Looking up sha256sum for firmware OK
Getting Module Info... { "seq":2, "error":0, "data": { "switch":"off", "startup":"off", "pulse":"off", "pulseWidth":500, "ssid":"koala-iot", "otaUnlock":false, "fwVersion":"3.6.0", "deviceid":"1000a05bf6", "bssid":"46:d9:e7:49:83:a8", "signalStrength":-43 } }
Unlocking for OTA flashing...
and then after a couple of minutes it says:
curl: (52) Empty reply from server Error posting to: http://192.168.20.13:8081/zeroconf/ota_unlock
i have been trying to post ota_unlock to the mini for several hours now.
am i doing something wrong?