| # Copyright (c) 2021 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/bouffalolab_iot_sdk.gni") |
| import("//build_overrides/build.gni") |
| import("//build_overrides/chip.gni") |
| |
| import("${bouffalolab_iot_sdk_build_root}/bl602/bl_iot_sdk.gni") |
| import("${bouffalolab_iot_sdk_build_root}/common/bouffalolab_executable.gni") |
| import("${build_root}/config/defaults.gni") |
| import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") |
| import("${chip_root}/src/platform/device.gni") |
| |
| import("${chip_root}/src/app/chip_data_model.gni") |
| |
| if (chip_enable_pw_rpc) { |
| import("//build_overrides/pigweed.gni") |
| import("$dir_pw_build/target_types.gni") |
| } |
| |
| assert(current_os == "freertos") |
| |
| example_common_dir = "${chip_root}/examples/lighting-app/bouffalolab/common" |
| example_dir = "${chip_root}/examples/lighting-app/bouffalolab/bl602" |
| examples_plat_common_dir = "${chip_root}/examples/platform/bouffalolab/common" |
| examples_plat_dir = "${chip_root}/examples/platform/bouffalolab/bl602" |
| |
| declare_args() { |
| # Dump memory usage at link time. |
| chip_print_memory_usage = true |
| |
| # OTA periodic query timeout in seconds |
| ota_periodic_query_timeout_seconds = 86400 |
| |
| # reboot delay in seconds to apply new OTA image |
| ota_auto_reboot_delay_seconds = 5 |
| |
| enable_heap_monitoring = false |
| enable_reset_counter = false |
| |
| setupPinCode = 20202021 |
| setupDiscriminator = 3840 |
| |
| board = "BL602-IoT-Matter-V1" |
| module_type = "BL602" |
| baudrate = 2000000 |
| } |
| |
| bl_iot_sdk("sdk") { |
| include_dirs = [ |
| "${chip_root}/src/platform/bouffalolab/BL602", |
| "${example_dir}", |
| "${example_dir}/include", |
| ] |
| |
| freertos_config = "${examples_plat_dir}/FreeRTOSConfig.h" |
| |
| defines = [ |
| "INCLUDE_xSemaphoreGetMutexHolder=1", |
| "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", |
| "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}", |
| "OTA_PERIODIC_TIMEOUT=${ota_periodic_query_timeout_seconds}", |
| "OTA_AUTO_REBOOT_DELAY=${ota_auto_reboot_delay_seconds}", |
| "CHIP_UART_BAUDRATE=${baudrate}", |
| "SYS_AOS_LOOP_ENABLE", |
| ] |
| |
| if (chip_enable_pw_rpc) { |
| include_dirs += [ "${examples_plat_common_dir}/rpc" ] |
| defines += [ "PW_RPC_ENABLED=1" ] |
| defines += [ "DISABLE_PRINT=1" ] |
| } else if (chip_build_libshell) { |
| include_dirs += [ "${examples_plat_common_dir}/plat" ] |
| } |
| } |
| |
| chip_data_model("bouffalolab-lighting") { |
| zap_file = "${example_dir}/../data_model/lighting-app-wifi.zap" |
| |
| zap_pregenerated_dir = "${chip_root}/zzz_generated/lighting-app/zap-generated" |
| is_server = true |
| } |
| |
| bouffalolab_executable("lighting_app") { |
| output_name = "chip-bl602-lighting-example.out" |
| |
| defines = [ |
| "APP_TASK_STACK_SIZE=2044", |
| "CHIP_UART_BAUDRATE=${baudrate}", |
| "BL602_ENABLE", |
| "START_ENTRY=bfl_main", |
| "SYS_AOS_LOOP_ENABLE", |
| ] |
| |
| if (false == enable_reset_counter) { |
| defines += [ "BOOT_PIN_RESET=8" ] |
| } |
| |
| bl_plat_name = "bl602" |
| sources = [ |
| "${examples_plat_common_dir}/route_hook/bl_route_hook.c", |
| "${examples_plat_common_dir}/route_hook/bl_route_table.c", |
| ] |
| |
| if ("BL602-IoT-Matter-V1" == board) { |
| defines += [ "BL602_IoT_Matter_V1" ] |
| } else if ("BL602-NIGHT-LIGHT" == board) { |
| defines += [ "BL602_NIGHT_LIGHT" ] |
| } |
| |
| sources += [ |
| "${chip_root}/examples/providers/DeviceInfoProviderImpl.cpp", |
| "${example_common_dir}/AppTask.cpp", |
| "${example_common_dir}/ZclCallbacks.cpp", |
| "${examples_plat_common_dir}/plat/LEDWidget.cpp", |
| "${examples_plat_common_dir}/plat/OTAConfig.cpp", |
| "${examples_plat_common_dir}/plat/aos_task.c", |
| "${examples_plat_common_dir}/plat/demo_pwm.c", |
| "${examples_plat_common_dir}/plat/main.cpp", |
| "${examples_plat_common_dir}/plat/platform.cpp", |
| "${examples_plat_common_dir}/plat/uart.c", |
| ] |
| |
| deps = [ |
| ":bouffalolab-lighting", |
| ":sdk", |
| "${chip_root}/examples/common/QRCode", |
| "${chip_root}/examples/providers:device_info_provider", |
| "${chip_root}/src/lib", |
| "${chip_root}/src/setup_payload", |
| ] |
| |
| include_dirs = [ |
| "${chip_root}/src/platform/bouffalolab/BL602", |
| "${example_common_dir}", |
| "${examples_plat_common_dir}/route_hook", |
| "${examples_plat_common_dir}/plat", |
| "${examples_plat_dir}", |
| ] |
| |
| if (chip_enable_pw_rpc) { |
| defines += [ |
| "PW_RPC_ENABLED", |
| "PW_RPC_ATTRIBUTE_SERVICE=1", |
| "PW_RPC_BUTTON_SERVICE=1", |
| "PW_RPC_DESCRIPTOR_SERVICE=1", |
| "PW_RPC_DEVICE_SERVICE=1", |
| "PW_RPC_LIGHTING_SERVICE=1", |
| |
| #"PW_RPC_TRACING_SERVICE=1", |
| ] |
| |
| sources += [ |
| "${chip_root}/examples/common/pigweed/RpcService.cpp", |
| "${chip_root}/examples/common/pigweed/bouffalolab/PigweedLoggerMutex.cpp", |
| "${examples_plat_common_dir}/rpc/PigweedLogger.cpp", |
| "${examples_plat_common_dir}/rpc/Rpc.cpp", |
| ] |
| |
| deps += [ |
| "$dir_pw_hdlc:rpc_channel_output", |
| "$dir_pw_kvs:crc16", |
| "$dir_pw_log", |
| "$dir_pw_stream:sys_io_stream", |
| |
| #"$dir_pw_trace", |
| #"$dir_pw_trace_tokenized", |
| #"$dir_pw_trace_tokenized:trace_rpc_service", |
| "${chip_root}/config/bouffalolab/common/lib/pw_rpc:pw_rpc", |
| "${chip_root}/examples/common/pigweed:attributes_service.nanopb_rpc", |
| "${chip_root}/examples/common/pigweed:button_service.nanopb_rpc", |
| "${chip_root}/examples/common/pigweed:descriptor_service.nanopb_rpc", |
| "${chip_root}/examples/common/pigweed:device_service.nanopb_rpc", |
| "${chip_root}/examples/common/pigweed:lighting_service.nanopb_rpc", |
| "${examples_plat_common_dir}/rpc/pw_sys_io:pw_sys_io", |
| ] |
| |
| public_deps = [ |
| "$dir_pw_checksum", |
| "$dir_pw_kvs", |
| ] |
| |
| deps += pw_build_LINK_DEPS |
| |
| include_dirs += [ |
| "${chip_root}/examples/common", |
| "${chip_root}/examples/common/pigweed/bouffalolab", |
| ] |
| } else if (chip_build_libshell) { |
| defines += [ "CONFIG_ENABLE_CHIP_SHELL=1" ] |
| |
| deps += [ "${chip_root}/examples/shell/shell_common:shell_common" ] |
| |
| include_dirs += [ |
| "${chip_root}/src/lib/shell", |
| "${chip_root}/examples/shell/shell_common/include", |
| ] |
| } |
| |
| if (enable_heap_monitoring) { |
| sources += [ "${examples_plat_common_dir}/plat/MemMonitoring.cpp" ] |
| defines += [ "HEAP_MONITORING=1" ] |
| } |
| |
| cflags_c = [ "-Wno-sign-compare" ] |
| ldscript = "${examples_plat_dir}/ldscripts/flash_rom.ld" |
| |
| ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ] |
| |
| inputs = [ ldscript ] |
| |
| if (chip_print_memory_usage) { |
| ldflags += [ |
| "-Wl,--print-memory-usage", |
| "-fstack-usage", |
| ] |
| } |
| |
| output_dir = root_out_dir |
| } |
| |
| group("bl602") { |
| deps = [ ":lighting_app" ] |
| } |
| |
| group("default") { |
| deps = [ ":bl602" ] |
| } |