Merge branch 'bugfix/customer_baidu_psram_stack_backtrace_v3.3' into 'release/v3.3'

backport v3.3: added psram stack check in backtrace

See merge request espressif/esp-idf!8460
This commit is contained in:
Jiang Jiang Jian 2020-11-12 21:01:12 +08:00
commit 68b237fe53
2 changed files with 28 additions and 1 deletions

View File

@ -20,6 +20,7 @@ extern "C"
#ifndef __ASSEMBLER__
#include "esp_err.h"
#include "soc/soc.h"
/**
@ -61,12 +62,36 @@ esp_err_t esp_set_watchpoint(int no, void *adr, int size, int flags);
*/
void esp_clear_watchpoint(int no);
/**
* @brief Checks stack pointer in dram
*/
inline static bool esp_stack_ptr_in_dram(uint32_t sp)
{
//Check if stack ptr is in between SOC_DRAM_LOW and SOC_DRAM_HIGH, and 16 byte aligned.
return !(sp < SOC_DRAM_LOW + 0x10 || sp > SOC_DRAM_HIGH - 0x10 || ((sp & 0xF) != 0));
}
#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
/**
* @brief Checks stack pointer in external ram
*/
inline static bool esp_stack_ptr_in_extram(uint32_t sp)
{
//Check if stack ptr is in between SOC_EXTRAM_DATA_LOW and SOC_EXTRAM_DATA_HIGH, and 16 byte aligned.
return !(sp < SOC_EXTRAM_DATA_LOW + 0x10 || sp > SOC_EXTRAM_DATA_HIGH - 0x10 || ((sp & 0xF) != 0));
}
#endif
/**
* @brief Checks stack pointer
*/
static inline bool esp_stack_ptr_is_sane(uint32_t sp)
{
return !(sp < 0x3ffae010UL || sp > 0x3ffffff0UL || ((sp & 0xf) != 0));
#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
return (esp_stack_ptr_in_dram(sp) || esp_stack_ptr_in_extram(sp));
#else
return esp_stack_ptr_in_dram(sp);
#endif
}
#endif

View File

@ -92,6 +92,8 @@ void IRAM_ATTR spi_flash_op_block_func(void* arg)
void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu()
{
assert(esp_ptr_in_dram((const void *)get_sp()));
spi_flash_op_lock();
const uint32_t cpuid = xPortGetCoreID();