From ef281dff5aace565e2542c2c09c1fd96914ebf4e Mon Sep 17 00:00:00 2001 From: Song Ruo Jing Date: Wed, 22 Nov 2023 19:19:42 +0800 Subject: [PATCH] fix(esp_driver_uart): always use heap_caps_malloc to malloc memory base on flags --- components/esp_driver_uart/src/uart.c | 3 +-- .../test_apps/uart/main/CMakeLists.txt | 2 +- .../esp_driver_uart/test_apps/uart/pytest_uart.py | 15 +++++++++++++++ .../test_apps/uart/sdkconfig.defaults.esp32s3 | 4 ++++ 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 components/esp_driver_uart/test_apps/uart/sdkconfig.defaults.esp32s3 diff --git a/components/esp_driver_uart/src/uart.c b/components/esp_driver_uart/src/uart.c index a9c3ae51d9..2cc2c2dccd 100644 --- a/components/esp_driver_uart/src/uart.c +++ b/components/esp_driver_uart/src/uart.c @@ -11,7 +11,6 @@ #include "esp_log.h" #include "esp_err.h" #include "esp_check.h" -#include "malloc.h" #include "freertos/FreeRTOS.h" #include "freertos/queue.h" #include "freertos/semphr.h" @@ -525,7 +524,7 @@ esp_err_t uart_pattern_queue_reset(uart_port_t uart_num, int queue_length) ESP_RETURN_ON_FALSE((uart_num < UART_NUM_MAX), ESP_FAIL, UART_TAG, "uart_num error"); ESP_RETURN_ON_FALSE((p_uart_obj[uart_num]), ESP_ERR_INVALID_STATE, UART_TAG, "uart driver error"); - int *pdata = (int *) malloc(queue_length * sizeof(int)); + int *pdata = (int *)heap_caps_malloc(queue_length * sizeof(int), UART_MALLOC_CAPS); if (pdata == NULL) { return ESP_ERR_NO_MEM; } diff --git a/components/esp_driver_uart/test_apps/uart/main/CMakeLists.txt b/components/esp_driver_uart/test_apps/uart/main/CMakeLists.txt index 3f7856d5f5..44ddd7a4d8 100644 --- a/components/esp_driver_uart/test_apps/uart/main/CMakeLists.txt +++ b/components/esp_driver_uart/test_apps/uart/main/CMakeLists.txt @@ -2,6 +2,6 @@ # the component can be registered as WHOLE_ARCHIVE idf_component_register( SRCS "test_app_main.c" "test_uart.c" - REQUIRES esp_driver_uart unity + REQUIRES esp_driver_uart unity esp_psram WHOLE_ARCHIVE ) diff --git a/components/esp_driver_uart/test_apps/uart/pytest_uart.py b/components/esp_driver_uart/test_apps/uart/pytest_uart.py index a93ac513e6..dea1980c9d 100644 --- a/components/esp_driver_uart/test_apps/uart/pytest_uart.py +++ b/components/esp_driver_uart/test_apps/uart/pytest_uart.py @@ -5,6 +5,7 @@ import pytest @pytest.mark.supported_targets +@pytest.mark.temp_skip_ci(targets=['esp32s3'], reason='skip due to duplication with test_uart_single_dev_psram') @pytest.mark.generic @pytest.mark.parametrize( 'config', @@ -16,3 +17,17 @@ import pytest ) def test_uart_single_dev(case_tester) -> None: # type: ignore case_tester.run_all_normal_cases(reset=True) + + +@pytest.mark.esp32s3 +@pytest.mark.octal_psram +@pytest.mark.parametrize( + 'config', + [ + 'iram_safe', + 'release', + ], + indirect=True, +) +def test_uart_single_dev_psram(case_tester) -> None: # type: ignore + case_tester.run_all_normal_cases(reset=True) diff --git a/components/esp_driver_uart/test_apps/uart/sdkconfig.defaults.esp32s3 b/components/esp_driver_uart/test_apps/uart/sdkconfig.defaults.esp32s3 new file mode 100644 index 0000000000..24336a0742 --- /dev/null +++ b/components/esp_driver_uart/test_apps/uart/sdkconfig.defaults.esp32s3 @@ -0,0 +1,4 @@ +CONFIG_SPIRAM=y +CONFIG_SPIRAM_MODE_OCT=y +CONFIG_SPIRAM_SPEED_80M=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0