From 6efc64d5daceee4e50189042c5c794656b6fe811 Mon Sep 17 00:00:00 2001 From: Chen Wu Date: Wed, 21 Feb 2024 14:24:39 +0800 Subject: [PATCH] fix(ESPAT-1934): Fixed that uart cannot work if upgrades from v2.0 to v3.3 Reason: On v2.0.0.0 version, UART port configuration was not stored in flash. The UART port read from flash was actually an incorrect value, further resulting in UART malfunction. Fix: Set the default UART port, then read the UART port from flash. If it is valid, overwrite the default UART port. --- main/interface/uart/at_uart_api.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main/interface/uart/at_uart_api.c b/main/interface/uart/at_uart_api.c index 7dda4774..d44f4139 100644 --- a/main/interface/uart/at_uart_api.c +++ b/main/interface/uart/at_uart_api.c @@ -151,7 +151,7 @@ esp_err_t at_mfg_uart_port_pins_get(at_uart_port_pins_t *config) config->rts_pin = CONFIG_AT_UART_PORT_RTS_PIN_DEFAULT; // get uart port and uart pins from flash - int8_t uart_num; + int8_t uart_num = g_at_cmd_port; int32_t tx_pin, rx_pin, cts_pin, rts_pin; at_mfg_params_storage_mode_t mode = at_get_mfg_params_storage_mode(); if (mode == AT_PARAMS_IN_MFG_NVS) { @@ -193,7 +193,9 @@ esp_err_t at_mfg_uart_port_pins_get(at_uart_port_pins_t *config) return ESP_FAIL; } // uart configurations are stored in the 12nd to 19th bytes of the partition - uart_num = data[5]; + if (data[5] != 0xFF) { + uart_num = data[5]; + } if (data[16] != 0xFF && data[17] != 0xFF) { tx_pin = data[16]; rx_pin = data[17];