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

ota: detect Tasmota magic numbers when booting #2370

Merged
merged 1 commit into from
Sep 27, 2020

Conversation

mcspr
Copy link
Collaborator

@mcspr mcspr commented Sep 27, 2020

Some magic to allow seamless Tasmota OTA upgrades

  • inject dummy data sequence that is expected to hold current version info
  • check rtcmem markers and purge settings, since we don't want accidentally reading something as a kv
  • sometimes we cannot boot b/c of certain SDK params, purge last 16KiB as well

ref. SetOption78 1
https://tasmota.github.io/docs/Commands/#setoptions

The original idea from Esphome:
https://github.com/esphome/esphome/blob/0e59243b83913fc724d0229514a84b6ea14717cc/esphome/core/esphal.cpp#L275-L287
Does not seem to be working atm. Will need to re-check with the esphome builder, c/p did not work and I tried building with gcc-10

Specific things we want to do is to have 'version' byte between 2 'marker' bytes:
https://github.com/arendst/Tasmota/blob/217addc2bb2cf46e7633c93e87954b245cb96556/tasmota/settings.ino#L218-L262 https://github.com/arendst/Tasmota/blob/0dfa38df89c8f2a1e582d53d79243881645be0b8/tasmota/i18n.h#L780-L782


Hopefully settings reset helps reliably and does not break things, since I crash 99% of the time after doing:

backlog ssid1 SSID; password1 PASSWORD

And OTA'ing the binary. Right after softAP is brought up, everything halts and device resets after some time
(might be interesting to check with the esp8266/Arduino#7010, since this is a pretty reliable source of WDTs...)

@mcspr
Copy link
Collaborator Author

mcspr commented Sep 27, 2020

@alextircovnicu btw I had noticed the sp111 wiki page mentioning setoption78 for tasmota

could you check out these changes without doing it? OTA now should be able to mimic tasmota .bin and also will reset any existing flash settings when encountered

nvm Codacy checks here, it is expected to 'soft-crash' after Tasmota OTA and normally reboot after erasing any persistent settings

@mcspr mcspr merged commit 0586f5d into xoseperez:dev Sep 27, 2020
@mcspr mcspr deleted the ota/tasmota-magics branch September 27, 2020 02:01
@alextircovnicu
Copy link
Contributor

@alextircovnicu btw I had noticed the sp111 wiki page mentioning setoption78 for tasmota

could you check out these changes without doing it? OTA now should be able to mimic tasmota .bin and also will reset any existing flash settings when encountered

nvm Codacy checks here, it is expected to 'soft-crash' after Tasmota OTA and normally reboot after erasing any persistent settings

Sure thing. Tomorrow I will get some new SP111 sockets (for the dishwasher and coffee filter :) ) and I will test it. I don't want to test with the ones that I already flashed - they are now embedded in the bathroom furniture and it is hard for me to get them in case physical action is needed.

@alextircovnicu
Copy link
Contributor

@mcspr, I confirm, this works like a charm. You can now switch from TASMOTA to ESPURNA without setting option 78 to 1.

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

Successfully merging this pull request may close these issues.

2 participants