-
-
Notifications
You must be signed in to change notification settings - Fork 177
/
binutils.FreeRTOS.cmake
301 lines (222 loc) · 10.1 KB
/
binutils.FreeRTOS.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
#
# Copyright (c) .NET Foundation and Contributors
# See LICENSE file in the project root for full license information.
#
function(nf_set_optimization_options target)
# debug compile options: -Og (optimize for debugging) and -ggdb (produce debug symbols specifically for gdb)
target_compile_options(${target} PRIVATE
$<$<CONFIG:Debug>:-Og -ggdb>
$<$<CONFIG:Release>:-O3 -flto>
$<$<CONFIG:MinSizeRel>:-Os -flto>
$<$<CONFIG:RelWithDebInfo>:-Os -ggdb>
)
endfunction()
function(nf_set_linker_file target linker_file_name)
# set linker file name
set_target_properties(${target} PROPERTIES LINK_FLAGS "-T${linker_file_name}")
endfunction()
# setting compile definitions for a target based on general build options
# TARGET parameter to set the target that's setting them for
# optional BUILD_TARGET when target it's a library pass here the name ot the target that's building for (either nanoBooter or nanoCLR)
# optional EXTRA_COMPILE_DEFINITIONS with compiler definitions to be added to the library
macro(nf_set_compile_definitions)
# parse arguments
cmake_parse_arguments(NFSCD "" "TARGET;BUILD_TARGET" "EXTRA_COMPILE_DEFINITIONS" ${ARGN})
if(NOT NFSCD_TARGET OR "${NFSCD_TARGET}" STREQUAL "")
message(FATAL_ERROR "Need to set TARGET argument when calling nf_set_compile_definitions()")
endif()
nf_common_compiler_definitions(TARGET ${NFSCD_TARGET} BUILD_TARGET ${NFSCD_BUILD_TARGET})
# include extra compiler definitions
target_compile_definitions(${NFSCD_TARGET} PUBLIC ${NFSCD_EXTRA_COMPILE_DEFINITIONS})
endmacro()
# Add packages that are common to FreeRTOS platform builds
# To be called from target CMakeList.txt
# optional TARGET argument with target name
macro(nf_add_platform_packages)
# parse arguments
cmake_parse_arguments(NFAPP "" "TARGET" "" ${ARGN})
find_package(FreeRTOS REQUIRED QUIET)
find_package(CMSIS REQUIRED QUIET)
if(USE_FILESYSTEM_OPTION)
find_package(FATFS REQUIRED QUIET)
endif()
# packages specific for nanoBooter
if("${NFAPP_TARGET}" STREQUAL "${NANOBOOTER_PROJECT_NAME}")
# no packages for booter
endif()
# packages specific for nanoCLR
if("${NFAPP_TARGET}" STREQUAL "${NANOCLR_PROJECT_NAME}")
if(USE_NETWORKING_OPTION)
find_package(NF_Network REQUIRED QUIET)
find_package(lwIP REQUIRED QUIET)
endif()
endif()
endmacro()
# Add FreeRTOS platform dependencies to a specific CMake target
# To be called from target CMakeList.txt
macro(nf_add_platform_dependencies target)
nf_add_common_dependencies(${target})
# packages specific for nanoBooter
if("${target}" STREQUAL "${NANOBOOTER_PROJECT_NAME}")
# no packages for booter
endif()
# dependencies specific to nanoCLR
if("${target}" STREQUAL "${NANOCLR_PROJECT_NAME}")
nf_add_lib_coreclr(
EXTRA_INCLUDES
${CMSIS_INCLUDE_DIRS}
${FreeRTOS_INCLUDE_DIRS}
${TARGET_NXP_COMMON_INCLUDE_DIRS}
${TARGET_FREERTOS_COMMON_INCLUDE_DIRS}
${TARGET_FREERTOS_NANOCLR_INCLUDE_DIRS})
add_dependencies(${target}.elf nano::NF_CoreCLR)
nf_add_lib_wireprotocol(
EXTRA_INCLUDES
${CMSIS_INCLUDE_DIRS}
${FreeRTOS_INCLUDE_DIRS}
${TARGET_NXP_COMMON_INCLUDE_DIRS}
${TARGET_FREERTOS_COMMON_INCLUDE_DIRS}
${TARGET_FREERTOS_NANOCLR_INCLUDE_DIRS})
add_dependencies(${target}.elf nano::WireProtocol)
if(NF_FEATURE_DEBUGGER)
nf_add_lib_debugger(
EXTRA_INCLUDES
${CMSIS_INCLUDE_DIRS}
${FreeRTOS_INCLUDE_DIRS}
${TARGET_NXP_COMMON_INCLUDE_DIRS}
${TARGET_FREERTOS_COMMON_INCLUDE_DIRS}
${TARGET_FREERTOS_NANOCLR_INCLUDE_DIRS})
add_dependencies(${target}.elf nano::NF_Debugger)
endif()
if(API_nanoFramework.System.Security.Cryptography)
FetchContent_GetProperties(mbedtls)
endif()
nf_add_lib_native_assemblies(
EXTRA_INCLUDES
${CMSIS_INCLUDE_DIRS}
${FreeRTOS_INCLUDE_DIRS}
${lWIP_INCLUDE_DIRS}
${TARGET_NXP_COMMON_INCLUDE_DIRS}
${TARGET_NXP_NANOCLR_INCLUDE_DIRS}
${TARGET_FREERTOS_COMMON_INCLUDE_DIRS}
${TARGET_FREERTOS_NANOCLR_INCLUDE_DIRS}
${FATFS_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/targets/FreeRTOS/NXP/_fatfs
${CMAKE_BINARY_DIR}/targets/${RTOS}/${TARGET_BOARD}
${mbedtls_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/src/PAL/COM/sockets/ssl/MbedTLS)
add_dependencies(${target}.elf nano::NF_NativeAssemblies)
if(USE_NETWORKING_OPTION)
nf_add_lib_network(
BUILD_TARGET
${target}
EXTRA_SOURCES
${lWIP_SOURCES}
EXTRA_INCLUDES
${FreeRTOS_INCLUDE_DIRS}
${TARGET_NXP_COMMON_INCLUDE_DIRS}
${TARGET_FREERTOS_COMMON_INCLUDE_DIRS}
${lWIP_INCLUDE_DIRS}
${CMSIS_INCLUDE_DIRS})
add_dependencies(${target}.elf nano::NF_Network)
endif()
endif()
endmacro()
# Add FreeRTOS platform include directories to a specific CMake target
# To be called from target CMakeList.txt
macro(nf_add_platform_include_directories target)
target_include_directories(${target}.elf PUBLIC
${TARGET_FREERTOS_COMMON_INCLUDE_DIRS}
${TARGET_NXP_COMMON_INCLUDE_DIRS}
${FreeRTOS_INCLUDE_DIRS}
${lWIP_INCLUDE_DIRS}
${CMSIS_INCLUDE_DIRS}
)
# includes specific to nanoBooter
if(${target} STREQUAL ${NANOBOOTER_PROJECT_NAME})
target_include_directories(${target}.elf PUBLIC
${TARGET_NXP_NANOBOOTER_INCLUDE_DIRS}
${TARGET_FREERTOS_NANOBOOTER_INCLUDE_DIRS}
)
endif()
# includes specific to nanoCLR
if(${target} STREQUAL ${NANOCLR_PROJECT_NAME})
target_include_directories(${target}.elf PUBLIC
${TARGET_NXP_NANOCLR_INCLUDE_DIRS}
${NANOCLR_PROJECT_INCLUDE_DIRS}
${TARGET_FREERTOS_COMMON_INCLUDE_DIRS}
${TARGET_FREERTOS_NANOCLR_INCLUDE_DIRS}
${lWIP_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
)
endif()
endmacro()
# Add FreeRTOS platform target sources to a specific CMake target
# To be called from target CMakeList.txt
macro(nf_add_platform_sources target)
# add header files with common OS definitions and board definitions
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/target_common.h.in
${CMAKE_BINARY_DIR}/targets/${RTOS}/${TARGET_BOARD}/target_common.h @ONLY)
# sources common to both builds
target_sources(${target}.elf PUBLIC
${TARGET_FREERTOS_COMMON_SOURCES}
${TARGET_NXP_COMMON_SOURCES}
${FreeRTOS_SOURCES}
)
# sources specific to nanoBooter
if(${target} STREQUAL ${NANOBOOTER_PROJECT_NAME})
# add header files with common OS definitions and board definitions
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nanoBooter/target_board.h.in
${CMAKE_BINARY_DIR}/targets/${RTOS}/${TARGET_BOARD}/nanoBooter/target_board.h @ONLY)
target_sources(${target}.elf PUBLIC
${TARGET_NXP_NANOBOOTER_SOURCES}
)
endif()
# sources specific to nanoCLR
if(${target} STREQUAL ${NANOCLR_PROJECT_NAME})
# add header files with common OS definitions and board definitions
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nanoCLR/target_board.h.in
${CMAKE_BINARY_DIR}/targets/${RTOS}/${TARGET_BOARD}/nanoCLR/target_board.h @ONLY)
target_sources(${target}.elf PUBLIC
${TARGET_FREERTOS_COMMON_SOURCES}
${TARGET_FREERTOS_NANOCLR_SOURCES}
${TARGET_NXP_COMMON_SOURCES}
${TARGET_NXP_NANOCLR_SOURCES}
${FATFS_SOURCES}
)
if(USE_NETWORKING_OPTION)
target_link_libraries(${target}.elf
nano::NF_Network
)
endif()
endif()
endmacro()
# macro to setup the build for a target
# mandatory HAS_NANOBOOTER specifing if the target implements nanoBooter
# BOOTER_LINKER_FILE with the path to the linker file for nanoBooter (if the target has it)
# mandatory CLR_LINKER_FILE with the path to the linker file for nanoCLR
# optional BOOTER_EXTRA_SOURCE_FILES with paths to extra files to be added to the nanoBooter build target
# optional CLR_EXTRA_SOURCE_FILES with paths to extra files to be added to the nanoCLR build target
# optional BOOTER_EXTRA_COMPILE_DEFINITIONS extra nanoBooter compile definitions to pass to nf_set_compile_definitions()
# optional CLR_EXTRA_COMPILE_DEFINITIONS extra nanoCLR compile definitions to pass to nf_set_compile_definitions()
# optional BOOTER_EXTRA_LINKMAP_PROPERTIES extra nanoBooter link map properties to pass to nf_set_link_map()
# optional CLR_EXTRA_LINKMAP_PROPERTIES extra nanoCLR link map properties to pass to nf_set_link_map()
# optional BOOTER_EXTRA_LINK_FLAGS extra nanoBooter link flags to pass to nf_set_link_options()
# optional CLR_EXTRA_LINK_FLAGS extra nanoCLR link flags to pass to nf_set_link_options()
macro(nf_setup_target_build)
# OK to pass ARGN, to have it perform it's parsings and validation
nf_setup_target_build_common(${ARGN})
endmacro()
# macro to clear binary files related with nanoBooter from output
# to make sure that the build file it's up to date
macro(nf_clear_output_files_nanobooter)
nf_clear_common_output_files_nanobooter()
# other files specific to this platform should go here
endmacro()
# macro to clear binary files related with nanoCLR from output
# to make sure that the build file it's up to date
macro(nf_clear_output_files_nanoclr)
nf_clear_common_output_files_nanoclr()
# other files specific to this platform should go here
endmacro()