• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
15load(
16    "//pw_build:pigweed.bzl",
17    "pw_linker_script",
18)
19
20package(default_visibility = ["//visibility:public"])
21
22licenses(["notice"])
23
24cc_library(
25    name = "freertos_config",
26    hdrs = [
27        "config/FreeRTOSConfig.h",
28    ],
29    includes = ["config/"],
30    target_compatible_with = [":freertos_config_cv"],
31    deps = ["//third_party/freertos:config_assert"],
32)
33
34# Constraint value corresponding to :freertos_config.
35#
36# If you include this in your platform definition, you will tell Bazel to use
37# the :freertos_config defined above when compiling FreeRTOS.  (See
38# //third_party/freertos/BUILD.bazel.) If you include it in a target's
39# `target_compatible_with`, you will tell Bazel the target can only be built
40# for platforms that specify this FreeRTOS config.
41constraint_value(
42    name = "freertos_config_cv",
43    constraint_setting = "@freertos//:freertos_config_setting",
44)
45
46# TODO: b/301334234 - Set the flags currently in the stm32f429i config in
47# .bazelrc using this platform, once that's supported.
48platform(
49    name = "platform",
50    constraint_values = [
51        ":freertos_config_cv",
52        "//pw_build/constraints/rtos:freertos",
53        "//pw_interrupt_cortex_m:backend",
54        "//pw_malloc:bucket_block_allocator_backend",
55        "//pw_sys_io_stm32cube:backend",
56        "@freertos//:port_ARM_CM4F",
57        "@freertos//:disable_task_statics",
58        "@platforms//cpu:armv7e-m",
59        "@pw_toolchain//constraints/arm_mcpu:cortex-m4",
60        "@rust_crates//:no_std",
61    ],
62)
63
64cc_library(
65    name = "hal_config",
66    hdrs = [
67        "config/stm32f4xx_hal_conf.h",
68    ],
69    includes = ["config"],
70)
71
72cc_library(
73    name = "pre_init",
74    srcs = [
75        "boot.cc",
76        "vector_table.c",
77    ],
78    copts = ["-Wno-return-type"],
79    defines = ["PW_MALLOC_ACTIVE=1"],
80    target_compatible_with = [":freertos_config_cv"],
81    deps = [
82        ":freertos_config",
83        "//pw_assert",
84        "//pw_boot",
85        "//pw_boot_cortex_m",
86        "//pw_malloc",
87        "//pw_preprocessor",
88        "//pw_string",
89        "//pw_sys_io_stm32cube",
90        "//pw_system:init",
91        "//third_party/freertos:support",
92        "//third_party/stm32cube",
93        "@freertos",
94    ],
95    alwayslink = 1,
96)
97
98cc_library(
99    name = "extra_platform_libs",
100    deps = [
101        # The linker script for pw_boot_cortex_m.
102        ":linker_script",
103        # The initialization code.
104        ":pre_init",
105        # The linker script for pw_tokenizer.
106        "//pw_tokenizer:linker_script",
107        # Arm GCC support libraries.
108        "//pw_toolchain/arm_gcc:arm_none_eabi_gcc_support",
109    ],
110)
111
112pw_linker_script(
113    name = "linker_script",
114    defines = [
115        "PW_BOOT_FLASH_BEGIN=0x08000200",
116        "PW_BOOT_FLASH_SIZE=2048K",
117
118        # TODO(b/235348465): Currently "pw_tokenizer/detokenize_test" requires
119        # at least 6K bytes in heap when using pw_malloc:bucket_block_allocator.
120        # The heap size required for tests should be investigated.
121        "PW_BOOT_HEAP_SIZE=7K",
122        "PW_BOOT_MIN_STACK_SIZE=1K",
123        "PW_BOOT_RAM_BEGIN=0x20000000",
124        "PW_BOOT_RAM_SIZE=192K",
125        "PW_BOOT_VECTOR_TABLE_BEGIN=0x08000000",
126        "PW_BOOT_VECTOR_TABLE_SIZE=512",
127    ],
128    linker_script = "//pw_boot_cortex_m:basic_cortex_m.ld",
129)
130