xref: /aosp_15_r20/external/pigweed/targets/mimxrt595_evk_freertos/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2021 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15import("//build_overrides/pigweed.gni")
16
17import("$dir_pw_build/linker_script.gni")
18import("$dir_pw_build/target_types.gni")
19import("$dir_pw_docgen/docs.gni")
20import("$dir_pw_malloc/backend.gni")
21import("$dir_pw_third_party/freertos/freertos.gni")
22import("$dir_pw_third_party/mcuxpresso/mcuxpresso.gni")
23import("$dir_pw_toolchain/generate_toolchain.gni")
24import("target_toolchains.gni")
25
26generate_toolchains("target_toolchains") {
27  toolchains = pw_target_toolchain_mimxrt595_evk_freertos_list
28}
29
30declare_args() {
31  # When compiling with an MCUXpresso SDK, this variable is set to the path of
32  # the manifest file within the SDK installation. When set, a pw_source_set
33  # for a sample project SDK is created at
34  # "//targets/mimxrt595_evk_freertos:sdk".
35  pw_target_mimxrt595_evk_freertos_MANIFEST = ""
36
37  # This list should contain the necessary defines for setting linker script
38  # memory regions. While we don't directly use the pw_boot_cortex_m linker
39  # script, these are deliberately matching to make being able to later easier.
40  pw_target_mimxrt595_evk_freertos_LINK_CONFIG_DEFINES = []
41}
42
43config("pw_malloc_active") {
44  if (pw_malloc_BACKEND != "") {
45    defines = [ "PW_MALLOC_ACTIVE=1" ]
46  }
47}
48
49config("disable_warnings") {
50  cflags = [
51    "-Wno-cast-qual",
52    "-Wno-redundant-decls",
53    "-Wno-undef",
54    "-Wno-unused-parameter",
55    "-Wno-unused-variable",
56    "-Wno-error=strict-prototypes",
57  ]
58  visibility = [ ":*" ]
59}
60
61config("freestanding") {
62  cflags = [
63    "-ffreestanding",
64    "-fno-builtin",
65  ]
66  asmflags = cflags
67  ldflags = cflags
68  visibility = [ ":*" ]
69}
70
71config("sdk_defines") {
72  defines = [
73    "CPU_MIMXRT595SFFOC_cm33",
74    "DEBUG_CONSOLE_TRANSFER_NON_BLOCKING",
75    "SDK_DEBUGCONSOLE=1",
76  ]
77  visibility = [ ":*" ]
78}
79
80if (current_toolchain != default_toolchain) {
81  pw_linker_script("flash_linker_script") {
82    defines = pw_target_mimxrt595_evk_freertos_LINK_CONFIG_DEFINES
83    linker_script = "mimxrt595_flash.ld"
84  }
85}
86
87if (pw_third_party_mcuxpresso_SDK != "") {
88  # Startup and vector table for NXP MIMXRT595-EVK.
89  pw_source_set("boot") {
90    public_configs = [ ":pw_malloc_active" ]
91    deps = [
92      "$dir_pw_boot",
93      "$dir_pw_boot_cortex_m:armv8m",
94      "$dir_pw_malloc",
95      "$dir_pw_preprocessor",
96      "$dir_pw_sys_io_mcuxpresso",
97      "$dir_pw_third_party/freertos",
98      "$dir_pw_third_party/freertos:support",
99      pw_third_party_mcuxpresso_SDK,
100    ]
101    if (pw_malloc_BACKEND != "") {
102      deps += [ "$dir_pw_malloc" ]
103    }
104    sources = [
105      "boot.cc",
106      "vector_table.c",
107    ]
108  }
109}
110
111if (pw_third_party_mcuxpresso_SDK == "//targets/mimxrt595_evk_freertos:sdk") {
112  pw_mcuxpresso_sdk("sdk") {
113    manifest = pw_target_mimxrt595_evk_freertos_MANIFEST
114    include = [
115      "project_template.evkmimxrt595.MIMXRT595S",
116      "component.serial_manager_uart.MIMXRT595S",
117      "platform.drivers.flexcomm_i2c.MIMXRT595S",
118      "platform.drivers.flexcomm_spi.MIMXRT595S",
119      "platform.drivers.flexcomm_usart_dma.MIMXRT595S",
120      "platform.drivers.flexcomm_usart_freertos.MIMXRT595S",
121      "platform.drivers.flexio_spi.MIMXRT595S",
122      "platform.drivers.inputmux.MIMXRT595S",
123      "platform.drivers.lpc_dma.MIMXRT595S",
124      "platform.drivers.lpc_gpio.MIMXRT595S",
125      "platform.drivers.mu.MIMXRT595S",
126      "platform.drivers.pint.MIMXRT595S",
127      "platform.drivers.power.MIMXRT595S",
128      "utility.debug_console.MIMXRT595S",
129    ]
130    exclude = [
131      "device.MIMXRT595S_startup.MIMXRT595S",
132
133      # Don't need to generate build rules for freertos, we use pigweed's.
134      "middleware.freertos-kernel.MIMXRT595S",
135    ]
136
137    public_configs = [
138      ":disable_warnings",
139      ":freestanding",
140      ":sdk_defines",
141    ]
142
143    public_deps = [
144      ":mimxrt595_config",
145      "$dir_pw_third_party/freertos",
146    ]
147  }
148
149  config("config_public_includes") {
150    include_dirs = [ "board" ]
151    visibility = [ ":*" ]
152  }
153
154  config("config_public_defines") {
155    defines = [
156      "CPU_MIMXRT595SFFOC_cm33",
157      "DEBUG_CONSOLE_DISABLE_RTOS_SYNCHRONIZATION",
158      "FSL_RTOS_FREE_RTOS",
159      "FSL_SDK_DRIVER_QUICK_ACCESS_ENABLE=1",
160      "SDK_DEBUGCONSOLE=1",
161      "SDK_OS_FREE_RTOS",
162    ]
163    visibility = [ ":*" ]
164  }
165
166  # Project-specific board configuration.
167  pw_source_set("mimxrt595_config") {
168    public_configs = [
169      ":config_public_defines",
170      ":config_public_includes",
171      ":disable_warnings",
172      ":sdk__defines",
173      ":sdk__includes",
174    ]
175  }
176
177  # Project-specific FreeRTOS configurations.
178  config("freertos_config_public_includes") {
179    include_dirs = [ "." ]
180    visibility = [ ":*" ]
181  }
182
183  pw_source_set("freertos_config") {
184    public_configs = [
185      ":config_public_defines",
186      ":config_public_includes",
187      ":disable_warnings",
188      ":freertos_config_public_includes",
189    ]
190    public_deps = [ "$dir_pw_third_party/freertos:config_assert" ]
191    public = [ "FreeRTOSConfig.h" ]
192  }
193
194  # Project-specific FreeRTOS port.
195  _freertos_port_dir =
196      "$dir_pw_third_party_freertos/portable/GCC/ARM_CM33_NTZ/non_secure"
197  config("freertos_port_public_includes") {
198    include_dirs = [
199      "$_freertos_port_dir",
200      "$dir_pw_third_party_freertos/include",
201    ]
202    visibility = [ ":*" ]
203  }
204
205  pw_source_set("freertos_port") {
206    public_configs = [ ":freertos_port_public_includes" ]
207    public = [
208      "$_freertos_port_dir/portasm.h",
209      "$_freertos_port_dir/portmacro.h",
210    ]
211    configs = [ ":disable_warnings" ]
212    sources = [
213      "$_freertos_port_dir/port.c",
214      "$_freertos_port_dir/portasm.c",
215      "$dir_pw_third_party_freertos/portable/MemMang/heap_4.c",
216    ]
217    deps = [ ":freertos_config" ]
218  }
219}
220
221pw_doc_group("target_docs") {
222  sources = [ "target_docs.rst" ]
223}
224