yzamstm | 0b9dfec | 2023-09-06 21:05:35 +0200 | [diff] [blame] | 1 | # # Copyright (c) 2023 Project CHIP Authors |
| 2 | # # |
| 3 | # # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # # you may not use this file except in compliance with the License. |
| 5 | # # You may obtain a copy of the License at |
| 6 | # # |
| 7 | # # http://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, |
| 11 | # # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # # See the License for the specific language governing permissions and |
| 13 | # # limitations under the License. |
| 14 | |
| 15 | import("//build_overrides/build.gni") |
| 16 | import("//build_overrides/chip.gni") |
| 17 | import("//build_overrides/stm32_sdk.gni") |
| 18 | |
| 19 | import("${build_root}/config/defaults.gni") |
| 20 | import("${chip_root}/src/platform/device.gni") |
| 21 | import("${stm32_sdk_build_root}/stm32_executable.gni") |
| 22 | import("${stm32_sdk_build_root}/stm32_sdk.gni") |
| 23 | |
| 24 | assert(current_os == "freertos") |
| 25 | |
| 26 | stm32_project_dir = "${chip_root}/examples/lighting-app/stm32" |
| 27 | examples_plat_dir = "${chip_root}/examples/platform/stm32" |
| 28 | stm32_board_src = "${chip_root}/examples/platform/stm32/common/STM32WB5MM-DK" |
| 29 | |
| 30 | declare_args() { |
| 31 | # Dump memory usage at link time. |
| 32 | chip_print_memory_usage = false |
| 33 | |
| 34 | # PIN code for PASE session establishment. |
| 35 | setupPinCode = 20202021 |
| 36 | setupDiscriminator = 3840 |
| 37 | |
| 38 | # Monitor & log memory usage at runtime. |
| 39 | enable_heap_monitoring = false |
| 40 | |
| 41 | # Enable Sleepy end device |
| 42 | enable_sleepy_device = false |
| 43 | |
| 44 | # OTA timeout in seconds |
| 45 | OTA_periodic_query_timeout = 86400 |
| 46 | } |
| 47 | |
| 48 | # Sanity check |
| 49 | assert(!(chip_enable_wifi && chip_enable_openthread)) |
| 50 | |
| 51 | # ThunderBoards and Explorer Kit |
| 52 | if (stm32_board == "STM32WB5MM-DK") { |
| 53 | chip_enable_openthread = true |
| 54 | } |
| 55 | |
| 56 | stm32_sdk("sdk") { |
yzamstm | bd2e2b9 | 2024-05-21 23:05:00 +0200 | [diff] [blame] | 57 | include_dirs = [ |
| 58 | "${chip_root}/src/platform/stm32", |
| 59 | "${examples_plat_dir}", |
| 60 | "${stm32_project_dir}/include/STM32WB5", |
| 61 | "${chip_root}/src/lib", |
| 62 | ] |
| 63 | |
yzamstm | 0b9dfec | 2023-09-06 21:05:35 +0200 | [diff] [blame] | 64 | if (stm32_board == "STM32WB5MM-DK") { |
| 65 | sources = [ |
| 66 | "${examples_plat_dir}/config_files/STM32WB5/FreeRTOSConfig.h", |
| 67 | "${examples_plat_dir}/config_files/STM32WB5/matter_config.h", |
| 68 | "${stm32_project_dir}/include/STM32WB5/CHIPProjectConfig.h", |
| 69 | ] |
yzamstm | 0b9dfec | 2023-09-06 21:05:35 +0200 | [diff] [blame] | 70 | |
yzamstm | 0b9dfec | 2023-09-06 21:05:35 +0200 | [diff] [blame] | 71 | include_dirs += [ |
| 72 | "${stm32_project_dir}/include/STM32WB5", |
yzamstm | 0b9dfec | 2023-09-06 21:05:35 +0200 | [diff] [blame] | 73 | "${chip_root}/src/include", |
| 74 | ] |
| 75 | } |
| 76 | |
| 77 | defines = [ |
| 78 | "BOARD_ID=${stm32_board}", |
| 79 | "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", |
| 80 | "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}", |
| 81 | "OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}", |
| 82 | "STM32STORE_MAX_KEY_SIZE=75", |
| 83 | ] |
| 84 | } |
| 85 | |
| 86 | stm32_executable("lighting_app") { |
Maksymilian Knust | 686e73b | 2024-06-25 07:47:08 +0200 | [diff] [blame] | 87 | deps = [] |
| 88 | |
yzamstm | 0b9dfec | 2023-09-06 21:05:35 +0200 | [diff] [blame] | 89 | if (stm32_board == "STM32WB5MM-DK") { |
| 90 | output_name = "chip-stm32-lighting-example.elf" |
| 91 | include_dirs = [ |
| 92 | "${chip_root}/examples/platform/stm32/config_files/STM32WB5/", |
| 93 | "${chip_root}/examples/platform/stm32/common/STM32WB5MM-DK/Inc", |
| 94 | "${chip_root}/src/include/", |
| 95 | ] |
| 96 | defines = [] |
| 97 | |
| 98 | sources = [ |
| 99 | "${stm32_board_src}/STM32_WPAN/App/app_ble.c", |
| 100 | "${stm32_board_src}/STM32_WPAN/App/app_matter.c", |
| 101 | "${stm32_board_src}/STM32_WPAN/App/app_thread.c", |
| 102 | "${stm32_board_src}/STM32_WPAN/App/custom_stm.c", |
yzamstm | bd2e2b9 | 2024-05-21 23:05:00 +0200 | [diff] [blame] | 103 | |
| 104 | #"${stm32_board_src}/STM32_WPAN/Target/hw_ipcc.c", |
yzamstm | 0b9dfec | 2023-09-06 21:05:35 +0200 | [diff] [blame] | 105 | "${stm32_board_src}/Src/app_entry.cpp", |
| 106 | "${stm32_board_src}/Src/main.cpp", |
yzamstm | bd2e2b9 | 2024-05-21 23:05:00 +0200 | [diff] [blame] | 107 | "${stm32_board_src}/Src/ota.cpp", |
yzamstm | 0b9dfec | 2023-09-06 21:05:35 +0200 | [diff] [blame] | 108 | "src/STM32WB5/AppTask.cpp", |
yzamstm | bd2e2b9 | 2024-05-21 23:05:00 +0200 | [diff] [blame] | 109 | "src/STM32WB5/IdentifierEffect.cpp", |
yzamstm | 0b9dfec | 2023-09-06 21:05:35 +0200 | [diff] [blame] | 110 | "src/STM32WB5/LightingManager.cpp", |
| 111 | "src/STM32WB5/ZclCallbacks.cpp", |
| 112 | ] |
yzamstm | bd2e2b9 | 2024-05-21 23:05:00 +0200 | [diff] [blame] | 113 | |
| 114 | deps = [ |
| 115 | ":sdk", |
| 116 | "${chip_root}/examples/lighting-app/lighting-common", |
| 117 | "${chip_root}/examples/providers:device_info_provider", |
| 118 | "${chip_root}/src/lib", |
| 119 | "${chip_root}/src/setup_payload", |
| 120 | ] |
yzamstm | 0b9dfec | 2023-09-06 21:05:35 +0200 | [diff] [blame] | 121 | } |
| 122 | |
Maksymilian Knust | 686e73b | 2024-06-25 07:47:08 +0200 | [diff] [blame] | 123 | deps += [ "${chip_root}/src/platform/logging:default" ] |
| 124 | |
yzamstm | 0b9dfec | 2023-09-06 21:05:35 +0200 | [diff] [blame] | 125 | # Add the startup file to the target |
| 126 | sources += [ "${examples_plat_dir}/startup_files/startup_${stm32_mcu}.s" ] |
| 127 | |
yzamstm | 0b9dfec | 2023-09-06 21:05:35 +0200 | [diff] [blame] | 128 | defines += [ |
| 129 | "DEBUG", |
| 130 | "USE_HAL_DRIVER", |
| 131 | ] |
| 132 | |
| 133 | # OpenThread Settings |
| 134 | if (chip_enable_openthread) { |
| 135 | deps += [ |
| 136 | "${chip_root}/third_party/openthread:openthread", |
| 137 | "${chip_root}/third_party/openthread:openthread-platform", |
| 138 | ] |
| 139 | } |
| 140 | |
| 141 | if (chip_enable_ota_requestor) { |
| 142 | defines += [ "STM32_OTA_ENABLED" ] |
| 143 | sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] |
| 144 | } |
| 145 | |
| 146 | ldscript = "${examples_plat_dir}/ldscripts/${stm32_mcu}_FLASH.ld" |
| 147 | |
| 148 | inputs = [ ldscript ] |
| 149 | |
| 150 | ldflags = [ |
| 151 | "-T" + rebase_path(ldscript, root_build_dir), |
| 152 | |
| 153 | # other linker flags ... |
| 154 | "-static", |
| 155 | "-Wl,--cref", |
| 156 | "-Wl,--start-group", |
| 157 | "-lc", |
| 158 | "-lm", |
| 159 | "-lstdc++", |
| 160 | "-lsupc++", |
| 161 | "-Wl,--no-warn-rwx-segments", |
| 162 | "-Wl,--end-group", |
| 163 | ] |
| 164 | if (chip_print_memory_usage) { |
| 165 | ldflags += [ |
| 166 | "-Wl,--print-memory-usage", |
| 167 | "-fstack-usage", |
| 168 | ] |
| 169 | } |
| 170 | |
| 171 | output_dir = root_out_dir |
| 172 | } |
| 173 | group("stm32") { |
| 174 | deps = [ ":lighting_app" ] |
| 175 | } |
| 176 | |
| 177 | group("default") { |
| 178 | deps = [ ":stm32" ] |
| 179 | } |