blob: 6e338610d94821c596d2e7518a8dbffa7b81d2a5 [file] [log] [blame]
yzamstm0b9dfec2023-09-06 21:05:35 +02001# # 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
15import("//build_overrides/build.gni")
16import("//build_overrides/chip.gni")
17import("//build_overrides/stm32_sdk.gni")
18
19import("${build_root}/config/defaults.gni")
20import("${chip_root}/src/platform/device.gni")
21import("${stm32_sdk_build_root}/stm32_executable.gni")
22import("${stm32_sdk_build_root}/stm32_sdk.gni")
23
24assert(current_os == "freertos")
25
26stm32_project_dir = "${chip_root}/examples/lighting-app/stm32"
27examples_plat_dir = "${chip_root}/examples/platform/stm32"
28stm32_board_src = "${chip_root}/examples/platform/stm32/common/STM32WB5MM-DK"
29
30declare_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
49assert(!(chip_enable_wifi && chip_enable_openthread))
50
51# ThunderBoards and Explorer Kit
52if (stm32_board == "STM32WB5MM-DK") {
53 chip_enable_openthread = true
54}
55
56stm32_sdk("sdk") {
yzamstmbd2e2b92024-05-21 23:05:00 +020057 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
yzamstm0b9dfec2023-09-06 21:05:35 +020064 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 ]
yzamstm0b9dfec2023-09-06 21:05:35 +020070
yzamstm0b9dfec2023-09-06 21:05:35 +020071 include_dirs += [
72 "${stm32_project_dir}/include/STM32WB5",
yzamstm0b9dfec2023-09-06 21:05:35 +020073 "${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
86stm32_executable("lighting_app") {
Maksymilian Knust686e73b2024-06-25 07:47:08 +020087 deps = []
88
yzamstm0b9dfec2023-09-06 21:05:35 +020089 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",
yzamstmbd2e2b92024-05-21 23:05:00 +0200103
104 #"${stm32_board_src}/STM32_WPAN/Target/hw_ipcc.c",
yzamstm0b9dfec2023-09-06 21:05:35 +0200105 "${stm32_board_src}/Src/app_entry.cpp",
106 "${stm32_board_src}/Src/main.cpp",
yzamstmbd2e2b92024-05-21 23:05:00 +0200107 "${stm32_board_src}/Src/ota.cpp",
yzamstm0b9dfec2023-09-06 21:05:35 +0200108 "src/STM32WB5/AppTask.cpp",
yzamstmbd2e2b92024-05-21 23:05:00 +0200109 "src/STM32WB5/IdentifierEffect.cpp",
yzamstm0b9dfec2023-09-06 21:05:35 +0200110 "src/STM32WB5/LightingManager.cpp",
111 "src/STM32WB5/ZclCallbacks.cpp",
112 ]
yzamstmbd2e2b92024-05-21 23:05:00 +0200113
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 ]
yzamstm0b9dfec2023-09-06 21:05:35 +0200121 }
122
Maksymilian Knust686e73b2024-06-25 07:47:08 +0200123 deps += [ "${chip_root}/src/platform/logging:default" ]
124
yzamstm0b9dfec2023-09-06 21:05:35 +0200125 # Add the startup file to the target
126 sources += [ "${examples_plat_dir}/startup_files/startup_${stm32_mcu}.s" ]
127
yzamstm0b9dfec2023-09-06 21:05:35 +0200128 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}
173group("stm32") {
174 deps = [ ":lighting_app" ]
175}
176
177group("default") {
178 deps = [ ":stm32" ]
179}