hal: use ROM implementation for systimer and wdt on esp32c2

This commit is contained in:
morris 2022-05-06 18:57:14 +08:00
parent 334126315f
commit 24f5fecef0
14 changed files with 88 additions and 71 deletions

View File

@ -88,7 +88,7 @@ if(${target} STREQUAL "esp32")
"esp32/dac.c")
endif()
if(IDF_TARGET STREQUAL "esp32s2")
if(${target} STREQUAL "esp32s2")
list(APPEND srcs "dac_common.c"
"touch_sensor_common.c"
"esp32s2/touch_sensor.c"
@ -103,7 +103,7 @@ if(${target} STREQUAL "esp32s3")
"esp32s3/touch_sensor.c")
endif()
if(IDF_TARGET STREQUAL "esp32c3")
if(${target} STREQUAL "esp32c3")
list(APPEND srcs "esp32c3/adc2_init_cal.c")
endif()

View File

@ -26,3 +26,11 @@ config ESP_ROM_GET_CLK_FREQ
config ESP_ROM_HAS_RVFPLIB
bool
default y
config ESP_ROM_HAS_HAL_WDT
bool
default y
config ESP_ROM_HAS_HAL_SYSTIMER
bool
default y

View File

@ -11,4 +11,6 @@
#define ESP_ROM_UART_CLK_IS_XTAL (1) // UART clock source is selected to XTAL in ROM
#define ESP_ROM_HAS_RETARGETABLE_LOCKING (1) // ROM was built with retargetable locking
#define ESP_ROM_GET_CLK_FREQ (1) // Get clk frequency with rom function `ets_get_cpu_frequency`
#define ESP_ROM_HAS_RVFPLIB (1) // ROM has the rvfplib
#define ESP_ROM_HAS_RVFPLIB (1) // ROM has the rvfplib
#define ESP_ROM_HAS_HAL_WDT (1) // ROM has the implementation of Watchdog HAL driver
#define ESP_ROM_HAS_HAL_SYSTIMER (1) // ROM has the implementation of Systimer HAL driver

View File

@ -38,3 +38,7 @@ config ESP_ROM_HAS_ERASE_0_REGION_BUG
config ESP_ROM_GET_CLK_FREQ
bool
default y
config ESP_ROM_HAS_HAL_WDT
bool
default y

View File

@ -15,3 +15,4 @@
#define ESP_ROM_USB_SERIAL_DEVICE_NUM (4) // The serial port ID (UART, USB, ...) of USB_SERIAL_JTAG in the ROM.
#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_HAL_WDT (1) // ROM has the implementation of Watchdog HAL driver

View File

@ -366,7 +366,8 @@ menu "ESP System Settings"
config ESP_INT_WDT
bool "Interrupt watchdog"
default y if !IDF_TARGET_ESP32C2 # add support in IDF-4114
default n if IDF_TARGET_ESP32C2 # add support in IDF-4114
default y
help
This watchdog timer can detect if the FreeRTOS tick interrupt has not been called for a certain time,
either because a task turned off interrupts and did not turn them on for a long time, or because an

View File

@ -149,7 +149,9 @@ void esp_int_wdt_cpu_init(void)
esp_register_freertos_tick_hook_for_cpu(tick_hook, cpu_hal_get_core_id());
ESP_INTR_DISABLE(WDT_INT_NUM);
#if SOC_TIMER_GROUPS > 1
esp_rom_route_intr_matrix(cpu_hal_get_core_id(), ETS_TG1_WDT_LEVEL_INTR_SOURCE, WDT_INT_NUM);
#endif
/* Set the type and priority to watch dog interrupts */
#if SOC_CPU_HAS_FLEXIBLE_INTC

View File

@ -8,7 +8,7 @@ set(srcs "mpu_hal.c"
set(includes "${target}/include" "include" "platform_port/include")
if(NOT CONFIG_HAL_WDT_ROM_IMPL)
if(NOT CONFIG_HAL_WDT_USE_ROM_IMPL)
list(APPEND srcs "wdt_hal_iram.c")
endif()
@ -16,7 +16,7 @@ if(NOT ${target} STREQUAL "esp32")
list(APPEND srcs "cache_hal.c")
endif()
if(target STREQUAL "esp32h2")
if(${target} STREQUAL "esp32h2")
if(CONFIG_IDF_TARGET_ESP32H2_BETA_VERSION_1)
list(APPEND includes "${target}/include/rev1")
elseif(CONFIG_IDF_TARGET_ESP32H2_BETA_VERSION_2)
@ -49,50 +49,64 @@ if(NOT BOOTLOADER_BUILD)
"adc_hal_common.c"
"adc_hal.c")
if(CONFIG_SOC_SYSTIMER_SUPPORTED)
if(NOT CONFIG_HAL_SYSTIMER_ROM_IMPL)
list(APPEND srcs "systimer_hal.c")
endif()
if(CONFIG_SOC_SYSTIMER_SUPPORTED AND NOT CONFIG_HAL_SYSTIMER_USE_ROM_IMPL)
list(APPEND srcs "systimer_hal.c")
endif()
if(CONFIG_SOC_RMT_SUPPORTED)
list(APPEND srcs "rmt_hal.c")
endif()
if(CONFIG_SOC_PCNT_SUPPORTED)
list(APPEND srcs "pcnt_hal.c")
endif()
if(CONFIG_SOC_MCPWM_SUPPORTED)
list(APPEND srcs "mcpwm_hal.c")
endif()
if(CONFIG_SOC_TWAI_SUPPORTED)
list(APPEND srcs "twai_hal.c" "twai_hal_iram.c")
endif()
if(CONFIG_SOC_GDMA_SUPPORTED)
list(APPEND srcs "gdma_hal.c")
endif()
if(CONFIG_SOC_I2S_SUPPORTED)
list(APPEND srcs "i2s_hal.c")
endif()
if(CONFIG_SOC_SIGMADELTA_SUPPORTED)
list(APPEND srcs "sigmadelta_hal.c")
endif()
if(CONFIG_ETH_USE_ESP32_EMAC)
list(APPEND srcs "emac_hal.c")
endif()
if(${target} STREQUAL "esp32")
list(APPEND srcs
"dac_hal.c"
"rmt_hal.c"
"sigmadelta_hal.c"
"mcpwm_hal.c"
"pcnt_hal.c"
"sdio_slave_hal.c"
"touch_sensor_hal.c"
"i2s_hal.c"
"twai_hal.c"
"twai_hal_iram.c"
"aes_hal.c"
"esp32/adc_hal.c"
"esp32/brownout_hal.c"
"esp32/interrupt_descriptor_table.c"
"esp32/touch_sensor_hal.c"
"esp32/gpio_hal_workaround.c")
if(NOT BOOTLOADER_BUILD AND CONFIG_ETH_USE_ESP32_EMAC)
list(APPEND srcs "emac_hal.c")
endif()
endif()
if(${target} STREQUAL "esp32s2")
list(APPEND srcs
"dac_hal.c"
"rmt_hal.c"
"sigmadelta_hal.c"
"pcnt_hal.c"
"spi_flash_hal_gpspi.c"
"spi_slave_hd_hal.c"
"touch_sensor_hal.c"
"usb_hal.c"
"usb_phy_hal.c"
"xt_wdt_hal.c"
"i2s_hal.c"
"twai_hal.c"
"twai_hal_iram.c"
"aes_hal.c"
"esp32s2/brownout_hal.c"
"esp32s2/cp_dma_hal.c"
@ -105,21 +119,13 @@ if(NOT BOOTLOADER_BUILD)
if(${target} STREQUAL "esp32s3")
list(APPEND srcs
"ds_hal.c"
"rmt_hal.c"
"sigmadelta_hal.c"
"gdma_hal.c"
"lcd_hal.c"
"mcpwm_hal.c"
"pcnt_hal.c"
"spi_flash_hal_gpspi.c"
"spi_slave_hd_hal.c"
"touch_sensor_hal.c"
"usb_hal.c"
"usb_phy_hal.c"
"xt_wdt_hal.c"
"i2s_hal.c"
"twai_hal.c"
"twai_hal_iram.c"
"aes_hal.c"
"esp32s3/brownout_hal.c"
"esp32s3/hmac_hal.c"
@ -132,15 +138,9 @@ if(NOT BOOTLOADER_BUILD)
if(${target} STREQUAL "esp32c3")
list(APPEND srcs
"ds_hal.c"
"gdma_hal.c"
"rmt_hal.c"
"sigmadelta_hal.c"
"spi_flash_hal_gpspi.c"
"spi_slave_hd_hal.c"
"xt_wdt_hal.c"
"i2s_hal.c"
"twai_hal.c"
"twai_hal_iram.c"
"aes_hal.c"
"esp32c3/adc_hal.c"
"esp32c3/brownout_hal.c"
@ -151,14 +151,8 @@ if(NOT BOOTLOADER_BUILD)
if(${target} STREQUAL "esp32h2")
list(APPEND srcs
"ds_hal.c"
"gdma_hal.c"
"rmt_hal.c"
"sigmadelta_hal.c"
"spi_flash_hal_gpspi.c"
"spi_slave_hd_hal.c"
"i2s_hal.c"
"twai_hal.c"
"twai_hal_iram.c"
"aes_hal.c"
"esp32h2/brownout_hal.c"
"esp32h2/hmac_hal.c"
@ -168,7 +162,6 @@ if(NOT BOOTLOADER_BUILD)
if(${target} STREQUAL "esp32c2")
list(APPEND srcs
"ecc_hal.c"
"gdma_hal.c"
"spi_flash_hal_gpspi.c"
"spi_slave_hd_hal.c"
"esp32c2/brownout_hal.c"

View File

@ -65,14 +65,9 @@ menu "Hardware Abstraction Layer (HAL) and Low Level (LL)"
default 4 if HAL_LOG_LEVEL_DEBUG
default 5 if HAL_LOG_LEVEL_VERBOSE
config HAL_SYSTIMER_HAS_ROM_IMPL
bool
depends on IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32S3
default y if IDF_TARGET_ESP32C2 # TODO: IDF-4917
config HAL_SYSTIMER_ROM_IMPL
bool "Use systimer HAL implementation in ROM"
depends on HAL_SYSTIMER_HAS_ROM_IMPL
config HAL_SYSTIMER_USE_ROM_IMPL
bool "Use ROM implementation of SysTimer HAL driver"
depends on ESP_ROM_HAS_HAL_SYSTIMER
default y
help
Enable this flag to use HAL functions from ROM instead of ESP-IDF.
@ -83,14 +78,9 @@ menu "Hardware Abstraction Layer (HAL) and Low Level (LL)"
features will be added and bugs will be fixed in the IDF source
but cannot be synced to ROM.
config HAL_WDT_HAS_ROM_IMPL
bool
depends on IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32S3
default y if IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32S3
config HAL_WDT_ROM_IMPL
bool "Use WDT HAL implementation in ROM"
depends on HAL_WDT_HAS_ROM_IMPL
config HAL_WDT_USE_ROM_IMPL
bool "Use ROM implementation of WDT HAL driver"
depends on ESP_ROM_HAS_HAL_WDT
default y
help
Enable this flag to use HAL functions from ROM instead of ESP-IDF.

View File

@ -16,14 +16,14 @@ entries:
i2c_hal_iram (noflash)
cpu_hal (noflash)
soc_hal (noflash)
if HAL_WDT_HAS_ROM_IMPL = n || HAL_WDT_ROM_IMPL = n:
if HAL_WDT_USE_ROM_IMPL = n:
wdt_hal_iram (noflash)
if SOC_SYSTIMER_SUPPORTED = y && HAL_SYSTIMER_USE_ROM_IMPL = n:
systimer_hal (noflash)
if TWAI_ISR_IN_IRAM = y:
twai_hal_iram (noflash)
if IDF_TARGET_ESP32 = n:
spi_flash_hal_gpspi (noflash)
if HAL_SYSTIMER_HAS_ROM_IMPL = n || HAL_SYSTIMER_ROM_IMPL = n:
systimer_hal (noflash)
if GPTIMER_CTRL_FUNC_IN_IRAM = y:
timer_hal_iram (noflash)
if GPIO_CTRL_FUNC_IN_IRAM = y:

View File

@ -411,6 +411,17 @@ VFS
* :ref:`CONFIG_VFS_SUPPORT_DIR` — can be disabled if the application doesn't use directory related functions, such as ``readdir`` (see the description of this option for the complete list). Applications which only open, read and write specific files and don't need to enumerate or create directories can disable this option, reducing the code size by 0.5 kB or more, depending on the filesystem drivers in use.
* :ref:`CONFIG_VFS_SUPPORT_IO` — can be disabled if the application doesn't use filesystems or file-like peripheral drivers. This disables all VFS functionality, including the three options mentioned above. When this option is disabled, :doc:`console </api-reference/system/console>` can't be used. Note that the application can still use standard I/O functions with socket file descriptors when this option is disabled. Compared to the default configuration, disabling this option reduces code size by about 9.4 kB.
.. only:: esp32c2
HAL
@@@
.. list::
:CONFIG_ESP_ROM_HAS_HAL_SYSTIMER: * Enabling :ref:`CONFIG_HAL_SYSTIMER_USE_ROM_IMPL` can reduce the IRAM usage and binary size by linking in the systimer HAL driver of ROM implementation.
:CONFIG_ESP_ROM_HAS_HAL_WDT: * Enabling :ref:`CONFIG_HAL_WDT_USE_ROM_IMPL` can reduce the IRAM usage and binary size by linking in the watchdog HAL driver of ROM implementation.
Bootloader Size
---------------

View File

@ -0,0 +1,5 @@
CONFIG_IDF_TARGET="esp32c2"
CONFIG_HAL_WDT_USE_ROM_IMPL=y
CONFIG_HAL_SYSTIMER_USE_ROM_IMPL=y
CONFIG_HEAP_TLSF_USE_ROM_IMPL=y
CONFIG_SPI_FLASH_ROM_IMPL=y

View File

@ -1,5 +0,0 @@
CONFIG_IDF_TARGET="esp32c2"
CONFIG_HAL_WDT_ROM_IMPL=n
CONFIG_HAL_SYSTIMER_ROM_IMPL=n
CONFIG_HEAP_ROM_IMPL=n
CONFIG_SPI_FLASH_ROM_IMPL=y

View File

@ -0,0 +1,5 @@
CONFIG_IDF_TARGET="esp32c2"
CONFIG_HAL_WDT_USE_ROM_IMPL=n
CONFIG_HAL_SYSTIMER_USE_ROM_IMPL=n
CONFIG_HEAP_TLSF_USE_ROM_IMPL=n
CONFIG_SPI_FLASH_ROM_IMPL=n