mirror of
https://github.com/espressif/esp-idf.git
synced 2026-05-04 20:05:25 +02:00
reset_reason: fix setting wake stub entry point to 0x80000000
esp_reset_reason_init would check for reset reason hint, and unconditionally set RTC_RESET_CAUSE_REG (which is also RTC_ENTRY_ADDR_REG) to hint value 0, i.e. 0x80000000. However the ROM code treats this value as valid deep sleep wake stub entry point, and tries to jump to it. Clear RTC_RESET_CAUSE_REG only if it contained a valid reset reason hint, and simply set the register value to 0 when doing so. Also add a check to esp_get_deep_sleep_wake_stub function that deep sleep wake stub entry address must be in IRAM. Reported in https://esp32.com/viewtopic.php?f=13&t=6919.
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
#include "rom/rtc.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
|
||||
static void esp_reset_reason_clear_hint();
|
||||
|
||||
static esp_reset_reason_t s_reset_reason;
|
||||
|
||||
static esp_reset_reason_t get_reset_reason(RESET_REASON rtc_reset_reason, esp_reset_reason_t reset_reason_hint)
|
||||
@@ -69,9 +71,12 @@ static esp_reset_reason_t get_reset_reason(RESET_REASON rtc_reset_reason, esp_re
|
||||
|
||||
static void __attribute__((constructor)) esp_reset_reason_init(void)
|
||||
{
|
||||
esp_reset_reason_t hint = esp_reset_reason_get_hint();
|
||||
s_reset_reason = get_reset_reason(rtc_get_reset_reason(PRO_CPU_NUM),
|
||||
esp_reset_reason_get_hint());
|
||||
esp_reset_reason_set_hint(ESP_RST_UNKNOWN);
|
||||
hint);
|
||||
if (hint != ESP_RST_UNKNOWN) {
|
||||
esp_reset_reason_clear_hint();
|
||||
}
|
||||
}
|
||||
|
||||
esp_reset_reason_t esp_reset_reason(void)
|
||||
@@ -114,3 +119,8 @@ esp_reset_reason_t IRAM_ATTR esp_reset_reason_get_hint(void)
|
||||
}
|
||||
return (esp_reset_reason_t) low;
|
||||
}
|
||||
static void esp_reset_reason_clear_hint()
|
||||
{
|
||||
REG_WRITE(RTC_RESET_CAUSE_REG, 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user