From 9e3ba8d061368bba159982a10e66ad4236cdcac7 Mon Sep 17 00:00:00 2001 From: jiangguangming Date: Thu, 1 Dec 2022 19:55:58 +0800 Subject: [PATCH 1/3] esp_rom: update esp32h2 rom caps --- .../esp_rom/esp32h2/Kconfig.soc_caps.in | 24 +++++++++++++++++++ components/esp_rom/esp32h2/esp_rom_caps.h | 6 +++++ 2 files changed, 30 insertions(+) diff --git a/components/esp_rom/esp32h2/Kconfig.soc_caps.in b/components/esp_rom/esp32h2/Kconfig.soc_caps.in index 525f5cd62c..7b51a3c744 100644 --- a/components/esp_rom/esp32h2/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32h2/Kconfig.soc_caps.in @@ -26,3 +26,27 @@ config ESP_ROM_HAS_RETARGETABLE_LOCKING config ESP_ROM_GET_CLK_FREQ bool default y + +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 + +config ESP_ROM_HAS_HEAP_TLSF + bool + default y + +config ESP_ROM_HAS_LAYOUT_TABLE + bool + default y + +config ESP_ROM_HAS_SPI_FLASH + bool + default y diff --git a/components/esp_rom/esp32h2/esp_rom_caps.h b/components/esp_rom/esp32h2/esp_rom_caps.h index 231b495667..d024043253 100644 --- a/components/esp_rom/esp32h2/esp_rom_caps.h +++ b/components/esp_rom/esp32h2/esp_rom_caps.h @@ -12,3 +12,9 @@ #define ESP_ROM_USB_SERIAL_DEVICE_NUM (3) // UART uses USB_SERIAL_JTAG port 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_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 +#define ESP_ROM_HAS_HEAP_TLSF (1) // ROM has the implementation of the tlsf and multi-heap library +#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 From f9b6e25b55f5b2632b4ec960c329bf4df57d106c Mon Sep 17 00:00:00 2001 From: jiangguangming Date: Thu, 1 Dec 2022 20:27:51 +0800 Subject: [PATCH 2/3] esp_rom: update CMakeList.txt --- components/esp_rom/CMakeLists.txt | 38 +++++++++++++++++-------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/components/esp_rom/CMakeLists.txt b/components/esp_rom/CMakeLists.txt index affbd79fc8..e80719afab 100644 --- a/components/esp_rom/CMakeLists.txt +++ b/components/esp_rom/CMakeLists.txt @@ -255,27 +255,31 @@ else() # Regular app build # Normal(Non-nano) formatting functions in ROM are also built for 64-bit time_t. rom_linker_script("newlib-normal") endif() - endif() + endif() elseif(target STREQUAL "esp32h2") - rom_linker_script("newlib") - rom_linker_script("version") - rom_linker_script("phy") - rom_linker_script("coexist") - rom_linker_script("net80211") - rom_linker_script("pp") + rom_linker_script("newlib") + rom_linker_script("version") + rom_linker_script("phy") + rom_linker_script("coexist") + rom_linker_script("net80211") + rom_linker_script("pp") - if(time_t_size EQUAL 8) - # The ROM functions listed in this linker script depend on sizeof(time_t). - # Since ROM for ESP32-H2 was compiled for 64-bit time_t, only link these functions - # if the toolchain is also using 64-bit time_t. - rom_linker_script("newlib-time") + if(CONFIG_SPI_FLASH_ROM_IMPL) + rom_linker_script("spiflash") + endif() - if(CONFIG_NEWLIB_NANO_FORMAT) - # nano formatting functions in ROM are also built for 64-bit time_t. - rom_linker_script("newlib-nano") - endif() - endif() + if(time_t_size EQUAL 8) + # The ROM functions listed in this linker script depend on sizeof(time_t). + # Since ROM for ESP32-H2 was compiled for 64-bit time_t, only link these functions + # if the toolchain is also using 64-bit time_t. + rom_linker_script("newlib-time") + + if(CONFIG_NEWLIB_NANO_FORMAT) + # nano formatting functions in ROM are also built for 64-bit time_t. + rom_linker_script("newlib-nano") + endif() + endif() endif() From 7db7269a92f409f321e0ff76e8fa8ca8357da551 Mon Sep 17 00:00:00 2001 From: jiangguangming Date: Fri, 2 Dec 2022 14:41:07 +0800 Subject: [PATCH 3/3] esp_rom: patch systimer_hal_init/deinit for esp32h2 rom --- components/esp_rom/esp32h2/ld/esp32h2.rom.ld | 6 ++++-- components/esp_rom/patches/esp_rom_systimer.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/components/esp_rom/esp32h2/ld/esp32h2.rom.ld b/components/esp_rom/esp32h2/ld/esp32h2.rom.ld index 3f7a7a2930..74a19aad2f 100644 --- a/components/esp_rom/esp32h2/ld/esp32h2.rom.ld +++ b/components/esp_rom/esp32h2/ld/esp32h2.rom.ld @@ -183,8 +183,10 @@ wdt_hal_is_enabled = 0x400003b4; ***************************************/ /* Functions */ -systimer_hal_init = 0x400003b8; -systimer_hal_deinit = 0x400003bc; +/* The following ROM functions are commented out because they're patched in the esp_rom_systimer.c */ +/* systimer_hal_init = 0x400003b8; */ +/* systimer_hal_deinit = 0x400003bc; */ + systimer_hal_set_tick_rate_ops = 0x400003c0; systimer_hal_get_counter_value = 0x400003c4; systimer_hal_get_time = 0x400003c8; diff --git a/components/esp_rom/patches/esp_rom_systimer.c b/components/esp_rom/patches/esp_rom_systimer.c index bf930139a1..1b71b6f7f7 100644 --- a/components/esp_rom/patches/esp_rom_systimer.c +++ b/components/esp_rom/patches/esp_rom_systimer.c @@ -64,7 +64,7 @@ void systimer_hal_counter_value_advance(systimer_hal_context_t *hal, uint32_t co } #endif // CONFIG_IDF_TARGET_ESP32C2 -#if CONFIG_IDF_TARGET_ESP32C6 +#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 void systimer_hal_init(systimer_hal_context_t *hal) { hal->dev = &SYSTIMER;