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

3.7.6 - Mini - Needs change to work #18

Open
JonLaliberte opened this issue Jun 2, 2023 · 31 comments
Open

3.7.6 - Mini - Needs change to work #18

JonLaliberte opened this issue Jun 2, 2023 · 31 comments

Comments

@JonLaliberte
Copy link

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.

@njh
Copy link
Owner

njh commented Jun 4, 2023

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.

@JonLaliberte
Copy link
Author

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?

@RKeme
Copy link

RKeme commented Jun 8, 2023

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

@gonzalonaveira
Copy link

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

@njh
Copy link
Owner

njh commented Jul 10, 2023

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 😬

@LngWork
Copy link

LngWork commented Jul 21, 2023

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 :

Thank you @njh for your job !

@solarsnoop
Copy link

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

@mifraburneo
Copy link

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

@IBims1NicerTobi
Copy link

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

@IBims1NicerTobi
Copy link

@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.

@jesusvallejo
Copy link

@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!

@3N37
Copy link

3N37 commented Nov 19, 2023

@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.

@Siftah
Copy link

Siftah commented Nov 26, 2023

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 :(

@3N37
Copy link

3N37 commented Nov 29, 2023

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

@Siftah
Copy link

Siftah commented Nov 30, 2023

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 :(

@3N37
Copy link

3N37 commented Nov 30, 2023

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

@Siftah
Copy link

Siftah commented Nov 30, 2023

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 "-" "-"

@3N37
Copy link

3N37 commented Nov 30, 2023

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

@Siftah
Copy link

Siftah commented Nov 30, 2023

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 %

@3N37
Copy link

3N37 commented Nov 30, 2023

@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

@Siftah
Copy link

Siftah commented Nov 30, 2023

@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! :)

@3N37
Copy link

3N37 commented Nov 30, 2023

@Siftah ,

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

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

@Siftah
Copy link

Siftah commented Nov 30, 2023

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.

@3N37
Copy link

3N37 commented Nov 30, 2023

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
Copy link

3N37 commented Nov 30, 2023

this is the correct form

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

@Siftah
Copy link

Siftah commented Nov 30, 2023

@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

@3N37
Copy link

3N37 commented Dec 5, 2023

@stefan-STMODE
Copy link

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)

@3N37
Copy link

3N37 commented Mar 18, 2024

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.

@stefan-STMODE
Copy link

it are "newer" ones with wifi inside

@Gyrohammer
Copy link

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.

Just used this method with a Mini R2 purchased a a few weeks ago and it worked! Thanks.

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

No branches or pull requests