From afb6534b00273ae984276988c9450b7475209044 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 13 Mar 2023 18:17:43 -0400 Subject: [PATCH 1/3] fix wait for serial data --- components/stm_pro_mode/stm_pro_mode.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/components/stm_pro_mode/stm_pro_mode.c b/components/stm_pro_mode/stm_pro_mode.c index 17edcfa..8549335 100755 --- a/components/stm_pro_mode/stm_pro_mode.c +++ b/components/stm_pro_mode/stm_pro_mode.c @@ -245,14 +245,21 @@ int waitForSerialData(int dataCount, int timeout) { int timer = 0; int length = 0; - while (timer < timeout) + + const int ticks = pdMS_TO_TICKS(timeout); + // Minimum one ticks + if (ticks < 1) + ticks = 1; + + while (timer < ticks) { uart_get_buffered_data_len(UART_CONTROLLER, (size_t *)&length); if (length >= dataCount) { return length; } - vTaskDelay(1 / portTICK_PERIOD_MS); + + vTaskDelay(1); timer++; } return 0; From 7b72d51520304bfd44d315af84c50a9aa5f54702 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 13 Mar 2023 18:21:50 -0400 Subject: [PATCH 2/3] Improve MS_TO_TICKS --- components/stm_pro_mode/stm_pro_mode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/stm_pro_mode/stm_pro_mode.c b/components/stm_pro_mode/stm_pro_mode.c index 8549335..f345279 100755 --- a/components/stm_pro_mode/stm_pro_mode.c +++ b/components/stm_pro_mode/stm_pro_mode.c @@ -246,9 +246,9 @@ int waitForSerialData(int dataCount, int timeout) int timer = 0; int length = 0; - const int ticks = pdMS_TO_TICKS(timeout); + int ticks = pdMS_TO_TICKS(timeout); // Minimum one ticks - if (ticks < 1) + if (ticks == 0) ticks = 1; while (timer < ticks) From b3bdda61b6901931ab3c6b75d4cd64d296acb293 Mon Sep 17 00:00:00 2001 From: Maxime Carrier Date: Tue, 14 Mar 2023 12:21:54 -0400 Subject: [PATCH 3/3] Increase delay --- components/stm_pro_mode/include/stm_pro_mode.h | 4 +++- examples/file_serving_stm/sdkconfig.defaults | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/stm_pro_mode/include/stm_pro_mode.h b/components/stm_pro_mode/include/stm_pro_mode.h index b250320..9913d29 100755 --- a/components/stm_pro_mode/include/stm_pro_mode.h +++ b/components/stm_pro_mode/include/stm_pro_mode.h @@ -46,7 +46,9 @@ #define LOW 0 #define ACK 0x79 -#define SERIAL_TIMEOUT 5000 +// You may needs to increase this delay, on some chip with bigger flash memory it may takes some time to erase +// over 8s in my case. +#define SERIAL_TIMEOUT 15000 #define FILE_PATH_MAX 128 #define BASE_PATH "/spiffs/" diff --git a/examples/file_serving_stm/sdkconfig.defaults b/examples/file_serving_stm/sdkconfig.defaults index be87a17..4562b66 100644 --- a/examples/file_serving_stm/sdkconfig.defaults +++ b/examples/file_serving_stm/sdkconfig.defaults @@ -3,3 +3,5 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB" CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_example.csv" CONFIG_PARTITION_TABLE_FILENAME="partitions_example.csv" + +CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024 \ No newline at end of file