xref: /aosp_15_r20/external/pigweed/targets/mimxrt595_evk/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker# Copyright 2021 The Pigweed Authors
2*61c4878aSAndroid Build Coastguard Worker#
3*61c4878aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4*61c4878aSAndroid Build Coastguard Worker# use this file except in compliance with the License. You may obtain a copy of
5*61c4878aSAndroid Build Coastguard Worker# the License at
6*61c4878aSAndroid Build Coastguard Worker#
7*61c4878aSAndroid Build Coastguard Worker#     https://www.apache.org/licenses/LICENSE-2.0
8*61c4878aSAndroid Build Coastguard Worker#
9*61c4878aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
10*61c4878aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11*61c4878aSAndroid Build Coastguard Worker# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12*61c4878aSAndroid Build Coastguard Worker# License for the specific language governing permissions and limitations under
13*61c4878aSAndroid Build Coastguard Worker# the License.
14*61c4878aSAndroid Build Coastguard Worker
15*61c4878aSAndroid Build Coastguard Workerimport("//build_overrides/pigweed.gni")
16*61c4878aSAndroid Build Coastguard Worker
17*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_build/linker_script.gni")
18*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_build/target_types.gni")
19*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_docgen/docs.gni")
20*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_malloc/backend.gni")
21*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_third_party/mcuxpresso/mcuxpresso.gni")
22*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_toolchain/generate_toolchain.gni")
23*61c4878aSAndroid Build Coastguard Workerimport("target_toolchains.gni")
24*61c4878aSAndroid Build Coastguard Worker
25*61c4878aSAndroid Build Coastguard Workergenerate_toolchains("target_toolchains") {
26*61c4878aSAndroid Build Coastguard Worker  toolchains = pw_target_toolchain_mimxrt595_evk_list
27*61c4878aSAndroid Build Coastguard Worker}
28*61c4878aSAndroid Build Coastguard Worker
29*61c4878aSAndroid Build Coastguard Workerdeclare_args() {
30*61c4878aSAndroid Build Coastguard Worker  # When compiling with an MCUXpresso SDK, this variable is set to the path of
31*61c4878aSAndroid Build Coastguard Worker  # the manifest file within the SDK installation. When set, a pw_source_set
32*61c4878aSAndroid Build Coastguard Worker  # for a sample project SDK is created at
33*61c4878aSAndroid Build Coastguard Worker  # "//targets/mimxrt595_evk/sample_sdk".
34*61c4878aSAndroid Build Coastguard Worker  pw_target_mimxrt595_evk_MANIFEST = ""
35*61c4878aSAndroid Build Coastguard Worker
36*61c4878aSAndroid Build Coastguard Worker  # This list should contain the necessary defines for setting linker script
37*61c4878aSAndroid Build Coastguard Worker  # memory regions. While we don't directly use the pw_boot_cortex_m linker
38*61c4878aSAndroid Build Coastguard Worker  # script, these are deliberately matching to make being able to later easier.
39*61c4878aSAndroid Build Coastguard Worker  pw_target_mimxrt595_evk_LINK_CONFIG_DEFINES = []
40*61c4878aSAndroid Build Coastguard Worker}
41*61c4878aSAndroid Build Coastguard Worker
42*61c4878aSAndroid Build Coastguard Workerconfig("pw_malloc_active") {
43*61c4878aSAndroid Build Coastguard Worker  if (pw_malloc_BACKEND != "") {
44*61c4878aSAndroid Build Coastguard Worker    defines = [ "PW_MALLOC_ACTIVE=1" ]
45*61c4878aSAndroid Build Coastguard Worker  }
46*61c4878aSAndroid Build Coastguard Worker}
47*61c4878aSAndroid Build Coastguard Worker
48*61c4878aSAndroid Build Coastguard Workerconfig("disable_warnings") {
49*61c4878aSAndroid Build Coastguard Worker  cflags = [
50*61c4878aSAndroid Build Coastguard Worker    "-Wno-cast-qual",
51*61c4878aSAndroid Build Coastguard Worker    "-Wno-redundant-decls",
52*61c4878aSAndroid Build Coastguard Worker    "-Wno-undef",
53*61c4878aSAndroid Build Coastguard Worker    "-Wno-unused-parameter",
54*61c4878aSAndroid Build Coastguard Worker    "-Wno-unused-variable",
55*61c4878aSAndroid Build Coastguard Worker  ]
56*61c4878aSAndroid Build Coastguard Worker  visibility = [ ":*" ]
57*61c4878aSAndroid Build Coastguard Worker}
58*61c4878aSAndroid Build Coastguard Worker
59*61c4878aSAndroid Build Coastguard Workerconfig("freestanding") {
60*61c4878aSAndroid Build Coastguard Worker  cflags = [
61*61c4878aSAndroid Build Coastguard Worker    "-ffreestanding",
62*61c4878aSAndroid Build Coastguard Worker    "-fno-builtin",
63*61c4878aSAndroid Build Coastguard Worker  ]
64*61c4878aSAndroid Build Coastguard Worker  asmflags = cflags
65*61c4878aSAndroid Build Coastguard Worker  ldflags = cflags
66*61c4878aSAndroid Build Coastguard Worker  visibility = [ ":*" ]
67*61c4878aSAndroid Build Coastguard Worker}
68*61c4878aSAndroid Build Coastguard Worker
69*61c4878aSAndroid Build Coastguard Workerconfig("sdk_defines") {
70*61c4878aSAndroid Build Coastguard Worker  defines = [
71*61c4878aSAndroid Build Coastguard Worker    "CPU_MIMXRT595SFFOC_cm33",
72*61c4878aSAndroid Build Coastguard Worker    "DEBUG_CONSOLE_TRANSFER_NON_BLOCKING",
73*61c4878aSAndroid Build Coastguard Worker    "SDK_DEBUGCONSOLE=1",
74*61c4878aSAndroid Build Coastguard Worker  ]
75*61c4878aSAndroid Build Coastguard Worker  visibility = [ ":*" ]
76*61c4878aSAndroid Build Coastguard Worker}
77*61c4878aSAndroid Build Coastguard Worker
78*61c4878aSAndroid Build Coastguard Workerif (current_toolchain != default_toolchain) {
79*61c4878aSAndroid Build Coastguard Worker  pw_linker_script("flash_linker_script") {
80*61c4878aSAndroid Build Coastguard Worker    defines = pw_target_mimxrt595_evk_LINK_CONFIG_DEFINES
81*61c4878aSAndroid Build Coastguard Worker    linker_script = "mimxrt595_flash.ld"
82*61c4878aSAndroid Build Coastguard Worker  }
83*61c4878aSAndroid Build Coastguard Worker}
84*61c4878aSAndroid Build Coastguard Worker
85*61c4878aSAndroid Build Coastguard Workerif (pw_third_party_mcuxpresso_SDK != "") {
86*61c4878aSAndroid Build Coastguard Worker  # Startup and vector table for NXP MIMXRT595-EVK.
87*61c4878aSAndroid Build Coastguard Worker  pw_source_set("boot") {
88*61c4878aSAndroid Build Coastguard Worker    public_configs = [ ":pw_malloc_active" ]
89*61c4878aSAndroid Build Coastguard Worker    deps = [
90*61c4878aSAndroid Build Coastguard Worker      "$dir_pw_boot",
91*61c4878aSAndroid Build Coastguard Worker      "$dir_pw_boot_cortex_m",
92*61c4878aSAndroid Build Coastguard Worker      "$dir_pw_preprocessor",
93*61c4878aSAndroid Build Coastguard Worker      "$dir_pw_sys_io_mcuxpresso",
94*61c4878aSAndroid Build Coastguard Worker      pw_third_party_mcuxpresso_SDK,
95*61c4878aSAndroid Build Coastguard Worker    ]
96*61c4878aSAndroid Build Coastguard Worker    if (pw_malloc_BACKEND != "") {
97*61c4878aSAndroid Build Coastguard Worker      deps += [ "$dir_pw_malloc" ]
98*61c4878aSAndroid Build Coastguard Worker    }
99*61c4878aSAndroid Build Coastguard Worker    sources = [
100*61c4878aSAndroid Build Coastguard Worker      "boot.cc",
101*61c4878aSAndroid Build Coastguard Worker      "vector_table.c",
102*61c4878aSAndroid Build Coastguard Worker    ]
103*61c4878aSAndroid Build Coastguard Worker  }
104*61c4878aSAndroid Build Coastguard Worker}
105*61c4878aSAndroid Build Coastguard Worker
106*61c4878aSAndroid Build Coastguard Workerif (pw_third_party_mcuxpresso_SDK == "//targets/mimxrt595_evk:sample_sdk") {
107*61c4878aSAndroid Build Coastguard Worker  pw_mcuxpresso_sdk("sample_sdk") {
108*61c4878aSAndroid Build Coastguard Worker    manifest = pw_target_mimxrt595_evk_MANIFEST
109*61c4878aSAndroid Build Coastguard Worker    include = [
110*61c4878aSAndroid Build Coastguard Worker      "component.serial_manager_uart.MIMXRT595S",
111*61c4878aSAndroid Build Coastguard Worker      "project_template.evkmimxrt595.MIMXRT595S",
112*61c4878aSAndroid Build Coastguard Worker      "utility.debug_console.MIMXRT595S",
113*61c4878aSAndroid Build Coastguard Worker    ]
114*61c4878aSAndroid Build Coastguard Worker    exclude = [ "device.MIMXRT595S_startup.MIMXRT595S" ]
115*61c4878aSAndroid Build Coastguard Worker
116*61c4878aSAndroid Build Coastguard Worker    public_configs = [
117*61c4878aSAndroid Build Coastguard Worker      ":disable_warnings",
118*61c4878aSAndroid Build Coastguard Worker      ":freestanding",
119*61c4878aSAndroid Build Coastguard Worker      ":sdk_defines",
120*61c4878aSAndroid Build Coastguard Worker    ]
121*61c4878aSAndroid Build Coastguard Worker  }
122*61c4878aSAndroid Build Coastguard Worker}
123*61c4878aSAndroid Build Coastguard Worker
124*61c4878aSAndroid Build Coastguard Workerpw_doc_group("target_docs") {
125*61c4878aSAndroid Build Coastguard Worker  sources = [ "target_docs.rst" ]
126*61c4878aSAndroid Build Coastguard Worker}
127