From 194b616c3620a7e490f3edbd190e1c73bc5f9c61 Mon Sep 17 00:00:00 2001 From: Cao Sen Miao Date: Fri, 1 Mar 2024 18:17:01 +0800 Subject: [PATCH] fix(usb_serial_jtag): Fix issue that boot failed on esp32c3, Closes https://github.com/espressif/esp-idf/issues/13197 --- components/esp_rom/esp32/Kconfig.soc_caps.in | 4 ++++ components/esp_rom/esp32/esp_rom_caps.h | 1 + .../esp_rom/esp32c2/Kconfig.soc_caps.in | 4 ++++ components/esp_rom/esp32c2/esp_rom_caps.h | 1 + .../esp_rom/esp32s2/Kconfig.soc_caps.in | 4 ++++ components/esp_rom/esp32s2/esp_rom_caps.h | 1 + components/esp_rom/linux/Kconfig.soc_caps.in | 12 +++++++++++ components/esp_rom/linux/esp_rom_caps.h | 8 +++++++ components/esp_system/Kconfig | 3 +++ .../gen_soc_caps_kconfig.py | 21 +++++++++++++------ 10 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 components/esp_rom/linux/Kconfig.soc_caps.in create mode 100644 components/esp_rom/linux/esp_rom_caps.h diff --git a/components/esp_rom/esp32/Kconfig.soc_caps.in b/components/esp_rom/esp32/Kconfig.soc_caps.in index 1e2fb931a3..d63d250e47 100644 --- a/components/esp_rom/esp32/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32/Kconfig.soc_caps.in @@ -34,3 +34,7 @@ config ESP_ROM_HAS_NEWLIB_NANO_FORMAT config ESP_ROM_HAS_SW_FLOAT bool default y + +config ESP_ROM_USB_SERIAL_DEVICE_NUM + int + default -1 diff --git a/components/esp_rom/esp32/esp_rom_caps.h b/components/esp_rom/esp32/esp_rom_caps.h index f072c6cc8f..906906045c 100644 --- a/components/esp_rom/esp32/esp_rom_caps.h +++ b/components/esp_rom/esp32/esp_rom_caps.h @@ -14,3 +14,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_NEWLIB_NANO_FORMAT (1) // ROM has the newlib nano version of formatting functions #define ESP_ROM_HAS_SW_FLOAT (1) // ROM has libgcc software floating point emulation functions +#define ESP_ROM_USB_SERIAL_DEVICE_NUM (-1) // No USB_SERIAL_JTAG in the ROM, set -1 for Kconfig usage. diff --git a/components/esp_rom/esp32c2/Kconfig.soc_caps.in b/components/esp_rom/esp32c2/Kconfig.soc_caps.in index 0a73025f75..39ec3ca968 100644 --- a/components/esp_rom/esp32c2/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32c2/Kconfig.soc_caps.in @@ -70,3 +70,7 @@ config ESP_ROM_HAS_MBEDTLS_CRYPTO_LIB config ESP_ROM_HAS_SW_FLOAT bool default y + +config ESP_ROM_USB_SERIAL_DEVICE_NUM + int + default -1 diff --git a/components/esp_rom/esp32c2/esp_rom_caps.h b/components/esp_rom/esp32c2/esp_rom_caps.h index dadfd9f4ff..e6ad0d2bfb 100644 --- a/components/esp_rom/esp32c2/esp_rom_caps.h +++ b/components/esp_rom/esp32c2/esp_rom_caps.h @@ -23,3 +23,4 @@ #define ESP_ROM_RAM_APP_NEEDS_MMU_INIT (1) // ROM doesn't init cache MMU when it's a RAM APP, needs MMU hal to init #define ESP_ROM_HAS_MBEDTLS_CRYPTO_LIB (1) // ROM has the mbedtls crypto algorithm lib #define ESP_ROM_HAS_SW_FLOAT (1) // ROM has libgcc software floating point emulation functions +#define ESP_ROM_USB_SERIAL_DEVICE_NUM (-1) // No USB_SERIAL_JTAG in the ROM, set -1 for Kconfig usage. diff --git a/components/esp_rom/esp32s2/Kconfig.soc_caps.in b/components/esp_rom/esp32s2/Kconfig.soc_caps.in index c8dc1b24b9..077d3f780d 100644 --- a/components/esp_rom/esp32s2/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32s2/Kconfig.soc_caps.in @@ -38,3 +38,7 @@ config ESP_ROM_HAS_FLASH_COUNT_PAGES_BUG config ESP_ROM_HAS_SW_FLOAT bool default y + +config ESP_ROM_USB_SERIAL_DEVICE_NUM + int + default -1 diff --git a/components/esp_rom/esp32s2/esp_rom_caps.h b/components/esp_rom/esp32s2/esp_rom_caps.h index b80ede21ce..0409926678 100644 --- a/components/esp_rom/esp32s2/esp_rom_caps.h +++ b/components/esp_rom/esp32s2/esp_rom_caps.h @@ -15,3 +15,4 @@ #define ESP_ROM_USB_OTG_NUM (3) // The serial port ID (UART, USB, ...) of USB_OTG CDC in the ROM. #define ESP_ROM_HAS_FLASH_COUNT_PAGES_BUG (1) // ROM api Cache_Count_Flash_Pages will return unexpected value #define ESP_ROM_HAS_SW_FLOAT (1) // ROM has libgcc software floating point emulation functions +#define ESP_ROM_USB_SERIAL_DEVICE_NUM (-1) // No USB_SERIAL_JTAG in the ROM, set -1 for Kconfig usage. diff --git a/components/esp_rom/linux/Kconfig.soc_caps.in b/components/esp_rom/linux/Kconfig.soc_caps.in new file mode 100644 index 0000000000..d29fdef99a --- /dev/null +++ b/components/esp_rom/linux/Kconfig.soc_caps.in @@ -0,0 +1,12 @@ +##################################################### +# This file is auto-generated from SoC caps +# using gen_soc_caps_kconfig.py, do not edit manually +##################################################### + +config ESP_ROM_USB_OTG_NUM + int + default -1 + +config ESP_ROM_USB_SERIAL_DEVICE_NUM + int + default -1 diff --git a/components/esp_rom/linux/esp_rom_caps.h b/components/esp_rom/linux/esp_rom_caps.h new file mode 100644 index 0000000000..f51f1cda1f --- /dev/null +++ b/components/esp_rom/linux/esp_rom_caps.h @@ -0,0 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#define ESP_ROM_USB_OTG_NUM (-1) // No USB_OTG CDC in the ROM, set -1 for Kconfig usage. +#define ESP_ROM_USB_SERIAL_DEVICE_NUM (-1) // No USB_SERIAL_JTAG in the ROM, set -1 for Kconfig usage. diff --git a/components/esp_system/Kconfig b/components/esp_system/Kconfig index 84ce6f1f73..ce9e66629a 100644 --- a/components/esp_system/Kconfig +++ b/components/esp_system/Kconfig @@ -299,6 +299,9 @@ menu "ESP System Settings" default 0 if ESP_CONSOLE_UART_DEFAULT default 0 if ESP_CONSOLE_UART_CUSTOM_NUM_0 default 1 if ESP_CONSOLE_UART_CUSTOM_NUM_1 + default 0 if ESP_CONSOLE_NONE + # Temporarily workaround for serial_jtag usage. + default ESP_ROM_USB_SERIAL_DEVICE_NUM if ESP_CONSOLE_USB_SERIAL_JTAG default -1 if !ESP_CONSOLE_UART config ESP_CONSOLE_UART_TX_GPIO diff --git a/tools/gen_soc_caps_kconfig/gen_soc_caps_kconfig.py b/tools/gen_soc_caps_kconfig/gen_soc_caps_kconfig.py index a2ebffab39..3ba6608652 100755 --- a/tools/gen_soc_caps_kconfig/gen_soc_caps_kconfig.py +++ b/tools/gen_soc_caps_kconfig/gen_soc_caps_kconfig.py @@ -1,12 +1,10 @@ #!/usr/bin/env python # -# SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 - """ Generate Kconfig.soc_caps.in with defines from soc_caps.h """ - import argparse import inspect import io @@ -18,8 +16,19 @@ from pathlib import Path from string import Template import pyparsing -from pyparsing import (CaselessLiteral, Char, Combine, Group, Literal, OneOrMore, # pylint: disable=unused-import - Optional, ParserElement, QuotedString, Word, alphas, hexnums, nums) +from pyparsing import alphas +from pyparsing import CaselessLiteral +from pyparsing import Char +from pyparsing import Combine +from pyparsing import Group +from pyparsing import hexnums +from pyparsing import Literal +from pyparsing import nums +from pyparsing import OneOrMore +from pyparsing import Optional +from pyparsing import ParserElement +from pyparsing import QuotedString +from pyparsing import Word pyparsing.usePackrat = True @@ -107,7 +116,7 @@ def parse_define(define_line): # type: (str) -> typing.Any[typing.Type[ParserEl # Define value, either a hex, int or a string hex_value = Combine(Literal('0x') + Word(hexnums) + Optional(literal_suffix).suppress())('hex_value') - int_value = Word(nums)('int_value') + ~Char('.') + Optional(literal_suffix)('literal_suffix') + int_value = Combine(Optional('-') + Word(nums))('int_value') + ~Char('.') + Optional(literal_suffix)('literal_suffix') str_value = QuotedString('"')('str_value') # Remove optional parenthesis around values