Skip to content

Commit a73ba52

Browse files
committed
Merge branch 'bugfix/extram_stack_coredump_v4.4' into 'release/v4.4'
coredump: add support for stacks in external RAM (backport v4.4) See merge request espressif/esp-idf!22391
2 parents ae77cd6 + 2ef2271 commit a73ba52

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

components/espcoredump/Kconfig

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ menu "Core dump"
1414

1515
config ESP_COREDUMP_ENABLE_TO_FLASH
1616
bool "Flash"
17-
depends on !SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
1817
select FREERTOS_ENABLE_TASK_SNAPSHOT
1918
select ESP_COREDUMP_ENABLE
2019
config ESP_COREDUMP_ENABLE_TO_UART
@@ -79,10 +78,21 @@ menu "Core dump"
7978
Config delay (in ms) before printing core dump to UART.
8079
Delay can be interrupted by pressing Enter key.
8180

81+
82+
config ESP_COREDUMP_USE_STACK_SIZE
83+
bool
84+
default y if ESP_COREDUMP_ENABLE_TO_FLASH && SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
85+
default n
86+
help
87+
Force the use of a custom DRAM stack for coredump when Task stacks can be in PSRAM.
88+
8289
config ESP_COREDUMP_STACK_SIZE
8390
int "Reserved stack size"
8491
depends on ESP_COREDUMP_ENABLE
85-
default 0
92+
range 0 4096 if !ESP_COREDUMP_USE_STACK_SIZE
93+
range 1280 4096 if ESP_COREDUMP_USE_STACK_SIZE
94+
default 0 if !ESP_COREDUMP_USE_STACK_SIZE
95+
default 1280 if ESP_COREDUMP_USE_STACK_SIZE
8696
help
8797
Size of the memory to be reserved for core dump stack. If 0 core dump process will run on
8898
the stack of crashed task/ISR, otherwise special stack will be allocated.

components/espcoredump/src/core_dump_common.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,13 @@ FORCE_INLINE_ATTR void esp_core_dump_report_stack_usage(void)
121121
esp_core_dump_restore_sp(&s_stack_context);
122122
}
123123

124-
#else
124+
#else // CONFIG_ESP_COREDUMP_STACK_SIZE > 0
125+
126+
/* Here, we are not going to use a custom stack for coredump. Make sure the current configuration doesn't require one. */
127+
#if CONFIG_ESP_COREDUMP_USE_STACK_SIZE
128+
#pragma error "CONFIG_ESP_COREDUMP_STACK_SIZE must not be 0 in the current configuration"
129+
#endif // ESP_COREDUMP_USE_STACK_SIZE
130+
125131
FORCE_INLINE_ATTR void esp_core_dump_setup_stack(void)
126132
{
127133
/* If we are in ISR set watchpoint to the end of ISR stack */
@@ -139,7 +145,7 @@ FORCE_INLINE_ATTR void esp_core_dump_setup_stack(void)
139145
FORCE_INLINE_ATTR void esp_core_dump_report_stack_usage(void)
140146
{
141147
}
142-
#endif
148+
#endif // CONFIG_ESP_COREDUMP_STACK_SIZE > 0
143149

144150
static void* s_exc_frame = NULL;
145151

components/espcoredump/src/port/riscv/core_dump_port.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,10 @@ bool esp_core_dump_check_task(core_dump_task_header_t *task)
312312
*/
313313
bool esp_core_dump_mem_seg_is_sane(uint32_t addr, uint32_t sz)
314314
{
315-
//TODO: external SRAM not supported yet
316315
return (esp_ptr_in_dram((void *)addr) && esp_ptr_in_dram((void *)(addr+sz-1)))
317316
|| (esp_ptr_in_rtc_slow((void *)addr) && esp_ptr_in_rtc_slow((void *)(addr+sz-1)))
318317
|| (esp_ptr_in_rtc_dram_fast((void *)addr) && esp_ptr_in_rtc_dram_fast((void *)(addr+sz-1)))
318+
|| (esp_ptr_external_ram((void *)addr) && esp_ptr_external_ram((void *)(addr+sz-1)))
319319
|| (esp_ptr_in_iram((void *)addr) && esp_ptr_in_iram((void *)(addr+sz-1)));
320320
}
321321

components/espcoredump/src/port/xtensa/core_dump_port.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,10 @@ bool esp_core_dump_check_stack(core_dump_task_header_t *task)
324324
*/
325325
bool esp_core_dump_mem_seg_is_sane(uint32_t addr, uint32_t sz)
326326
{
327-
//TODO: external SRAM not supported yet
328327
return (esp_ptr_in_dram((void *)addr) && esp_ptr_in_dram((void *)(addr+sz-1)))
329328
|| (esp_ptr_in_rtc_slow((void *)addr) && esp_ptr_in_rtc_slow((void *)(addr+sz-1)))
330329
|| (esp_ptr_in_rtc_dram_fast((void *)addr) && esp_ptr_in_rtc_dram_fast((void *)(addr+sz-1)))
330+
|| (esp_ptr_external_ram((void *)addr) && esp_ptr_external_ram((void *)(addr+sz-1)))
331331
|| (esp_ptr_in_iram((void *)addr) && esp_ptr_in_iram((void *)(addr+sz-1)));
332332
}
333333

components/spi_flash/spi_flash_os_func_noos.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ static IRAM_ATTR esp_err_t start(void *arg)
6969
static IRAM_ATTR esp_err_t end(void *arg)
7070
{
7171
#if CONFIG_IDF_TARGET_ESP32
72-
Cache_Flush(0);
73-
Cache_Flush(1);
7472
Cache_Read_Enable(0);
7573
Cache_Read_Enable(1);
7674
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3

0 commit comments

Comments
 (0)