]> granicus.if.org Git - esp-idf/commitdiff
esp32: Add reset uart
authorKonstantin Kondrashov <konstantin@espressif.com>
Fri, 17 May 2019 04:33:45 +0000 (12:33 +0800)
committerKonstantinKondrashov <konstantin@espressif.com>
Tue, 4 Jun 2019 12:15:35 +0000 (20:15 +0800)
Fixed the case when the first part of log was missed
this was happened when:
 * CONFIG_CONSOLE_UART_CUSTOM option is selected (UART1)
 * The selected CONSOLE_UART port is used also for the console component
 * in code esp_restart() or abort() functions were called.

components/bootloader_support/src/bootloader_init.c
components/esp32/system_api.c

index e273d338c160d01a7d1e2add92803b38890e09fa..5ae8a5e8138a29289cd458b5835f215fa73f479e 100644 (file)
@@ -440,6 +440,7 @@ static void uart_console_configure(void)
         // (arrays should be optimized away by the compiler)
         const uint32_t tx_idx_list[3] = { U0TXD_OUT_IDX, U1TXD_OUT_IDX, U2TXD_OUT_IDX };
         const uint32_t rx_idx_list[3] = { U0RXD_IN_IDX, U1RXD_IN_IDX, U2RXD_IN_IDX };
+        const uint32_t uart_reset[3] = { DPORT_UART_RST, DPORT_UART1_RST, DPORT_UART2_RST };
         const uint32_t tx_idx = tx_idx_list[uart_num];
         const uint32_t rx_idx = rx_idx_list[uart_num];
 
@@ -448,6 +449,9 @@ static void uart_console_configure(void)
 
         gpio_matrix_out(uart_tx_gpio, tx_idx, 0, 0);
         gpio_matrix_in(uart_rx_gpio, rx_idx, 0);
+
+        DPORT_SET_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, uart_reset[uart_num]);
+        DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, uart_reset[uart_num]);
     }
 #endif // CONFIG_CONSOLE_UART_CUSTOM
 
index f9f5239b1f1f440324b068e05005f75900546a3a..d8b87847fc20c9a6481fe31b9f870af57b4f7af9 100644 (file)
@@ -305,7 +305,7 @@ void IRAM_ATTR esp_restart_noos()
 
     // Reset timer/spi/uart
     DPORT_SET_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG,
-            DPORT_TIMERS_RST | DPORT_SPI01_RST | DPORT_UART_RST);
+            DPORT_TIMERS_RST | DPORT_SPI01_RST | DPORT_UART_RST | DPORT_UART1_RST | DPORT_UART2_RST);
     DPORT_REG_WRITE(DPORT_PERIP_RST_EN_REG, 0);
 
     // Set CPU back to XTAL source, no PLL, same as hard reset