Hi All,
I have in the field multiple ESP32 devices running. These devices measure some stuff, and report back the values every 10 seconds.
Now I have notices sometimes these device lose internet connection, or reboot after days of operation. Now my question is: is there some way of logging these reboots? So I can examine the exception thrown?
I don't now if this is possible, and what the best approach would be. Now I need to 'guess' the reason way the device rebooted, and I have no clue.
Best regards,
Peter
Logging reboots
-
- Posts: 76
- Joined: Tue May 29, 2018 8:00 pm
Re: Logging reboots
You can use rtc_get_reset_reason() to get some idea of why the reset occurred.
See table 9 in the tech reference manual for the values this can take:
https://www.espressif.com/sites/default ... ual_en.pdf
But, beware the spurious resets which may be generated:
https://github.com/espressif/esp-idf/is ... -291916959
You could also do something more sophisticated where you keep some state information in RAM at a known location, and then look for that at boot time prior to initialization that may overwrite the RAM. On many architectures, the RAM is not initialized at reset/boot, but only by later initialization code. I'm not sure about ESP32's behavior in this regard. I would suspect that you need to write a little bit of code in assembler in the bootloader, but an expert could better advise you there.
Of course, if its a power supply dropout, you may not have any info persist the reset. (And attempting to write to flash during a brownout is not advisable!)
See table 9 in the tech reference manual for the values this can take:
https://www.espressif.com/sites/default ... ual_en.pdf
But, beware the spurious resets which may be generated:
https://github.com/espressif/esp-idf/is ... -291916959
You could also do something more sophisticated where you keep some state information in RAM at a known location, and then look for that at boot time prior to initialization that may overwrite the RAM. On many architectures, the RAM is not initialized at reset/boot, but only by later initialization code. I'm not sure about ESP32's behavior in this regard. I would suspect that you need to write a little bit of code in assembler in the bootloader, but an expert could better advise you there.
Of course, if its a power supply dropout, you may not have any info persist the reset. (And attempting to write to flash during a brownout is not advisable!)
Re: Logging reboots
Thanks,
I will look into this!
I will look into this!
Who is online
Users browsing this forum: Marcosss and 134 guests