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("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library") 16load("//pw_build:compatibility.bzl", "incompatible_with_mcu") 17load("//pw_build:merge_flags.bzl", "flags_from_dict") 18load("//pw_build:pw_linker_script.bzl", "pw_linker_script") 19load("//third_party/freertos:flags.bzl", "FREERTOS_FLAGS") 20 21package(default_visibility = ["//visibility:public"]) 22 23licenses(["notice"]) 24 25cc_library( 26 name = "freertos_config", 27 hdrs = [ 28 "config/FreeRTOSConfig.h", 29 ], 30 includes = ["config/"], 31 target_compatible_with = [":freertos_config_cv"], 32 deps = ["//third_party/freertos:config_assert"], 33) 34 35# Constraint value corresponding to :freertos_config. 36# 37# If you include this in your platform definition, you will tell Bazel to use 38# the :freertos_config defined above when compiling FreeRTOS. (See 39# //third_party/freertos/BUILD.bazel.) If you include it in a target's 40# `target_compatible_with`, you will tell Bazel the target can only be built 41# for platforms that specify this FreeRTOS config. 42constraint_value( 43 name = "freertos_config_cv", 44 constraint_setting = "@freertos//:freertos_config_setting", 45) 46 47platform( 48 name = "platform", 49 constraint_values = [ 50 ":freertos_config_cv", 51 "//pw_build/constraints/rtos:freertos", 52 "//pw_interrupt_cortex_m:backend", 53 "//pw_malloc:bucket_block_allocator_backend", 54 "@freertos//:port_ARM_CM4F", 55 "@freertos//:disable_task_statics", 56 "@platforms//cpu:armv7e-m", 57 "@platforms//os:none", 58 "@pw_toolchain//constraints/arm_mcpu:cortex-m4", 59 "@rust_crates//:no_std", 60 ], 61 flags = flags_from_dict(FREERTOS_FLAGS | { 62 "@cmsis_core//:cc_defines": ":cc_defines", 63 "@pigweed//pw_assert:check_backend": "//pw_assert_basic", 64 "@pigweed//pw_assert:check_backend_impl": "//pw_assert_basic:impl", 65 "@pigweed//pw_boot:backend": "//pw_boot_cortex_m", 66 "@pigweed//pw_log:backend": "//pw_log_tokenized", 67 "@pigweed//pw_log:backend_impl": "//pw_log_tokenized:impl", 68 "@pigweed//pw_log_tokenized:handler_backend": "//pw_system:log_backend", 69 "@pigweed//pw_malloc:backend": "//pw_malloc:bucket_block_allocator", 70 "@pigweed//pw_sys_io:backend": "//pw_sys_io_stm32cube", 71 "@pigweed//pw_system:extra_platform_libs": "//targets/stm32f429i_disc1_stm32cube:extra_platform_libs", 72 "@pigweed//pw_unit_test:main": "//targets/stm32f429i_disc1_stm32cube:unit_test_app", 73 "@stm32f4xx_hal_driver//:hal_config": "//targets/stm32f429i_disc1_stm32cube:hal_config", 74 }), 75) 76 77cc_library( 78 name = "cc_defines", 79 defines = [ 80 "STM32CUBE_HEADER=\\\"stm32f4xx.h\\\"", 81 "STM32F429xx", 82 ], 83) 84 85cc_library( 86 name = "hal_config", 87 hdrs = [ 88 "config/stm32f4xx_hal_conf.h", 89 ], 90 includes = ["config"], 91) 92 93cc_library( 94 name = "unit_test_app", 95 testonly = True, 96 srcs = [ 97 "unit_test_app.cc", 98 ], 99 deps = [ 100 "//pw_status", 101 "//pw_system", 102 "//pw_unit_test:rpc_service", 103 ], 104 alwayslink = 1, 105) 106 107cc_library( 108 name = "pre_init", 109 srcs = [ 110 "boot.cc", 111 "vector_table.c", 112 ], 113 copts = ["-Wno-return-type"], 114 defines = ["PW_MALLOC_ACTIVE=1"], 115 target_compatible_with = [":freertos_config_cv"], 116 deps = [ 117 ":freertos_config", 118 "//pw_assert", 119 "//pw_boot", 120 "//pw_boot_cortex_m", 121 "//pw_malloc", 122 "//pw_preprocessor", 123 "//pw_string", 124 "//pw_sys_io_stm32cube", 125 "//pw_system:init", 126 "//third_party/freertos:support", 127 "//third_party/stm32cube", 128 "@freertos", 129 ], 130 alwayslink = 1, 131) 132 133cc_library( 134 name = "extra_platform_libs", 135 deps = [ 136 # The linker script for pw_boot_cortex_m. 137 ":linker_script", 138 # The initialization code. 139 ":pre_init", 140 # The linker script for pw_tokenizer. 141 "//pw_tokenizer:linker_script", 142 # Arm GCC support libraries. 143 "//pw_toolchain/arm_gcc:arm_none_eabi_gcc_support", 144 ], 145) 146 147pw_linker_script( 148 name = "linker_script", 149 defines = [ 150 "PW_BOOT_FLASH_BEGIN=0x08000200", 151 "PW_BOOT_FLASH_SIZE=2048K", 152 153 # TODO(b/235348465): Currently "pw_tokenizer/detokenize_test" requires 154 # at least 6K bytes in heap when using pw_malloc:bucket_block_allocator. 155 # The heap size required for tests should be investigated. 156 "PW_BOOT_HEAP_SIZE=7K", 157 "PW_BOOT_MIN_STACK_SIZE=1K", 158 "PW_BOOT_RAM_BEGIN=0x20000000", 159 "PW_BOOT_RAM_SIZE=192K", 160 "PW_BOOT_VECTOR_TABLE_BEGIN=0x08000000", 161 "PW_BOOT_VECTOR_TABLE_SIZE=512", 162 ], 163 linker_script = "//pw_boot_cortex_m:basic_cortex_m.ld", 164) 165 166sphinx_docs_library( 167 name = "docs", 168 srcs = [ 169 "target_docs.rst", 170 ], 171 target_compatible_with = incompatible_with_mcu(), 172) 173