ESP32-S3 Feather losing the function

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
tenapier
 
Posts: 18
Joined: Mon Feb 04, 2019 11:48 am

ESP32-S3 Feather losing the function

Post by tenapier »

Have been playing with some ESP32-S3 Feathers (8M Flash, No PSRAM) and they seem to lose the code function and need to be reset frequently. I am just experimenting with using an e-paper display, BME280, and LEDs, and the ESP32-S3 (with Arduino code) will boot, load the code, and function great, for a while. Then it checks out and looses the function of the code, and this occurs with using the USB for power, and drops USB debug feedback, and/or with a 3.3 volt power supply to the 3.3 volt pin and GND, (unplugged from USB). Once unpowered (or sometimes reset) and re-powered, it will work again for a while. Doesn’t seem to be an e-paper issue, as the LEDs also lose function. Any help or suggestions appreciated.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: ESP32-S3 Feather losing the function

Post by adafruit_support_mike »

Without specific symptoms, I'd guess you're seeing either a memory issue or a timing issue.

Microcontrollers have a fairly small amount of RAM by today's computing standards, and it's possible to fill it completely. It's also possible for code that allocates and releases memory frequently to end up with chunks of unused memory between data structures that are still in use, called 'memory fragmentation'. Worst of all is code that allocates memory but doesn't release it properly, leaving chunks that aren't being used but can't be reallocated, called a 'memory leak'.

In all cases, when the microcontroller runs out of available RAM the code will hang because it can't get the resources it needs. Random failures after a certain amount of time running are a common symptom of a memory overflow.

The ESP8266 and ESP32 have another way to fail because they both run simple operating systems. The OS spends some time running your code, and some time running firmware that keeps all the radios happy. If the OS can't run the radio firmware often enough, it declares a timeout fault and hangs.

The OS uses a policy called 'cooperative multitasking' where your code periodically agrees to give the radio firmware a turn. That's handled by the yield() function, which is baked into the lower layers of the Arduino code so you usually get correct behavior for free.

Sometimes a piece of code will loop in a way that doesn't call yield(), and the loop will last long enough to make the OS hang. That can occur at almost any time, regardless of how long the code has been running. The OS prints an error message when it does hang, so you might be able to spot that in a Serial Monitor trace.

User avatar
tenapier
 
Posts: 18
Joined: Mon Feb 04, 2019 11:48 am

Re: ESP32-S3 Feather losing the function

Post by tenapier »

Thanks Mike for your reply and the education. Do you have any recommendations for work-arounds, or perhaps other development boards/microcontrollers that do better with this problem? Most of my experience is with ESP32 Dev Modules and ESP8266 to utilize WiFi capabilities.Thanks again!!

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: ESP32-S3 Feather losing the function

Post by adafruit_support_mike »

Based on generalizations? No.

Debugging is about details. Memory leaks will swamp any hardware eventually, so moving to another platform just changes the timing of the failures. Look around for code that reports the amount of free memory your microcontroller has, and check it periodically to see if the number keeps getting smaller. If so, you have a memory leak.

For any kind of failure, the first step is to look for patterns and related details. Being able to make a system fail on demand is almost as good as fixing the bug because you know where to look. That involves trying everything until you begin to see patterns.

One general technique is to tear down your code one small piece at a time. Save what you have as a backup, start with a new copy, and start deleting things. Try to keep each deletion small, then run the code to see if it still crashes. If it does, snip out another small piece.

Once you get to a version that doesn't crash, add back the pieces you removed, but in a different order. If the code stops crashing after you've removed A, B, C, D, and E (in that order), try adding A back to see what happens. Then clip that out and try B, and so on. Every new combination gives you more information to help isolate the problem.

User avatar
tenapier
 
Posts: 18
Joined: Mon Feb 04, 2019 11:48 am

Re: ESP32-S3 Feather losing the function

Post by tenapier »

Again, thanks so much for the education!! Will start with your recommended approach, and try to read more about “memory leaks”, it’s a new one on me, but, I’m a grateful and ever present newbie to this science and art. It’s wonderful stuff, and thank you for your help with it!!

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

Return to “Microcontrollers”