Răsfoiți Sursa

Merge branch 'bugfix/move_ringbuf_lib_to_iram' into 'master'

esp_ringbuf: fix default placement from flash to IRAM

See merge request idf/esp-idf!3452
Ivan Grokhotkov 7 ani în urmă
părinte
comite
c76f71cd5f

+ 1 - 0
components/esp32/ld/esp32.common.ld

@@ -153,6 +153,7 @@ SECTIONS
     /* Code marked as runnning out of IRAM */
     /* Code marked as runnning out of IRAM */
     _iram_text_start = ABSOLUTE(.);
     _iram_text_start = ABSOLUTE(.);
     *(.iram1 .iram1.*)
     *(.iram1 .iram1.*)
+    *libesp_ringbuf.a:(.literal .text .literal.* .text.*)
     *libfreertos.a:(.literal .text .literal.* .text.*)
     *libfreertos.a:(.literal .text .literal.* .text.*)
     *libheap.a:multi_heap.*(.literal .text .literal.* .text.*)
     *libheap.a:multi_heap.*(.literal .text .literal.* .text.*)
     *libheap.a:multi_heap_poisoning.*(.literal .text .literal.* .text.*)
     *libheap.a:multi_heap_poisoning.*(.literal .text .literal.* .text.*)

+ 20 - 0
components/esp_ringbuf/test/test_ringbuf.c

@@ -6,6 +6,7 @@
 #include "freertos/semphr.h"
 #include "freertos/semphr.h"
 #include "freertos/ringbuf.h"
 #include "freertos/ringbuf.h"
 #include "driver/timer.h"
 #include "driver/timer.h"
+#include "esp_spi_flash.h"
 #include "unity.h"
 #include "unity.h"
 
 
 //Definitions used in multiple test cases
 //Definitions used in multiple test cases
@@ -604,3 +605,22 @@ TEST_CASE("Test ring buffer SMP", "[freertos]")
     vSemaphoreDelete(rx_done);
     vSemaphoreDelete(rx_done);
     vSemaphoreDelete(tasks_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() );
+}

+ 1 - 1
components/freertos/component.mk

@@ -6,4 +6,4 @@ COMPONENT_ADD_LDFLAGS += -Wl,--undefined=uxTopUsedPriority
 COMPONENT_ADD_INCLUDEDIRS := include
 COMPONENT_ADD_INCLUDEDIRS := include
 COMPONENT_PRIV_INCLUDEDIRS := include/freertos
 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

+ 1 - 1
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_SUPPORT=y
 CONFIG_SPIRAM_BANKSWITCH_ENABLE=n
 CONFIG_SPIRAM_BANKSWITCH_ENABLE=n

+ 3 - 0
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