Metro ESP32-S2 complete looses it's code

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jfabernathy
 
Posts: 110
Joined: Thu Dec 17, 2020 10:58 pm

Metro ESP32-S2 complete looses it's code

Post by jfabernathy »

I've been using Circuit Python 6/7 on a Metro ESP32-S2 Express board for almost a year. I actually have 2 running similar code, but the one in question is not running off of battery so when power fails in the house it's off until it gets power again.

2 times recently when power failed in the house, I noticed that the Metro was not publishing any data after the power was restored. When I plugged it up to my PC and checked the CIRCUITPY drive, code.py file had the "hello world" program and no libraries. Only other file on the Metro was the boot_out.txt which contains:

Code: Select all

Adafruit CircuitPython 7.0.0 on 2021-09-20; Adafruit Metro ESP32S2 with ESP32S2
Board ID:adafruit_metro_esp32s2
Any idea what is causing this? I have to save and eject the Metro to move it to it use location where it powers on again and works until it looses it code.

User avatar
dastels
 
Posts: 15817
Joined: Tue Oct 20, 2015 3:22 pm

Re: Metro ESP32-S2 complete looses it's code

Post by dastels »

Is this loosing of the code correlated to the power going out?

Dave

User avatar
jfabernathy
 
Posts: 110
Joined: Thu Dec 17, 2020 10:58 pm

Re: Metro ESP32-S2 complete looses it's code

Post by jfabernathy »

dastels wrote:Is this loosing of the code correlated to the power going out?

Dave
Exactly, The Metro is part of my environmental data gather system and all the other micro-controller kept running and posted data after a restart, I noticed the Metro's data was not getting posted later in the day and I could look at the graph and see the data stopped at the time of the 20 second power outage. This particular Metro has been running this code with minor changes since last February. But the last two power off situations have cleared the code and libraries without messing with Circuitpython itself.

User avatar
dastels
 
Posts: 15817
Joined: Tue Oct 20, 2015 3:22 pm

Re: Metro ESP32-S2 complete looses it's code

Post by dastels »

It could have caused a mess on the power line, glitches and such, that caused a very low level restart. I recommend a battery backup to avoid the problem. Possibly with a way to notice the blackout and do a clean shutdown.

Dave

User avatar
jfabernathy
 
Posts: 110
Joined: Thu Dec 17, 2020 10:58 pm

Re: Metro ESP32-S2 complete looses it's code

Post by jfabernathy »

I don't think it's a need for a battery. This application does a deep sleep every minute and those resets have no issues. This all started after I upgraded the CP from version 6 to version 7.

User avatar
dastels
 
Posts: 15817
Joined: Tue Oct 20, 2015 3:22 pm

Re: Metro ESP32-S2 complete looses it's code

Post by dastels »

Interesting. I wonder if there have been changes to the sleep code or the deep reset code. Possibly the filesystem got scrambled and CP rebuilt it when it came back up.
Does this happen predictably (I know power disruption is unpredictable).

Dave

User avatar
jfabernathy
 
Posts: 110
Joined: Thu Dec 17, 2020 10:58 pm

Re: Metro ESP32-S2 complete looses it's code

Post by jfabernathy »

Power glitches are rare around here but we had 2 this week due to some construction. These are the only cases I've had. Normally I unplug the Metro without issue which should be the same condition. I use a watchdog timer that resets the system if it can't connect to the WiFi and that works and has no effect on the code disappearing. The only change has been recent update of the CP version and the matching libraries.

I have the same program written in Arduino for my ESP32 Huzzah. I might try putting Arduino on the ESP32-S2 and see if the problem goes away.

I was hoping someone else had seen this problem and a solution was known.

User avatar
dastels
 
Posts: 15817
Joined: Tue Oct 20, 2015 3:22 pm

Re: Metro ESP32-S2 complete looses it's code

Post by dastels »

Code in C++ should be far more robust as it's directly in flash without having to be read/loaded from a flash filesystem. I'm guessing that either when the power went out or (more likely) came back on there was a glitch/surge that the Metro didn't appreciate. I doubt you'd see that unplugging/plugging the wall supply.

Dave

User avatar
jfabernathy
 
Posts: 110
Joined: Thu Dec 17, 2020 10:58 pm

Re: Metro ESP32-S2 complete looses it's code

Post by jfabernathy »

I did have it erase all it's code without a power glitch or unplugging. So this morning I replaced the CP with v7.1.1.

So far it's working.

Locked
Please be positive and constructive with your questions and comments.

Return to “Metro, Metro Express, and Grand Central Boards”