From 634125820744efa33679fb95a6e441dadaa4f6a7 Mon Sep 17 00:00:00 2001 From: Alessandro Gatti Date: Thu, 11 Dec 2025 03:42:33 +0100 Subject: [PATCH] esp32/mpconfigport: Enable Zcmp opcodes for ESP32P4. This commit enables support for Zcmp opcodes when the firmware is built to target ESP32P4 microcontrollers. The ESP32P4 explicitly supports the Zcmp extension for reducing the amount of code needed for function prologues and epilogues (see section 4.1.1.1 of the ESP32P4 datasheet). Signed-off-by: Alessandro Gatti --- ports/esp32/esp32_common.cmake | 6 +++++- ports/esp32/mpconfigport.h | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ports/esp32/esp32_common.cmake b/ports/esp32/esp32_common.cmake index e3b1b81cae..ea60c395a7 100644 --- a/ports/esp32/esp32_common.cmake +++ b/ports/esp32/esp32_common.cmake @@ -244,7 +244,11 @@ set(MICROPY_TARGET ${COMPONENT_TARGET}) if(CONFIG_IDF_TARGET_ARCH_XTENSA) set(MICROPY_CROSS_FLAGS -march=xtensawin) elseif(CONFIG_IDF_TARGET_ARCH_RISCV) - set(MICROPY_CROSS_FLAGS -march=rv32imc) + if (CONFIG_IDF_TARGET_ESP32P4) + set(MICROPY_CROSS_FLAGS "-march=rv32imc -march-flags=zcmp") + else() + set(MICROPY_CROSS_FLAGS -march=rv32imc) + endif() endif() # Set compile options for this port. diff --git a/ports/esp32/mpconfigport.h b/ports/esp32/mpconfigport.h index 55503ff0ba..69419ce009 100644 --- a/ports/esp32/mpconfigport.h +++ b/ports/esp32/mpconfigport.h @@ -44,6 +44,9 @@ #define MICROPY_EMIT_RV32 (0) #else #define MICROPY_EMIT_RV32 (1) +#if CONFIG_IDF_TARGET_ESP32P4 +#define MICROPY_EMIT_RV32_ZCMP (1) +#endif #endif #else #define MICROPY_EMIT_XTENSAWIN (1)