1#-------------------------------------------------------------------------------
2# Copyright (c) 2020, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8cmake_policy(SET CMP0076 NEW)
9
10if(POLICY CMP0115)
11    cmake_policy(SET CMP0115 OLD)
12endif()
13set(B_U585I_IOT02A_DIR ${CMAKE_CURRENT_LIST_DIR})
14set(STM_COMMON_DIR ${B_U585I_IOT02A_DIR}/../common)
15
16#def for stm32u5xx
17include(${STM_COMMON_DIR}/stm32u5xx/CMakeLists.txt)
18#========================= Platform defs ===============================#
19
20# Specify the location of platform specific build dependencies.
21target_sources(tfm_s
22    PRIVATE
23        ${STM_COMMON_DIR}/stm32u5xx/Device/Source/startup_stm32u5xx_s.c
24        ${STM_COMMON_DIR}/stm32u5xx/bl2/low_level_ospi_device.c
25        ${STM_COMMON_DIR}/hal/CMSIS_Driver/low_level_ospi_flash.c
26        ${STM_COMMON_DIR}/hal/Components/mx25lm51245g/mx25lm51245g.c
27        ${B_U585I_IOT02A_DIR}/src/b_u585i_iot02a_ospi.c
28)
29
30if(STSAFEA)
31    set(STSAFEA_INTERFACE_SRC_DIR ${B_U585I_IOT02A_DIR}/src/)
32    include(${STM_COMMON_DIR}/secure_element/CMakeLists.txt)
33endif()
34
35# cpuarch.cmake is used to set things that related to the platform that are both
36install(FILES
37    ${TARGET_PLATFORM_PATH}/cpuarch.cmake
38    DESTINATION ${INSTALL_PLATFORM_NS_DIR}
39)
40
41install(FILES
42    ${STM_COMMON_DIR}/stm32u5xx/Device/Source/startup_stm32u5xx_ns.c
43    DESTINATION ${INSTALL_PLATFORM_NS_DIR}/Device/Source
44)
45
46install(DIRECTORY
47    ${TARGET_PLATFORM_PATH}/ns/
48    DESTINATION ${INSTALL_PLATFORM_NS_DIR}
49)
50
51install(DIRECTORY
52    ${TARGET_PLATFORM_PATH}/include
53    DESTINATION ${INSTALL_PLATFORM_NS_DIR}
54)
55
56install(FILES
57    ${TARGET_PLATFORM_PATH}//accelerator/crypto_accelerator_config.h
58    DESTINATION ${INSTALL_PLATFORM_NS_DIR}/include
59)
60
61install(DIRECTORY
62    ${STM_COMMON_DIR}/hal/accelerator/
63    DESTINATION ${INSTALL_PLATFORM_NS_DIR}/include
64    FILES_MATCHING PATTERN "*.h"
65)
66
67install(FILES
68    ${B_U585I_IOT02A_DIR}/partition/flash_layout.h
69    ${B_U585I_IOT02A_DIR}/partition/region_defs.h
70    DESTINATION ${INSTALL_PLATFORM_NS_DIR}/partition
71)
72
73if(BL2)
74    target_sources(bl2
75        PRIVATE
76            ${STM_COMMON_DIR}/stm32u5xx/Device/Source/startup_stm32u5xx_bl2.c
77            ${STM_COMMON_DIR}/stm32u5xx/bl2/low_level_ospi_device.c
78            ${STM_COMMON_DIR}/hal/CMSIS_Driver/low_level_ospi_flash.c
79            ${STM_COMMON_DIR}/hal/Components/mx25lm51245g/mx25lm51245g.c
80            ${B_U585I_IOT02A_DIR}/src/b_u585i_iot02a_ospi.c
81    )
82endif()
83#install flash layout for postbuild.sh
84install(FILES
85    ${B_U585I_IOT02A_DIR}/partition/flash_layout.h
86    ${B_U585I_IOT02A_DIR}/partition/region_defs.h
87    DESTINATION ${CMAKE_INSTALL_PREFIX}
88)
89set (BL2_FILE_TO_PREPROCESS ${CMAKE_CURRENT_BINARY_DIR}/image_macros_to_preprocess_bl2.c)
90file(WRITE ${BL2_FILE_TO_PREPROCESS} ${BL2_PREPROCESSING})
91
92install(FILES
93    ${BL2_FILE_TO_PREPROCESS}
94    DESTINATION ${CMAKE_INSTALL_PREFIX}
95)
96