s60sc / ESP32-CAM_MJPEG2SD

ESP32 Camera motion capture application to record JPEGs to SD card as AVI files and stream to browser as MJPEG. If a microphone is installed then a WAV file is also created. Files can be uploaded via FTP or downloaded to browser.
GNU Affero General Public License v3.0
939 stars 216 forks source link

(not really code related): Imrove StatUp of esp when powered by UPS - to often "crash loop detected..." #498

Closed vermoi63 closed 1 month ago

vermoi63 commented 1 month ago

Some Ideas on this - perhaps solution by software possible?

I'm powering the AI Thinker board with a battery extension pack as a UPS...UPS powering by PV...

Config: PVmodule with USBout --> Bat. extensionPack with Lion --> USBout --> esp32CAM dev board (including USB part of board)

Behavior: works fine in general..esp32 running on bat-power and bat can be charged at any time without esp down

BUT: when the bat goes emty it cuts the power to the esp - also fine Once I recharge the bat with PV or Powerbank the esp is immediately powered.....and shows "startup failure...loop crash..." And from this state it never comes up again unattended!!!

Assumption: in the very eary stage of recharging the bat unfortunately the extension pack immediately provides an USBout but my not yet be able (due to SoC) to drive the esp fully....this my lead to the coded startup failure:

Solutions? (sure Issue is that UPS goes up on USB out to eary)

but as the code seems to run already (as crash loop can be reported via WLAN to browser.....the esp is not fully dead - so there may be a software solution for this?'

Ideas:

Thanks for any idea on software-solution (or if required) hardware solution

P.S. it may be a hint for a solution stating that once the esp is in that mode of too early boot with bad power and printing WARN crash loop........AFTER a while (until bat-power seems good enough) pressing the RST button on the Dev board is enough to start properly - so a complete power off/on on the esp is not required...

s60sc commented 1 month ago

Your power supply should not start up the esp until the battery has sufficient charge - that is why it crash loops, so use a more intelligent supply. You can reboot from a crash loop remotely by entering your ip/control?reset=1 in the browser, but if the problem hasnt been fixed it will just crash again I'll add a reboot button to the warning in the next release.

vermoi63 commented 1 month ago

Tks for fast reply!

Sure you are right about the root cause - I though as long as the Code has control on the CPU there could be a automatic workaround...examples I wrote...lopping until it works, sleep a while, but how to wake up?....or anything like this

yes the esp is powered up to early - BUT code is running already! so I need something that retries proper restart automatically as the device shall be unattended and should go by itself ON.

It is about 10 mins - 30 mins I need to wait until net try, that it works (which is also show by the fact that in this un-proper state a RST is ok (no need to cut power OFF

Sure I want to solve something at the wrong place, but such a UPS is very cheap...

Perhaps I can somehow use your idea that in this state the code is still under control and a external WEB call can force a retry...but this requires something externally....hmmmmm?

Thanks, and I'm still interested in ideas to solve my problem even at the wrong place.

-as mentioned perhaps putting the USB/UART part away from the Dev.board may help as it also sucks current (I did not yet try) OR

Thanks again for sharing all you precious work with us!

vermoi63 commented 1 month ago

add: idea could be......adding a retry-count (param1) for a automatical restart after a while/time (param2) that can be configure!

my delay(..) and than ESP.restart after your code did not work - I assume simply becaue it is blocking, so perhaps it work non-blocking...

this could be an idea for UNATTENDED devices somewhere in the field with self-healing :-)

rjsachse commented 1 month ago

In Arduino ide what core do you have set for Arduino runs on core:? and Events runs on core:?

vermoi63 commented 1 month ago

Final: can't solve this HW issue by SW... but can use the WEB request for reset control and the fact that in advance to powerdown code get brownout where I can at least react on

Greatings!