From 101e6a18ebf62d0a6e76f38e41c899dc67c3e194 Mon Sep 17 00:00:00 2001 From: Armando Date: Fri, 9 Jun 2023 20:31:22 +0800 Subject: [PATCH] esp32p4: introduce the target Add esp32p4 target to tools and Kconfig Create directories and files that are essential for `idf.py --preview set-target esp32p4` --- Kconfig | 6 ++++++ .../src/bootloader_flash_config_esp32p4.c | 0 .../include/esp_app_format.h | 1 + .../src/bootloader_random_esp32p4.c | 0 components/bt/controller/esp32p4/Kconfig.in | 0 components/esp_adc/esp32p4/include/.gitkeep | 0 .../esp_hw_support/include/esp_chip_info.h | 1 + .../include/soc/esp32p4/.gitkeep | 0 .../port/esp32p4/CMakeLists.txt | 0 .../port/esp32p4/cpu_region_protect.c | 0 .../port/esp32p4/esp_clk_tree.c | 0 .../esp_hw_support/port/esp32p4/io_mux.c | 0 .../esp_mm/port/esp32p4/ext_mem_layout.c | 0 components/esp_phy/CMakeLists.txt | 5 +++++ components/esp_rom/esp32p4/.gitkeep | 0 components/esp_rom/include/esp32p4/.gitkeep | 0 components/esp_system/ld/esp32p4/memory.ld.in | 0 .../port/soc/esp32p4/CMakeLists.txt | 0 .../esp_system/port/soc/esp32p4/Kconfig.cpu | 0 .../port/soc/esp32p4/Kconfig.system | 0 components/hal/esp32p4/clk_tree_hal.c | 0 components/hal/esp32p4/efuse_hal.c | 0 components/hal/esp32p4/include/.gitkeep | 0 components/heap/port/esp32p4/memory_layout.c | 0 components/idf_test/include/esp32p4/.gitkeep | 0 components/soc/esp32p4/gpio_periph.c | 0 components/soc/esp32p4/interrupts.c | 0 components/soc/esp32p4/uart_periph.c | 0 tools/cmake/dfu.cmake | 2 ++ tools/cmake/toolchain-esp32p4.cmake | 20 +++++++++++++++++++ tools/cmake/uf2.cmake | 2 ++ tools/idf_py_actions/constants.py | 2 +- tools/tools.json | 3 ++- 33 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32p4.c create mode 100644 components/bootloader_support/src/bootloader_random_esp32p4.c create mode 100644 components/bt/controller/esp32p4/Kconfig.in create mode 100644 components/esp_adc/esp32p4/include/.gitkeep create mode 100644 components/esp_hw_support/include/soc/esp32p4/.gitkeep create mode 100644 components/esp_hw_support/port/esp32p4/CMakeLists.txt create mode 100644 components/esp_hw_support/port/esp32p4/cpu_region_protect.c create mode 100644 components/esp_hw_support/port/esp32p4/esp_clk_tree.c create mode 100644 components/esp_hw_support/port/esp32p4/io_mux.c create mode 100644 components/esp_mm/port/esp32p4/ext_mem_layout.c create mode 100644 components/esp_rom/esp32p4/.gitkeep create mode 100644 components/esp_rom/include/esp32p4/.gitkeep create mode 100644 components/esp_system/ld/esp32p4/memory.ld.in create mode 100644 components/esp_system/port/soc/esp32p4/CMakeLists.txt create mode 100644 components/esp_system/port/soc/esp32p4/Kconfig.cpu create mode 100644 components/esp_system/port/soc/esp32p4/Kconfig.system create mode 100644 components/hal/esp32p4/clk_tree_hal.c create mode 100644 components/hal/esp32p4/efuse_hal.c create mode 100644 components/hal/esp32p4/include/.gitkeep create mode 100644 components/heap/port/esp32p4/memory_layout.c create mode 100644 components/idf_test/include/esp32p4/.gitkeep create mode 100644 components/soc/esp32p4/gpio_periph.c create mode 100644 components/soc/esp32p4/interrupts.c create mode 100644 components/soc/esp32p4/uart_periph.c create mode 100644 tools/cmake/toolchain-esp32p4.cmake diff --git a/Kconfig b/Kconfig index 02d53a4537..ab8c76d910 100644 --- a/Kconfig +++ b/Kconfig @@ -90,6 +90,11 @@ mainmenu "Espressif IoT Development Framework Configuration" select FREERTOS_UNICORE select IDF_TARGET_ARCH_RISCV + config IDF_TARGET_ESP32P4 + bool + default "y" if IDF_TARGET="esp32p4" + select IDF_TARGET_ARCH_RISCV + config IDF_TARGET_ESP32H2 bool default "y" if IDF_TARGET="esp32h2" @@ -109,6 +114,7 @@ mainmenu "Espressif IoT Development Framework Configuration" default 0x000C if IDF_TARGET_ESP32C2 default 0x000D if IDF_TARGET_ESP32C6 default 0x0010 if IDF_TARGET_ESP32H2 + default 0x0012 if IDF_TARGET_ESP32P4 default 0xFFFF diff --git a/components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32p4.c b/components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32p4.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/bootloader_support/include/esp_app_format.h b/components/bootloader_support/include/esp_app_format.h index 3845399e42..33990e65cd 100644 --- a/components/bootloader_support/include/esp_app_format.h +++ b/components/bootloader_support/include/esp_app_format.h @@ -20,6 +20,7 @@ typedef enum { ESP_CHIP_ID_ESP32C2 = 0x000C, /*!< chip ID: ESP32-C2 */ ESP_CHIP_ID_ESP32C6 = 0x000D, /*!< chip ID: ESP32-C6 */ ESP_CHIP_ID_ESP32H2 = 0x0010, /*!< chip ID: ESP32-H2 */ + ESP_CHIP_ID_ESP32P4 = 0x0012, /*!< chip ID: ESP32-P4 */ ESP_CHIP_ID_INVALID = 0xFFFF /*!< Invalid chip ID (we defined it to make sure the esp_chip_id_t is 2 bytes size) */ } __attribute__((packed)) esp_chip_id_t; diff --git a/components/bootloader_support/src/bootloader_random_esp32p4.c b/components/bootloader_support/src/bootloader_random_esp32p4.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/bt/controller/esp32p4/Kconfig.in b/components/bt/controller/esp32p4/Kconfig.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_adc/esp32p4/include/.gitkeep b/components/esp_adc/esp32p4/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 c9003cde7c..a4509f5b0e 100644 --- a/components/esp_hw_support/include/esp_chip_info.h +++ b/components/esp_hw_support/include/esp_chip_info.h @@ -27,6 +27,7 @@ typedef enum { CHIP_ESP32C2 = 12, //!< ESP32-C2 CHIP_ESP32C6 = 13, //!< ESP32-C6 CHIP_ESP32H2 = 16, //!< ESP32-H2 + CHIP_ESP32P4 = 18, //!< ESP32-P4 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/esp32p4/.gitkeep b/components/esp_hw_support/include/soc/esp32p4/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_hw_support/port/esp32p4/CMakeLists.txt b/components/esp_hw_support/port/esp32p4/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_hw_support/port/esp32p4/cpu_region_protect.c b/components/esp_hw_support/port/esp32p4/cpu_region_protect.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_hw_support/port/esp32p4/esp_clk_tree.c b/components/esp_hw_support/port/esp32p4/esp_clk_tree.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_hw_support/port/esp32p4/io_mux.c b/components/esp_hw_support/port/esp32p4/io_mux.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_mm/port/esp32p4/ext_mem_layout.c b/components/esp_mm/port/esp32p4/ext_mem_layout.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_phy/CMakeLists.txt b/components/esp_phy/CMakeLists.txt index 6b68cc9596..ecc37747fe 100644 --- a/components/esp_phy/CMakeLists.txt +++ b/components/esp_phy/CMakeLists.txt @@ -1,5 +1,10 @@ idf_build_get_property(idf_target IDF_TARGET) +if(IDF_TARGET STREQUAL "esp32p4") + # TODO: IDF-7460 + return() +endif() + set(srcs "src/phy_override.c" "src/lib_printf.c") if(CONFIG_APP_NO_BLOBS) diff --git a/components/esp_rom/esp32p4/.gitkeep b/components/esp_rom/esp32p4/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_rom/include/esp32p4/.gitkeep b/components/esp_rom/include/esp32p4/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_system/ld/esp32p4/memory.ld.in b/components/esp_system/ld/esp32p4/memory.ld.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_system/port/soc/esp32p4/CMakeLists.txt b/components/esp_system/port/soc/esp32p4/CMakeLists.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_system/port/soc/esp32p4/Kconfig.cpu b/components/esp_system/port/soc/esp32p4/Kconfig.cpu new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/esp_system/port/soc/esp32p4/Kconfig.system b/components/esp_system/port/soc/esp32p4/Kconfig.system new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/hal/esp32p4/clk_tree_hal.c b/components/hal/esp32p4/clk_tree_hal.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/hal/esp32p4/efuse_hal.c b/components/hal/esp32p4/efuse_hal.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/hal/esp32p4/include/.gitkeep b/components/hal/esp32p4/include/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/heap/port/esp32p4/memory_layout.c b/components/heap/port/esp32p4/memory_layout.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/idf_test/include/esp32p4/.gitkeep b/components/idf_test/include/esp32p4/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/soc/esp32p4/gpio_periph.c b/components/soc/esp32p4/gpio_periph.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/soc/esp32p4/interrupts.c b/components/soc/esp32p4/interrupts.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/soc/esp32p4/uart_periph.c b/components/soc/esp32p4/uart_periph.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/cmake/dfu.cmake b/tools/cmake/dfu.cmake index f1ecd940e9..ead9bac1e1 100644 --- a/tools/cmake/dfu.cmake +++ b/tools/cmake/dfu.cmake @@ -17,6 +17,8 @@ function(__add_dfu_targets) return() elseif("${target}" STREQUAL "esp32h2") return() + elseif("${target}" STREQUAL "esp32p4") + set(dfu_pid "12") elseif("${target}" STREQUAL "linux") return() else() diff --git a/tools/cmake/toolchain-esp32p4.cmake b/tools/cmake/toolchain-esp32p4.cmake new file mode 100644 index 0000000000..c768ed0c75 --- /dev/null +++ b/tools/cmake/toolchain-esp32p4.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/cmake/uf2.cmake b/tools/cmake/uf2.cmake index 4e80d8decf..94ec006ad9 100644 --- a/tools/cmake/uf2.cmake +++ b/tools/cmake/uf2.cmake @@ -16,6 +16,8 @@ function(__add_uf2_targets) set(uf2_family_id "0x2b88d29c") elseif("${target}" STREQUAL "esp32c6") # TODO: IDF-5626 set(uf2_family_id "0x2b88d29c") + elseif("${target}" STREQUAL "esp32p4") + set(uf2_family_id "0x2b88d29c") elseif("${target}" STREQUAL "linux") return() else() diff --git a/tools/idf_py_actions/constants.py b/tools/idf_py_actions/constants.py index ebb7a789f6..42d5cbe0d9 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', 'esp32c6', 'esp32h2'] -PREVIEW_TARGETS = ['linux'] +PREVIEW_TARGETS = ['linux', 'esp32p4'] 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/tools.json b/tools/tools.json index 2983a4c093..5b8352aa65 100644 --- a/tools/tools.json +++ b/tools/tools.json @@ -92,7 +92,8 @@ "esp32c3", "esp32c2", "esp32c6", - "esp32h2" + "esp32h2", + "esp32p4" ], "version_cmd": [ "riscv32-esp-elf-gdb-no-python",