summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKshitij Sisodia <kshitij.sisodia@arm.com>2021-05-07 16:08:14 +0100
committerKshitij Sisodia <kshitij.sisodia@arm.com>2021-05-07 17:28:51 +0100
commitf9c19eaa9ab11e4409679fc6d2862c89410493a7 (patch)
treeb791a4c03f1fe986a2ac32593a3dc817ae3f247a /scripts
parent2181d0ac35f30202985a877950c88325ff665f6b (diff)
downloadml-embedded-evaluation-kit-f9c19eaa9ab11e4409679fc6d2862c89410493a7.tar.gz
MLECO-1860: Support for Arm GNU Embedded Toolchain
This patch enables compilation of ML use cases bare-metal applications using Arm GNU Embedded Toolchain. The GNU toolchain can be used instead of the Arm Compiler that was already supported. The GNU toolchain is also set as the default toolchain when building applications for the MPS3 target. Note: The version of GNU toolchain must be 10.2.1 or higher. Change-Id: I5fff242f0f52d2db6c75d292f9fa990df1aec978 Signed-off-by: Kshitij Sisodia <kshitij.sisodia@arm.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/cmake/bare-metal-sources.cmake42
-rw-r--r--scripts/cmake/bare-metal-toolchain.cmake65
-rw-r--r--scripts/cmake/cmsis-dsp.cmake25
-rw-r--r--scripts/cmake/native-sources.cmake8
-rw-r--r--scripts/cmake/toolchains/bare-metal-armclang.cmake134
-rw-r--r--scripts/cmake/toolchains/bare-metal-gcc.cmake145
-rw-r--r--scripts/cmake/toolchains/native-gcc.cmake (renamed from scripts/cmake/native-toolchain.cmake)40
-rw-r--r--scripts/mps3/sse-300/images.txt23
-rw-r--r--scripts/py/gen_fpga_mem_map.py178
9 files changed, 377 insertions, 283 deletions
diff --git a/scripts/cmake/bare-metal-sources.cmake b/scripts/cmake/bare-metal-sources.cmake
index 8b348e3..2bfe616 100644
--- a/scripts/cmake/bare-metal-sources.cmake
+++ b/scripts/cmake/bare-metal-sources.cmake
@@ -28,13 +28,15 @@ set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/bsp)
if (NOT DEFINED MEM_PROFILES_SRC_DIR)
set(MEM_PROFILES_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/subsystem-profiles)
endif()
+
set(MEM_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/templates/peripheral_memmap.h.template)
set(IRQ_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/templates/peripheral_irqs.h.template)
set(MEM_REGIONS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/templates/mem_regions.h.template)
set(TA_SETTINGS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/templates/timing_adapter_settings.template)
+set(LINKER_SCRIPT_DIR "${PLAT_HAL}/bsp/mem_layout")
set(TENSORFLOW_LITE_MICRO_PLATFORM_LIB_NAME "libtensorflow-microlite.a")
set(TENSORFLOW_LITE_MICRO_FLAG "-DTF_LITE_STATIC_MEMORY")
-set(ETHOS_U55_FLAG "-DARM_NPU=1")
+set(ETHOS_U55_FLAG "-DARM_NPU=1")
if (ETHOS_U55_ENABLED)
set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS} ${ETHOS_U55_FLAG}")
@@ -54,23 +56,33 @@ if (TARGET_PLATFORM STREQUAL mps3)
if (TARGET_SUBSYSTEM STREQUAL sse-300)
message(STATUS "target subsystem is ${TARGET_SUBSYSTEM}")
set(BSP_PACKAGE_DIR "${PLAT_HAL}/bsp/bsp-packs/mps3")
- set(SCAT_FILE "${PLAT_HAL}/bsp/mem_layout/mps3-${TARGET_SUBSYSTEM}.sct")
+ set(LINKER_SCRIPT_NAME "${TARGET_PLATFORM}-${TARGET_SUBSYSTEM}")
# Include the mem profile definitions specific to our target subsystem
include(${MEM_PROFILES_SRC_DIR}/corstone-${TARGET_SUBSYSTEM}.cmake)
set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS} ${MPS3_PLATFORM_FLAG}")
+
+ # For deployment on the MPS3 FPGA platform, we need to produce
+ # two bin files - one that is loaded into the ITCM, and another
+ # that is loaded into the DDR region.
+ set(MPS3_SECTION_PATTERNS "*.at_itcm" "*.at_ddr")
+ set(MPS3_OUTPUT_BIN_NAMES "itcm.bin" "ddr.bin")
+ set(MPS3_FPGA_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/scripts/${TARGET_PLATFORM}/${TARGET_SUBSYSTEM}/images.txt")
else ()
message(FATAL_ERROR "Non compatible target subsystem: ${TARGET_SUBSYSTEM}")
endif ()
elseif (TARGET_PLATFORM STREQUAL simple_platform)
set(BSP_PACKAGE_DIR "${PLAT_HAL}/bsp/bsp-packs/${TARGET_PLATFORM}")
- set(SCAT_FILE "${PLAT_HAL}/bsp/mem_layout/${TARGET_PLATFORM}.sct")
+ set(LINKER_SCRIPT_NAME "${TARGET_PLATFORM}")
include(${MEM_PROFILES_SRC_DIR}/${TARGET_PLATFORM}.cmake)
set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS}")
else ()
message(FATAL_ERROR "Non compatible target platform ${TARGET_PLATFORM}")
endif ()
+# Add link options for the linker script to be used:
+add_linker_script(${LINKER_SCRIPT_DIR} ${LINKER_SCRIPT_NAME})
+
if (ETHOS_U55_ENABLED)
USER_OPTION(TA_CONFIG_FILE "Path to the timing adapter configuration file"
"${CMAKE_SCRIPTS_DIR}/ta_config.cmake"
@@ -91,7 +103,6 @@ configure_file("${IRQ_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_irqs.h")
configure_file("${MEM_REGIONS_TEMPLATE}" "${SOURCE_GEN_DIR}/mem_regions.h")
configure_file("${TA_SETTINGS_TEMPLATE}" "${SOURCE_GEN_DIR}/timing_adapter_settings.h")
-message(STATUS "Scatter file: ${SCAT_FILE}")
message(STATUS "Using BSP package from: ${BSP_PACKAGE_DIR}")
if (DEFINED VERIFY_TEST_OUTPUT)
@@ -114,27 +125,14 @@ if (DEFINED ARMCLANG_DEBUG_DWARF_LEVEL)
set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS} -gdwarf-${ARMCLANG_DEBUG_DWARF_LEVEL}")
endif()
-set(COMPILER_FLAGS "${ALL_COMMON_FLAGS} ${TENSORFLOW_LITE_MICRO_FLAG} ${PROFILING_OPT} ${OPTIONAL_FLAGS}")
+set(COMPILER_FLAGS "${TENSORFLOW_LITE_MICRO_FLAG} ${PROFILING_OPT} ${OPTIONAL_FLAGS}")
# For some reason, cmake doesn't pass the c++ standard flag, adding it manually
set(CMAKE_CXX_FLAGS "${COMPILER_FLAGS} -std=c++11" CACHE INTERNAL "")
set(CMAKE_C_FLAGS "${COMPILER_FLAGS}" CACHE INTERNAL "")
-set(CMAKE_ASM_FLAGS "${CPU_LD}")
set(CMAKE_ASM_COMPILE_OBJECT ${CMAKE_CXX_FLAGS})
-add_link_options(--strict --callgraph --load_addr_map_info --map)
-add_link_options(--symbols --xref --scatter=${SCAT_FILE})
-
-# Warnings to be ignored:
-# L6314W = No section matches pattern
-# L6439W = Multiply defined Global Symbol
-add_link_options(--diag_suppress=L6439W,L6314W)
-add_link_options(--info sizes,totals,unused,veneers --entry Reset_Handler)
-
-if (CMAKE_BUILD_TYPE STREQUAL Release)
- add_link_options(--no_debug)
-endif ()
-
-set(CMAKE_EXE_LINKER_FLAGS "${CPU_LD}")
+# Tell linker that reset interrupt handler is our entry point
+add_link_options(--entry Reset_Handler)
set(PLAT_BSP_INCLUDES
${PLAT_HAL}/bsp/cmsis-device/include
@@ -168,3 +166,7 @@ file(GLOB_RECURSE SRC_PLAT_HAL
"${PLAT_HAL}/bsp/bsp-core/*.c"
"${BSP_PACKAGE_DIR}/*.c"
)
+
+# Special retarget source to direct stdin, stdout and stderr streams to the
+# UART block.
+set(PLAT_RETARGET_SOURCE "${PLAT_HAL}/bsp/bsp-core/retarget.c")
diff --git a/scripts/cmake/bare-metal-toolchain.cmake b/scripts/cmake/bare-metal-toolchain.cmake
deleted file mode 100644
index 5d91b98..0000000
--- a/scripts/cmake/bare-metal-toolchain.cmake
+++ /dev/null
@@ -1,65 +0,0 @@
-#----------------------------------------------------------------------------
-# Copyright (c) 2021 Arm Limited. All rights reserved.
-# SPDX-License-Identifier: Apache-2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#----------------------------------------------------------------------------
-# specify the cross compiler
-set(CMAKE_C_COMPILER armclang)
-set(CMAKE_CXX_COMPILER armclang)
-set(CMAKE_C_LINKER_PREFERENCE armlink)
-set(CMAKE_ASM_LINKER_PREFERENCE armlink)
-set(CMAKE_ASM_COMPILER armasm)
-set(CMAKE_ASM_COMPILER_AR armar)
-
-set(CMAKE_CROSSCOMPILING true)
-set(CMAKE_SYSTEM_NAME Generic)
-
-set(MIN_ARM_CLANG_VERSION 6.14)
-
-if (NOT DEFINED CMAKE_SYSTEM_PROCESSOR)
- set(CMAKE_SYSTEM_PROCESSOR cortex-m55)
-endif()
-
-# Skip compiler test execution
-set(CMAKE_C_COMPILER_WORKS 1)
-set(CMAKE_CXX_COMPILER_WORKS 1)
-
-set(PLATFORM_HAL 1)
-
-set(WARNING_OPTS "-Wall -Wextra -Wvla")
-set(SPECIAL_OPTS "-fno-rtti -funsigned-char -fno-function-sections -fno-exceptions")
-set(PLATFORM_FLAGS "-mthumb --target=arm-arm-non-eabi -mlittle-endian -DPLATFORM_HAL=${PLATFORM_HAL}")
-
-set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -O0")
-set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O3")
-
-set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -O0")
-set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3")
-
-if (CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m55)
- # Flags for cortex-m55
- set(CPU_CORTEX_M55 1)
- set(CPU_CC "-mcpu=cortex-m55 -mfloat-abi=hard -MD -DCPU_CORTEX_M55=1 -DARM_MATH_DSP -DARM_MATH_LOOPUNROLL -D__FPU_USED=1")
- set(CPU_LD "--cpu=8.1-M.Main.dsp")
-elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m33)
- # Flags for cortex-m33 to go here
-endif()
-
-set(ALL_COMMON_FLAGS "${CPU_CC} ${WARNING_OPTS} ${SPECIAL_OPTS} ${PLATFORM_FLAGS}")
-
-function(enforce_compiler_version)
- if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${MIN_ARM_CLANG_VERSION})
- message( FATAL_ERROR "Arm compiler version must be ${MIN_ARM_CLANG_VERSION} or greater to support ${CMAKE_SYSTEM_PROCESSOR} architecture." )
- endif()
-endfunction()
diff --git a/scripts/cmake/cmsis-dsp.cmake b/scripts/cmake/cmsis-dsp.cmake
index cb0243b..bb26b69 100644
--- a/scripts/cmake/cmsis-dsp.cmake
+++ b/scripts/cmake/cmsis-dsp.cmake
@@ -37,7 +37,16 @@ set(CMSIS_CORE_INC_DIR "${CMSIS_SRC_PATH}/${CMSIS_CORE_PATH_SUFFIX}/Include
file(GLOB_RECURSE
CMSIS_DSP_SRC
- "${CMSIS_DSP_SRC_DIR}/arm_*.c")
+
+ "${CMSIS_DSP_SRC_DIR}/BasicMathFunctions/arm_*.c"
+ "${CMSIS_DSP_SRC_DIR}/FastMathFunctions/arm_*.c"
+ "${CMSIS_DSP_SRC_DIR}/CommonTables/arm_*.c"
+ "${CMSIS_DSP_SRC_DIR}/TransformFunctions/arm_*.c"
+ "${CMSIS_DSP_SRC_DIR}/StatisticsFunctions/arm_*.c"
+
+ # Issue with q15 and q31 functions with Arm GNU toolchain, we only
+ # need f32 functions.
+ "${CMSIS_DSP_SRC_DIR}/ComplexMathFunctions/arm_*f32.c")
# 4. Create static library
set(CMSIS_DSP_TARGET cmsis-dsp)
@@ -50,6 +59,20 @@ target_include_directories(${CMSIS_DSP_TARGET} PUBLIC
target_include_directories(${CMSIS_DSP_TARGET} PRIVATE
${CMSIS_DSP_PRI_INC_DIR})
+if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ target_compile_options(${CMSIS_DSP_TARGET} PUBLIC -flax-vector-conversions)
+
+ # There is a known issue with -O0 optimisation option that affects
+ # FFT functions from CMSIS-DSP when compiling with Arm GNU embedded
+ # toolchain version 10.2.1
+ if (CMAKE_BUILD_TYPE STREQUAL Debug)
+ message(WARNING "There are known issues with CMSIS-DSP builds using "
+ "MVE extension without optimisation. Forcing -O3 "
+ "optimisation level")
+ target_compile_options(${CMSIS_DSP_TARGET} PUBLIC -O3)
+ endif()
+endif ()
+
# 5. Add any custom/conditional flags for compilation or linkage
if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL cortex-m55)
target_compile_definitions(${CMSIS_DSP_TARGET} PUBLIC
diff --git a/scripts/cmake/native-sources.cmake b/scripts/cmake/native-sources.cmake
index 743e075..1b1431a 100644
--- a/scripts/cmake/native-sources.cmake
+++ b/scripts/cmake/native-sources.cmake
@@ -34,13 +34,11 @@ set(TENSORFLOW_LITE_MICRO_PLATFORM_LIB_NAME "libtensorflow-microlite.a")
set(TENSORFLOW_LITE_MICRO_FLAGS "-DTF_LITE_STATIC_MEMORY -DACTIVATION_BUF_SRAM_SZ=0")
set(CMAKE_C_FLAGS
- "${WARNING_FLAGS} ${SPECIAL_OPTS} ${PLATFORM_FLAGS}\
- ${PROFILING_OPT} ${TF_FLAG} ${LOG_FLAG} ${TENSORFLOW_LITE_MICRO_FLAGS}"
+ "${PROFILING_OPT} ${LOG_FLAG} ${TENSORFLOW_LITE_MICRO_FLAGS}"
CACHE INTERNAL "")
+
set(CMAKE_CXX_FLAGS
- "${WARNING_FLAGS} ${SPECIAL_OPTS} ${SPECIAL_OPTS_CXX}\
- ${PLATFORM_FLAGS} ${PROFILING_OPT} ${TF_FLAG} ${LOG_FLAG}\
- ${TENSORFLOW_LITE_MICRO_FLAGS}"
+ "${PROFILING_OPT} ${LOG_FLAG} ${TENSORFLOW_LITE_MICRO_FLAGS}"
CACHE INTERNAL "")
# Include directories:
diff --git a/scripts/cmake/toolchains/bare-metal-armclang.cmake b/scripts/cmake/toolchains/bare-metal-armclang.cmake
new file mode 100644
index 0000000..0a86eb6
--- /dev/null
+++ b/scripts/cmake/toolchains/bare-metal-armclang.cmake
@@ -0,0 +1,134 @@
+#----------------------------------------------------------------------------
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#----------------------------------------------------------------------------
+# specify the cross compiler
+set(CMAKE_C_COMPILER armclang)
+set(CMAKE_CXX_COMPILER armclang)
+set(CMAKE_C_LINKER_PREFERENCE armlink)
+set(CMAKE_ASM_LINKER_PREFERENCE armlink)
+set(CMAKE_ASM_COMPILER armasm)
+set(CMAKE_ASM_COMPILER_AR armar)
+
+set(CMAKE_CROSSCOMPILING true)
+set(CMAKE_SYSTEM_NAME Generic)
+
+set(MIN_ARM_CLANG_VERSION 6.14)
+
+# Skip compiler test execution
+set(CMAKE_C_COMPILER_WORKS 1)
+set(CMAKE_CXX_COMPILER_WORKS 1)
+set(PLATFORM_HAL 1)
+
+if (NOT DEFINED CMAKE_SYSTEM_PROCESSOR)
+ set(CMAKE_SYSTEM_PROCESSOR cortex-m55)
+endif()
+
+if (CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m55)
+ # Flags for cortex-m55
+ set(CPU_COMPILE_DEF CPU_CORTEX_M55)
+ set(CPU_NAME ${CMAKE_SYSTEM_PROCESSOR})
+ set(FLOAT_ABI hard)
+ set(ARM_MATH_DSP 1)
+ set(ARM_MATH_LOOPUNROLL 1)
+ set(CPU_LINK_OPT "--cpu=8.1-M.Main.dsp")
+elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m33)
+ # Flags for cortex-m33 to go here
+endif()
+
+set(${CPU_COMPILE_DEF} 1)
+
+# Warning options
+add_compile_options(
+ -Wall
+ -Wextra
+ -Wvla)
+
+# General purpose compile options:
+add_compile_options(
+ -funsigned-char
+ -fno-function-sections
+ "$<$<COMPILE_LANGUAGE:CXX>:-fno-unwind-tables;-fno-rtti;-fno-exceptions>")
+
+# Arch compile options:
+add_compile_options(
+ -mthumb
+ -mcpu=${CPU_NAME}
+ -mfloat-abi=${FLOAT_ABI}
+ --target=arm-arm-non-eabi
+ -mlittle-endian
+ -MD)
+
+# Compile definitions:
+add_compile_definitions(
+ PLATFORM_HAL=${PLATFORM_HAL}
+ ${CPU_COMPILE_DEF}=1
+ $<$<BOOL:${ARM_MATH_DSP}>:ARM_MATH_DSP>
+ $<$<BOOL:${ARM_MATH_LOOPUNROLL}>:ARM_MATH_LOOPUNROLL>)
+
+# Link options:
+add_link_options(${CPU_LINK_OPT})
+set(CMAKE_ASM_FLAGS "${CPU_LINK_OPT}")
+
+# Warnings to be ignored:
+# L6314W = No section matches pattern
+# L6439W = Multiply defined Global Symbol
+add_link_options(
+ --diag_suppress=L6439W,L6314W
+ --info sizes,totals,unused,veneers
+ --strict
+ --callgraph
+ --load_addr_map_info
+ --xref
+ "$<$<CONFIG:RELEASE>:--no_debug>")
+
+# Function to add a map file output for the linker to dump diagnostic information to.
+function(add_target_map_file TARGET_NAME MAP_FILE_PATH)
+ target_link_options(${TARGET_NAME} PUBLIC
+ --map --symbols --list=${MAP_FILE_PATH})
+endfunction()
+
+# Function to add linker option to use the chosen linker script (scatter file).
+function(add_linker_script SCRIPT_DIR SCRIPT_NAME)
+ set(LINKER_SCRIPT_PATH ${SCRIPT_DIR}/${SCRIPT_NAME}.sct
+ CACHE STRING "Linker script path")
+ if (NOT EXISTS ${LINKER_SCRIPT_PATH})
+ message(FATAL_ERROR "Scatter file not found: ${LINKER_SCRIPT_PATH}")
+ endif()
+ message(STATUS "Using linker script: ${LINKER_SCRIPT_PATH}")
+ add_link_options(--scatter=${LINKER_SCRIPT_PATH})
+endfunction()
+
+# Function to set the command to copy/extract contents from an elf
+# into a binary file.
+function(add_bin_generation_command)
+
+ set(multiValueArgs SECTION_PATTERNS OUTPUT_BIN_NAMES)
+ set(oneValueArgs TARGET_NAME OUTPUT_DIR AXF_PATH)
+ cmake_parse_arguments(PARSED "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ add_custom_command(TARGET ${PARSED_TARGET_NAME}
+ POST_BUILD
+ COMMAND fromelf --bin --output=${PARSED_OUTPUT_DIR}/
+ ${PARSED_AXF_PATH})
+
+endfunction()
+
+# Function to assert the compiler version
+function(enforce_compiler_version)
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${MIN_ARM_CLANG_VERSION})
+ message( FATAL_ERROR "Arm compiler version must be ${MIN_ARM_CLANG_VERSION} or greater to support ${CMAKE_SYSTEM_PROCESSOR} architecture." )
+ endif()
+endfunction()
diff --git a/scripts/cmake/toolchains/bare-metal-gcc.cmake b/scripts/cmake/toolchains/bare-metal-gcc.cmake
new file mode 100644
index 0000000..2ffc1bb
--- /dev/null
+++ b/scripts/cmake/toolchains/bare-metal-gcc.cmake
@@ -0,0 +1,145 @@
+#----------------------------------------------------------------------------
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#----------------------------------------------------------------------------
+# specify the cross compiler
+set(TRIPLET arm-none-eabi)
+
+set(CMAKE_C_COMPILER ${TRIPLET}-gcc)
+set(CMAKE_CXX_COMPILER ${TRIPLET}-g++)
+
+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)
+set(PLATFORM_HAL 1)
+
+if (NOT DEFINED CMAKE_SYSTEM_PROCESSOR)
+ set(CMAKE_SYSTEM_PROCESSOR cortex-m55)
+endif()
+
+if (CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m55)
+ # Flags for cortex-m55
+ set(CPU_COMPILE_DEF CPU_CORTEX_M55)
+ set(CPU_NAME ${CMAKE_SYSTEM_PROCESSOR})
+ set(FLOAT_ABI hard)
+ set(ARM_MATH_DSP 1)
+ set(ARM_MATH_LOOPUNROLL 1)
+elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m33)
+ # Flags for cortex-m33 to go here
+endif()
+
+set(${CPU_COMPILE_DEF} 1)
+
+# Warning options
+add_compile_options(
+ -Wall
+ -Wextra
+ -Wvla
+ -Wno-psabi)
+
+# General purpose compile options:
+add_compile_options(
+ -funsigned-char
+ -fno-function-sections
+ "$<$<COMPILE_LANGUAGE:CXX>:-fno-unwind-tables;-fno-rtti;-fno-exceptions>")
+
+# Arch compile options:
+add_compile_options(
+ -mthumb
+ -mcpu=${CPU_NAME}
+ -mfloat-abi=${FLOAT_ABI}
+ -mlittle-endian
+ -MD)
+
+# Compile definitions:
+add_compile_definitions(
+ PLATFORM_HAL=${PLATFORM_HAL}
+ ${CPU_COMPILE_DEF}=1
+ $<$<BOOL:${ARM_MATH_DSP}>:ARM_MATH_DSP>
+ $<$<BOOL:${ARM_MATH_LOOPUNROLL}>:ARM_MATH_LOOPUNROLL>)
+
+# Link options:
+add_link_options(
+ -mthumb
+ -mcpu=${CPU_NAME}
+ -mfloat-abi=${FLOAT_ABI}
+ -mlittle-endian
+ --specs=nosys.specs
+ --stats
+ "$<$<CONFIG:RELEASE>:--no-debug>")
+
+# Function to add a map file output for the linker to dump diagnostic information to.
+function(add_target_map_file TARGET_NAME MAP_FILE_PATH)
+ target_link_options(${TARGET_NAME} PUBLIC
+ -Xlinker -Map=${MAP_FILE_PATH})
+endfunction()
+
+# Function to add linker option to use the chosen linker script.
+function(add_linker_script SCRIPT_DIR SCRIPT_NAME)
+ set(LINKER_SCRIPT_PATH ${SCRIPT_DIR}/${SCRIPT_NAME}.ld
+ CACHE STRING "Linker script path")
+ if (NOT EXISTS ${LINKER_SCRIPT_PATH})
+ message(FATAL_ERROR "Linker script not found: ${LINKER_SCRIPT_PATH}")
+ endif()
+ message(STATUS "Using linker script: ${LINKER_SCRIPT_PATH}")
+ add_link_options("SHELL:-T ${LINKER_SCRIPT_PATH}")
+endfunction()
+
+# Function to set the command to copy/extract contents from an elf
+# into a binary file.
+function(add_bin_generation_command)
+
+ set(multiValueArgs SECTION_PATTERNS OUTPUT_BIN_NAMES)
+ set(oneValueArgs TARGET_NAME OUTPUT_DIR AXF_PATH)
+ cmake_parse_arguments(PARSED "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ list(LENGTH PARSED_SECTION_PATTERNS N_SECTION_PATTERNS)
+ list(LENGTH PARSED_OUTPUT_BIN_NAMES N_OUTPUT_BIN_NAMES)
+
+ if (NOT ${N_SECTION_PATTERNS} STREQUAL ${N_OUTPUT_BIN_NAMES})
+ message(FATAL_ERROR "Section patterns and the output binary names "
+ "should be of the same length")
+ endif()
+
+ message(STATUS "${TRIPLET}-objcopy requested to generate "
+ "${N_OUTPUT_BIN_NAMES} bin files.")
+
+ math(EXPR MAX_IDX "${N_SECTION_PATTERNS} - 1")
+
+ foreach(IDX RANGE ${MAX_IDX})
+
+ list(GET PARSED_OUTPUT_BIN_NAMES ${IDX} OUTPUT_BIN_NAME)
+ list(GET PARSED_SECTION_PATTERNS ${IDX} SECTION_PATTERN)
+
+ add_custom_command(TARGET ${PARSED_TARGET_NAME}
+ POST_BUILD
+ COMMAND ${TRIPLET}-objcopy -O binary
+ --only-section ${SECTION_PATTERN} ${PARSED_AXF_PATH}
+ ${PARSED_OUTPUT_DIR}/${OUTPUT_BIN_NAME})
+ endforeach()
+
+endfunction()
+
+# Function to assert the compiler version
+function(enforce_compiler_version)
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${MIN_GCC_VERSION})
+ message( FATAL_ERROR "arm-none-eabi-gcc version must be ${MIN_GCC_VERSION} or greater to support ${CMAKE_SYSTEM_PROCESSOR} architecture." )
+ endif()
+endfunction()
diff --git a/scripts/cmake/native-toolchain.cmake b/scripts/cmake/toolchains/native-gcc.cmake
index 2e28cd4..4b5a62b 100644
--- a/scripts/cmake/native-toolchain.cmake
+++ b/scripts/cmake/toolchains/native-gcc.cmake
@@ -19,22 +19,34 @@ set(CMAKE_C_COMPILER gcc)
set(CMAKE_C_LINKER_PREFERENCE gcc)
set(CMAKE_CXX_LINKER_PREFERENCE gcc)
-set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -O0 -g")
-set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O3")
-
-set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -O0 -g")
-set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3")
-
# Platform specific directory:
set(PLATFORM_HAL 3)
-set(WARNING_FLAGS "-Wsign-compare -Wshadow \
- -Wextra -Wall -Wunused-function \
- -Wmissing-field-initializers \
- -Wswitch -Wvla -Wunused-parameter")
-set(SPECIAL_OPTS "-fPIC -pthread")
-set(PLATFORM_FLAGS "-DPLATFORM_HAL=${PLATFORM_HAL}")
-set(SPECIAL_OPTS_CXX "-fno-threadsafe-statics")
-set(CMAKE_EXE_LINKER_FLAGS "-lm -lc -lstdc++ --verbose")
+
+# Warning compiler definitions:
+add_compile_options(
+ -Wsign-compare
+ -Wshadow
+ -Wextra
+ -Wall
+ -Wunused-function
+ -Wmissing-field-initializers
+ -Wswitch
+ -Wvla
+ -Wunused-parameter)
+
+# General purpose compile definitions:
+add_compile_options(
+ -fPIC
+ -pthread
+ -DPLATFORM_HAL=${PLATFORM_HAL}
+ "$<$<COMPILE_LANGUAGE:CXX>:-fno-threadsafe-statics>")
+
+# Linker options
+add_link_options(
+ -lm
+ -lc
+ -lstdc++
+ --verbose)
function(enforce_compiler_version)
endfunction()
diff --git a/scripts/mps3/sse-300/images.txt b/scripts/mps3/sse-300/images.txt
new file mode 100644
index 0000000..b00c8b7
--- /dev/null
+++ b/scripts/mps3/sse-300/images.txt
@@ -0,0 +1,23 @@
+TITLE: Arm MPS3 FPGA prototyping board Images Configuration File
+
+; MCC mapping for Corstone-300 MPS3 bitfile package AN547
+; +-------------+---------------+-------------------------------+
+; | FPGA addr | MCC addr | Region |
+; +-------------+---------------+-------------------------------+
+; | 0x00000000 | 0x00000000 | ITCM (NS) |
+; | 0x01000000 | 0x02000000 | BRAM or FPGA's data SRAM (NS) |
+; | 0x60000000 | 0x08000000 | DDR (NS) |
+; | 0x70000000 | 0x0c000000 | DDR (S) |
+; +-------------+---------------+-------------------------------+
+
+[IMAGES]
+
+TOTALIMAGES: 2 ;Number of Images (Max: 32)
+
+IMAGE0ADDRESS: 0x00000000 ; MCC@0x00000000 <=> FPGA@0x00000000
+IMAGE0UPDATE: AUTO
+IMAGE0FILE: \SOFTWARE\itcm.bin
+
+IMAGE1ADDRESS: 0x0c000000 ; MCC@0x0c000000 <=> FPGA@0x70000000
+IMAGE1UPDATE: AUTO
+IMAGE1FILE: \SOFTWARE\ddr.bin
diff --git a/scripts/py/gen_fpga_mem_map.py b/scripts/py/gen_fpga_mem_map.py
deleted file mode 100644
index 5703a8d..0000000
--- a/scripts/py/gen_fpga_mem_map.py
+++ /dev/null
@@ -1,178 +0,0 @@
-# Copyright (c) 2021 Arm Limited. All rights reserved.
-# SPDX-License-Identifier: Apache-2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import os
-from argparse import ArgumentParser
-
-"""
-This file is used as part of post build steps to generate 'images.txt' file
-which can be copied over onto the MPS3 board's SD card. The purpose is to
-limit having to manually edit the file based on different load regions that
-the build scatter file might dictate.
-"""
-
-def is_commented(line):
- if (line.startswith(";")):
- return True
- else:
- return False
-
-
-def is_load_rom(line):
- load_region_specifiers = ['LOAD_ROM', 'LD_ROM', 'LOAD_REGION']
-
- for load_specifier in load_region_specifiers:
- if line.startswith(load_specifier):
- return True
-
- return False
-
-
-class TargetSubsystem:
-
- def __init__(self, target_subsystem_name: str):
- """
- Constructor for target class.
- Arguments:
- target_subsystem_name: name of the target subsystem
- """
- # Dict with mem map and binary names we expect
- self.subsystems = {
- "sse-300": {
- "mmap_mcc" : {
- # FPGA addr | MCC addr |
- "0x00000000": "0x00000000", # ITCM (NS)
- "0x01000000": "0x02000000", # BRAM or FPGA's data SRAM (NS)
- "0x60000000": "0x08000000", # DDR (NS)
- "0x70000000": "0x0c000000" # DDR (S)
- },
- "bin_names": {
- 0: "itcm.bin",
- 1: "dram.bin"
- }
- }
- }
-
- self.name = target_subsystem_name
-
-
- def is_supported(self, target_subsystem: str) -> bool:
- """
- Checks if the target subsystem exists within systems
- supported by this script
- """
- if target_subsystem in self.subsystems.keys():
- return True
-
- print(f"Platforms supported: {self.subsystems.keys()}")
- return False
-
-
- def mps3_mappings(self) -> dict:
- """
- Returns the FPGA <--> MCC address translations
- as a dict
- """
- if self.is_supported(self.name):
- return self.subsystems[self.name]['mmap_mcc']
- return {}
-
-
- def mps3_bin_names(self) -> dict:
- """
- Returns expected binary names for the executable built
- for Cortex-M55 or Cortex-M55+Ethos-U55 targets in the
- form of a dict with index and name
- """
- if self.is_supported(self.name):
- return self.subsystems[self.name]['bin_names']
-
- return {}
-
-
-def main(args):
- """
- Generates the output txt file with MCC to FPGA address mapping used
- that is used by the MCC on FPGA to load executable regions into
- correct regions in memory.
- """
- # List out arguments used:
- scatter_file_path = args.scatter_file_path
- target_subsystem_name = args.target_subsystem
- output_file_path = args.output_file_path
-
- target = TargetSubsystem(target_subsystem_name=target_subsystem_name)
-
- if target.is_supported(target_subsystem_name) != True:
- print(f'Target {target_subsystem_name} not supported.')
- return
-
- with open(scatter_file_path,'r') as scatter_file:
- lines_read = scatter_file.readlines()
- str_list = []
-
- bin_names = None
- mem_map = None
-
- mem_map = target.mps3_mappings()
- bin_names = target.mps3_bin_names()
-
- str_list.append("TITLE: Arm MPS3 FPGA prototyping board Images Configuration File\n")
- str_list.append("[IMAGES]\n\n")
-
- cnt = 0
- for line in lines_read:
- if is_commented(line) or is_load_rom(line) != True:
- continue
-
- addr = line.split()[1]
-
- if mem_map.get(addr, None) == None:
- raise RuntimeError(
- 'Translation for this address unavailable')
- if cnt > len(bin_names):
- raise RuntimeError(
- f"bin names len exceeded: {cnt}")
-
- str_list.append("IMAGE" + str(cnt) + "ADDRESS: " +
- mem_map[addr] + " ; MCC@" + mem_map[addr] +
- " <=> FPGA@" + addr + "\n")
- str_list.append("IMAGE" + str(cnt) + "UPDATE: AUTO\n")
- str_list.append("IMAGE" + str(cnt) + "FILE: \SOFTWARE\\" +
- bin_names[cnt] + "\n\n")
- cnt += 1
-
- if cnt > 0 and cnt < 33:
- str_list.insert(2,
- "TOTALIMAGES: {} ;Number of Images (Max: 32)\n\n".format(
- cnt))
- else:
- raise RuntimeError('Invalid image count')
-
- if os.path.exists(output_file_path):
- os.remove(output_file_path)
- print(''.join(str_list), file=open(output_file_path, "a"))
-
-
-if __name__ == "__main__":
- parser = ArgumentParser()
- parser.add_argument("--scatter_file_path", type=str, required=True,
- help="Path to the scatter file")
- parser.add_argument("--target_subsystem", type=str, required=True,
- help="Target subsystem in use")
- parser.add_argument("--output_file_path", type=str, required=True,
- help="Output file path")
- args = parser.parse_args()
- main(args)