Build: Fix arm/mps3/corstone310_fvp build with cmake 3.16.3
ARMClang.cmake in cmake 3.16 only checks CMAKE_SYSTEM_PROCESSOR variable.
In this case if only ARCH is defined in the build, cmake will throw
an error. But, GCC doesn't support the cortex-m85 processor yet. So we
define the cpu type, and check it in the toolchain_GNUARM.cmake file.
Signed-off-by: Dávid Házi <david.hazi@arm.com>
Change-Id: I12e9f9c0085a0fe1c5bd9900df9e4e923ec0629b
diff --git a/docs/platform/ext/target/arm/mps3/corstone310_fvp/README.rst b/docs/platform/ext/target/arm/mps3/corstone310_fvp/README.rst
index d619bfc..b1fa793 100644
--- a/docs/platform/ext/target/arm/mps3/corstone310_fvp/README.rst
+++ b/docs/platform/ext/target/arm/mps3/corstone310_fvp/README.rst
@@ -30,6 +30,9 @@
The built binaries can be run on the Corstone-310 Arm Virtual Hardware
(VHT_Corstone_SSE-310). At least VHT version 11.17 is required.
+.. note::
+
+ For Armclang compiler v6.18 or later version is required.
To run the example code on Corstone-310 Ethos-U55 Arm Virtual Hardware
----------------------------------------------------------------------
diff --git a/platform/ext/target/arm/mps3/corstone310_fvp/check_config.cmake b/platform/ext/target/arm/mps3/corstone310_fvp/check_config.cmake
new file mode 100644
index 0000000..33f91b4
--- /dev/null
+++ b/platform/ext/target/arm/mps3/corstone310_fvp/check_config.cmake
@@ -0,0 +1,9 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2022, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+## test incompatible compiler
+tfm_invalid_config(CMAKE_C_COMPILER MATCHES "armclang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 6.18.0)
diff --git a/platform/ext/target/arm/mps3/corstone310_fvp/preload.cmake b/platform/ext/target/arm/mps3/corstone310_fvp/preload.cmake
index e83e3db..be18337 100644
--- a/platform/ext/target/arm/mps3/corstone310_fvp/preload.cmake
+++ b/platform/ext/target/arm/mps3/corstone310_fvp/preload.cmake
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2021, Arm Limited. All rights reserved.
+# Copyright (c) 2021-2022, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -10,6 +10,7 @@
# that uses this platform. In practise this is normally compiler definitions and
# variables related to hardware.
-# Set architecture
+# Set architecture and CPU
+set(TFM_SYSTEM_PROCESSOR cortex-m85)
set(TFM_SYSTEM_ARCHITECTURE armv8.1-m.main)
set(TFM_SYSTEM_MVE OFF)
diff --git a/toolchain_GNUARM.cmake b/toolchain_GNUARM.cmake
index ee31875..e47668e 100644
--- a/toolchain_GNUARM.cmake
+++ b/toolchain_GNUARM.cmake
@@ -75,18 +75,24 @@
macro(tfm_toolchain_set_processor_arch)
if (DEFINED TFM_SYSTEM_PROCESSOR)
- set(CMAKE_SYSTEM_PROCESSOR ${TFM_SYSTEM_PROCESSOR})
+ if(TFM_SYSTEM_PROCESSOR MATCHES "cortex-m85")
+ # GNUARM does not support the -mcpu=cortex-m85 flag yet
+ # TODO: Remove this exception when the cortex-m85 support comes out.
+ message(WARNING "Cortex-m85 is not supported by GCC. Falling back to -march usage.")
+ else()
+ set(CMAKE_SYSTEM_PROCESSOR ${TFM_SYSTEM_PROCESSOR})
- if (DEFINED TFM_SYSTEM_DSP)
- if (NOT TFM_SYSTEM_DSP)
- string(APPEND CMAKE_SYSTEM_PROCESSOR "+nodsp")
+ if (DEFINED TFM_SYSTEM_DSP)
+ if (NOT TFM_SYSTEM_DSP)
+ string(APPEND CMAKE_SYSTEM_PROCESSOR "+nodsp")
+ endif()
endif()
- endif()
- if(GCC_VERSION VERSION_GREATER_EQUAL "8.0.0")
- if (DEFINED CONFIG_TFM_FP)
- if(CONFIG_TFM_FP STREQUAL "0" AND
- NOT TFM_SYSTEM_ARCHITECTURE STREQUAL "armv6-m")
- string(APPEND CMAKE_SYSTEM_PROCESSOR "+nofp")
+ if(GCC_VERSION VERSION_GREATER_EQUAL "8.0.0")
+ if (DEFINED CONFIG_TFM_FP)
+ if(CONFIG_TFM_FP STREQUAL "0" AND
+ NOT TFM_SYSTEM_ARCHITECTURE STREQUAL "armv6-m")
+ string(APPEND CMAKE_SYSTEM_PROCESSOR "+nofp")
+ endif()
endif()
endif()
endif()
@@ -140,7 +146,7 @@
unset(CMAKE_C_FLAGS_INIT)
unset(CMAKE_ASM_FLAGS_INIT)
- if (DEFINED TFM_SYSTEM_PROCESSOR)
+ if (CMAKE_SYSTEM_PROCESSOR)
set(CMAKE_C_FLAGS_INIT "-mcpu=${CMAKE_SYSTEM_PROCESSOR}")
set(CMAKE_ASM_FLAGS_INIT "-mcpu=${CMAKE_SYSTEM_PROCESSOR}")
set(CMAKE_C_LINK_FLAGS "-mcpu=${CMAKE_SYSTEM_PROCESSOR}")