xref: /aosp_15_r20/external/pigweed/targets/stm32f429i_disc1/BUILD.bazel (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker# Copyright 2020 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 Workerload("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
16*61c4878aSAndroid Build Coastguard Workerload("//pw_build:compatibility.bzl", "incompatible_with_mcu")
17*61c4878aSAndroid Build Coastguard Workerload("//pw_build:merge_flags.bzl", "flags_from_dict")
18*61c4878aSAndroid Build Coastguard Workerload("//pw_build:pw_linker_script.bzl", "pw_linker_script")
19*61c4878aSAndroid Build Coastguard Worker
20*61c4878aSAndroid Build Coastguard Workerpackage(default_visibility = ["//visibility:public"])
21*61c4878aSAndroid Build Coastguard Worker
22*61c4878aSAndroid Build Coastguard Workerlicenses(["notice"])
23*61c4878aSAndroid Build Coastguard Worker
24*61c4878aSAndroid Build Coastguard Workerplatform(
25*61c4878aSAndroid Build Coastguard Worker    name = "platform",
26*61c4878aSAndroid Build Coastguard Worker    constraint_values = [
27*61c4878aSAndroid Build Coastguard Worker        "//pw_interrupt_cortex_m:backend",
28*61c4878aSAndroid Build Coastguard Worker        "//pw_malloc:bucket_block_allocator_backend",
29*61c4878aSAndroid Build Coastguard Worker        "//pw_sys_io_baremetal_stm32f429:compatible",
30*61c4878aSAndroid Build Coastguard Worker        "@platforms//cpu:armv7e-m",
31*61c4878aSAndroid Build Coastguard Worker        "@platforms//os:none",
32*61c4878aSAndroid Build Coastguard Worker        "@pw_toolchain//constraints/arm_mcpu:cortex-m4",
33*61c4878aSAndroid Build Coastguard Worker        "@rust_crates//:no_std",
34*61c4878aSAndroid Build Coastguard Worker    ],
35*61c4878aSAndroid Build Coastguard Worker    flags = flags_from_dict({
36*61c4878aSAndroid Build Coastguard Worker        "@pigweed//pw_assert:check_backend": "//pw_assert_basic",
37*61c4878aSAndroid Build Coastguard Worker        "@pigweed//pw_assert:check_backend_impl": "//pw_assert_basic:impl",
38*61c4878aSAndroid Build Coastguard Worker        "@pigweed//pw_boot:backend": "//pw_boot_cortex_m",
39*61c4878aSAndroid Build Coastguard Worker        "@pigweed//pw_log:backend": "//pw_log_basic",
40*61c4878aSAndroid Build Coastguard Worker        "@pigweed//pw_log:backend_impl": "//pw_log_basic:impl",
41*61c4878aSAndroid Build Coastguard Worker        "@pigweed//pw_malloc:backend": "//pw_malloc:bucket_block_allocator",
42*61c4878aSAndroid Build Coastguard Worker        "@pigweed//pw_sys_io:backend": "//pw_sys_io_baremetal_stm32f429",
43*61c4878aSAndroid Build Coastguard Worker        "@pigweed//pw_system:extra_platform_libs": "//targets/stm32f429i_disc1:extra_platform_libs",
44*61c4878aSAndroid Build Coastguard Worker    }),
45*61c4878aSAndroid Build Coastguard Worker)
46*61c4878aSAndroid Build Coastguard Worker
47*61c4878aSAndroid Build Coastguard Workercc_library(
48*61c4878aSAndroid Build Coastguard Worker    name = "pre_init",
49*61c4878aSAndroid Build Coastguard Worker    srcs = [
50*61c4878aSAndroid Build Coastguard Worker        "boot.cc",
51*61c4878aSAndroid Build Coastguard Worker        "vector_table.c",
52*61c4878aSAndroid Build Coastguard Worker    ],
53*61c4878aSAndroid Build Coastguard Worker    defines = [
54*61c4878aSAndroid Build Coastguard Worker        "PW_MALLOC_ACTIVE=1",
55*61c4878aSAndroid Build Coastguard Worker    ],
56*61c4878aSAndroid Build Coastguard Worker    deps = [
57*61c4878aSAndroid Build Coastguard Worker        "//pw_boot",
58*61c4878aSAndroid Build Coastguard Worker        "//pw_malloc",
59*61c4878aSAndroid Build Coastguard Worker        "//pw_preprocessor",
60*61c4878aSAndroid Build Coastguard Worker        "//pw_sys_io_baremetal_stm32f429",
61*61c4878aSAndroid Build Coastguard Worker    ],
62*61c4878aSAndroid Build Coastguard Worker    # TODO: b/251939135 - Remove the need for alwayslink by rethinking how
63*61c4878aSAndroid Build Coastguard Worker    # pw_boot_cortex_m is structured in the build system.
64*61c4878aSAndroid Build Coastguard Worker    alwayslink = 1,
65*61c4878aSAndroid Build Coastguard Worker)
66*61c4878aSAndroid Build Coastguard Worker
67*61c4878aSAndroid Build Coastguard Workercc_library(
68*61c4878aSAndroid Build Coastguard Worker    name = "extra_platform_libs",
69*61c4878aSAndroid Build Coastguard Worker    deps = [
70*61c4878aSAndroid Build Coastguard Worker        # The initialization code.
71*61c4878aSAndroid Build Coastguard Worker        ":pre_init",
72*61c4878aSAndroid Build Coastguard Worker        # Arm GCC support libraries.
73*61c4878aSAndroid Build Coastguard Worker        "//pw_toolchain/arm_gcc:arm_none_eabi_gcc_support",
74*61c4878aSAndroid Build Coastguard Worker    ],
75*61c4878aSAndroid Build Coastguard Worker)
76*61c4878aSAndroid Build Coastguard Worker
77*61c4878aSAndroid Build Coastguard Workerpw_linker_script(
78*61c4878aSAndroid Build Coastguard Worker    name = "basic_linker_script",
79*61c4878aSAndroid Build Coastguard Worker    # These come from
80*61c4878aSAndroid Build Coastguard Worker    # https://cs.opensource.google/pigweed/pigweed/+/main:targets/stm32f429i_disc1/target_toolchains.gni
81*61c4878aSAndroid Build Coastguard Worker    # TODO(tpudlik): Figure out how to share them between bazel and GN.
82*61c4878aSAndroid Build Coastguard Worker    defines = [
83*61c4878aSAndroid Build Coastguard Worker        "PW_BOOT_FLASH_BEGIN=0x08000200",
84*61c4878aSAndroid Build Coastguard Worker        "PW_BOOT_FLASH_SIZE=1024K",
85*61c4878aSAndroid Build Coastguard Worker        "PW_BOOT_HEAP_SIZE=112K",
86*61c4878aSAndroid Build Coastguard Worker        "PW_BOOT_MIN_STACK_SIZE=1K",
87*61c4878aSAndroid Build Coastguard Worker        "PW_BOOT_RAM_BEGIN=0x20000000",
88*61c4878aSAndroid Build Coastguard Worker        "PW_BOOT_RAM_SIZE=192K",
89*61c4878aSAndroid Build Coastguard Worker        "PW_BOOT_VECTOR_TABLE_BEGIN=0x08000000",
90*61c4878aSAndroid Build Coastguard Worker        "PW_BOOT_VECTOR_TABLE_SIZE=512",
91*61c4878aSAndroid Build Coastguard Worker    ],
92*61c4878aSAndroid Build Coastguard Worker    linker_script = "//pw_boot_cortex_m:basic_cortex_m.ld",
93*61c4878aSAndroid Build Coastguard Worker)
94*61c4878aSAndroid Build Coastguard Worker
95*61c4878aSAndroid Build Coastguard Workersphinx_docs_library(
96*61c4878aSAndroid Build Coastguard Worker    name = "docs",
97*61c4878aSAndroid Build Coastguard Worker    srcs = [
98*61c4878aSAndroid Build Coastguard Worker        "target_docs.rst",
99*61c4878aSAndroid Build Coastguard Worker    ],
100*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = incompatible_with_mcu(),
101*61c4878aSAndroid Build Coastguard Worker)
102