MLECO-3640 MLECO-3678: Adding support for M85 in GCC

Signed-off-by: Richard Burton <richard.burton@arm.com>

Change-Id: I087e23f43b41fa0ef97ec7dcaeba807f6cba17e7
diff --git a/Dockerfile b/Dockerfile
index 75bc927..c98a950 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-#  SPDX-FileCopyrightText: Copyright 2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
+#  SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
 #  SPDX-License-Identifier: Apache-2.0
 #
 #  Licensed under the Apache License, Version 2.0 (the "License");
@@ -38,9 +38,9 @@
     update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 20 && \
     update-alternatives --set python3 /usr/bin/python3.9 && python3 --version
 
-# Download and install gcc 11.2
-RUN curl -L https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/binrel/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi.tar.xz -o gcc-arm-none-eabi.tar.xz && \
-    echo "8c5acd5ae567c0100245b0556941c237369f210bceb196edfe5a2e7532c60326 gcc-arm-none-eabi.tar.xz" | sha256sum -c && \
+# Download and install gcc 13.2
+RUN curl -L https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz -o gcc-arm-none-eabi.tar.xz && \
+    echo "6cd1bbc1d9ae57312bcd169ae283153a9572bd6a8e4eeae2fedfbc33b115fdbb gcc-arm-none-eabi.tar.xz" | sha256sum -c && \
     mkdir /opt/gcc-arm-none-eabi && \
     tar -xf  gcc-arm-none-eabi.tar.xz -C /opt/gcc-arm-none-eabi --strip-components 1 && \
     rm gcc-arm-none-eabi.tar.xz
diff --git a/docs/sections/building.md b/docs/sections/building.md
index 776117f..e84acf9 100644
--- a/docs/sections/building.md
+++ b/docs/sections/building.md
@@ -34,8 +34,9 @@
 
 Before proceeding, it is *essential* to ensure that the following prerequisites have been fulfilled:
 
-- GNU Arm embedded toolchain 10.2.1 (or higher) or the Arm Compiler version 6.19, or higher, is installed and available
-  on the path.
+- At least GNU Arm embedded toolchain 10.2.1, if building for SSE-300, is installed and available on the path
+- At least GNU Arm embedded toolchain 13.2.1, if building for SSE-310, is installed and available on the path
+- Alternatively, Arm Compiler version 6.19 or higher is installed and available on the path.
 
 > **Note**: There is a known issue with Arm GNU Embedded Toolchain version 12.2.Rel1. See
 > [Internal Compiler Error](./troubleshooting.md#internal-compiler-error) for details.
diff --git a/scripts/cmake/toolchains/bare-metal-gcc.cmake b/scripts/cmake/toolchains/bare-metal-gcc.cmake
index d693fc6..015f962 100644
--- a/scripts/cmake/toolchains/bare-metal-gcc.cmake
+++ b/scripts/cmake/toolchains/bare-metal-gcc.cmake
@@ -1,5 +1,5 @@
 #----------------------------------------------------------------------------
-#  SPDX-FileCopyrightText: Copyright 2021 - 2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
+#  SPDX-FileCopyrightText: Copyright 2021-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
 #  SPDX-License-Identifier: Apache-2.0
 #
 #  Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,8 +23,6 @@
 set(CMAKE_CROSSCOMPILING            true)
 set(CMAKE_SYSTEM_NAME               Generic)
 
-set(MIN_GCC_VERSION                 10.2.1)
-
 # Skip compiler test execution
 set(CMAKE_C_COMPILER_WORKS          1)
 set(CMAKE_CXX_COMPILER_WORKS        1)
@@ -35,6 +33,7 @@
 
 if (CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m55)
     # Flags for cortex-m55
+    set(MIN_GCC_VERSION             10.2.1)
     set(CPU_ID                      M55)
     set(CPU_COMPILE_DEF             CPU_CORTEX_${CPU_ID})
     set(ARM_CPU                     "ARMC${CPU_ID}")
@@ -44,13 +43,17 @@
     set(CPU_LINK_OPT                "--cpu=Cortex-${CPU_ID}")
 elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m85)
     # Flags for cortex-m85
-    # @TODO: Current versions of GNU compiler do not support Cortex-M85, we compile for Cortex-M55 instead.
-    message(WARNING                 "Arm GNU Toolchain does not support Arm Cortex-M85 yet, switching to Cortex-M55.")
-    set(CMAKE_SYSTEM_PROCESSOR      cortex-m55 CACHE STRING "Cortex-M CPU to use" FORCE)
-    # No need to duplicate the definitions here.
-    # Flags from Cortex-M55 will be added as this toolchain file will be read by CMake again.
+    set(MIN_GCC_VERSION             13.2.1)
+    set(CPU_ID                      M85)
+    set(CPU_COMPILE_DEF             CPU_CORTEX_${CPU_ID})
+    set(ARM_CPU                     "ARMC${CPU_ID}")
+    set(CPU_HEADER_FILE             "${ARM_CPU}.h")
+    set(CPU_COMPILE_OPTION          "-mcpu=${CMAKE_SYSTEM_PROCESSOR}")
+    set(FLOAT_ABI_COMPILE_OPTION    "-mfloat-abi=hard")
+    set(CPU_LINK_OPT                "--cpu=Cortex-${CPU_ID}")
 elseif (CMAKE_SYSTEM_ARCH STREQUAL armv8.1-m.main)
     # Flags for generic target armv8.1-m.main (will work for cortex-m55 and cortex-m85
+    set(MIN_GCC_VERSION             10.2.1)
     set(CPU_ID                      ARMv81MML_DSP_DP_MVE_FP)
     set(ARM_CPU                     "ARMv81MML")
     set(CPU_COMPILE_DEF             ${CPU_ID})
@@ -63,6 +66,10 @@
     # Flags for cortex-m33 to go here
 endif()
 
+if (NOT DEFINED MIN_GCC_VERSION)
+    set(MIN_GCC_VERSION             10.2.1)
+endif()
+
 set(${CPU_COMPILE_DEF}              1)
 
 # Warning options
diff --git a/source/application/api/common/include/ClassificationResult.hpp b/source/application/api/common/include/ClassificationResult.hpp
index 244849f..704bb14 100644
--- a/source/application/api/common/include/ClassificationResult.hpp
+++ b/source/application/api/common/include/ClassificationResult.hpp
@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: Copyright 2021 Arm Limited and/or its affiliates <open-source-office@arm.com>
+ * SPDX-FileCopyrightText: Copyright 2021, 2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
  * SPDX-License-Identifier: Apache-2.0
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,6 +17,7 @@
 #ifndef CLASSIFICATION_RESULT_HPP
 #define CLASSIFICATION_RESULT_HPP
 
+#include <cstdint>
 #include <string>
 
 namespace arm {
diff --git a/source/hal/source/platform/mps3/source/platform_drivers.c b/source/hal/source/platform/mps3/source/platform_drivers.c
index 7ebb770..73b388b 100644
--- a/source/hal/source/platform/mps3/source/platform_drivers.c
+++ b/source/hal/source/platform/mps3/source/platform_drivers.c
@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: Copyright 2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
+ * SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
  * SPDX-License-Identifier: Apache-2.0
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -149,13 +149,10 @@
         if (EXTRACT_BITS(id, 7, 4) == 3) {
             info ("CPU: Cortex-M85 r%dp%d\n\n",
                   EXTRACT_BITS(id, 23, 20),EXTRACT_BITS(id, 3, 0));
-            /* @TODO: Remove CPU_CORTEX_M55 from here once CMake min version is > 3.21.0 or when
-             * toolchains officially support Cortex-M85. Currently, for CMake versions older than
-             * this, Cortex-M85 is built using Cortex-M55 flags. */
-#if defined (CPU_CORTEX_M55) || defined (ARMv81MML_DSP_DP_MVE_FP) || defined(CPU_CORTEX_M85)
+#if defined (ARMv81MML_DSP_DP_MVE_FP) || defined (CPU_CORTEX_M85)
             /* CPU ID should be "0x_41_0f_d2_30" for Cortex-M85 */
             return 0;
-#endif /* (CPU_CORTEX_M55) || (ARMv81MML_DSP_DP_MVE_FP) || (CPU_CORTEX_M85) */
+#endif /* (ARMv81MML_DSP_DP_MVE_FP) || (CPU_CORTEX_M85) */
         } else if (EXTRACT_BITS(id, 7, 4) == 2) {
             info ("CPU: Cortex-M55 r%dp%d\n\n",
                 EXTRACT_BITS(id, 23, 20),EXTRACT_BITS(id, 3, 0));
@@ -185,7 +182,7 @@
             EXTRACT_BITS(id, 3, 0));
     }
 
-    /* If the CPU is anything other than M33 or M55, we return 1 */
+    /* If the CPU is anything other than M33, M55 or M85, we return 1 */
     printf_err("CPU mismatch!\n");
     return 1;
 }
diff --git a/source/profiler/include/Profiler.hpp b/source/profiler/include/Profiler.hpp
index 8ae9e15..8c2a61c 100644
--- a/source/profiler/include/Profiler.hpp
+++ b/source/profiler/include/Profiler.hpp
@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: Copyright 2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
+ * SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
  * SPDX-License-Identifier: Apache-2.0
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,6 +19,7 @@
 
 #include "hal.h"
 
+#include <cstdint>
 #include <string>
 #include <map>
 #include <vector>