From 86aa4df5b59b06e3f0d430699fcfce449ff52f7a Mon Sep 17 00:00:00 2001 From: Cao Sen Miao Date: Tue, 22 Nov 2022 15:14:51 +0800 Subject: [PATCH] ESP32-H2: Introduce new target for ESP32H2 --- .../src/bootloader_flash_config_esp32h2.c | 5 ++++ .../src/bootloader_random_esp32h2.c | 5 ++++ components/bt/controller/esp32h2/Kconfig.in | 0 components/esp_adc/CMakeLists.txt | 5 ++++ .../include/soc/esp32h2/.gitkeep | 0 .../port/esp32h2/CMakeLists.txt | 0 .../esp_hw_support/port/esp32h2/Kconfig.mac | 0 components/esp_phy/CMakeLists.txt | 3 ++- components/esp_rom/esp32h2/.gitkeep | 0 components/esp_rom/include/esp32h2/.gitkeep | 0 components/esp_system/ld/esp32h2/memory.ld.in | 5 ++++ .../esp_system/ld/esp32h2/sections.ld.in | 5 ++++ .../port/soc/esp32h2/CMakeLists.txt | 13 +++++++++ .../esp_system/port/soc/esp32h2/Kconfig.cpu | 27 +++++++++++++++++++ .../port/soc/esp32h2/Kconfig.system | 0 .../port/soc/esp32h2/cache_err_int.c | 5 ++++ components/esp_system/port/soc/esp32h2/clk.c | 5 ++++ .../port/soc/esp32h2/reset_reason.c | 5 ++++ .../port/soc/esp32h2/system_internal.c | 5 ++++ components/hal/esp32h2/efuse_hal.c | 5 ++++ components/hal/esp32h2/include/.gitkeep | 0 components/heap/port/esp32h2/memory_layout.c | 5 ++++ components/idf_test/include/esp32h2/.gitkeep | 0 components/soc/esp32h2/CMakeLists.txt | 0 .../spi_flash/esp32h2/flash_ops_esp32h2.c | 5 ++++ tools/cmake/dfu.cmake | 2 ++ tools/cmake/toolchain-esp32h2.cmake | 18 +++++++++++++ tools/idf_py_actions/constants.py | 2 +- 28 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32h2.c create mode 100644 components/bootloader_support/src/bootloader_random_esp32h2.c create mode 100644 components/bt/controller/esp32h2/Kconfig.in create mode 100644 components/esp_hw_support/include/soc/esp32h2/.gitkeep create mode 100644 components/esp_hw_support/port/esp32h2/CMakeLists.txt create mode 100644 components/esp_hw_support/port/esp32h2/Kconfig.mac create mode 100644 components/esp_rom/esp32h2/.gitkeep create mode 100644 components/esp_rom/include/esp32h2/.gitkeep create mode 100644 components/esp_system/ld/esp32h2/memory.ld.in create mode 100644 components/esp_system/ld/esp32h2/sections.ld.in create mode 100644 components/esp_system/port/soc/esp32h2/CMakeLists.txt create mode 100644 components/esp_system/port/soc/esp32h2/Kconfig.cpu create mode 100644 components/esp_system/port/soc/esp32h2/Kconfig.system create mode 100644 components/esp_system/port/soc/esp32h2/cache_err_int.c create mode 100644 components/esp_system/port/soc/esp32h2/clk.c create mode 100644 components/esp_system/port/soc/esp32h2/reset_reason.c create mode 100644 components/esp_system/port/soc/esp32h2/system_internal.c create mode 100644 components/hal/esp32h2/efuse_hal.c create mode 100644 components/hal/esp32h2/include/.gitkeep create mode 100644 components/heap/port/esp32h2/memory_layout.c create mode 100644 components/idf_test/include/esp32h2/.gitkeep create mode 100644 components/soc/esp32h2/CMakeLists.txt create mode 100644 components/spi_flash/esp32h2/flash_ops_esp32h2.c create mode 100644 tools/cmake/toolchain-esp32h2.cmake diff --git a/components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32h2.c b/components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32h2.c new file mode 100644 index 0000000000..44826a0fea --- /dev/null +++ b/components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32h2.c @@ -0,0 +1,5 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ diff --git a/components/bootloader_support/src/bootloader_random_esp32h2.c b/components/bootloader_support/src/bootloader_random_esp32h2.c new file mode 100644 index 0000000000..44826a0fea --- /dev/null +++ b/components/bootloader_support/src/bootloader_random_esp32h2.c @@ -0,0 +1,5 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ diff --git a/components/bt/controller/esp32h2/Kconfig.in b/components/bt/controller/esp32h2/Kconfig.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_adc/CMakeLists.txt b/components/esp_adc/CMakeLists.txt index b52dffa1d0..fdeaf44f69 100644 --- a/components/esp_adc/CMakeLists.txt +++ b/components/esp_adc/CMakeLists.txt @@ -1,3 +1,8 @@ +if(IDF_TARGET STREQUAL "esp32h2") + # TODO : IDF-6214 + return() +endif() + idf_build_get_property(target IDF_TARGET) set(includes "include" "interface" "${target}/include" "deprecated/include") diff --git a/components/esp_hw_support/include/soc/esp32h2/.gitkeep b/components/esp_hw_support/include/soc/esp32h2/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_hw_support/port/esp32h2/CMakeLists.txt b/components/esp_hw_support/port/esp32h2/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_hw_support/port/esp32h2/Kconfig.mac b/components/esp_hw_support/port/esp32h2/Kconfig.mac new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_phy/CMakeLists.txt b/components/esp_phy/CMakeLists.txt index cf2e7db86e..499caea25f 100644 --- a/components/esp_phy/CMakeLists.txt +++ b/components/esp_phy/CMakeLists.txt @@ -1,7 +1,8 @@ idf_build_get_property(idf_target IDF_TARGET) -if(IDF_TARGET STREQUAL "esp32c6") +if(IDF_TARGET STREQUAL "esp32c6" OR IDF_TARGET STREQUAL "esp32h2") # TODO : IDF-5680 + # TODO : IDF-6337 return() endif() diff --git a/components/esp_rom/esp32h2/.gitkeep b/components/esp_rom/esp32h2/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_rom/include/esp32h2/.gitkeep b/components/esp_rom/include/esp32h2/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_system/ld/esp32h2/memory.ld.in b/components/esp_system/ld/esp32h2/memory.ld.in new file mode 100644 index 0000000000..44826a0fea --- /dev/null +++ b/components/esp_system/ld/esp32h2/memory.ld.in @@ -0,0 +1,5 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ diff --git a/components/esp_system/ld/esp32h2/sections.ld.in b/components/esp_system/ld/esp32h2/sections.ld.in new file mode 100644 index 0000000000..44826a0fea --- /dev/null +++ b/components/esp_system/ld/esp32h2/sections.ld.in @@ -0,0 +1,5 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ diff --git a/components/esp_system/port/soc/esp32h2/CMakeLists.txt b/components/esp_system/port/soc/esp32h2/CMakeLists.txt new file mode 100644 index 0000000000..75863a3fd7 --- /dev/null +++ b/components/esp_system/port/soc/esp32h2/CMakeLists.txt @@ -0,0 +1,13 @@ +set(srcs + "clk.c" + "reset_reason.c" + "system_internal.c" + "cache_err_int.c" + "../../arch/riscv/expression_with_stack.c" + "../../arch/riscv/expression_with_stack_asm.S" + "../../arch/riscv/panic_arch.c" + "../../arch/riscv/debug_stubs.c") + +add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" ${srcs}) + +target_sources(${COMPONENT_LIB} PRIVATE ${srcs}) diff --git a/components/esp_system/port/soc/esp32h2/Kconfig.cpu b/components/esp_system/port/soc/esp32h2/Kconfig.cpu new file mode 100644 index 0000000000..8056348a4b --- /dev/null +++ b/components/esp_system/port/soc/esp32h2/Kconfig.cpu @@ -0,0 +1,27 @@ +choice ESP_DEFAULT_CPU_FREQ_MHZ + prompt "CPU frequency" + default ESP_DEFAULT_CPU_FREQ_MHZ_64 if IDF_ENV_FPGA + default ESP_DEFAULT_CPU_FREQ_MHZ_96 + help + CPU frequency to be set on application startup. + + config ESP_DEFAULT_CPU_FREQ_MHZ_16 + bool "16 MHz" + depends on IDF_ENV_FPGA #ESP32H2-TODO: IDF-3786 + config ESP_DEFAULT_CPU_FREQ_MHZ_32 + bool "32 MHz" + depends on IDF_ENV_FPGA #ESP32H2-TODO: IDF-3786 + config ESP_DEFAULT_CPU_FREQ_MHZ_64 + bool "64 MHz" + depends on IDF_ENV_FPGA #ESP32H2-TODO: IDF-3786 + config ESP_DEFAULT_CPU_FREQ_MHZ_96 + bool "96 MHz" + depends on !IDF_ENV_FPGA +endchoice + +config ESP_DEFAULT_CPU_FREQ_MHZ + int + default 16 if ESP_DEFAULT_CPU_FREQ_MHZ_16 + default 32 if ESP_DEFAULT_CPU_FREQ_MHZ_32 + default 64 if ESP_DEFAULT_CPU_FREQ_MHZ_64 + default 96 if ESP_DEFAULT_CPU_FREQ_MHZ_96 diff --git a/components/esp_system/port/soc/esp32h2/Kconfig.system b/components/esp_system/port/soc/esp32h2/Kconfig.system new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_system/port/soc/esp32h2/cache_err_int.c b/components/esp_system/port/soc/esp32h2/cache_err_int.c new file mode 100644 index 0000000000..44826a0fea --- /dev/null +++ b/components/esp_system/port/soc/esp32h2/cache_err_int.c @@ -0,0 +1,5 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ diff --git a/components/esp_system/port/soc/esp32h2/clk.c b/components/esp_system/port/soc/esp32h2/clk.c new file mode 100644 index 0000000000..4527c30e1b --- /dev/null +++ b/components/esp_system/port/soc/esp32h2/clk.c @@ -0,0 +1,5 @@ +/* + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ diff --git a/components/esp_system/port/soc/esp32h2/reset_reason.c b/components/esp_system/port/soc/esp32h2/reset_reason.c new file mode 100644 index 0000000000..44826a0fea --- /dev/null +++ b/components/esp_system/port/soc/esp32h2/reset_reason.c @@ -0,0 +1,5 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ diff --git a/components/esp_system/port/soc/esp32h2/system_internal.c b/components/esp_system/port/soc/esp32h2/system_internal.c new file mode 100644 index 0000000000..44826a0fea --- /dev/null +++ b/components/esp_system/port/soc/esp32h2/system_internal.c @@ -0,0 +1,5 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ diff --git a/components/hal/esp32h2/efuse_hal.c b/components/hal/esp32h2/efuse_hal.c new file mode 100644 index 0000000000..44826a0fea --- /dev/null +++ b/components/hal/esp32h2/efuse_hal.c @@ -0,0 +1,5 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ diff --git a/components/hal/esp32h2/include/.gitkeep b/components/hal/esp32h2/include/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/heap/port/esp32h2/memory_layout.c b/components/heap/port/esp32h2/memory_layout.c new file mode 100644 index 0000000000..44826a0fea --- /dev/null +++ b/components/heap/port/esp32h2/memory_layout.c @@ -0,0 +1,5 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ diff --git a/components/idf_test/include/esp32h2/.gitkeep b/components/idf_test/include/esp32h2/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/soc/esp32h2/CMakeLists.txt b/components/soc/esp32h2/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/spi_flash/esp32h2/flash_ops_esp32h2.c b/components/spi_flash/esp32h2/flash_ops_esp32h2.c new file mode 100644 index 0000000000..44826a0fea --- /dev/null +++ b/components/spi_flash/esp32h2/flash_ops_esp32h2.c @@ -0,0 +1,5 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ diff --git a/tools/cmake/dfu.cmake b/tools/cmake/dfu.cmake index 3de89d4b26..677d1c16f1 100644 --- a/tools/cmake/dfu.cmake +++ b/tools/cmake/dfu.cmake @@ -17,6 +17,8 @@ function(__add_dfu_targets) return() elseif("${target}" STREQUAL "esp32c6") return() + elseif("${target}" STREQUAL "esp32h2") + return() elseif("${target}" STREQUAL "linux") return() else() diff --git a/tools/cmake/toolchain-esp32h2.cmake b/tools/cmake/toolchain-esp32h2.cmake new file mode 100644 index 0000000000..7242a1ac42 --- /dev/null +++ b/tools/cmake/toolchain-esp32h2.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=rv32imc ${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=rv32imc ${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=rv32imc --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 0cb9197fe8..61b84813f1 100644 --- a/tools/idf_py_actions/constants.py +++ b/tools/idf_py_actions/constants.py @@ -33,7 +33,7 @@ if os.name != 'nt': URL_TO_DOC = 'https://docs.espressif.com/projects/esp-idf' SUPPORTED_TARGETS = ['esp32', 'esp32s2', 'esp32c3', 'esp32s3', 'esp32c2'] -PREVIEW_TARGETS = ['linux', 'esp32h4', 'esp32c6'] +PREVIEW_TARGETS = ['linux', 'esp32h4', 'esp32c6', 'esp32h2'] OPENOCD_TAGET_CONFIG_DEFAULT = '-f interface/ftdi/esp32_devkitj_v1.cfg -f target/{target}.cfg' OPENOCD_TAGET_CONFIG: Dict[str, str] = {