From a008ecf7077f6e454f1114d49d0e48aac4ca42da Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Sat, 5 Jul 2025 14:02:15 +0200 Subject: [PATCH] misc: Add GCC minimum toolchain check for CM55. Signed-off-by: iabdalkader --- Makefile | 5 +++-- boot/Makefile | 4 ++-- common/check_toolchain.mk | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 common/check_toolchain.mk diff --git a/Makefile b/Makefile index 991f75d3f..479251fe1 100755 --- a/Makefile +++ b/Makefile @@ -127,9 +127,10 @@ MPY_MKARGS = PORT=$(PORT) BOARD=$(TARGET) DEBUG=$(DEBUG) MICROPY_MANIFEST_OMV_LI MICROPY_ROM_TEXT_COMPRESSION=$(ROM_TEXT_COMPRESSION) USER_C_MODULES=$(TOP_DIR) -# Disable broken optimization for CM55. + +# Check GCC toolchain version. ifeq ($(CPU),cortex-m55) -CFLAGS += -fdisable-rtl-loop2_doloop +include $(TOP_DIR)/common/check_toolchain.mk endif # Configure additional built-in modules. Note must define both the CFLAGS and the Make command line args. diff --git a/boot/Makefile b/boot/Makefile index 43538bee1..2fdf4aab3 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -49,8 +49,8 @@ endif # Include the port Makefile. include $(PORT_DIR)/$(PORT_LOWER)_port.mk -# Disable broken optimization for CM55. +# Check GCC toolchain version. ifeq ($(CPU),cortex-m55) -CFLAGS += -fdisable-rtl-loop2_doloop +include $(TOP_DIR)/common/check_toolchain.mk endif diff --git a/common/check_toolchain.mk b/common/check_toolchain.mk new file mode 100644 index 000000000..b23814847 --- /dev/null +++ b/common/check_toolchain.mk @@ -0,0 +1,17 @@ +ifeq ($(CPU),cortex-m55) +# Check if GCC version is less than 14.3 +GCC_VERSION := $(shell arm-none-eabi-gcc -dumpversion | cut -d. -f1-2) +GCC_MAJOR := $(shell echo $(GCC_VERSION) | cut -d. -f1) +GCC_MINOR := $(shell echo $(GCC_VERSION) | cut -d. -f2) + +# Convert to comparable number (14.3 becomes 1403) +GCC_VERSION_NUM := $(shell echo $$(($(GCC_MAJOR) * 100 + $(GCC_MINOR)))) + +# Only add the flag if version < 14.3 (1403) +ifeq ($(shell test $(GCC_VERSION_NUM) -lt 1403 && echo yes),yes) +$(warning *** ERROR ***) +$(warning GCC $(GCC_VERSION) has known issues with Cortex-M55) +$(warning Upgrade to GCC 14.3+ for proper CM55 support) +$(error ) +endif +endif