Detect if new software flashed

0xffff
Posts: 41
Joined: Tue Jun 19, 2018 1:53 am

Detect if new software flashed

Postby 0xffff » Wed Jul 11, 2018 5:47 pm

Hi,

Is there a way to detect if new software has been flashed to the system? That is, upon restart, I would like to check if this is brand new software, and if so, take certain actions. I think I can save some kind of build number to nv ram, and then check on boot if the build number is the same as the last one, but I wonder if there is already a facility provided.

Thanks

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Detect if new software flashed

Postby kolban » Wed Jul 11, 2018 6:09 pm

Ive not heard of such a capability. However, if you generate a hash of the content of the executing partition and save it in NVS then the next time you start you can compute the hash again and see if it matches what was previously saved.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Detect if new software flashed

Postby fly135 » Wed Jul 11, 2018 7:06 pm

Just put a print statement in your code to print the version that you called it and look at it with a terminal program. To be quite frank, your explanation of your problem is woefully lacking. Hence wondering why you don't know if you did or didn't flash new software to the ESP32.

John A

michprev
Posts: 92
Joined: Fri Aug 04, 2017 8:57 pm

Re: Detect if new software flashed

Postby michprev » Wed Jul 11, 2018 7:13 pm

In fact there probably is SHA256 checksum of ESP image in flash so you don't have to compute it. Take a look at https://github.com/espressif/esp-idf/bl ... e_format.c. Unfortunately there is no note about it here https://github.com/espressif/esptool/wi ... age-Format.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Detect if new software flashed

Postby ESP_Angus » Thu Jul 12, 2018 1:04 am

We're adding an API to return this SHA value as part of IDF v3.2. This will give you a canonical identifier for the app.

However if you actually want to do version updates (ie migrate some NVS schema, or set some values when a new version is loaded) then I suggest adding a version constant somewhere in your app and check it. You can save the last loaded version in NVS as an integer, and compare to the version compiled into the running app.

0xffff
Posts: 41
Joined: Tue Jun 19, 2018 1:53 am

Re: Detect if new software flashed

Postby 0xffff » Thu Jul 12, 2018 6:26 am

Thanks, sounds like until 3.2 easiest thing is to save a build/version number to nvs and then check upon boot.

Who is online

Users browsing this forum: No registered users and 74 guests