Page 1 of 1

Difference between esp_reset_reason() and rtc_get_reset_reason(int cpuNo)

Posted: Mon Jul 31, 2023 1:01 pm
by LGermano
What is the difference between esp_reset_reason() and rtc_get_reset_reason(int cpuNo) for ESP32 and respective descriptions of the return codes of each of the functions?

Re: Difference between esp_reset_reason() and rtc_get_reset_reason(int cpuNo)

Posted: Mon Jul 31, 2023 9:51 pm
by ESP_igrr
esp_reset_reason is a public API provided in IDF, you can find the description here: https://docs.espressif.com/projects/esp ... set-reason


rtc_get_reset_reason is a lower level function implemented in the ROM code, which simply returns the reset reason value captured by the hardware. As such it can't distinguish between various causes of software reset (for example: esp_restart() being called or a CPU exception occurring). Return values of this function are chip-specific, the values can be found in rom/rtc.h header file.

In pretty much every case in an IDF application it is better to use esp_reset_reason().