Due to high demand, expect some shipping delays at this time - orders may not ship for up to 2-3 business days.
0

Metro ESP32-S2 complete looses it's code
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Metro ESP32-S2 complete looses it's code

by jfabernathy on Fri Jan 21, 2022 8:18 am

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 | TOGGLE FULL SIZE
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.

jfabernathy
 
Posts: 108
Joined: Thu Dec 17, 2020 10:58 pm

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

by dastels on Fri Jan 21, 2022 9:44 am

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

Dave

dastels
 
Posts: 9782
Joined: Tue Oct 20, 2015 3:22 pm

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

by jfabernathy on Fri Jan 21, 2022 9:57 am

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.

jfabernathy
 
Posts: 108
Joined: Thu Dec 17, 2020 10:58 pm

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

by dastels on Fri Jan 21, 2022 1:58 pm

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

dastels
 
Posts: 9782
Joined: Tue Oct 20, 2015 3:22 pm

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

by jfabernathy on Fri Jan 21, 2022 3:06 pm

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.

jfabernathy
 
Posts: 108
Joined: Thu Dec 17, 2020 10:58 pm

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

by dastels on Fri Jan 21, 2022 3:32 pm

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

dastels
 
Posts: 9782
Joined: Tue Oct 20, 2015 3:22 pm

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

by jfabernathy on Fri Jan 21, 2022 4:26 pm

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.

jfabernathy
 
Posts: 108
Joined: Thu Dec 17, 2020 10:58 pm

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

by dastels on Fri Jan 21, 2022 4:58 pm

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

dastels
 
Posts: 9782
Joined: Tue Oct 20, 2015 3:22 pm

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

by jfabernathy on Sat Jan 22, 2022 12:47 pm

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.

jfabernathy
 
Posts: 108
Joined: Thu Dec 17, 2020 10:58 pm

Please be positive and constructive with your questions and comments.