feat(soc_cap_kconfig): support to search recursively

This commit is contained in:
laokaiyao 2024-02-23 16:50:31 +08:00
parent 45a094367d
commit db2435fd14
11 changed files with 156 additions and 461 deletions

View File

@ -1,7 +1,12 @@
#####################################################
# This file is auto-generated from SoC caps
# using gen_soc_caps_kconfig.py, do not edit manually
#####################################################
if IDF_TARGET_ESP32C5_BETA3_VERSION if IDF_TARGET_ESP32C5_BETA3_VERSION
orsource "./beta3/esp32c5/Kconfig.soc_caps.in" source "$IDF_PATH/components/esp_rom/esp32c5/beta3/esp32c5/Kconfig.soc_caps.in"
endif endif
if IDF_TARGET_ESP32C5_MP_VERSION if IDF_TARGET_ESP32C5_MP_VERSION
orsource "./mp/esp32c5/Kconfig.soc_caps.in" source "$IDF_PATH/components/esp_rom/esp32c5/mp/esp32c5/Kconfig.soc_caps.in"
endif endif

View File

@ -0,0 +1,17 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "sdkconfig.h"
// TODO: IDF-9197 This file is created to glob the soc_caps correctly in esp-docs
#if CONFIG_IDF_TARGET_ESP32C5_BETA3_VERSION
#include "beta3/esp32c5/esp_rom_caps.h" // recursive, condition: IDF_TARGET_ESP32C5_BETA3_VERSION
#elif CONFIG_IDF_TARGET_ESP32C5_MP_VERSION
#include "mp/esp32c5/esp_rom_caps.h" // recursive, condition: IDF_TARGET_ESP32C5_MP_VERSION
#endif

View File

@ -0,0 +1,4 @@
#####################################################
# This file is auto-generated from SoC caps
# using gen_soc_caps_kconfig.py, do not edit manually
#####################################################

View File

@ -0,0 +1,7 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once

View File

@ -31,6 +31,14 @@ config SOC_SYSTIMER_SUPPORTED
bool bool
default y default y
config SOC_ECC_SUPPORTED
bool
default y
config SOC_ECC_EXTENDED_MODES_SUPPORTED
bool
default y
config SOC_FLASH_ENC_SUPPORTED config SOC_FLASH_ENC_SUPPORTED
bool bool
default y default y
@ -107,17 +115,49 @@ config SOC_CPU_IDRAM_SPLIT_USING_PMP
bool bool
default y default y
config SOC_GPIO_PORT
int
default 1
config SOC_GPIO_PIN_COUNT config SOC_GPIO_PIN_COUNT
int int
default 31 default 27
config SOC_GPIO_SUPPORT_PIN_HYS_FILTER
bool
default y
config SOC_GPIO_ETM_EVENTS_PER_GROUP
int
default 8
config SOC_GPIO_ETM_TASKS_PER_GROUP
int
default 8
config SOC_GPIO_SUPPORT_RTC_INDEPENDENT
bool
default y
config SOC_GPIO_IN_RANGE_MAX config SOC_GPIO_IN_RANGE_MAX
int int
default 30 default 26
config SOC_GPIO_OUT_RANGE_MAX config SOC_GPIO_OUT_RANGE_MAX
int int
default 30 default 26
config SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK
int
default 0
config SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK
hex
default 0x0000000007FFFF00
config SOC_GPIO_SUPPORT_FORCE_HOLD
bool
default y
config SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP config SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP
bool bool
@ -295,10 +335,6 @@ config SOC_PM_SUPPORT_VDDSDIO_PD
bool bool
default y default y
config SOC_PM_SUPPORT_TOP_PD
bool
default y
config SOC_PM_SUPPORT_HP_AON_PD config SOC_PM_SUPPORT_HP_AON_PD
bool bool
default y default y

View File

@ -1,455 +1,12 @@
#####################################################
# This file is auto-generated from SoC caps
# using gen_soc_caps_kconfig.py, do not edit manually
#####################################################
if IDF_TARGET_ESP32C5_BETA3_VERSION if IDF_TARGET_ESP32C5_BETA3_VERSION
orsource "../../beta3/include/soc/Kconfig.soc_caps.in" source "$IDF_PATH/components/soc/esp32c5/include/soc/../../beta3/include/soc/Kconfig.soc_caps.in"
endif endif
config SOC_UART_SUPPORTED if IDF_TARGET_ESP32C5_MP_VERSION
bool source "$IDF_PATH/components/soc/esp32c5/include/soc/../../mp/include/soc/Kconfig.soc_caps.in"
default y endif
config SOC_GDMA_SUPPORTED
bool
default y
config SOC_AHB_GDMA_SUPPORTED
bool
default y
config SOC_GPTIMER_SUPPORTED
bool
default y
config SOC_ASYNC_MEMCPY_SUPPORTED
bool
default y
config SOC_EFUSE_KEY_PURPOSE_FIELD
bool
default y
config SOC_EFUSE_SUPPORTED
bool
default y
config SOC_RTC_FAST_MEM_SUPPORTED
bool
default y
config SOC_RTC_MEM_SUPPORTED
bool
default y
config SOC_I2C_SUPPORTED
bool
default y
config SOC_SYSTIMER_SUPPORTED
bool
default y
config SOC_ECC_SUPPORTED
bool
default y
config SOC_ECC_EXTENDED_MODES_SUPPORTED
bool
default y
config SOC_FLASH_ENC_SUPPORTED
bool
default y
config SOC_LP_PERIPHERALS_SUPPORTED
bool
default y
config SOC_SPI_FLASH_SUPPORTED
bool
default y
config SOC_XTAL_SUPPORT_40M
bool
default y
config SOC_XTAL_SUPPORT_48M
bool
default y
config SOC_ADC_PERIPH_NUM
int
default 1
config SOC_ADC_MAX_CHANNEL_NUM
int
default 7
config SOC_SHARED_IDCACHE_SUPPORTED
bool
default y
config SOC_CACHE_FREEZE_SUPPORTED
bool
default y
config SOC_CPU_CORES_NUM
int
default 1
config SOC_CPU_INTR_NUM
int
default 32
config SOC_CPU_HAS_FLEXIBLE_INTC
bool
default y
config SOC_INT_CLIC_SUPPORTED
bool
default y
config SOC_INT_HW_NESTED_SUPPORTED
bool
default y
config SOC_BRANCH_PREDICTOR_SUPPORTED
bool
default y
config SOC_CPU_BREAKPOINTS_NUM
int
default 4
config SOC_CPU_WATCHPOINTS_NUM
int
default 4
config SOC_CPU_WATCHPOINT_MAX_REGION_SIZE
hex
default 0x100
config SOC_CPU_HAS_PMA
bool
default y
config SOC_CPU_IDRAM_SPLIT_USING_PMP
bool
default y
config SOC_AHB_GDMA_VERSION
int
default 1
config SOC_GDMA_NUM_GROUPS_MAX
int
default 1
config SOC_GDMA_PAIRS_PER_GROUP_MAX
int
default 3
config SOC_GPIO_PORT
int
default 1
config SOC_GPIO_PIN_COUNT
int
default 27
config SOC_GPIO_SUPPORT_PIN_HYS_FILTER
bool
default y
config SOC_GPIO_ETM_EVENTS_PER_GROUP
int
default 8
config SOC_GPIO_ETM_TASKS_PER_GROUP
int
default 8
config SOC_GPIO_SUPPORT_RTC_INDEPENDENT
bool
default y
config SOC_GPIO_IN_RANGE_MAX
int
default 26
config SOC_GPIO_OUT_RANGE_MAX
int
default 26
config SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK
int
default 0
config SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK
hex
default 0x0000000007FFFF00
config SOC_GPIO_SUPPORT_FORCE_HOLD
bool
default y
config SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP
bool
default y
config SOC_RTCIO_PIN_COUNT
bool
default n
config SOC_I2C_NUM
int
default 1
config SOC_I2C_FIFO_LEN
int
default 32
config SOC_I2C_CMD_REG_NUM
int
default 8
config SOC_I2C_SUPPORT_SLAVE
bool
default y
config SOC_I2C_SUPPORT_HW_FSM_RST
bool
default y
config SOC_I2C_SUPPORT_HW_CLR_BUS
bool
default y
config SOC_I2C_SUPPORT_XTAL
bool
default y
config SOC_I2C_SUPPORT_10BIT_ADDR
bool
default y
config SOC_I2C_SLAVE_SUPPORT_BROADCAST
bool
default y
config SOC_I2C_SLAVE_CAN_GET_STRETCH_CAUSE
bool
default y
config SOC_I2C_SLAVE_SUPPORT_I2CRAM_ACCESS
bool
default y
config SOC_LEDC_SUPPORT_PLL_DIV_CLOCK
bool
default y
config SOC_LEDC_SUPPORT_XTAL_CLOCK
bool
default y
config SOC_LEDC_CHANNEL_NUM
int
default 6
config SOC_MMU_PERIPH_NUM
int
default 1
config SOC_MMU_LINEAR_ADDRESS_REGION_NUM
int
default 1
config SOC_MMU_DI_VADDR_SHARED
bool
default y
config SOC_RSA_MAX_BIT_LEN
int
default 3072
config SOC_SPI_PERIPH_NUM
int
default 2
config SOC_SPI_MAX_CS_NUM
int
default 6
config SOC_MEMSPI_SRC_FREQ_80M_SUPPORTED
bool
default y
config SOC_MEMSPI_SRC_FREQ_40M_SUPPORTED
bool
default y
config SOC_MEMSPI_SRC_FREQ_20M_SUPPORTED
bool
default y
config SOC_SYSTIMER_COUNTER_NUM
int
default 2
config SOC_SYSTIMER_ALARM_NUM
int
default 3
config SOC_SYSTIMER_BIT_WIDTH_LO
int
default 32
config SOC_SYSTIMER_BIT_WIDTH_HI
int
default 20
config SOC_SYSTIMER_FIXED_DIVIDER
bool
default y
config SOC_SYSTIMER_SUPPORT_RC_FAST
bool
default y
config SOC_SYSTIMER_INT_LEVEL
bool
default y
config SOC_SYSTIMER_ALARM_MISS_COMPENSATE
bool
default y
config SOC_TIMER_GROUPS
int
default 2
config SOC_TIMER_GROUP_TIMERS_PER_GROUP
int
default 1
config SOC_TIMER_GROUP_COUNTER_BIT_WIDTH
int
default 54
config SOC_TIMER_GROUP_SUPPORT_XTAL
bool
default y
config SOC_TIMER_GROUP_TOTAL_TIMERS
int
default 2
config SOC_EFUSE_SECURE_BOOT_KEY_DIGESTS
int
default 3
config SOC_FLASH_ENCRYPTED_XTS_AES_BLOCK_MAX
int
default 64
config SOC_FLASH_ENCRYPTION_XTS_AES
bool
default y
config SOC_FLASH_ENCRYPTION_XTS_AES_128
bool
default y
config SOC_UART_NUM
int
default 3
config SOC_UART_HP_NUM
int
default 2
config SOC_UART_LP_NUM
int
default 1
config SOC_UART_FIFO_LEN
int
default 128
config SOC_LP_UART_FIFO_LEN
int
default 16
config SOC_UART_BITRATE_MAX
int
default 5000000
config SOC_UART_SUPPORT_PLL_F80M_CLK
bool
default y
config SOC_UART_SUPPORT_XTAL_CLK
bool
default y
config SOC_UART_SUPPORT_WAKEUP_INT
bool
default y
config SOC_UART_SUPPORT_FSM_TX_WAIT_SEND
bool
default y
config SOC_PM_SUPPORT_CPU_PD
bool
default y
config SOC_PM_SUPPORT_MODEM_PD
bool
default y
config SOC_PM_SUPPORT_XTAL32K_PD
bool
default y
config SOC_PM_SUPPORT_RC32K_PD
bool
default y
config SOC_PM_SUPPORT_RC_FAST_PD
bool
default y
config SOC_PM_SUPPORT_VDDSDIO_PD
bool
default y
config SOC_PM_SUPPORT_HP_AON_PD
bool
default y
config SOC_PM_SUPPORT_RTC_PERIPH_PD
bool
default y
config SOC_CLK_RC_FAST_SUPPORT_CALIBRATION
bool
default y
config SOC_MODEM_CLOCK_IS_INDEPENDENT
bool
default y
config SOC_CLK_XTAL32K_SUPPORTED
bool
default y
config SOC_CLK_OSC_SLOW_SUPPORTED
bool
default y
config SOC_CLK_RC32K_SUPPORTED
bool
default y
config SOC_RCC_IS_INDEPENDENT
bool
default y

View File

@ -0,0 +1,17 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "sdkconfig.h"
// TODO: IDF-9197 This file is created to glob the soc_caps correctly in esp-docs
#if CONFIG_IDF_TARGET_ESP32C5_BETA3_VERSION
#include "../../beta3/include/soc/soc_caps.h" // recursive, condition: IDF_TARGET_ESP32C5_BETA3_VERSION
#elif CONFIG_IDF_TARGET_ESP32C5_MP_VERSION
#include "../../mp/include/soc/soc_caps.h" // recursive, condition: IDF_TARGET_ESP32C5_MP_VERSION
#endif

View File

@ -0,0 +1,4 @@
#####################################################
# This file is auto-generated from SoC caps
# using gen_soc_caps_kconfig.py, do not edit manually
#####################################################

View File

@ -0,0 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

View File

@ -28,6 +28,8 @@ from pyparsing import OneOrMore
from pyparsing import Optional from pyparsing import Optional
from pyparsing import ParserElement from pyparsing import ParserElement
from pyparsing import QuotedString from pyparsing import QuotedString
from pyparsing import restOfLine
from pyparsing import Suppress
from pyparsing import Word from pyparsing import Word
pyparsing.usePackrat = True pyparsing.usePackrat = True
@ -52,6 +54,12 @@ class KconfigWriter():
$entry_type $entry_type
default $value default $value
''')) '''))
KCONFIG_CONDITION_SOURCE_TEMPLATE = Template(
inspect.cleandoc('''
if $condition
source "$source_path"
endif
'''))
def __init__(self): # type: () -> None def __init__(self): # type: () -> None
self.entries = set('') self.entries = set('')
@ -77,6 +85,14 @@ class KconfigWriter():
entry = self.KCONFIG_ENTRY_TEMPLATE.substitute(name=name, entry_type=entry_type, value=value) entry = self.KCONFIG_ENTRY_TEMPLATE.substitute(name=name, entry_type=entry_type, value=value)
self.kconfig_text.write(entry) self.kconfig_text.write(entry)
def add_source(self, source_path, condition): # type: (str, str) -> None
self.kconfig_text.write('\n\n')
if condition:
source = self.KCONFIG_CONDITION_SOURCE_TEMPLATE.substitute(source_path=source_path, condition=condition)
self.kconfig_text.write(source)
else:
self.kconfig_text.write('source "' + source_path + '"')
def update_file(self, kconfig_path, always_write): # type: (Path, bool) -> bool def update_file(self, kconfig_path, always_write): # type: (Path, bool) -> bool
try: try:
@ -105,6 +121,22 @@ class KconfigWriter():
return file_needs_update return file_needs_update
def parse_include(inc_line): # type: (str) -> typing.Any[typing.Type[ParserElement]]
# Comment with recursive pattern
recursive_deli = OneOrMore(Group(Literal(' ') | Literal(',') | Literal('.')))
recursive = CaselessLiteral('// recursive')('recursive') + Optional(recursive_deli)
# Comment with condition pattern
condition_deli = OneOrMore(Group(Literal(' ') | Literal(':')))
condition = CaselessLiteral('condition') + Optional(condition_deli) + restOfLine('condition')
# Parse the include line
# e.g. #include "../../beta3/include/soc/soc_caps.h" // recursive, condition: IDF_TARGET_ESP32C5_VERSION_BETA3
expr = Suppress('#include') + QuotedString('"')('inc_path') + recursive + Optional(condition)
res = expr.parseString(inc_line)
return res
def parse_define(define_line): # type: (str) -> typing.Any[typing.Type[ParserElement]] def parse_define(define_line): # type: (str) -> typing.Any[typing.Type[ParserElement]]
# Group for parsing literal suffix of a numbers, e.g. 100UL # Group for parsing literal suffix of a numbers, e.g. 100UL
@ -144,6 +176,17 @@ def generate_defines(soc_caps_dir, filename, always_write): # type: (Path, str,
writer = KconfigWriter() writer = KconfigWriter()
for line in defines: for line in defines:
try:
inc = parse_include(line)
if 'inc_path' in inc and 'recursive' in inc and inc['inc_path'][-6:] == 'caps.h':
source_path = path.join('$IDF_PATH', str(soc_caps_dir), path.dirname(inc['inc_path']), 'Kconfig.soc_caps.in')
condition = inc['condition'].strip(' ') if 'condition' in inc else ''
writer.add_source(source_path, condition)
sub_soc_cap_dir = soc_caps_dir.joinpath(str(inc['inc_path'])).parent
generate_defines(sub_soc_cap_dir, filename, always_write)
continue
except pyparsing.ParseException:
pass
try: try:
res = parse_define(line) res = parse_define(line)