From d0ba86f176bf261a7ecd49b0459000e0b122afbc Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Wed, 24 Jun 2020 09:26:34 +1000 Subject: [PATCH 1/2] common: Limit UART console baud rate if power management is enabled Also add some comments explaining how the console settings are used by both bootloader and app. Based on config bug and discussion here: https://esp32.com/viewtopic.php?f=2&t=16111&p=61520#p61520 --- components/esp_common/Kconfig | 41 +++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/components/esp_common/Kconfig b/components/esp_common/Kconfig index 671d02c4bb..66d4c5bd4e 100644 --- a/components/esp_common/Kconfig +++ b/components/esp_common/Kconfig @@ -99,8 +99,13 @@ menu "Common ESP-related" depends on ESP_CONSOLE_UART_CUSTOM default ESP_CONSOLE_UART_CUSTOM_NUM_0 help - Select which UART peripheral to use for console output. - On ESP32, UART2 is not supported for console output via ets_printf. + This UART peripheral is used for console output from the ESP-IDF Bootloader and the app. + + If the configuration is different in the Bootloader binary compared to the app binary, UART + is reconfigured after the bootloader exits and the app starts. + + Due to an ESP32 ROM bug, UART2 is not supported for console output + via ets_printf. config ESP_CONSOLE_UART_CUSTOM_NUM_0 bool "UART0" @@ -121,6 +126,12 @@ menu "Common ESP-related" range 0 46 default 1 if IDF_TARGET_ESP32 default 43 if IDF_TARGET_ESP32S2 + help + This GPIO is used for console UART TX output in the ESP-IDF Bootloader and the app (including + boot log output and default standard output and standard error of the app). + + If the configuration is different in the Bootloader binary compared to the app binary, UART + is reconfigured after the bootloader exits and the app starts. config ESP_CONSOLE_UART_RX_GPIO int "UART RX on GPIO#" @@ -128,13 +139,35 @@ menu "Common ESP-related" range 0 46 default 3 if IDF_TARGET_ESP32 default 44 if IDF_TARGET_ESP32S2 + help + This GPIO is used for UART RX input in the ESP-IDF Bootloader and the app (including + default default standard input of the app). + + Note: The default ESP-IDF Bootloader configures this pin but doesn't read anything from the UART. + + If the configuration is different in the Bootloader binary compared to the app binary, UART + is reconfigured after the bootloader exits and the app starts. + config ESP_CONSOLE_UART_BAUDRATE int prompt "UART console baud rate" if ESP_CONSOLE_UART_CUSTOM depends on ESP_CONSOLE_UART default 115200 - range 1200 4000000 + range 1200 4000000 if !PM_ENABLE + range 1200 1000000 if PM_ENABLE + help + This baud rate is used by both the ESP-IDF Bootloader and the app (including + boot log output and default standard input/output/error of the app). + + The app's maximum baud rate depends on the UART clock source. If Power Management is disabled, + the UART clock source is the APB clock and all baud rates in the available range will be sufficiently + accurate. If Power Management is enabled, REF_TICK clock source is used so the baud rate is divided + from 1MHz. Baud rates above 1Mbps are not possible and values between 500Kbps and 1Mbps may not be + accurate. + + If the configuration is different in the Bootloader binary compared to the app binary, UART + is reconfigured after the bootloader exits and the app starts. config ESP_CONSOLE_USB_CDC_RX_BUF_SIZE int "Size of USB CDC RX buffer" @@ -264,4 +297,4 @@ menu "Common ESP-related" config ESP_MAC_ADDR_UNIVERSE_ETH bool -endmenu # Common ESP-related \ No newline at end of file +endmenu # Common ESP-related From f1ac79747b1f8520ceb6cfc99b5042cdf5861e29 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Wed, 24 Jun 2020 09:27:26 +1000 Subject: [PATCH 2/2] monitor: Add a "Same as UART Console baud rate" setting Usually the monitor will want to run at the same speed as the boot log output. --- components/esptool_py/Kconfig.projbuild | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/esptool_py/Kconfig.projbuild b/components/esptool_py/Kconfig.projbuild index 7fcba13701..3069be8a69 100644 --- a/components/esptool_py/Kconfig.projbuild +++ b/components/esptool_py/Kconfig.projbuild @@ -195,8 +195,13 @@ menu "Serial flasher config" Baud rate to use when running 'idf.py monitor' or 'make monitor' to view serial output from a running chip. + If "Same as UART Console baud rate" is chosen then the value will + follow the "UART Console baud rate" config item. + Can override by setting the MONITORBAUD environment variable. + config ESPTOOLPY_MONITOR_BAUD_CONSOLE + bool "Same as UART console baud rate" config ESPTOOLPY_MONITOR_BAUD_9600B bool "9600 bps" config ESPTOOLPY_MONITOR_BAUD_57600B @@ -220,6 +225,7 @@ menu "Serial flasher config" config ESPTOOLPY_MONITOR_BAUD int + default ESP_CONSOLE_UART_BAUDRATE if ESPTOOLPY_MONITOR_BAUD_CONSOLE default 9600 if ESPTOOLPY_MONITOR_BAUD_9600B default 57600 if ESPTOOLPY_MONITOR_BAUD_57600B default 115200 if ESPTOOLPY_MONITOR_BAUD_115200B