re-flash Sonoff 4CH

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
manjh
Normal user
Posts: 516
Joined: 08 Feb 2016, 11:22

re-flash Sonoff 4CH

#1 Post by manjh » 14 Nov 2022, 12:42

I have a pair of SOnOff 4ch devices that have been running for several years.
I decided to upgrade them, but I messed up with the first one by trying to OTA the wrong bin file... :(

Reading the Wiki (should've done that first :mrgreen: ) I noticed I need a 1M file for the 8285.
Looked through the binaries, but don't see that file.

Can you point me at the right bin file please?

TD-er
Core team member
Posts: 8754
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: re-flash Sonoff 4CH

#2 Post by TD-er » 14 Nov 2022, 12:50

Please don't start looking at the wiki, but rather the readthedocs as those are (often, not always) the most up to date source.

This GitHub Actions build should have 2 "minimal OTA" builds: https://github.com/letscontrolit/ESPEas ... 3457567222

I recently removed the "special ESP8285" builds, as ESPEasy can now detect at runtime whether it is running on ESP8285 or ESP8266.
So any "1M ESP8266" build should work on your node.
However, only the "minimal OTA" builds should be used when you plan on performing OTA updates using the 2-step binary as inbetween version.

manjh
Normal user
Posts: 516
Joined: 08 Feb 2016, 11:22

Re: re-flash Sonoff 4CH

#3 Post by manjh » 14 Nov 2022, 13:37

TD-er wrote: 14 Nov 2022, 12:50 Please don't start looking at the wiki, but rather the readthedocs as those are (often, not always) the most up to date source.

This GitHub Actions build should have 2 "minimal OTA" builds: https://github.com/letscontrolit/ESPEas ... 3457567222

I recently removed the "special ESP8285" builds, as ESPEasy can now detect at runtime whether it is running on ESP8285 or ESP8266.
So any "1M ESP8266" build should work on your node.
However, only the "minimal OTA" builds should be used when you plan on performing OTA updates using the 2-step binary as inbetween version.
OK, but how about the 1M limit? Is there a bin to load for that?
Keep in mind that I am past the OTA at this moment, as I tried to load a 4M version... now the unit does not start up any more so I will have to connect the wires.

TD-er
Core team member
Posts: 8754
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: re-flash Sonoff 4CH

#4 Post by TD-er » 14 Nov 2022, 13:46

You can use any "1M" build. But for later updates you either need to connect the wires again, or now pick a build labelled "minimal OTA".
If you flash a larger one, it will overwrite the file system when trying to update via WiFi.

manjh
Normal user
Posts: 516
Joined: 08 Feb 2016, 11:22

Re: re-flash Sonoff 4CH

#5 Post by manjh » 15 Nov 2022, 12:30

TD-er wrote: 14 Nov 2022, 13:46 You can use any "1M" build. But for later updates you either need to connect the wires again, or now pick a build labelled "minimal OTA".
If you flash a larger one, it will overwrite the file system when trying to update via WiFi.
OK, so if I understand this correctly: Once I have the SOnOff running ESPEasy again, I'm all set.
For future updates (via OTA) I would first install the minimal OTA, and then load the new firmware (1M version).

TD-er
Core team member
Posts: 8754
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: re-flash Sonoff 4CH

#6 Post by TD-er » 15 Nov 2022, 14:25

Yep, you have to realize how the flash is structured on an ESP8266

Starting at address 0 of the flash, upto the end of the flash, we have in this order:
-Active sketch
-Free space
-Space for OTA
-File system
-Few k of some other stuff, some of it is used by the SDK

The first 3 make up one large block, so these are the restrictions:
- Free space cannot become "negative" for obvious reasons.
- OTA being flashed + active sketch cannot be larger than this large block. (or else "free space" will become negative)

The max. size we can use, given our smallest available 2-step OTA bin file, is roughly 600k.
If you flash a binary file which is larger than 600k, you cannot perform a 2-step OTA upgrade.
Also if you try to upload a file larger than the "space for OTA" + "free space", you will start overwriting the active sketch.
While overwriting this, your ESP will most likely crash and no longer be able to boot the previous "active sketch" as it has been corrupted.
The bootloader also cannot copy the uploaded OTA image as it is not complete.
End result is an unusable ESP, which needs to be flashed again via serial.

Thus, in order to perform OTA update:
- serial flash build < 600k
- upload the small (roughly 270k) 2-step OTA bin
- reboot
- Open web interface with 2-step OTA bin running
- Upload new build < 600k

If you need a larger build, you cannot update it via OTA.

Post Reply

Who is online

Users browsing this forum: No registered users and 133 guests