sonoff-ota-flash-cli icon indicating copy to clipboard operation
sonoff-ota-flash-cli copied to clipboard

3.7.6 - Mini - Needs change to work

Open JonLaliberte opened this issue 1 year ago • 31 comments

For some reason, the script was not working on a Mini (I think R1? I got it a long time ago) running firmware 3.7.6. I was able to get it working by completely removing the "deviceid" from the body variable in the sonoff_http_request function, and also from the ota_flash function.

That made the script start working and got Tasmota flashed.

JonLaliberte avatar Jun 02 '23 17:06 JonLaliberte

Hm, interesting, thanks!

I have tested quite a bit with Firmware versions 3.5.0 and 3.6.0 and both R1 and R2 but didn't experience this. I can't remember how essential the deviceid parameter was when I was testing.

I wonder if it is possible to test if the parameter is needed somehow.

njh avatar Jun 04 '23 22:06 njh

With the deviceid there I wasn’t getting any response when it tries to get the device info. Maybe after X seconds timeout and try without it?

JonLaliberte avatar Jun 05 '23 00:06 JonLaliberte

I confirm Jonathans findings- I was able to use the scipt by removing the deviceid at the mentioned places four times. 3.3.0 -> 3.7.6 -> diy-> adapted script

RKeme avatar Jun 08 '23 00:06 RKeme

Can confirm using Mini R2 and firmware version "3.7.6" as well

gonzalonaveira avatar Jul 06 '23 10:07 gonzalonaveira

It would be good to try the following things:

  • Test if the deviceid parameter is actually required for older firmware versions
  • If it isn't: just it remove the deviceid parameter completely
  • If it is: look at automatically detecting if it is required (maybe look at fwVersion when getting /info), or add a manual option

I am going to have to get my serial cable and tazmotizer out, to load different firmware versions on to a test device 😬

njh avatar Jul 10 '23 12:07 njh

Thank you for this report, same issue. Firmware version 3.7.0 : impossible to flash, with or without deviceid. Very difficult to configure WiFi.

Finaly here was my way :

  • Connect with eWeLink APP
  • Upgrade to last firmware version (3.7.6 in my case)
  • Remove device from eWeLink APP (very important). Device config is then restored to default config.
  • Press button 5s+5s, connect to AP ITEAD-xxxx, setup WiFi config thru http://10.10.7.1
  • POST to /zeroconf/info without deviceid (reference : https://sonoff.tech/sonoff-diy-developer-documentation-basicr3-rfr3-mini-http-api/ ). Within response you get deviceid
  • Then follow normal procedure WITH deviceid

Thank you @njh for your job !

LngWork avatar Jul 21 '23 18:07 LngWork

Hi Thanks you all, my expierence is the same and i have my problems to modify this scrip so i used RESTer Add on for send the requests to the SONOFF with FW 3.7.6. What i can say ist that the ID you can see in the SSID ITEAD-ID. In my case: ITEAD-10017318ef So what i did is i request the /zeroconf/info with using this ID and was succesful. { "deviceid": "10017318ef", "data": { } } Than I enable OTA Flashing with /zeroconf/ota_unlock:

{ "deviceid": "10017318ef", "data": { } }

and than i flash tasmato fw with zeroconf/ota_flash { "deviceid": "10017318ef", "data": { "downloadUrl": "http://sonoff-ota.aelius.com/tasmota-latest-lite.bin", "sha256sum": "5c1aecd2a19a49ae1bec0c863f69b83ef40812145c8392eebe5fd2677a6250cc" } }

So the Setting for RESTler was Clean Request and the Method is POST.

So hope this will help someone has the same problem .-)

@njh Nicholas maybe you can extend your script whre we can add the ID smae like the IP etc... Thanks in advance Guido

solarsnoop avatar Jul 24 '23 10:07 solarsnoop

Hi! I’m having an issue (that’s actually happening in 3.6.0 as well as after updating to 3.7.6) in which I can get the response on the Module Info but it hangs with an empty reply whoen trying to do the ota_unlock… Have you run into some simmilar issue? I’ve now tried with two brand new MINI R2.

Thanks a lot! image

mifraburneo avatar Aug 29 '23 10:08 mifraburneo

@mifraburneo Can you please try flashing again with https://github.com/IBims1NicerTobi/sonoff-ota-flash-cli-devid-fix?

IBims1NicerTobi avatar Sep 10 '23 13:09 IBims1NicerTobi

@njh There is a pull request now. I have personally tested it on a sonoff mini r2 with 3.7.6 and it worked while the current base version did not work at all.

IBims1NicerTobi avatar Sep 10 '23 13:09 IBims1NicerTobi

@njh There is a pull request now. I have personally tested it on a sonoff mini r2 with 3.7.6 and it worked while the current base version did not work at all.

it worked like a charm, thanks a lot!

jesusvallejo avatar Sep 16 '23 22:09 jesusvallejo

@mifraburneo

I have the same problem as you, I have version 3.7.3 on sonoffminiR2. 2 I managed to flash and 2 others I can't.Another strange thing, I installed ewelink but when I try to register it crashes.

3N37 avatar Nov 19 '23 09:11 3N37

Same issue as @mifraburneo and @3N37, running 3.7.6 firmware the curl always times out when trying to unlock.

I can see it's trying to contact apid.coolkit.cn/v2/d/otaflash (changed URL from earlier versions) and have redirected this to a local http server which is responding with { "error": 422 }, which I've seen elsewhere can allow the flash to proceed, but no dice, it still times out even though I can see in the logs it's hitting that URL correctly.

Unfortunately @IBims1NicerTobi fix doesn't help either :(

Siftah avatar Nov 26 '23 12:11 Siftah

@Siftah I've written a guide here flashing sonoffminiR2.it.en.pdf

3N37 avatar Nov 29 '23 20:11 3N37

Thanks for sharing it @3N37, unfortunately it no longer works - the call to the unlock server is happening but the response seems to be ignored, the curl eventually times out and the Sonoff is never unlocked :(

I presume this must be a bug in the latest firmware, or they've changed the necessary response from what's in your example :(

Siftah avatar Nov 30 '23 11:11 Siftah

@Siftah , check if the apache server has the rewrite module enabled . I have unblocked sonoffminiR2 that had 3 different firmware. It works !

3N37 avatar Nov 30 '23 12:11 3N37

Rewrite module is working great:

siftah@fozzie sonoff-ota-flash-cli-devid-fix % curl -v -X POST http://apid.coolkit.cn/v2/d/otaflash --data-raw '{"deviceid":"10009be24e","data":{} }'
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 192.168.1.253:80...
* Connected to apid.coolkit.cn (192.168.1.253) port 80 (#0)
> POST /v2/d/otaflash HTTP/1.1
> Host: apid.coolkit.cn
> User-Agent: curl/8.1.2
> Accept: */*
> Content-Length: 36
> Content-Type: application/x-www-form-urlencoded
> 
< HTTP/1.1 200 OK
< Date: Thu, 30 Nov 2023 14:18:12 GMT
< Server: Apache/2.4.52 (Ubuntu)
< Vary: Accept-Encoding
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8
< 
{
"error": 422
* Connection #0 to host apid.coolkit.cn left intact
}%                                                                                                                                                                                                                                                                 siftah@fozzie sonoff-ota-flash-cli-devid-fix %

And I see the corresponding hit in the local server also: /var/log/apache2/access.log.1:192.168.1.90 - - [29/Nov/2023:14:32:42 +0100] "POST /v2/d/otaflash HTTP/1.1" 200 194 "-" "-"

Siftah avatar Nov 30 '23 14:11 Siftah

@Siftah , ok so it works? where does it get stuck?

3N37 avatar Nov 30 '23 14:11 3N37

Times out when calling the ota_unlock :(

siftah@fozzie sonoff-ota-flash-cli-devid-fix % curl http://192.168.1.90:8081/zeroconf/ota_unlock -XPOST --data-raw '{"deviceid":"10009be24e","data":{} }' -v
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 192.168.1.90:8081...
* Connected to 192.168.1.90 (192.168.1.90) port 8081 (#0)
> POST /zeroconf/ota_unlock HTTP/1.1
> Host: 192.168.1.90:8081
> User-Agent: curl/8.1.2
> Accept: */*
> Content-Length: 36
> Content-Type: application/x-www-form-urlencoded
> 
* Empty reply from server
* Closing connection 0
curl: (52) Empty reply from server
siftah@fozzie sonoff-ota-flash-cli-devid-fix %

Siftah avatar Nov 30 '23 15:11 Siftah

@Siftah
check these 2 things :

  1. with wireshark or tcpdump check that the sonoff actually calls apid.coolkit.cn
  2. that the .htaccess file (must be placed in the root directory and then before flashing should be moved to v2) transforms the otaflash call to otaflash.php

3N37 avatar Nov 30 '23 16:11 3N37

@3N37 Yes, both of those things are proven in the dumps I've pasted above;

  1. This is the Sonoff (192.168.1.90) on my local network making the POST to my server at 192.168.1.253: /var/log/apache2/access.log.1:192.168.1.90 - - [29/Nov/2023:14:32:42 +0100] "POST /v2/d/otaflash HTTP/1.1" 200 194 "-" "-"

  2. The last post confirms 2, that the URL is hit and the remote server is responding with the necessary response.

Thank you for your help, it's much appreciated! :)

Siftah avatar Nov 30 '23 16:11 Siftah

@Siftah ,

  • so were you able to unlock it ? otaUnlock:true ?

  • did you try to use the manual procedure as explained in my .pdf ?

3N37 avatar Nov 30 '23 16:11 3N37

I was not able to unlock it, because the curl times out and never completes.

I did use the manual procedure as explained in your .pdf, the logs I've pasted above show it being done and failing.

Siftah avatar Nov 30 '23 16:11 Siftah

i give up. i can still tell you that at the beginning i had the same errors as you , then applying the procedure as in the .pdf i was able to unlock them all . let me know if you solve

3N37 avatar Nov 30 '23 16:11 3N37

this is the correct form

curl -XPOST --header "Content-Type: application/json" --data-raw '{"data": {}}' http://192.168.1.90:8081/zeroconf/ota_unlock

3N37 avatar Nov 30 '23 16:11 3N37

@3N37 Exactly the same error.

siftah@fozzie ~ % curl -XPOST --header "Content-Type: application/json" --data-raw '{"data": {}}' 192.168.1.90:8081/zeroconf/ota_unlock
curl: (52) Empty reply from server

Siftah avatar Nov 30 '23 18:11 Siftah

@https://github.com/itead/Sonoff_Devices_DIY_Tools/issues/45

3N37 avatar Dec 05 '23 20:12 3N37

i got i working after lots of testing and trying, i just upgraded 2 r2 mini's

both added first with eWeLink app and upgraded them from 3.6.0 to 3.7.6 with the use of the script i only get the deviceid number, one i flashed tasmota lite on with "postman" and with the deviceid filled in the other one failed even to get info from it, but this one i could flash with the DIY tool (v1.2.0)

stefan-STMODE avatar Mar 18 '24 21:03 stefan-STMODE

in a nutshell those with jumpers should be updated with the old way , those without external antenna and without jumpers with the procedure described above.

3N37 avatar Mar 18 '24 21:03 3N37

it are "newer" ones with wifi inside

stefan-STMODE avatar Mar 18 '24 21:03 stefan-STMODE