blob: 6e338610d94821c596d2e7518a8dbffa7b81d2a5 [file] [log] [blame]
# # Copyright (c) 2023 Project CHIP Authors
# #
# # Licensed under the Apache License, Version 2.0 (the "License");
# # you may not use this file except in compliance with the License.
# # You may obtain a copy of the License at
# #
# # http://www.apache.org/licenses/LICENSE-2.0
# #
# # Unless required by applicable law or agreed to in writing, software
# # distributed under the License is distributed on an "AS IS" BASIS,
# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# # See the License for the specific language governing permissions and
# # limitations under the License.
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/stm32_sdk.gni")
import("${build_root}/config/defaults.gni")
import("${chip_root}/src/platform/device.gni")
import("${stm32_sdk_build_root}/stm32_executable.gni")
import("${stm32_sdk_build_root}/stm32_sdk.gni")
assert(current_os == "freertos")
stm32_project_dir = "${chip_root}/examples/lighting-app/stm32"
examples_plat_dir = "${chip_root}/examples/platform/stm32"
stm32_board_src = "${chip_root}/examples/platform/stm32/common/STM32WB5MM-DK"
declare_args() {
# Dump memory usage at link time.
chip_print_memory_usage = false
# PIN code for PASE session establishment.
setupPinCode = 20202021
setupDiscriminator = 3840
# Monitor & log memory usage at runtime.
enable_heap_monitoring = false
# Enable Sleepy end device
enable_sleepy_device = false
# OTA timeout in seconds
OTA_periodic_query_timeout = 86400
}
# Sanity check
assert(!(chip_enable_wifi && chip_enable_openthread))
# ThunderBoards and Explorer Kit
if (stm32_board == "STM32WB5MM-DK") {
chip_enable_openthread = true
}
stm32_sdk("sdk") {
include_dirs = [
"${chip_root}/src/platform/stm32",
"${examples_plat_dir}",
"${stm32_project_dir}/include/STM32WB5",
"${chip_root}/src/lib",
]
if (stm32_board == "STM32WB5MM-DK") {
sources = [
"${examples_plat_dir}/config_files/STM32WB5/FreeRTOSConfig.h",
"${examples_plat_dir}/config_files/STM32WB5/matter_config.h",
"${stm32_project_dir}/include/STM32WB5/CHIPProjectConfig.h",
]
include_dirs += [
"${stm32_project_dir}/include/STM32WB5",
"${chip_root}/src/include",
]
}
defines = [
"BOARD_ID=${stm32_board}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
"OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}",
"STM32STORE_MAX_KEY_SIZE=75",
]
}
stm32_executable("lighting_app") {
deps = []
if (stm32_board == "STM32WB5MM-DK") {
output_name = "chip-stm32-lighting-example.elf"
include_dirs = [
"${chip_root}/examples/platform/stm32/config_files/STM32WB5/",
"${chip_root}/examples/platform/stm32/common/STM32WB5MM-DK/Inc",
"${chip_root}/src/include/",
]
defines = []
sources = [
"${stm32_board_src}/STM32_WPAN/App/app_ble.c",
"${stm32_board_src}/STM32_WPAN/App/app_matter.c",
"${stm32_board_src}/STM32_WPAN/App/app_thread.c",
"${stm32_board_src}/STM32_WPAN/App/custom_stm.c",
#"${stm32_board_src}/STM32_WPAN/Target/hw_ipcc.c",
"${stm32_board_src}/Src/app_entry.cpp",
"${stm32_board_src}/Src/main.cpp",
"${stm32_board_src}/Src/ota.cpp",
"src/STM32WB5/AppTask.cpp",
"src/STM32WB5/IdentifierEffect.cpp",
"src/STM32WB5/LightingManager.cpp",
"src/STM32WB5/ZclCallbacks.cpp",
]
deps = [
":sdk",
"${chip_root}/examples/lighting-app/lighting-common",
"${chip_root}/examples/providers:device_info_provider",
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload",
]
}
deps += [ "${chip_root}/src/platform/logging:default" ]
# Add the startup file to the target
sources += [ "${examples_plat_dir}/startup_files/startup_${stm32_mcu}.s" ]
defines += [
"DEBUG",
"USE_HAL_DRIVER",
]
# OpenThread Settings
if (chip_enable_openthread) {
deps += [
"${chip_root}/third_party/openthread:openthread",
"${chip_root}/third_party/openthread:openthread-platform",
]
}
if (chip_enable_ota_requestor) {
defines += [ "STM32_OTA_ENABLED" ]
sources += [ "${examples_plat_dir}/OTAConfig.cpp" ]
}
ldscript = "${examples_plat_dir}/ldscripts/${stm32_mcu}_FLASH.ld"
inputs = [ ldscript ]
ldflags = [
"-T" + rebase_path(ldscript, root_build_dir),
# other linker flags ...
"-static",
"-Wl,--cref",
"-Wl,--start-group",
"-lc",
"-lm",
"-lstdc++",
"-lsupc++",
"-Wl,--no-warn-rwx-segments",
"-Wl,--end-group",
]
if (chip_print_memory_usage) {
ldflags += [
"-Wl,--print-memory-usage",
"-fstack-usage",
]
}
output_dir = root_out_dir
}
group("stm32") {
deps = [ ":lighting_app" ]
}
group("default") {
deps = [ ":stm32" ]
}