From d712ae83ee57043f622d4833d3f4c68877ddba05 Mon Sep 17 00:00:00 2001 From: Song Ruo Jing Date: Mon, 12 Aug 2024 16:14:47 +0800 Subject: [PATCH 1/4] fix(uart): increased stack size for the task in uart_events example The example cannot run successfully on ESP32S3 due to task stack overflow Introduced in a4e6f57a4053e304059c4269af34358f2a1ac411 --- .../uart/uart_events/main/uart_events_example_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/peripherals/uart/uart_events/main/uart_events_example_main.c b/examples/peripherals/uart/uart_events/main/uart_events_example_main.c index d5200164bd..19f8726a03 100644 --- a/examples/peripherals/uart/uart_events/main/uart_events_example_main.c +++ b/examples/peripherals/uart/uart_events/main/uart_events_example_main.c @@ -47,7 +47,7 @@ static void uart_event_task(void *pvParameters) bzero(dtmp, RD_BUF_SIZE); ESP_LOGI(TAG, "uart[%d] event:", EX_UART_NUM); switch (event.type) { - //Event of UART receving data + //Event of UART receiving data /*We'd better handler data event fast, there would be much more data events than other types of events. If we take too much time on data event, the queue might be full.*/ @@ -146,5 +146,5 @@ void app_main(void) uart_pattern_queue_reset(EX_UART_NUM, 20); //Create a task to handler UART event from ISR - xTaskCreate(uart_event_task, "uart_event_task", 2048, NULL, 12, NULL); + xTaskCreate(uart_event_task, "uart_event_task", 3072, NULL, 12, NULL); } From 7bb93a2b1e5c4b97a7ea367c32ef9801c7dcd38c Mon Sep 17 00:00:00 2001 From: franzhoepfinger Date: Fri, 16 Aug 2024 15:18:48 +0200 Subject: [PATCH 2/4] Update rs485_example.c Signed-off-by: aleks Merges https://github.com/espressif/esp-idf/pull/14382 --- examples/peripherals/uart/uart_echo_rs485/main/rs485_example.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/peripherals/uart/uart_echo_rs485/main/rs485_example.c b/examples/peripherals/uart/uart_echo_rs485/main/rs485_example.c index 63ff45e30c..db087b913b 100644 --- a/examples/peripherals/uart/uart_echo_rs485/main/rs485_example.c +++ b/examples/peripherals/uart/uart_echo_rs485/main/rs485_example.c @@ -39,7 +39,7 @@ // Read packet timeout #define PACKET_READ_TICS (100 / portTICK_PERIOD_MS) -#define ECHO_TASK_STACK_SIZE (2048) +#define ECHO_TASK_STACK_SIZE (2*2048) #define ECHO_TASK_PRIO (10) #define ECHO_UART_PORT (CONFIG_ECHO_UART_PORT_NUM) From 3ded6819f338cc8224411693e32263a8d7e311d5 Mon Sep 17 00:00:00 2001 From: aleks Date: Mon, 26 Aug 2024 09:52:54 +0200 Subject: [PATCH 3/4] fix(uart/example): Fixed the stack size allocation in uart_echo_rs485 example --- .../uart_echo_rs485/main/Kconfig.projbuild | 7 +++++++ .../uart/uart_echo_rs485/main/rs485_example.c | 18 +++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/examples/peripherals/uart/uart_echo_rs485/main/Kconfig.projbuild b/examples/peripherals/uart/uart_echo_rs485/main/Kconfig.projbuild index 786e2ad39b..af7591f1e0 100644 --- a/examples/peripherals/uart/uart_echo_rs485/main/Kconfig.projbuild +++ b/examples/peripherals/uart/uart_echo_rs485/main/Kconfig.projbuild @@ -48,4 +48,11 @@ menu "Echo RS485 Example Configuration" See UART documentation for more information about available pin numbers for UART. + config ECHO_TASK_STACK_SIZE + int "UART echo RS485 example task stack size" + range 1024 16384 + default 3072 + help + Defines stack size for UART echo RS485 example. Insufficient stack size can cause crash. + endmenu diff --git a/examples/peripherals/uart/uart_echo_rs485/main/rs485_example.c b/examples/peripherals/uart/uart_echo_rs485/main/rs485_example.c index db087b913b..bc7f138477 100644 --- a/examples/peripherals/uart/uart_echo_rs485/main/rs485_example.c +++ b/examples/peripherals/uart/uart_echo_rs485/main/rs485_example.c @@ -25,21 +25,21 @@ // Note: Some pins on target chip cannot be assigned for UART communication. // Please refer to documentation for selected board and target to configure pins using Kconfig. -#define ECHO_TEST_TXD (CONFIG_ECHO_UART_TXD) -#define ECHO_TEST_RXD (CONFIG_ECHO_UART_RXD) +#define ECHO_TEST_TXD (CONFIG_ECHO_UART_TXD) +#define ECHO_TEST_RXD (CONFIG_ECHO_UART_RXD) // RTS for RS485 Half-Duplex Mode manages DE/~RE -#define ECHO_TEST_RTS (CONFIG_ECHO_UART_RTS) +#define ECHO_TEST_RTS (CONFIG_ECHO_UART_RTS) // CTS is not used in RS485 Half-Duplex Mode -#define ECHO_TEST_CTS (UART_PIN_NO_CHANGE) +#define ECHO_TEST_CTS (UART_PIN_NO_CHANGE) -#define BUF_SIZE (127) -#define BAUD_RATE (CONFIG_ECHO_UART_BAUD_RATE) +#define BUF_SIZE (127) +#define BAUD_RATE (CONFIG_ECHO_UART_BAUD_RATE) // Read packet timeout #define PACKET_READ_TICS (100 / portTICK_PERIOD_MS) -#define ECHO_TASK_STACK_SIZE (2*2048) +#define ECHO_TASK_STACK_SIZE (CONFIG_ECHO_TASK_STACK_SIZE) #define ECHO_TASK_PRIO (10) #define ECHO_UART_PORT (CONFIG_ECHO_UART_PORT_NUM) @@ -95,7 +95,7 @@ static void echo_task(void *arg) // Allocate buffers for UART uint8_t* data = (uint8_t*) malloc(BUF_SIZE); - ESP_LOGI(TAG, "UART start recieve loop.\r"); + ESP_LOGI(TAG, "UART start receive loop.\r"); echo_send(uart_num, "Start RS485 UART test.\r\n", 24); while (1) { @@ -112,7 +112,7 @@ static void echo_task(void *arg) for (int i = 0; i < len; i++) { printf("0x%.2X ", (uint8_t)data[i]); echo_send(uart_num, (const char*)&data[i], 1); - // Add a Newline character if you get a return charater from paste (Paste tests multibyte receipt/buffer) + // Add a Newline character if you get a return character from paste (Paste tests multibyte receipt/buffer) if (data[i] == '\r') { echo_send(uart_num, "\n", 1); } From 1c9ff00e501b9df00e651b4de4edffadd87bf9c3 Mon Sep 17 00:00:00 2001 From: aleks Date: Tue, 27 Aug 2024 09:19:07 +0200 Subject: [PATCH 4/4] fix(uart/example): Fixed minimal stack size in uart_echo example --- examples/peripherals/uart/uart_echo/main/Kconfig.projbuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/peripherals/uart/uart_echo/main/Kconfig.projbuild b/examples/peripherals/uart/uart_echo/main/Kconfig.projbuild index 573604b107..64d4642126 100644 --- a/examples/peripherals/uart/uart_echo/main/Kconfig.projbuild +++ b/examples/peripherals/uart/uart_echo/main/Kconfig.projbuild @@ -38,7 +38,7 @@ menu "Echo Example Configuration" config EXAMPLE_TASK_STACK_SIZE int "UART echo example task stack size" range 1024 16384 - default 2048 + default 3072 help Defines stack size for UART echo example. Insufficient stack size can cause crash.