Logging reboots

kluverp
Posts: 6
Joined: Mon Jun 18, 2018 7:08 am

Logging reboots

Postby kluverp » Mon Jun 18, 2018 7:14 am

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

chrismerck
Posts: 16
Joined: Tue May 29, 2018 8:00 pm

Re: Logging reboots

Postby chrismerck » Mon Jun 18, 2018 8:55 pm

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!)

kluverp
Posts: 6
Joined: Mon Jun 18, 2018 7:08 am

Re: Logging reboots

Postby kluverp » Tue Jun 19, 2018 8:32 am

Thanks,
I will look into this!

Who is online

Users browsing this forum: jcsbanks and 5 guests