xref: /aosp_15_r20/external/pigweed/targets/apollo4/target_toolchains.gni (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2023 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_log/backend.gni")
18import("$dir_pw_toolchain/arm_gcc/toolchains.gni")
19
20_target_config = {
21  pw_third_party_ambiq_PRODUCT = "apollo4p"
22
23  # Use the logging main.
24  pw_unit_test_MAIN = "$dir_pw_unit_test:logging_main"
25
26  # Use ARM Cycle Counts
27  pw_perf_test_TIMER_INTERFACE_BACKEND = "$dir_pw_perf_test:arm_cortex_timer"
28
29  # Configuration options for Pigweed executable targets.
30  pw_build_EXECUTABLE_TARGET_TYPE = "apollo4_executable"
31
32  pw_build_EXECUTABLE_TARGET_TYPE_FILE =
33      get_path_info("apollo4_executable.gni", "abspath")
34
35  # Path to the bloaty config file for the output binaries.
36  pw_bloat_BLOATY_CONFIG = "$dir_pw_boot_cortex_m/bloaty_config.bloaty"
37
38  # Configure backend for assert facade.
39  pw_assert_BACKEND = dir_pw_assert_basic
40
41  pw_boot_BACKEND = "$dir_pw_boot_cortex_m"
42  pw_cpu_exception_ENTRY_BACKEND =
43      "$dir_pw_cpu_exception_cortex_m:cpu_exception"
44  pw_cpu_exception_HANDLER_BACKEND = "$dir_pw_cpu_exception:basic_handler"
45  pw_cpu_exception_SUPPORT_BACKEND = "$dir_pw_cpu_exception_cortex_m:support"
46  pw_sync_INTERRUPT_SPIN_LOCK_BACKEND =
47      "$dir_pw_sync_baremetal:interrupt_spin_lock"
48
49  # Configure backends for pw_sync's facades.
50  pw_sync_MUTEX_BACKEND = "$dir_pw_sync_baremetal:mutex"
51
52  # Configure backend for logging facade.
53  pw_log_BACKEND = "$dir_pw_log_basic"
54
55  # Configure backend for pw_sys_io facade.
56  pw_sys_io_BACKEND = "$dir_pw_sys_io_ambiq_sdk"
57
58  # Configure backend for pw_rpc_system_server.
59  pw_rpc_system_server_BACKEND = "$dir_pw_hdlc:hdlc_sys_io_system_server"
60  pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex"
61
62  pw_malloc_BACKEND = "$dir_pw_malloc:bucket_block_allocator"
63
64  pw_boot_cortex_m_LINK_CONFIG_DEFINES = [
65    "PW_BOOT_VECTOR_TABLE_BEGIN=0x00018000",
66    "PW_BOOT_VECTOR_TABLE_SIZE=512",
67
68    "PW_BOOT_FLASH_BEGIN=0x00018200",
69    "PW_BOOT_FLASH_SIZE=1951K",
70
71    "PW_BOOT_HEAP_SIZE=100K",
72    "PW_BOOT_MIN_STACK_SIZE=1K",
73
74    "PW_BOOT_RAM_BEGIN=0x10000000",
75    "PW_BOOT_RAM_SIZE=1408K",
76  ]
77
78  pw_build_LINK_DEPS = []  # Explicit list overwrite required by GN
79  pw_build_LINK_DEPS = [
80    "$dir_pw_assert:impl",
81    "$dir_pw_log:impl",
82    "$dir_pw_cpu_exception:entry_impl",
83    "$dir_pw_toolchain/arm_gcc:arm_none_eabi_gcc_support",
84  ]
85
86  current_cpu = "arm"
87  current_os = ""
88}
89
90_toolchain_properties = {
91  final_binary_extension = ".elf"
92}
93
94_target_default_configs = [
95  "$dir_pw_build:extra_strict_warnings",
96  "$dir_pw_toolchain/arm_gcc:enable_float_printf",
97]
98
99pw_target_toolchain_apollo4 = {
100  _excluded_members = [
101    "defaults",
102    "name",
103  ]
104
105  debug = {
106    name = "apollo4_debug"
107    _toolchain_base = pw_toolchain_arm_gcc.cortex_m4f_debug
108    forward_variables_from(_toolchain_base, "*", _excluded_members)
109    forward_variables_from(_toolchain_properties, "*")
110    defaults = {
111      forward_variables_from(_toolchain_base.defaults, "*")
112      forward_variables_from(_target_config, "*")
113      default_configs += _target_default_configs
114    }
115  }
116
117  speed_optimized = {
118    name = "apollo4_speed_optimized"
119    _toolchain_base = pw_toolchain_arm_gcc.cortex_m4f_speed_optimized
120    forward_variables_from(_toolchain_base, "*", _excluded_members)
121    forward_variables_from(_toolchain_properties, "*")
122    defaults = {
123      forward_variables_from(_toolchain_base.defaults, "*")
124      forward_variables_from(_target_config, "*")
125      default_configs += _target_default_configs
126    }
127  }
128
129  size_optimized = {
130    name = "apollo4_size_optimized"
131    _toolchain_base = pw_toolchain_arm_gcc.cortex_m4f_size_optimized
132    forward_variables_from(_toolchain_base, "*", _excluded_members)
133    forward_variables_from(_toolchain_properties, "*")
134    defaults = {
135      forward_variables_from(_toolchain_base.defaults, "*")
136      forward_variables_from(_target_config, "*")
137      default_configs += _target_default_configs
138    }
139  }
140}
141
142# This list just contains the members of the above scope for convenience to make
143# it trivial to generate all the toolchains in this file via a
144# `generate_toolchains` target.
145pw_target_toolchain_apollo4_list = [
146  pw_target_toolchain_apollo4.debug,
147  pw_target_toolchain_apollo4.speed_optimized,
148  pw_target_toolchain_apollo4.size_optimized,
149]
150