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_pigweed/third_party/ambiq/ambiq.gni") 18import("$dir_pw_build/error.gni") 19import("$dir_pw_build/linker_script.gni") 20import("$dir_pw_build/target_types.gni") 21import("$dir_pw_cpu_exception/backend.gni") 22import("$dir_pw_docgen/docs.gni") 23import("$dir_pw_malloc/backend.gni") 24import("$dir_pw_system/backend.gni") 25import("$dir_pw_toolchain/generate_toolchain.gni") 26import("target_toolchains.gni") 27 28generate_toolchains("target_toolchains") { 29 toolchains = pw_target_toolchain_apollo4_list 30} 31 32pw_build_assert("check_ambiq_product_defined") { 33 condition = pw_third_party_ambiq_PRODUCT == "apollo4p" || 34 pw_third_party_ambiq_PRODUCT == "apollo4b" 35 message = "Build argument pw_third_party_ambiq_PRODUCT must be one of " + 36 "the following values: 'apollo4p' or 'apollo4b'." 37 visibility = [ ":*" ] 38} 39 40config("disable_warnings") { 41 cflags = [ "-Wno-undef" ] 42 visibility = [ ":*" ] 43} 44 45config("pw_malloc_active") { 46 if (pw_malloc_BACKEND != "") { 47 defines = [ "PW_MALLOC_ACTIVE=1" ] 48 } else { 49 defines = [ "PW_MALLOC_ACTIVE=0" ] 50 } 51} 52 53config("pw_system_active") { 54 if (pw_system_TARGET_HOOKS_BACKEND != "") { 55 ldflags = [ 56 "-Wl,--defsym=SysTick_Handler=xPortSysTickHandler", 57 "-Wl,--defsym=PendSV_Handler=xPortPendSVHandler", 58 "-Wl,--defsym=SVC_Handler=vPortSVCHandler", 59 ] 60 } 61} 62 63config("pw_cpu_exception_active") { 64 if (pw_cpu_exception_ENTRY_BACKEND != "") { 65 ldflags = [ 66 "-Wl,--defsym=HardFault_Handler=pw_cpu_exception_Entry", 67 "-Wl,--defsym=MemManage_Handler=pw_cpu_exception_Entry", 68 "-Wl,--defsym=BusFault_Handler=pw_cpu_exception_Entry", 69 "-Wl,--defsym=UsageFault_Handler=pw_cpu_exception_Entry", 70 "-Wl,--defsym=NMI_Handler=pw_cpu_exception_Entry", 71 ] 72 } 73} 74 75if (current_toolchain != default_toolchain) { 76 pw_source_set("boot") { 77 public_configs = [ ":pw_malloc_active" ] 78 79 all_dependent_configs = [ 80 ":pw_system_active", 81 ":pw_cpu_exception_active", 82 ] 83 84 public_deps = [ "$dir_pw_third_party/ambiq:sdk" ] 85 86 deps = [ 87 ":check_ambiq_product_defined", 88 "$dir_pw_boot", 89 "$dir_pw_boot_cortex_m", 90 "$dir_pw_preprocessor", 91 "$dir_pw_sys_io_ambiq_sdk", 92 ] 93 94 if (pw_malloc_BACKEND != "") { 95 deps += [ "$dir_pw_malloc" ] 96 } 97 98 sources = [ 99 "boot.cc", 100 "vector_table.c", 101 ] 102 } 103} 104 105pw_doc_group("target_docs") { 106 sources = [ "target_docs.rst" ] 107} 108