diff --git a/components/driver/CMakeLists.txt b/components/driver/CMakeLists.txt index 22dce0b6b5..168619a024 100644 --- a/components/driver/CMakeLists.txt +++ b/components/driver/CMakeLists.txt @@ -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() diff --git a/components/esp_rom/esp32c2/Kconfig.soc_caps.in b/components/esp_rom/esp32c2/Kconfig.soc_caps.in index 162e79190c..0eebf6d89a 100644 --- a/components/esp_rom/esp32c2/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32c2/Kconfig.soc_caps.in @@ -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 diff --git a/components/esp_rom/esp32c2/esp_rom_caps.h b/components/esp_rom/esp32c2/esp_rom_caps.h index 9574825971..dfc376b77d 100644 --- a/components/esp_rom/esp32c2/esp_rom_caps.h +++ b/components/esp_rom/esp32c2/esp_rom_caps.h @@ -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 diff --git a/components/esp_rom/esp32s3/Kconfig.soc_caps.in b/components/esp_rom/esp32s3/Kconfig.soc_caps.in index 1b62cbaa28..b4e07adfd5 100644 --- a/components/esp_rom/esp32s3/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32s3/Kconfig.soc_caps.in @@ -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 diff --git a/components/esp_rom/esp32s3/esp_rom_caps.h b/components/esp_rom/esp32s3/esp_rom_caps.h index 9c8a4931cf..e5fe2017ff 100644 --- a/components/esp_rom/esp32s3/esp_rom_caps.h +++ b/components/esp_rom/esp32s3/esp_rom_caps.h @@ -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 diff --git a/components/esp_system/Kconfig b/components/esp_system/Kconfig index d717177546..f0a711161a 100644 --- a/components/esp_system/Kconfig +++ b/components/esp_system/Kconfig @@ -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 diff --git a/components/esp_system/int_wdt.c b/components/esp_system/int_wdt.c index 6f16f3b071..4a47bcb60c 100644 --- a/components/esp_system/int_wdt.c +++ b/components/esp_system/int_wdt.c @@ -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 diff --git a/components/hal/CMakeLists.txt b/components/hal/CMakeLists.txt index 903952646a..e87249d7fc 100644 --- a/components/hal/CMakeLists.txt +++ b/components/hal/CMakeLists.txt @@ -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" diff --git a/components/hal/Kconfig b/components/hal/Kconfig index fa8588620a..0e6b0bc2c1 100644 --- a/components/hal/Kconfig +++ b/components/hal/Kconfig @@ -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. diff --git a/components/hal/linker.lf b/components/hal/linker.lf index 729118368c..a2fa83ba21 100644 --- a/components/hal/linker.lf +++ b/components/hal/linker.lf @@ -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: diff --git a/docs/en/api-guides/performance/size.rst b/docs/en/api-guides/performance/size.rst index 39b6f148f9..adebc8f23b 100644 --- a/docs/en/api-guides/performance/size.rst +++ b/docs/en/api-guides/performance/size.rst @@ -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 ` 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 --------------- diff --git a/tools/test_apps/system/build_test/sdkconfig.ci copy.esp32c2_with_rom_impl_components b/tools/test_apps/system/build_test/sdkconfig.ci copy.esp32c2_with_rom_impl_components new file mode 100644 index 0000000000..68e9623a04 --- /dev/null +++ b/tools/test_apps/system/build_test/sdkconfig.ci copy.esp32c2_with_rom_impl_components @@ -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 diff --git a/tools/test_apps/system/build_test/sdkconfig.ci.esp32c2_rom_impl_components b/tools/test_apps/system/build_test/sdkconfig.ci.esp32c2_rom_impl_components deleted file mode 100644 index 9552d799b5..0000000000 --- a/tools/test_apps/system/build_test/sdkconfig.ci.esp32c2_rom_impl_components +++ /dev/null @@ -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 diff --git a/tools/test_apps/system/build_test/sdkconfig.ci.esp32c2_without_rom_impl_components b/tools/test_apps/system/build_test/sdkconfig.ci.esp32c2_without_rom_impl_components new file mode 100644 index 0000000000..e777b39382 --- /dev/null +++ b/tools/test_apps/system/build_test/sdkconfig.ci.esp32c2_without_rom_impl_components @@ -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