• 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
15import("//build_overrides/pigweed.gni")
16
17import("$dir_pw_build/target_types.gni")
18import("$dir_pw_docgen/docs.gni")
19import("$dir_pw_malloc/backend.gni")
20import("$dir_pw_system/system_target.gni")
21import("$dir_pw_third_party/stm32cube/stm32cube.gni")
22import("$dir_pw_toolchain/arm_clang/toolchains.gni")
23import("$dir_pw_toolchain/generate_toolchain.gni")
24
25config("pw_malloc_active") {
26  if (pw_malloc_BACKEND != "") {
27    defines = [ "PW_MALLOC_ACTIVE=1" ]
28  }
29}
30
31if (current_toolchain != default_toolchain) {
32  pw_source_set("pre_init") {
33    configs = [ ":pw_malloc_active" ]
34    deps = [
35      "$dir_pw_boot",
36      "$dir_pw_boot_cortex_m",
37      "$dir_pw_malloc",
38      "$dir_pw_preprocessor",
39      "$dir_pw_string",
40      "$dir_pw_sys_io_stm32cube",
41      "$dir_pw_system",
42      "$dir_pw_third_party/freertos",
43      "$dir_pw_third_party/freertos:support",
44      "$dir_pw_third_party/stm32cube",
45    ]
46    sources = [
47      "boot.cc",
48      "vector_table.c",
49    ]
50  }
51
52  config("config_includes") {
53    include_dirs = [ "config" ]
54  }
55
56  pw_source_set("stm32f4xx_hal_config") {
57    public_configs = [ ":config_includes" ]
58    public = [ "config/stm32f4xx_hal_conf.h" ]
59  }
60
61  pw_source_set("stm32f4xx_freertos_config") {
62    public_configs = [ ":config_includes" ]
63    public_deps = [ "$dir_pw_third_party/freertos:config_assert" ]
64    public = [ "config/FreeRTOSConfig.h" ]
65  }
66}
67
68common_link_deps =
69    [ "$dir_pigweed/targets/stm32f429i_disc1_stm32cube:pre_init" ]
70
71common_build_args = {
72  pw_log_BACKEND = dir_pw_log_tokenized
73  pw_log_tokenized_HANDLER_BACKEND = "$dir_pw_system:log_backend.impl"
74  pw_third_party_freertos_CONFIG = "$dir_pigweed/targets/stm32f429i_disc1_stm32cube:stm32f4xx_freertos_config"
75  pw_third_party_freertos_PORT = "$dir_pw_third_party/freertos:arm_cm4f"
76  pw_sys_io_BACKEND = dir_pw_sys_io_stm32cube
77  dir_pw_third_party_stm32cube = dir_pw_third_party_stm32cube_f4
78  pw_third_party_stm32cube_PRODUCT = "STM32F429xx"
79  pw_third_party_stm32cube_CONFIG =
80      "$dir_pigweed/targets/stm32f429i_disc1_stm32cube:stm32f4xx_hal_config"
81  pw_third_party_stm32cube_CORE_INIT = ""
82  pw_boot_cortex_m_LINK_CONFIG_DEFINES = [
83    "PW_BOOT_FLASH_BEGIN=0x08000200",
84    "PW_BOOT_FLASH_SIZE=2048K",
85
86    # TODO: b/235348465 - Currently "pw_tokenizer/detokenize_test" requires at
87    # least 6K bytes in heap when using pw_malloc:bucket_block_allocator.
88    # The heap size required for tests should be investigated.
89    "PW_BOOT_HEAP_SIZE=7K",
90    "PW_BOOT_MIN_STACK_SIZE=1K",
91    "PW_BOOT_RAM_BEGIN=0x20000000",
92    "PW_BOOT_RAM_SIZE=192K",
93    "PW_BOOT_VECTOR_TABLE_BEGIN=0x08000000",
94    "PW_BOOT_VECTOR_TABLE_SIZE=512",
95  ]
96}
97
98pw_system_target("stm32f429i_disc1_stm32cube") {
99  cpu = PW_SYSTEM_CPU.CORTEX_M4F
100  scheduler = PW_SYSTEM_SCHEDULER.FREERTOS
101
102  link_deps = common_link_deps
103  build_args = common_build_args
104}
105
106pw_system_target("stm32f429i_disc1_stm32cube_clang") {
107  cpu = PW_SYSTEM_CPU.CORTEX_M4F
108  scheduler = PW_SYSTEM_SCHEDULER.FREERTOS
109  system_toolchain = pw_toolchain_arm_clang
110
111  link_deps = common_link_deps
112  build_args = common_build_args
113}
114
115pw_doc_group("target_docs") {
116  sources = [ "target_docs.rst" ]
117}
118