SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY was always enabled on S2 and S3, but this option is not
compatible with ESP_COREDUMP_ENABLE_TO_FLASH. Make it configurable to allow users to deactive
it so that ESP_COREDUMP_ENABLE_TO_FLASH can be used.
As heap block may be allocated into multiple non-contiguous chunks, to
reserve enough memory for dma/internal usage, we do the malloc in the
step of max available block.
On ESP32 we use this way, this commit follows this way, on ESP32S2 and
ESP32S3