diff --git a/components/esp_hw_support/CMakeLists.txt b/components/esp_hw_support/CMakeLists.txt index ee1d12a02d..ea187da5b1 100644 --- a/components/esp_hw_support/CMakeLists.txt +++ b/components/esp_hw_support/CMakeLists.txt @@ -190,7 +190,12 @@ endif() if(CONFIG_ESP32P4_SELECTS_REV_LESS_V3) if(CMAKE_C_COMPILER_ID MATCHES "GNU") - idf_build_set_property(COMPILE_OPTIONS "-mespv-spec=2p1" APPEND) + # 1. Set xespv2p1 explicitly to override the default xespv2p2. + # 2. Remove zc* extensions: + # The ESP32-P4 has always supported the zc* extensions, + # but revisions earlier than v3.0 are affected by hardware issue DIG-661 + # and lack the mintthresh_csr register needed for the workaround. + idf_build_set_property(COMPILE_OPTIONS "-march=rv32imafc_zicsr_zifencei_zaamo_zalrsc_xesploop_xespv2p1" APPEND) endif() elseif(CONFIG_IDF_TARGET_ESP32P4) if(CMAKE_C_COMPILER_ID MATCHES "Clang") # TODO: LLVM-478 diff --git a/tools/cmake/toolchain-esp32p4.cmake b/tools/cmake/toolchain-esp32p4.cmake index de7b8d02df..af66eeb506 100644 --- a/tools/cmake/toolchain-esp32p4.cmake +++ b/tools/cmake/toolchain-esp32p4.cmake @@ -7,7 +7,9 @@ set(CMAKE_CXX_COMPILER riscv32-esp-elf-g++) set(CMAKE_ASM_COMPILER riscv32-esp-elf-gcc) set(_CMAKE_TOOLCHAIN_PREFIX riscv32-esp-elf-) -set(_CMAKE_TOOLCHAIN_COMMON_FLAGS "-march=rv32imafc_zicsr_zifencei_zaamo_zalrsc_xespv_xesploop -mabi=ilp32f") +set(_CMAKE_TOOLCHAIN_COMMON_FLAGS "-march=rv32imafc_zicsr_zifencei_zaamo_zalrsc_zcb_zcmp_zcmt_xesploop_xespv \ + -mabi=ilp32f \ + -mno-cm-popret -mno-cm-push-reverse") remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} -mtune=esp-base ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE)