From d91b18080b8251766a65b38930d676440e5070c9 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 16 Oct 2018 12:46:17 +0800 Subject: [PATCH 1/2] unit test: split psram config into two configs to free up IRAM --- tools/unit-test-app/configs/psram | 2 +- tools/unit-test-app/configs/psram_2 | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tools/unit-test-app/configs/psram_2 diff --git a/tools/unit-test-app/configs/psram b/tools/unit-test-app/configs/psram index 03380b2d4..541bff574 100644 --- a/tools/unit-test-app/configs/psram +++ b/tools/unit-test-app/configs/psram @@ -1,3 +1,3 @@ -TEST_EXCLUDE_COMPONENTS=libsodium bt app_update +TEST_EXCLUDE_COMPONENTS=libsodium bt app_update driver esp32 spi_flash CONFIG_SPIRAM_SUPPORT=y CONFIG_SPIRAM_BANKSWITCH_ENABLE=n diff --git a/tools/unit-test-app/configs/psram_2 b/tools/unit-test-app/configs/psram_2 new file mode 100644 index 000000000..4173606df --- /dev/null +++ b/tools/unit-test-app/configs/psram_2 @@ -0,0 +1,3 @@ +TEST_COMPONENTS=driver esp32 spi_flash +CONFIG_SPIRAM_SUPPORT=y +CONFIG_SPIRAM_BANKSWITCH_ENABLE=n From 49130c6b34af4b1b307d42c5c5ab6510207c7c8c Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Tue, 9 Oct 2018 17:26:14 +0530 Subject: [PATCH 2/2] esp_ringbuf: fix default placement from flash to IRAM In earlier change this component was decoupled from freertos and hence regression was introduced which changed default placement to flash. Some device drivers make use of ringbuffer while flash cache is being disabled and hence default placement should instead be internal memory. Closes: https://github.com/espressif/esp-idf/issues/2517 --- components/esp32/ld/esp32.common.ld | 1 + components/esp_ringbuf/test/test_ringbuf.c | 20 ++++++++++++++++++++ components/freertos/component.mk | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/components/esp32/ld/esp32.common.ld b/components/esp32/ld/esp32.common.ld index 4e8382913..744fbc211 100644 --- a/components/esp32/ld/esp32.common.ld +++ b/components/esp32/ld/esp32.common.ld @@ -153,6 +153,7 @@ SECTIONS /* Code marked as runnning out of IRAM */ _iram_text_start = ABSOLUTE(.); *(.iram1 .iram1.*) + *libesp_ringbuf.a:(.literal .text .literal.* .text.*) *libfreertos.a:(.literal .text .literal.* .text.*) *libheap.a:multi_heap.*(.literal .text .literal.* .text.*) *libheap.a:multi_heap_poisoning.*(.literal .text .literal.* .text.*) diff --git a/components/esp_ringbuf/test/test_ringbuf.c b/components/esp_ringbuf/test/test_ringbuf.c index e47512d8e..013685f4f 100644 --- a/components/esp_ringbuf/test/test_ringbuf.c +++ b/components/esp_ringbuf/test/test_ringbuf.c @@ -6,6 +6,7 @@ #include "freertos/semphr.h" #include "freertos/ringbuf.h" #include "driver/timer.h" +#include "esp_spi_flash.h" #include "unity.h" //Definitions used in multiple test cases @@ -604,3 +605,22 @@ TEST_CASE("Test ring buffer SMP", "[freertos]") vSemaphoreDelete(rx_done); vSemaphoreDelete(tasks_done); } + +static IRAM_ATTR __attribute__((noinline)) bool iram_ringbuf_test() +{ + bool result = true; + + spi_flash_guard_get()->start(); // Disables flash cache + RingbufHandle_t handle = xRingbufferCreate(CONT_DATA_TEST_BUFF_LEN, RINGBUF_TYPE_NOSPLIT); + result = result && (handle != NULL); + xRingbufferGetMaxItemSize(handle); + vRingbufferDelete(handle); + spi_flash_guard_get()->end(); // Re-enables flash cache + + return result; +} + +TEST_CASE("Test ringbuffer functions work with flash cache disabled", "[freertos]") +{ + TEST_ASSERT( iram_ringbuf_test() ); +} diff --git a/components/freertos/component.mk b/components/freertos/component.mk index a10f84d80..375ee5ae8 100644 --- a/components/freertos/component.mk +++ b/components/freertos/component.mk @@ -6,4 +6,4 @@ COMPONENT_ADD_LDFLAGS += -Wl,--undefined=uxTopUsedPriority COMPONENT_ADD_INCLUDEDIRS := include COMPONENT_PRIV_INCLUDEDIRS := include/freertos -tasks.o event_groups.o timers.o queue.o ringbuf.o: CFLAGS += -D_ESP_FREERTOS_INTERNAL +tasks.o event_groups.o timers.o queue.o: CFLAGS += -D_ESP_FREERTOS_INTERNAL