From 1af819d19b907158026cd02f5cbef2bb3c3f853e Mon Sep 17 00:00:00 2001 From: morris Date: Fri, 17 Jan 2020 13:46:34 +0800 Subject: [PATCH] spi: always put spihost handle in SRAM Closes https://github.com/espressif/esp-idf/issues/4635 --- components/driver/spi_master.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/driver/spi_master.c b/components/driver/spi_master.c index 966ecc6ae..c5de80589 100644 --- a/components/driver/spi_master.c +++ b/components/driver/spi_master.c @@ -238,8 +238,8 @@ esp_err_t spi_bus_initialize(spi_host_device_t host, const spi_bus_config_t *bus SPI_CHECK(false, "dma channel already in use", ESP_ERR_INVALID_STATE); } } - - spihost[host]=malloc(sizeof(spi_host_t)); + // spihost contains atomic variables, which should not be put in PSRAM + spihost[host] = heap_caps_malloc(sizeof(spi_host_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); if (spihost[host]==NULL) { ret = ESP_ERR_NO_MEM; goto cleanup;