Page 1 of 1
How to detect ESP restart from upgrade
Posted: Tue Mar 05, 2024 7:32 am
by Jimis1
Hi
I'm trying to check whether the ESP has reset from an upgrade (USB or OTA) to reset my "reset_counter" variable which is stored in flash.
I tried to detect that from the response from the function nvs_get(). If I get a "value not initialized" then it means I had a code upgrade and I should reset the "reset_counter" variable. But it seems that after I upgrade my code this variable is still initialized !
Can someone help ?
- Screenshot_2.jpg (35.54 KiB) Viewed 2874 times
Re: How to detect ESP restart from upgrade
Posted: Tue Mar 05, 2024 8:05 am
by MicroController
How about storing a "firmware version" in NVS?
If versionFromNvs != thisAppsVersion then there was an 'upgrade'.
Re: How to detect ESP restart from upgrade
Posted: Tue Mar 05, 2024 8:45 am
by Jimis1
Yes I have thought of that, but I was looking for something non-user dependent (during testing you don't change versions all the time).
If there is no other way I will do it this way, I just thought that it should work this way
For example ATMEL μCs have a register that defines the reason of a reset (WD,brown-out,external etc)
Re: How to detect ESP restart from upgrade
Posted: Tue Mar 05, 2024 10:17 am
by MicroController
Jimis1 wrote: ↑Tue Mar 05, 2024 8:45 am
Yes I have thought of that, but I was looking for something non-user dependent (during testing you don't change versions all the time).
esp_app_get_description() could help.
For example ATMEL μCs have a register that defines the reason of a reset (WD,brown-out,external etc)
->
https://docs.espressif.com/projects/esp ... set-reason
But that's probably of no use in your case.
Re: How to detect ESP restart from upgrade
Posted: Fri Mar 08, 2024 10:47 pm
by mikemoy
Yes I have thought of that, but I was looking for something non-user dependent (during testing you don't change versions all the time).
What about running a checksum on the flash, and comparing that value to the last value saved.
Re: How to detect ESP restart from upgrade
Posted: Fri Mar 08, 2024 10:48 pm
by mikemoy
Yes I have thought of that, but I was looking for something non-user dependent (during testing you don't change versions all the time).
What about running a checksum on the flash, and comparing that value to the last value saved.
Re: How to detect ESP restart from upgrade
Posted: Fri Mar 08, 2024 10:48 pm
by mikemoy
Yes I have thought of that, but I was looking for something non-user dependent (during testing you don't change versions all the time).
What about running a checksum on the flash, and comparing that value to the last value saved.
Re: How to detect ESP restart from upgrade
Posted: Sun Mar 10, 2024 12:14 pm
by Jimis1
Thanks all ! I will have to implement one of the above