From 0ed7927520347d623224d9bf862b1dd26855afdd Mon Sep 17 00:00:00 2001 From: jiangguangming Date: Wed, 12 Oct 2022 17:01:17 +0800 Subject: [PATCH] esp_rom: update esp_rom_caps.h --- components/esp_rom/esp32c2/ld/esp32c2.rom.api.ld | 1 + components/esp_rom/esp32c3/Kconfig.soc_caps.in | 4 ++++ components/esp_rom/esp32c3/esp_rom_caps.h | 1 + components/esp_rom/esp32h2/Kconfig.soc_caps.in | 4 ++++ components/esp_rom/esp32h2/esp_rom_caps.h | 1 + components/esp_rom/patches/esp_rom_sys.c | 6 ++++-- 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.api.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.api.ld index b214d50155..ab20c38b80 100644 --- a/components/esp_rom/esp32c2/ld/esp32c2.rom.api.ld +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.api.ld @@ -38,6 +38,7 @@ PROVIDE ( esp_rom_software_reset_system = software_reset ); PROVIDE ( esp_rom_software_reset_cpu = software_reset_cpu ); PROVIDE ( esp_rom_printf = ets_printf ); +PROVIDE ( esp_rom_install_uart_printf = ets_install_uart_printf ); PROVIDE ( esp_rom_delay_us = ets_delay_us ); PROVIDE ( esp_rom_get_reset_reason = rtc_get_reset_reason ); PROVIDE ( esp_rom_route_intr_matrix = intr_matrix_set ); diff --git a/components/esp_rom/esp32c3/Kconfig.soc_caps.in b/components/esp_rom/esp32c3/Kconfig.soc_caps.in index 7c5297eaae..56bbe6f338 100644 --- a/components/esp_rom/esp32c3/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32c3/Kconfig.soc_caps.in @@ -46,3 +46,7 @@ config ESP_ROM_HAS_LAYOUT_TABLE config ESP_ROM_HAS_SPI_FLASH bool default y + +config ESP_ROM_HAS_ETS_PRINTF_BUG + bool + default y diff --git a/components/esp_rom/esp32c3/esp_rom_caps.h b/components/esp_rom/esp32c3/esp_rom_caps.h index e8b86ff7e5..d058a7ab16 100644 --- a/components/esp_rom/esp32c3/esp_rom_caps.h +++ b/components/esp_rom/esp32c3/esp_rom_caps.h @@ -17,3 +17,4 @@ #define ESP_ROM_NEEDS_SWSETUP_WORKAROUND (1) // ROM uses 32-bit time_t. A workaround is required to prevent printf functions from crashing #define ESP_ROM_HAS_LAYOUT_TABLE (1) // ROM has the layout table #define ESP_ROM_HAS_SPI_FLASH (1) // ROM has the implementation of SPI Flash driver +#define ESP_ROM_HAS_ETS_PRINTF_BUG (1) // ROM has ets_printf bug when disable the ROM log either by eFuse or RTC storage register diff --git a/components/esp_rom/esp32h2/Kconfig.soc_caps.in b/components/esp_rom/esp32h2/Kconfig.soc_caps.in index b11f70e542..21ba1cf384 100644 --- a/components/esp_rom/esp32h2/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32h2/Kconfig.soc_caps.in @@ -38,3 +38,7 @@ config ESP_ROM_GET_CLK_FREQ config ESP_ROM_HAS_LAYOUT_TABLE bool default y + +config ESP_ROM_HAS_ETS_PRINTF_BUG + bool + default y diff --git a/components/esp_rom/esp32h2/esp_rom_caps.h b/components/esp_rom/esp32h2/esp_rom_caps.h index 60660e37a2..8cb6d35044 100644 --- a/components/esp_rom/esp32h2/esp_rom_caps.h +++ b/components/esp_rom/esp32h2/esp_rom_caps.h @@ -15,3 +15,4 @@ #define ESP_ROM_HAS_ERASE_0_REGION_BUG (1) // ROM has esp_flash_erase_region(size=0) bug #define ESP_ROM_GET_CLK_FREQ (1) // Get clk frequency with rom function `ets_get_cpu_frequency` #define ESP_ROM_HAS_LAYOUT_TABLE (1) // ROM has the layout table +#define ESP_ROM_HAS_ETS_PRINTF_BUG (1) // ROM has ets_printf bug when disable the ROM log either by eFuse or RTC storage register diff --git a/components/esp_rom/patches/esp_rom_sys.c b/components/esp_rom/patches/esp_rom_sys.c index 5500f3b712..dde99a1210 100644 --- a/components/esp_rom/patches/esp_rom_sys.c +++ b/components/esp_rom/patches/esp_rom_sys.c @@ -8,7 +8,7 @@ #include #include "esp_attr.h" -#include "sdkconfig.h" +#include "esp_rom_caps.h" IRAM_ATTR void esp_rom_install_channel_putc(int channel, void (*putc)(char c)) { @@ -26,14 +26,16 @@ IRAM_ATTR void esp_rom_install_channel_putc(int channel, void (*putc)(char c)) } } -#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32C2 +#if ESP_ROM_HAS_ETS_PRINTF_BUG IRAM_ATTR void esp_rom_install_uart_printf(void) { extern void ets_install_uart_printf(void); extern bool g_uart_print; + extern bool g_usb_print; // If ROM log is disabled permanently via eFuse or temporarily via RTC storage register, // this ROM symbol will be set to false, and cause ``esp_rom_printf`` can't work on esp-idf side. g_uart_print = true; + g_usb_print = true; ets_install_uart_printf(); } #endif