Does esp8266 save old sketches?

I ask because this morning I found a device running a prior version from September and not the last uploaded version of November. The device is a clock using a pinball backglass. , I modified it to show the outside temperature, and woke up to find it is not showing the temperature. I also give all the device html connectivity and when I look at the site the DATE I store is September and not November. Bizarre. How is this even possible?

The only way I can think of is that you think you programmed it successfully with the new code but the programming failed.

If you upload a new sketch successfully the old one is gone.

(Nice project by the way! :smiley: )

But until yesterday it was acting as if it had worked. I use the OTA stuff so I don't have to keep taking it off the wall to connect to usb,

Thanks for the compliment, the Game over means Saturday, the 40 is the number of seconds. Then every 10 seconds for two seconds it shows the temperature from open weather map where the 10 is. the tens number of the temp comes on 200ms before the ones number to avoid confusion. There is also a monty python silly mode where it flashes rainbow colors on all the numbers. But yeah, this is a head scratcher for me.

Then I don't know. I'll watch this topic with interest to see what anyone else says, maybe I am about to learn something.

One thing I have learned with esp devices. if you upload once with SSID and password, and take that out the next time, it remembers the SSID and password! So yeah, there is a lot we don't know about these things.

Prove it. Sounds like you just a bit disorganized.


How do you store the date?

the compiler function DATE

well _ _ DATE _ _. for some reason it isn't printing what I type.

then in the html handle, I have

        //       P r o g r a m   U p d a t e d
        strcat(html, "Program Updated");
        strcat(html, *ctdotd);
        strcat(html, __DATE__);
        strcat(html, *ctdotd);
        strcat(html, __TIME__);

        //      __FILE__
        strcat(html, "File");
        strcat(html, *ctdotd);
        strcat(html, __FILE__);
        strcat(html, *ctdotd);
        strcat(html, "name");

Bottom line is still NO. If the board is still running the old code then you were simply unsuccessful in overwriting it with the new code. End of story.

Double underscores is Markdown syntax for bold text emphasis:

You should always wrap code text in backticks to avoid this sort of problem, as well as to improve readability in general.

This markup:

the compiler function `__DATE__`

Renders as this:

the compiler function __DATE__

1 Like

I don't know if the esp8266 itself keeps the old firmware, but I wonder if the OTA library does. It must store the new firmware, as it is uploaded, in an unused part of the flash memory. It can't simply overwrite the old firmware in case the new firmware download fails part way through or gets corrupted. If I designed the OTA library, I think I would build in some kind of failsafe. If the new firmware, even though it downloaded ok, did not behave correctly in some particular way, not sure what that might be exactly, the library would intervene and switch back to the previous firmware version, having kept it as a backup.

You guys aren't going to believe this, but a few hours ago, it started using the new sketch and without checking the html, I just sat there shaking my head and ran some errands, NOW, a few hours after that it is using the older software. Here is a screen print from the html page with the old date.

It also shows it reset itself

and prior to that had been running

I sure wish I had checked that page when it was running the newer version, maybe it will flip again.

So why does it seem to have both copies? Evidently there is a lot we don't know about these things.

OTA, as I understand it, only works if you have not used more than half of your progmem. OTA uploads your code to the unused half of progmem then changes the start vector. Your prior code is still in progmem, but nothing points to it. If you upload by OTA again, then there would be two copies.

two slightly different copies in this case and something is moving the needle. I will keep that in mind and endeavor to stay below 50%. Does this have anything to do with spiff settings?

I guess I am within the limits
Sketch uses 344096 bytes (32%) of program storage space. Maximum is 1044464 bytes.
Global variables use 34808 bytes (42%) of dynamic memory, leaving 47112 bytes for local variables. Maximum is 81920 bytes.

If your sketch gets to be more than 50% of program space, OTA won't work.

Is that to ensure that one working copy remains if the new one fails?