Verified Commit 0bb7491f authored by Vincent Coubard's avatar Vincent Coubard
Browse files

Add Cmake support to build on Corstone-310



Target is controlled with the variable TS_TARGET which can be set to
either "Corstone-300" or "Corstone-310".
Signed-off-by: Vincent Coubard's avatarVincent Coubard <vincent.coubard@arm.com>
parent 9c51cc75
......@@ -9,10 +9,27 @@ include(FetchContent)
# Declare root and other build paths
set(PRJ_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
# Declare relative path to TFM target
# Underscore are used to accomodate TF-M conversion in install folder from dash
# to underscore
set(TFM_PLATFORM_LOCAL_PATH "bsp/tf_m_targets/arm/mps3/an547")
# Declare the target of the total solution
set(TS_TARGET "Corstone-300" CACHE STRING "Hardware target of the Total Solution")
# Configure target
# - Declare relative path to TFM target
# - MDH platform
if (${TS_TARGET} STREQUAL "Corstone-300")
set(TFM_PLATFORM_LOCAL_PATH "bsp/tf_m_targets/arm/mps3/an547")
set(MDH_PLATFORM "ARM_AN552_MPS3")
elseif(${TS_TARGET} STREQUAL "Corstone-310")
set(TFM_PLATFORM_LOCAL_PATH "bsp/tf_m_targets/arm/mps3/corstone_polaris")
set(MDH_PLATFORM "ARM_AN555_MPS3")
else()
message(FATAL_ERROR "Invalid TS_TARGET (${TS_TARGET}) set. It should be Corstone-300 or Corstone-310")
endif()
# Set build type to prevent MCU Driver HAL to set it to Develop by default which is not correct
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "The build type" FORCE)
endif()
# Override TF-M version
FetchContent_Declare(
......@@ -31,11 +48,26 @@ FetchContent_Declare(
SOURCE_SUBDIR NONE
)
FetchContent_Declare(iotsdk-toolchains
GIT_REPOSITORY https://git.gitlab.arm.com/iot/open-iot-sdk/toolchain.git
GIT_TAG 126d2092a2325c77fdf36043e931293c62e2ad29
SOURCE_DIR ${CMAKE_BINARY_DIR}/toolchains
)
# Override MCU driver HAL
FetchContent_Declare(
mcu-driver-reference-platforms-for-arm
GIT_REPOSITORY https://git.gitlab.arm.com/iot/open-iot-sdk/mcu-driver-hal/mcu-driver-reference-platforms-for-arm.git
GIT_TAG 9b7696596ca1c0f380e77f3d7c5de150635e340e
GIT_PROGRESS ON
)
# Declare the Open IoT SDK
FetchContent_Declare(
open_iot_sdk
GIT_REPOSITORY https://git.gitlab.oss.arm.com/engineering/iot-m-sw/open-iot-sdk/sdk.git
GIT_TAG 4b764827ef181b0c08c4f9d3b6bb244cc2b32e3b
GIT_REPOSITORY https://git.gitlab.arm.com/iot/open-iot-sdk/sdk.git
GIT_TAG dc62ef0bb0bc39f1ed67c33758e36482d3c6b2ff
)
# Declare the Open IoT SDK configuration flags
......@@ -67,9 +99,6 @@ set(MBED_C_LIB "std")
# Set FVP variant
set(VARIANT "FVP")
# Set platform
set(MDH_PLATFORM "ARM_AN552_MPS3")
# Apply TF-M patch
find_package(Git)
set(TFM_PATCH_COMMAND ${GIT_EXECUTABLE} apply "${PRJ_DIR}/patches/tf-m.patch" || true)
......@@ -119,11 +148,13 @@ target_include_directories(freertos-kernel
${PRJ_DIR}/kws/include
)
# Patch the MDH target to enable multicast
target_compile_definitions(mdh-arm-an552-mps3
INTERFACE
LAN91C111_RFS_MULTICAST_SUPPORT
)
# Patch the ethernet-lan91c111 target to enable multicast
if(TARGET ethernet-lan91c111)
target_compile_definitions(ethernet-lan91c111
INTERFACE
LAN91C111_RFS_MULTICAST_SUPPORT
)
endif()
# CMSIS 5 require projects to provide configuration macros via RTE_Components.h
# and CMSIS_device_header. The macro CMSIS_device_header is not automatically set
......@@ -136,8 +167,10 @@ target_include_directories(cmsis-core
target_compile_definitions(cmsis-core
INTERFACE
$<$<STREQUAL:${CMAKE_SYSTEM_PROCESSOR},cortex-m55>:CMSIS_device_header="ARMCM55.h">
$<$<STREQUAL:${CMAKE_SYSTEM_PROCESSOR},cortex-m85>:CMSIS_device_header="ARMCM85.h">
)
# It is required to pass to mcu-driver-hal that it is compiled in NS mode
target_compile_definitions(mcu-driver-hal
INTERFACE
DOMAIN_NS=1
......
......@@ -115,10 +115,10 @@ target_compile_definitions(${LIB_NAME}
-DARM_NPU=1
-DBL2
-DCONFIG_KWS_SCORE_THRESHOLD=0.8
-DCPU_CORTEX_M55=1
-D$<$<STREQUAL:${CMAKE_SYSTEM_PROCESSOR},cortex-m55>:CPU_CORTEX_M55=1>
-D$<$<STREQUAL:${CMAKE_SYSTEM_PROCESSOR},cortex-m85>:CPU_CORTEX_M85=1>
-DDAUTH_CHIP_DEFAULT
-DLIBRARY_LOG_LEVEL=3
-DMBEDTLS_CONFIG_FILE=\"<aws_mbedtls_config.h>\"
-DMCUBOOT_DATA_SHARING=1
-DMCUBOOT_IMAGE_NUMBER=2
-DMCUBOOT_SIGN_RSA
......@@ -161,35 +161,21 @@ target_link_libraries(${LIB_NAME}
bsp_serial
)
target_compile_options(${LIB_NAME}
PRIVATE
--target=arm-arm-none-eabi
-Ofast
-Wall
-Wno-error=cpp
-Wno-ignored-optimization-argument
-Wno-unused-command-line-argument
-c
-fdata-sections
-ffunction-sections
-fno-builtin
-funsigned-char
-g
-masm=auto
-mcpu=cortex-m55+fp+mve
-mfloat-abi=hard
-nostdlib
-std=c11
)
# Add Startup library
add_library(startup
"${TFM_PLATFORM}/device/source/startup_an547_ns.c"
$<$<STREQUAL:${TS_TARGET},Corstone-300>:${TFM_PLATFORM}/device/source/startup_an547_ns.c>
$<$<STREQUAL:${TS_TARGET},Corstone-310>:${TFM_PLATFORM}/device/source/startup_corstone_polaris_ns.c>
)
set(link_definitions_file ${CMAKE_CURRENT_BINARY_DIR}/link_definitions.txt)
mdh_generate_definitions_for_linker(mdh-arm-corstone-300-startup ${link_definitions_file})
mdh_set_linker_script(startup "${PRJ_DIR}/bsp/an547_ns.sct" ${link_definitions_file})
if (${TS_TARGET} STREQUAL "Corstone-300")
mdh_generate_definitions_for_linker(mdh-arm-corstone-300-startup ${link_definitions_file})
mdh_set_linker_script(startup "${PRJ_DIR}/bsp/an547_ns.sct" ${link_definitions_file})
elseif(${TS_TARGET} STREQUAL "Corstone-310")
mdh_generate_definitions_for_linker(mdh-arm-corstone-310-startup ${link_definitions_file})
mdh_set_linker_script(startup "${PRJ_DIR}/bsp/an555_ns.sct" ${link_definitions_file})
endif()
FetchContent_GetProperties(tf-m)
target_include_directories(startup
......
/*
* Copyright (c) 2021-2022 Arm Limited. All rights reserved.
*
* 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.
*/
LR_CODE (0x28000000 + ((((0) + (0x60000)) + (0x400)))) {
ER_CODE (0x28000000 + ((((0) + (0x60000)) + (0x400)))) { ;(((0x200000) - (0x400) - (0x800))) {
*.o (RESET +First)
* (InRoot$$Sections)
* (+RO)
}
ER_DATA 0x28700000 {
* (+ZI +RW)
}
ARM_LIB_STACK_MSP +0 ALIGN 32 EMPTY (0x0000800) {
}
ARM_LIB_STACK +0 ALIGN 32 EMPTY (0x0002000) {
}
ARM_LIB_HEAP +0 ALIGN 8 EMPTY (0x0008000) {
}
;-----------------------------------------------------
; SSE-300's internal SRAM of 4MiB - reserved for
; activation buffers.
; This region should have 3 cycle read latency from
; both Cortex-M55 and Ethos-U55
;-----------------------------------------------------
ddr.bin 0x60000000 NOCOMPRESS ALIGN 16 0x02000000
{
; nn model's baked in input matrices
*.o (ifm)
; nn model
*.o (nn_model)
; labels
*.o (labels)
; if the activation buffer (tensor arena) doesn't
; fit in the SRAM region, we accommodate it here
*.o (activation_buf)
; activation buffers a.k.a tensor arena
*.o (.bss.NoInit.activation_buf)
}
dma 0x8FFF0000 UNINIT ALIGN 16 0xFFFF
{
; Buffer for transferring VSI audio data from S to NS.
*.o (.bss.NoInit.audio_buf)
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment