From 64bbb53b8f42c192ca57642ae422bc93e7685939 Mon Sep 17 00:00:00 2001 From: gaoxu Date: Mon, 11 Nov 2024 12:01:39 +0800 Subject: [PATCH] feat(esp32h21): introduce target esp32h21(stage 1) --- Kconfig | 9 +++++++++ .../test_app_update/.build-test-rules.yml | 2 +- .../src/bootloader_flash_config_esp32h21.c | 0 components/bt/controller/esp32h21/Kconfig.in | 0 components/esp_adc/esp32h21/include/.gitkeep | 0 .../esp_hw_support/include/esp_chip_info.h | 1 + .../include/soc/esp32h21/.gitkeep | 0 .../port/esp32h21/CMakeLists.txt | 0 .../port/esp32h21/cpu_region_protect.c | 0 .../port/esp32h21/esp_clk_tree.c | 0 .../port/esp32h21/esp_cpu_intr.c | 0 .../esp_hw_support/port/esp32h21/io_mux.c | 0 .../esp_mm/port/esp32h21/ext_mem_layout.c | 0 components/esp_phy/esp32h21/include/.gitkeep | 0 .../esp32h21/include/esp32h21/rom/.gitkeep | 0 components/esp_security/src/esp32h21/.gitkeep | 0 components/esp_system/ld/esp32h21/memory.ld.in | 0 .../esp_system/ld/esp32h21/sections.ld.in | 0 .../port/soc/esp32h21/CMakeLists.txt | 0 .../esp_system/port/soc/esp32h21/Kconfig.cpu | 0 .../port/soc/esp32h21/Kconfig.system | 0 components/hal/esp32h21/include/.gitkeep | 0 components/heap/port/esp32h21/memory_layout.c | 0 components/idf_test/include/esp32h21/.gitkeep | 0 components/soc/esp32h21/gpio_periph.c | 0 components/soc/esp32h21/interrupts.c | 0 components/soc/esp32h21/uart_periph.c | 0 .../spi_flash/test_apps/.build-test-rules.yml | 2 +- tools/ci/check_build_test_rules.py | 2 ++ tools/cmake/dfu.cmake | 2 ++ tools/cmake/toolchain-esp32h21.cmake | 18 ++++++++++++++++++ tools/idf_py_actions/constants.py | 2 +- tools/test_apps/system/.build-test-rules.yml | 4 ++-- tools/tools.json | 9 ++++++--- 34 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32h21.c create mode 100644 components/bt/controller/esp32h21/Kconfig.in create mode 100644 components/esp_adc/esp32h21/include/.gitkeep create mode 100644 components/esp_hw_support/include/soc/esp32h21/.gitkeep create mode 100644 components/esp_hw_support/port/esp32h21/CMakeLists.txt create mode 100644 components/esp_hw_support/port/esp32h21/cpu_region_protect.c create mode 100644 components/esp_hw_support/port/esp32h21/esp_clk_tree.c create mode 100644 components/esp_hw_support/port/esp32h21/esp_cpu_intr.c create mode 100644 components/esp_hw_support/port/esp32h21/io_mux.c create mode 100644 components/esp_mm/port/esp32h21/ext_mem_layout.c create mode 100644 components/esp_phy/esp32h21/include/.gitkeep create mode 100644 components/esp_rom/esp32h21/include/esp32h21/rom/.gitkeep create mode 100644 components/esp_security/src/esp32h21/.gitkeep create mode 100644 components/esp_system/ld/esp32h21/memory.ld.in create mode 100644 components/esp_system/ld/esp32h21/sections.ld.in create mode 100644 components/esp_system/port/soc/esp32h21/CMakeLists.txt create mode 100644 components/esp_system/port/soc/esp32h21/Kconfig.cpu create mode 100644 components/esp_system/port/soc/esp32h21/Kconfig.system create mode 100644 components/hal/esp32h21/include/.gitkeep create mode 100644 components/heap/port/esp32h21/memory_layout.c create mode 100644 components/idf_test/include/esp32h21/.gitkeep create mode 100644 components/soc/esp32h21/gpio_periph.c create mode 100644 components/soc/esp32h21/interrupts.c create mode 100644 components/soc/esp32h21/uart_periph.c create mode 100644 tools/cmake/toolchain-esp32h21.cmake diff --git a/Kconfig b/Kconfig index 13d6c564cb..1f88204897 100644 --- a/Kconfig +++ b/Kconfig @@ -136,6 +136,14 @@ mainmenu "Espressif IoT Development Framework Configuration" select FREERTOS_UNICORE select IDF_TARGET_ARCH_RISCV + config IDF_TARGET_ESP32H21 + bool + default "y" if IDF_TARGET="esp32h21" + select FREERTOS_UNICORE + select IDF_TARGET_ARCH_RISCV + select IDF_ENV_FPGA + select IDF_ENV_BRINGUP + config IDF_TARGET_LINUX bool default "y" if IDF_TARGET="linux" @@ -152,6 +160,7 @@ mainmenu "Espressif IoT Development Framework Configuration" default 0x0012 if IDF_TARGET_ESP32P4 default 0x0017 if IDF_TARGET_ESP32C5 default 0x0014 if IDF_TARGET_ESP32C61 + default 0x0019 if IDF_TARGET_ESP32H21 default 0xFFFF diff --git a/components/app_update/test_apps/test_app_update/.build-test-rules.yml b/components/app_update/test_apps/test_app_update/.build-test-rules.yml index 49b89c9476..c6913f0010 100644 --- a/components/app_update/test_apps/test_app_update/.build-test-rules.yml +++ b/components/app_update/test_apps/test_app_update/.build-test-rules.yml @@ -2,7 +2,7 @@ components/app_update/test_apps: enable: - - if: CONFIG_NAME == "defaults" and IDF_TARGET != "linux" + - if: CONFIG_NAME == "defaults" and IDF_TARGET in ["esp32", "esp32c2", "esp32c3", "esp32c5", "esp32c6", "esp32c61", "esp32h2", "esp32p4", "esp32s2", "esp32s3"] - if: CONFIG_NAME == "xip_psram" and IDF_TARGET in ["esp32s2", "esp32s3", "esp32p4"] # S2 doesn't have ROM for flash - if: CONFIG_NAME == "xip_psram_with_rom_impl" and IDF_TARGET in ["esp32s3", "esp32p4"] diff --git a/components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32h21.c b/components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32h21.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/bt/controller/esp32h21/Kconfig.in b/components/bt/controller/esp32h21/Kconfig.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_adc/esp32h21/include/.gitkeep b/components/esp_adc/esp32h21/include/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_hw_support/include/esp_chip_info.h b/components/esp_hw_support/include/esp_chip_info.h index 603d5e5769..f2c91797b4 100644 --- a/components/esp_hw_support/include/esp_chip_info.h +++ b/components/esp_hw_support/include/esp_chip_info.h @@ -30,6 +30,7 @@ typedef enum { CHIP_ESP32P4 = 18, //!< ESP32-P4 CHIP_ESP32C61= 20, //!< ESP32-C61 CHIP_ESP32C5 = 23, //!< ESP32-C5 + CHIP_ESP32H21 = 25, //!< ESP32-H21 CHIP_POSIX_LINUX = 999, //!< The code is running on POSIX/Linux simulator } esp_chip_model_t; diff --git a/components/esp_hw_support/include/soc/esp32h21/.gitkeep b/components/esp_hw_support/include/soc/esp32h21/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_hw_support/port/esp32h21/CMakeLists.txt b/components/esp_hw_support/port/esp32h21/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_hw_support/port/esp32h21/cpu_region_protect.c b/components/esp_hw_support/port/esp32h21/cpu_region_protect.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_hw_support/port/esp32h21/esp_clk_tree.c b/components/esp_hw_support/port/esp32h21/esp_clk_tree.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_hw_support/port/esp32h21/esp_cpu_intr.c b/components/esp_hw_support/port/esp32h21/esp_cpu_intr.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_hw_support/port/esp32h21/io_mux.c b/components/esp_hw_support/port/esp32h21/io_mux.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_mm/port/esp32h21/ext_mem_layout.c b/components/esp_mm/port/esp32h21/ext_mem_layout.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_phy/esp32h21/include/.gitkeep b/components/esp_phy/esp32h21/include/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_rom/esp32h21/include/esp32h21/rom/.gitkeep b/components/esp_rom/esp32h21/include/esp32h21/rom/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_security/src/esp32h21/.gitkeep b/components/esp_security/src/esp32h21/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_system/ld/esp32h21/memory.ld.in b/components/esp_system/ld/esp32h21/memory.ld.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_system/ld/esp32h21/sections.ld.in b/components/esp_system/ld/esp32h21/sections.ld.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_system/port/soc/esp32h21/CMakeLists.txt b/components/esp_system/port/soc/esp32h21/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_system/port/soc/esp32h21/Kconfig.cpu b/components/esp_system/port/soc/esp32h21/Kconfig.cpu new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_system/port/soc/esp32h21/Kconfig.system b/components/esp_system/port/soc/esp32h21/Kconfig.system new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/hal/esp32h21/include/.gitkeep b/components/hal/esp32h21/include/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/heap/port/esp32h21/memory_layout.c b/components/heap/port/esp32h21/memory_layout.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/idf_test/include/esp32h21/.gitkeep b/components/idf_test/include/esp32h21/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/soc/esp32h21/gpio_periph.c b/components/soc/esp32h21/gpio_periph.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/soc/esp32h21/interrupts.c b/components/soc/esp32h21/interrupts.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/soc/esp32h21/uart_periph.c b/components/soc/esp32h21/uart_periph.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/spi_flash/test_apps/.build-test-rules.yml b/components/spi_flash/test_apps/.build-test-rules.yml index e2be1b0ff7..31969c6685 100644 --- a/components/spi_flash/test_apps/.build-test-rules.yml +++ b/components/spi_flash/test_apps/.build-test-rules.yml @@ -31,7 +31,7 @@ components/spi_flash/test_apps/flash_mmap: - esp_mm - spi_flash enable: - - if: CONFIG_NAME in ["release", "rom_impl"] and IDF_TARGET != "linux" + - if: CONFIG_NAME in ["release", "rom_impl"] and IDF_TARGET in ["esp32", "esp32c2", "esp32c3", "esp32c5", "esp32c6", "esp32c61", "esp32h2", "esp32p4", "esp32s2", "esp32s3"] - if: CONFIG_NAME == "xip_psram" and IDF_TARGET in ["esp32s2", "esp32s3", "esp32p4"] # S2 doesn't have ROM for flash - if: CONFIG_NAME == "xip_psram_with_rom_impl" and IDF_TARGET in ["esp32s3", "esp32p4"] diff --git a/tools/ci/check_build_test_rules.py b/tools/ci/check_build_test_rules.py index 39e55d9359..33e5f040f0 100755 --- a/tools/ci/check_build_test_rules.py +++ b/tools/ci/check_build_test_rules.py @@ -36,6 +36,7 @@ USUAL_TO_FORMAL = { 'esp32h2': 'ESP32-H2', 'esp32p4': 'ESP32-P4', 'esp32c61': 'ESP32-C61', + 'esp32h21': 'ESP32-H21', 'linux': 'Linux', } @@ -50,6 +51,7 @@ FORMAL_TO_USUAL = { 'ESP32-H2': 'esp32h2', 'ESP32-P4': 'esp32p4', 'ESP32-C61': 'esp32c61', + 'ESP32-H21': 'esp32h21', 'Linux': 'linux', } diff --git a/tools/cmake/dfu.cmake b/tools/cmake/dfu.cmake index 3c77d1cd51..44dd1b1aa4 100644 --- a/tools/cmake/dfu.cmake +++ b/tools/cmake/dfu.cmake @@ -21,6 +21,8 @@ function(__add_dfu_targets) return() elseif("${target}" STREQUAL "esp32h2") return() + elseif("${target}" STREQUAL "esp32h21") + return() elseif("${target}" STREQUAL "esp32p4") set(dfu_pid "12") elseif("${target}" STREQUAL "linux") diff --git a/tools/cmake/toolchain-esp32h21.cmake b/tools/cmake/toolchain-esp32h21.cmake new file mode 100644 index 0000000000..6415daa59b --- /dev/null +++ b/tools/cmake/toolchain-esp32h21.cmake @@ -0,0 +1,18 @@ +include($ENV{IDF_PATH}/tools/cmake/utilities.cmake) + +set(CMAKE_SYSTEM_NAME Generic) + +set(CMAKE_C_COMPILER riscv32-esp-elf-gcc) +set(CMAKE_CXX_COMPILER riscv32-esp-elf-g++) +set(CMAKE_ASM_COMPILER riscv32-esp-elf-gcc) +set(_CMAKE_TOOLCHAIN_PREFIX riscv32-esp-elf-) + +remove_duplicated_flags("-march=rv32imac_zicsr_zifencei ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) +set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) +remove_duplicated_flags("-march=rv32imac_zicsr_zifencei ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) +set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) + +remove_duplicated_flags("-nostartfiles -march=rv32imac_zicsr_zifencei --specs=nosys.specs \ + ${CMAKE_EXE_LINKER_FLAGS}" + UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS) +set(CMAKE_EXE_LINKER_FLAGS "${UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS}" CACHE STRING "Linker Base Flags" FORCE) diff --git a/tools/idf_py_actions/constants.py b/tools/idf_py_actions/constants.py index d7bf72bcdd..a354e06f0a 100644 --- a/tools/idf_py_actions/constants.py +++ b/tools/idf_py_actions/constants.py @@ -34,7 +34,7 @@ if os.name != 'nt': URL_TO_DOC = 'https://docs.espressif.com/projects/esp-idf' SUPPORTED_TARGETS = ['esp32', 'esp32s2', 'esp32c3', 'esp32s3', 'esp32c2', 'esp32c6', 'esp32h2', 'esp32p4'] -PREVIEW_TARGETS = ['linux', 'esp32c5', 'esp32c61'] +PREVIEW_TARGETS = ['linux', 'esp32c5', 'esp32c61', 'esp32h21'] OPENOCD_TAGET_CONFIG_DEFAULT = '-f interface/ftdi/esp32_devkitj_v1.cfg -f target/{target}.cfg' OPENOCD_TAGET_CONFIG: Dict[str, str] = { diff --git a/tools/test_apps/system/.build-test-rules.yml b/tools/test_apps/system/.build-test-rules.yml index c98392018b..04c5748599 100644 --- a/tools/test_apps/system/.build-test-rules.yml +++ b/tools/test_apps/system/.build-test-rules.yml @@ -24,8 +24,8 @@ tools/test_apps/system/cxx_no_except: reason: the other targets are not tested yet tools/test_apps/system/eh_frame: - enable: - - if: IDF_TARGET not in ["esp32", "esp32s2", "esp32s3", "linux"] + disable: + - if: IDF_TARGET in ["esp32", "esp32s2", "esp32s3", "linux"] reason: Only relevant for riscv targets tools/test_apps/system/esp_intr_dump: diff --git a/tools/tools.json b/tools/tools.json index 7fab2a8ec4..b7445274b1 100644 --- a/tools/tools.json +++ b/tools/tools.json @@ -95,7 +95,8 @@ "esp32c5", "esp32h2", "esp32p4", - "esp32c61" + "esp32c61", + "esp32h21" ], "version_cmd": [ "riscv32-esp-elf-gdb-no-python", @@ -252,7 +253,8 @@ "esp32c5", "esp32h2", "esp32p4", - "esp32c61" + "esp32c61", + "esp32h21" ], "version_cmd": [ "clang", @@ -318,7 +320,8 @@ "esp32c5", "esp32h2", "esp32c61", - "esp32p4" + "esp32p4", + "esp32h21" ], "version_cmd": [ "riscv32-esp-elf-gcc",