From 6f83f39dce861e5f71493e2c714d091c218aca15 Mon Sep 17 00:00:00 2001 From: Chen Jichang Date: Thu, 6 Feb 2025 19:32:57 +0800 Subject: [PATCH] feat(esp32h4): introduce target esp32h4(stage 1) --- Kconfig | 8 ++++++++ .../src/bootloader_flash_config_esp32h4.c | 0 components/bt/controller/esp32h4/Kconfig.in | 0 components/esp_adc/esp32h4/include/.gitkeep | 0 .../esp_hw_support/include/esp_chip_info.h | 1 + .../include/soc/esp32h4/.gitkeep | 0 .../port/esp32h4/CMakeLists.txt | 0 .../port/esp32h4/cpu_region_protect.c | 0 .../port/esp32h4/esp_clk_tree.c | 0 .../port/esp32h4/esp_cpu_intr.c | 0 .../esp_hw_support/port/esp32h4/io_mux.c | 0 .../esp_mm/port/esp32h4/ext_mem_layout.c | 0 components/esp_phy/esp32h4/include/.gitkeep | 0 .../esp32h4/include/esp32h4/rom/.gitkeep | 0 components/esp_security/src/esp32h4/.gitkeep | 0 components/esp_system/ld/esp32h4/memory.ld.in | 0 .../esp_system/ld/esp32h4/sections.ld.in | 0 .../port/soc/esp32h4/CMakeLists.txt | 0 .../esp_system/port/soc/esp32h4/Kconfig.cpu | 0 .../port/soc/esp32h4/Kconfig.system | 0 components/hal/esp32h4/include/.gitkeep | 0 components/heap/port/esp32h4/memory_layout.c | 0 components/idf_test/include/esp32h4/.gitkeep | 0 components/soc/esp32h4/gpio_periph.c | 0 components/soc/esp32h4/interrupts.c | 0 components/soc/esp32h4/uart_periph.c | 0 tools/ci/check_build_test_rules.py | 2 ++ tools/cmake/dfu.cmake | 2 ++ tools/cmake/toolchain-esp32h4.cmake | 20 +++++++++++++++++++ tools/idf_py_actions/constants.py | 2 +- tools/tools.json | 9 ++++++--- 31 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32h4.c create mode 100644 components/bt/controller/esp32h4/Kconfig.in create mode 100644 components/esp_adc/esp32h4/include/.gitkeep create mode 100644 components/esp_hw_support/include/soc/esp32h4/.gitkeep create mode 100644 components/esp_hw_support/port/esp32h4/CMakeLists.txt create mode 100644 components/esp_hw_support/port/esp32h4/cpu_region_protect.c create mode 100644 components/esp_hw_support/port/esp32h4/esp_clk_tree.c create mode 100644 components/esp_hw_support/port/esp32h4/esp_cpu_intr.c create mode 100644 components/esp_hw_support/port/esp32h4/io_mux.c create mode 100644 components/esp_mm/port/esp32h4/ext_mem_layout.c create mode 100644 components/esp_phy/esp32h4/include/.gitkeep create mode 100644 components/esp_rom/esp32h4/include/esp32h4/rom/.gitkeep create mode 100644 components/esp_security/src/esp32h4/.gitkeep create mode 100644 components/esp_system/ld/esp32h4/memory.ld.in create mode 100644 components/esp_system/ld/esp32h4/sections.ld.in create mode 100644 components/esp_system/port/soc/esp32h4/CMakeLists.txt create mode 100644 components/esp_system/port/soc/esp32h4/Kconfig.cpu create mode 100644 components/esp_system/port/soc/esp32h4/Kconfig.system create mode 100644 components/hal/esp32h4/include/.gitkeep create mode 100644 components/heap/port/esp32h4/memory_layout.c create mode 100644 components/idf_test/include/esp32h4/.gitkeep create mode 100644 components/soc/esp32h4/gpio_periph.c create mode 100644 components/soc/esp32h4/interrupts.c create mode 100644 components/soc/esp32h4/uart_periph.c create mode 100644 tools/cmake/toolchain-esp32h4.cmake diff --git a/Kconfig b/Kconfig index da25de649d..96cdd3f8a5 100644 --- a/Kconfig +++ b/Kconfig @@ -144,6 +144,13 @@ mainmenu "Espressif IoT Development Framework Configuration" select IDF_ENV_FPGA select IDF_ENV_BRINGUP + config IDF_TARGET_ESP32H4 + bool + default "y" if IDF_TARGET="esp32h4" + select IDF_TARGET_ARCH_RISCV + select IDF_ENV_FPGA + select IDF_ENV_BRINGUP + config IDF_TARGET_LINUX bool default "y" if IDF_TARGET="linux" @@ -161,6 +168,7 @@ mainmenu "Espressif IoT Development Framework Configuration" default 0x0017 if IDF_TARGET_ESP32C5 default 0x0014 if IDF_TARGET_ESP32C61 default 0x0019 if IDF_TARGET_ESP32H21 + default 0x001C if IDF_TARGET_ESP32H4 default 0xFFFF diff --git a/components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32h4.c b/components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32h4.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/bt/controller/esp32h4/Kconfig.in b/components/bt/controller/esp32h4/Kconfig.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_adc/esp32h4/include/.gitkeep b/components/esp_adc/esp32h4/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 f2c91797b4..1cb0e780d7 100644 --- a/components/esp_hw_support/include/esp_chip_info.h +++ b/components/esp_hw_support/include/esp_chip_info.h @@ -31,6 +31,7 @@ typedef enum { CHIP_ESP32C61= 20, //!< ESP32-C61 CHIP_ESP32C5 = 23, //!< ESP32-C5 CHIP_ESP32H21 = 25, //!< ESP32-H21 + CHIP_ESP32H4 = 28, //!< ESP32-H4 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/esp32h4/.gitkeep b/components/esp_hw_support/include/soc/esp32h4/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_hw_support/port/esp32h4/CMakeLists.txt b/components/esp_hw_support/port/esp32h4/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_hw_support/port/esp32h4/cpu_region_protect.c b/components/esp_hw_support/port/esp32h4/cpu_region_protect.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_hw_support/port/esp32h4/esp_clk_tree.c b/components/esp_hw_support/port/esp32h4/esp_clk_tree.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_hw_support/port/esp32h4/esp_cpu_intr.c b/components/esp_hw_support/port/esp32h4/esp_cpu_intr.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_hw_support/port/esp32h4/io_mux.c b/components/esp_hw_support/port/esp32h4/io_mux.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_mm/port/esp32h4/ext_mem_layout.c b/components/esp_mm/port/esp32h4/ext_mem_layout.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_phy/esp32h4/include/.gitkeep b/components/esp_phy/esp32h4/include/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_rom/esp32h4/include/esp32h4/rom/.gitkeep b/components/esp_rom/esp32h4/include/esp32h4/rom/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_security/src/esp32h4/.gitkeep b/components/esp_security/src/esp32h4/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_system/ld/esp32h4/memory.ld.in b/components/esp_system/ld/esp32h4/memory.ld.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_system/ld/esp32h4/sections.ld.in b/components/esp_system/ld/esp32h4/sections.ld.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_system/port/soc/esp32h4/CMakeLists.txt b/components/esp_system/port/soc/esp32h4/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_system/port/soc/esp32h4/Kconfig.cpu b/components/esp_system/port/soc/esp32h4/Kconfig.cpu new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_system/port/soc/esp32h4/Kconfig.system b/components/esp_system/port/soc/esp32h4/Kconfig.system new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/hal/esp32h4/include/.gitkeep b/components/hal/esp32h4/include/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/heap/port/esp32h4/memory_layout.c b/components/heap/port/esp32h4/memory_layout.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/idf_test/include/esp32h4/.gitkeep b/components/idf_test/include/esp32h4/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/soc/esp32h4/gpio_periph.c b/components/soc/esp32h4/gpio_periph.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/soc/esp32h4/interrupts.c b/components/soc/esp32h4/interrupts.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/soc/esp32h4/uart_periph.c b/components/soc/esp32h4/uart_periph.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/ci/check_build_test_rules.py b/tools/ci/check_build_test_rules.py index 33e5f040f0..a57b866eea 100755 --- a/tools/ci/check_build_test_rules.py +++ b/tools/ci/check_build_test_rules.py @@ -37,6 +37,7 @@ USUAL_TO_FORMAL = { 'esp32p4': 'ESP32-P4', 'esp32c61': 'ESP32-C61', 'esp32h21': 'ESP32-H21', + 'esp32h4': 'ESP32-H4', 'linux': 'Linux', } @@ -52,6 +53,7 @@ FORMAL_TO_USUAL = { 'ESP32-P4': 'esp32p4', 'ESP32-C61': 'esp32c61', 'ESP32-H21': 'esp32h21', + 'ESP32-H4': 'esp32h4', 'Linux': 'linux', } diff --git a/tools/cmake/dfu.cmake b/tools/cmake/dfu.cmake index 44dd1b1aa4..455377474c 100644 --- a/tools/cmake/dfu.cmake +++ b/tools/cmake/dfu.cmake @@ -23,6 +23,8 @@ function(__add_dfu_targets) return() elseif("${target}" STREQUAL "esp32h21") return() + elseif("${target}" STREQUAL "esp32h4") + return() elseif("${target}" STREQUAL "esp32p4") set(dfu_pid "12") elseif("${target}" STREQUAL "linux") diff --git a/tools/cmake/toolchain-esp32h4.cmake b/tools/cmake/toolchain-esp32h4.cmake new file mode 100644 index 0000000000..c768ed0c75 --- /dev/null +++ b/tools/cmake/toolchain-esp32h4.cmake @@ -0,0 +1,20 @@ +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=rv32imafc_zicsr_zifencei -mabi=ilp32f ${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=rv32imafc_zicsr_zifencei -mabi=ilp32f ${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("-march=rv32imafc_zicsr_zifencei -mabi=ilp32f ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) +set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "Asm Compiler Base Flags" FORCE) + +remove_duplicated_flags("-nostartfiles -march=rv32imafc_zicsr_zifencei -mabi=ilp32f --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 7106b60d99..f55646eb1f 100644 --- a/tools/idf_py_actions/constants.py +++ b/tools/idf_py_actions/constants.py @@ -34,4 +34,4 @@ 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', 'esp32h21'] +PREVIEW_TARGETS = ['linux', 'esp32c5', 'esp32c61', 'esp32h21', 'esp32h4'] diff --git a/tools/tools.json b/tools/tools.json index 72104191d4..aee1039620 100644 --- a/tools/tools.json +++ b/tools/tools.json @@ -96,7 +96,8 @@ "esp32h2", "esp32p4", "esp32c61", - "esp32h21" + "esp32h21", + "esp32h4" ], "version_cmd": [ "riscv32-esp-elf-gdb-no-python", @@ -254,7 +255,8 @@ "esp32h2", "esp32p4", "esp32c61", - "esp32h21" + "esp32h21", + "esp32h4" ], "version_cmd": [ "clang", @@ -321,7 +323,8 @@ "esp32h2", "esp32c61", "esp32p4", - "esp32h21" + "esp32h21", + "esp32h4" ], "version_cmd": [ "riscv32-esp-elf-gcc",