]> granicus.if.org Git - esp-idf/commitdiff
psram: add test for 4M psram
authorMichael (XIAO Xufeng) <xiaoxufeng@espressif.com>
Tue, 16 Oct 2018 11:06:41 +0000 (19:06 +0800)
committerMichael (XIAO Xufeng) <xiaoxufeng@espressif.com>
Mon, 29 Oct 2018 12:26:30 +0000 (20:26 +0800)
.gitlab-ci.yml
components/esp32/test/CMakeLists.txt
components/esp32/test/component.mk
components/esp32/test/psram_4m/test_4mpsram.c [new file with mode: 0644]
tools/unit-test-app/components/unity/Kconfig
tools/unit-test-app/configs/psram_hspi [new file with mode: 0644]
tools/unit-test-app/configs/psram_vspi [new file with mode: 0644]

index 897e612173f94772392ef17e9a5b855b7840e7b6..cc13757d1e8a8360ece5375494f7448ca6b631d5 100644 (file)
@@ -1313,7 +1313,7 @@ UT_004_13:
     - ESP32_IDF
     - UT_T1_1
     - psram
-    
+
 UT_005_01:
   <<: *unit_test_template
   tags:
@@ -1499,6 +1499,20 @@ UT_012_03:
     - UT_T1_1
     - 8Mpsram
 
+UT_012_04:
+  <<: *unit_test_template
+  tags:
+    - ESP32_IDF
+    - UT_T1_1
+    - 8Mpsram
+
+UT_012_05:
+  <<: *unit_test_template
+  tags:
+    - ESP32_IDF
+    - UT_T1_1
+    - 8Mpsram
+
 UT_601_01:
   <<: *unit_test_template
   tags:
index 3c6373fb9c9afabf9859bbabe9c55e81d173d12b..baaa34309b686512bbccda3d4aef564ea5cde64c 100644 (file)
@@ -1,30 +1,38 @@
-set(COMPONENT_SRCDIRS ".")
-set(COMPONENT_ADD_INCLUDEDIRS ". ${CMAKE_CURRENT_BINARY_DIR}")
+if (CONFIG_TEST_ESP32_SUBTEST_ONLY)
+    set(COMPONENT_SRCDIRS "psram_4m")
+    set(COMPONENT_ADD_INCLUDEDIRS ".")
 
-set(COMPONENT_REQUIRES unity nvs_flash ulp)
+    register_component()
 
-register_component()
+else()
+    set(COMPONENT_SRCDIRS ". psram_4m")
+    set(COMPONENT_ADD_INCLUDEDIRS ". ${CMAKE_CURRENT_BINARY_DIR}")
 
-add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h"
-                COMMAND xxd -i "logo.jpg" "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h"
-                WORKING_DIRECTORY ${COMPONENT_PATH}
-                DEPENDS "${CMAKE_CURRENT_LIST_DIR}/logo.jpg")
+    set(COMPONENT_REQUIRES unity nvs_flash ulp)
 
-# Calculate MD5 value of header file esp_wifi_os_adapter.h
-execute_process(COMMAND md5sum ${IDF_PATH}/components/esp32/include/esp_wifi_os_adapter.h
-                COMMAND cut -c 1-7
-                OUTPUT_VARIABLE WIFI_OS_ADAPTER_MD5
-                OUTPUT_STRIP_TRAILING_WHITESPACE)
+    register_component()
 
-# Calculate MD5 value of header file esp_wifi_crypto_types.h
-execute_process(COMMAND md5sum ${IDF_PATH}/components/esp32/include/esp_wifi_crypto_types.h
-                COMMAND cut -c 1-7
-                OUTPUT_VARIABLE WIFI_CRYPTO_MD5
-                OUTPUT_STRIP_TRAILING_WHITESPACE)
+    add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h"
+                    COMMAND xxd -i "logo.jpg" "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h"
+                    WORKING_DIRECTORY ${COMPONENT_PATH}
+                    DEPENDS "${CMAKE_CURRENT_LIST_DIR}/logo.jpg")
 
-add_definitions(-DWIFI_OS_ADAPTER_MD5=\"${WIFI_OS_ADAPTER_MD5}\")
-add_definitions(-DWIFI_CRYPTO_MD5=\"${WIFI_CRYPTO_MD5}\")
+    # Calculate MD5 value of header file esp_wifi_os_adapter.h
+    execute_process(COMMAND md5sum ${IDF_PATH}/components/esp32/include/esp_wifi_os_adapter.h
+                    COMMAND cut -c 1-7
+                    OUTPUT_VARIABLE WIFI_OS_ADAPTER_MD5
+                    OUTPUT_STRIP_TRAILING_WHITESPACE)
 
-add_custom_target(esp32_test_logo DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h")
+    # Calculate MD5 value of header file esp_wifi_crypto_types.h
+    execute_process(COMMAND md5sum ${IDF_PATH}/components/esp32/include/esp_wifi_crypto_types.h
+                    COMMAND cut -c 1-7
+                    OUTPUT_VARIABLE WIFI_CRYPTO_MD5
+                    OUTPUT_STRIP_TRAILING_WHITESPACE)
 
-add_dependencies(${COMPONENT_NAME} esp32_test_logo)
\ No newline at end of file
+    add_definitions(-DWIFI_OS_ADAPTER_MD5=\"${WIFI_OS_ADAPTER_MD5}\")
+    add_definitions(-DWIFI_CRYPTO_MD5=\"${WIFI_CRYPTO_MD5}\")
+
+    add_custom_target(esp32_test_logo DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h")
+
+    add_dependencies(${COMPONENT_NAME} esp32_test_logo)
+endif()
\ No newline at end of file
index 592b9b9048d1a9e5a77c03724cb465a13375579a..41947b1b7c54acc655a463bbc111a03127c5110b 100644 (file)
@@ -6,7 +6,11 @@ COMPONENT_EXTRA_CLEAN := test_tjpgd_logo.h
 
 COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
 
-COMPONENT_SRCDIRS := . test_vectors
+ifdef CONFIG_TEST_ESP32_SUBTEST_ONLY
+COMPONENT_SRCDIRS := psram_4m
+else
+COMPONENT_SRCDIRS := . test_vectors psram_4m
+endif
 
 # Calculate MD5 value of header file esp_wifi_os_adapter.h
 WIFI_OS_ADAPTER_MD5_VAL=\"$(shell md5sum $(IDF_PATH)/components/esp32/include/esp_wifi_os_adapter.h | cut -c 1-7)\"
diff --git a/components/esp32/test/psram_4m/test_4mpsram.c b/components/esp32/test/psram_4m/test_4mpsram.c
new file mode 100644 (file)
index 0000000..29aef65
--- /dev/null
@@ -0,0 +1,69 @@
+#include "esp_heap_caps.h"
+#include "unity.h"
+#include "esp_log.h"
+#include "driver/spi_common.h"
+
+static const char TAG[] = "test_psram";
+
+static void test_psram_content()
+{
+    const int test_size = 2048;
+    uint32_t *test_area = heap_caps_malloc(test_size, MALLOC_CAP_SPIRAM);
+
+    size_t p;
+    size_t s=test_size;
+    int errct=0;
+    int initial_err=-1;
+    for (p=0; p<(s/sizeof(int)); p+=4) {
+        test_area[p]=p^0xAAAAAAAA;
+    }
+    for (p=0; p<(s/sizeof(int)); p+=4) {
+        if (test_area[p]!=(p^0xAAAAAAAA)) {
+            errct++;
+            if (errct==1) initial_err=p*4;
+        }
+    }
+    if (errct) {
+        ESP_LOGE(TAG, "SPI SRAM memory test fail. %d/%d writes failed, first @ %p\n", errct, s/32, initial_err+test_area);
+        TEST_FAIL();
+    } else {
+        ESP_LOGI(TAG, "SPI SRAM memory test OK");
+    }
+
+    free(test_area);
+}
+
+// NOTE: this unit test rely on the config that PSRAM of 8MB is used only when CONFIG_SPIRAM_BNKSWITCH_ENABLE is set
+TEST_CASE("can use spi when not being used by psram", "[esp32]")
+{
+    spi_host_device_t host;
+#if !CONFIG_SPIRAM_SUPPORT || !CONFIG_SPIRAM_SPEED_80M || CONFIG_SPIRAM_BANKSWITCH_ENABLE
+    //currently all 8M psram don't need more SPI peripherals
+    host = -1;
+#elif CONFIG_SPIRAM_OCCUPY_HSPI_HOST
+    host = HSPI_HOST;
+#elif CONFIG_SPIRAM_OCCUPY_VSPI_HOST
+    host = VSPI_HOST;
+#endif
+
+    bool claim_hspi = spicommon_periph_claim(HSPI_HOST, "ut-hspi");
+    if (claim_hspi) ESP_LOGI(TAG, "HSPI claimed.");
+
+    bool claim_vspi = spicommon_periph_claim(VSPI_HOST, "ut-vspi");
+    if (claim_vspi) ESP_LOGI(TAG, "VSPI claimed.");
+
+    if (host == HSPI_HOST) {
+        TEST_ASSERT(claim_hspi==false);
+        TEST_ASSERT(claim_vspi==true);
+    } else if (host == VSPI_HOST) {
+        TEST_ASSERT(claim_vspi==false);
+        TEST_ASSERT(claim_hspi==true);
+    } else {
+        TEST_ASSERT(claim_hspi==true);
+        TEST_ASSERT(claim_vspi==true);
+    }
+
+#ifdef CONFIG_SPIRAM_SUPPORT
+    test_psram_content();
+#endif
+}
index 642d76f9d5a6c81780a5428d25cdc5ea82cf1007..02ffde126bf40d19935427429f5eab439b24686b 100644 (file)
@@ -13,3 +13,14 @@ config UNITY_FREERTOS_STACK_SIZE
        default 8192
 
 endmenu
+
+menu "Test options"
+
+config TEST_ESP32_SUBTEST_ONLY
+    bool "Test only 4M PSRAM cases for esp32 component"
+    depends on SPIRAM_SUPPORT
+    default n
+    help
+        If this option is enabled, only 4M PSRAM cases are compiled. Otherwise all cases are included.
+
+endmenu
diff --git a/tools/unit-test-app/configs/psram_hspi b/tools/unit-test-app/configs/psram_hspi
new file mode 100644 (file)
index 0000000..1e4583c
--- /dev/null
@@ -0,0 +1,6 @@
+TEST_COMPONENTS=esp32
+CONFIG_TEST_ESP32_SUBTEST_ONLY=y
+CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
+CONFIG_SPIRAM_SUPPORT=y
+CONFIG_SPIRAM_SPEED_80M=y
+CONFIG_SPIRAM_OCCUPY_HSPI_HOST=y
diff --git a/tools/unit-test-app/configs/psram_vspi b/tools/unit-test-app/configs/psram_vspi
new file mode 100644 (file)
index 0000000..73bbd48
--- /dev/null
@@ -0,0 +1,6 @@
+TEST_COMPONENTS=esp32
+CONFIG_TEST_ESP32_SUBTEST_ONLY=y
+CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
+CONFIG_SPIRAM_SUPPORT=y
+CONFIG_SPIRAM_SPEED_80M=y
+CONFIG_SPIRAM_OCCUPY_VSPI_HOST=y