Skip to content

Commit

Permalink
[Bouffalolab] Add Bouffalo Lab BL704L support (#27386)
Browse files Browse the repository at this point in the history
* add bl704l files

* add workflow for bl704l

* fix workflow error

* update image build script

* correct workflow

* fix restyle

* restore lighting-app-wifi.matter
  • Loading branch information
wy-hh authored and pull[bot] committed Jul 25, 2023
1 parent efc248f commit 5516321
Show file tree
Hide file tree
Showing 48 changed files with 3,385 additions and 90 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/examples-bouffalolab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,24 @@ jobs:
- name: Clean out build output
run: rm -rf ./out

- name: Build example BL702L Lighting App
timeout-minutes: 30
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target bouffalolab-bl704l-dvk-light \
build \
--copy-artifacts-to out/artifacts \
"
- name: Prepare some bloat report from the previous builds
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl702l bl702l lighting-app \
out/artifacts/bouffalolab-bl704l-dvk-light/chip-bl702l-lighting-example.out \
/tmp/bloat_reports/
- name: Clean out build output
run: rm -rf ./out

- name: Uploading Size Reports
uses: ./.github/actions/upload-size-reports
if: ${{ !env.ACT }}
Expand Down
11 changes: 8 additions & 3 deletions examples/lighting-app/bouffalolab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The steps were verified on `Bouffalo Lab` BL602 and BL706 development board.
- `BL602-NIGHT-LIGHT`
- `XT-ZB6-DevKit`
- `BL706-NIGHT-LIGHT`
- `BL704L-DVK`

> Warning: Changing the PID may cause compilation problems, we recommend leaving
> it as the default while using this example.
Expand Down Expand Up @@ -71,14 +72,15 @@ Mac OS.

## Build CHIP Lighting App example

The following steps take examples for BL602 develop board `BL602-IoT-Matter-V1`
and BL706 develop board `XT-ZB6-DevKit`.
The following steps take examples for BL602 develop board `BL602-IoT-Matter-V1`,
BL706 develop board `XT-ZB6-DevKit` and BL704L DVK board `BL704L-DVK`

- Build lighting app with UART baudrate 2000000

```
./scripts/build/build_examples.py --target bouffalolab-bl602-iot-matter-v1-light build
./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light build
./scripts/build/build_examples.py --target bouffalolab-bl704l-dvk-light build
```

- Build lighting app with UART baudrate 115200
Expand Down Expand Up @@ -124,10 +126,12 @@ and BL706 develop board `XT-ZB6-DevKit`.
- Type following command for image download. Please set serial port
accordingly, here we use /dev/ttyACM0 as a serial port example.

- `bl602-iot-matter-v1` without additional build options
- `bl602-iot-matter-v1` and `bl704l-dvk` without additional build
options

```shell
./out/bouffalolab-bl602-iot-matter-v1-light/chip-bl602-lighting-example.flash.py --port /dev/ttyACM0
./out/bouffalolab-bl704l-dvk-light/chip-bl702l-lighting-example.flash.py --port /dev/ttyACM0
```

- `xt-zb6-devkit` with 115200 baudrate setting
Expand All @@ -142,6 +146,7 @@ and BL706 develop board `XT-ZB6-DevKit`.
```shell
./out/bouffalolab-bl602-iot-matter-v1-light/chip-bl602-lighting-example.flash.py --port /dev/ttyACM0 --erase
./out/bouffalolab-xt-zb6-devkit-light-115200/chip-bl702-lighting-example.flash.py --port /dev/ttyACM0 --erase
./out/bouffalolab-bl704l-dvk-light/chip-bl702l-lighting-example.flash.py --port /dev/ttyACM0 --erase
```

> Note, better to append --erase option to download image for BL602
Expand Down
30 changes: 30 additions & 0 deletions examples/lighting-app/bouffalolab/bl702l/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (c) 2020 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")

# The location of the build configuration file.
buildconfig = "${build_root}/config/BUILDCONFIG.gn"

# CHIP uses angle bracket includes.
check_system_includes = true

default_args = {
target_cpu = "riscv"
target_os = "freertos"

chip_openthread_ftd = true

import("//args.gni")
}
261 changes: 261 additions & 0 deletions examples/lighting-app/bouffalolab/bl702l/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
# Copyright (c) 2020 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}/bl702l/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/bl702l"
examples_plat_common_dir = "${chip_root}/examples/platform/bouffalolab/common"
examples_plat_dir = "${chip_root}/examples/platform/bouffalolab/bl702l"

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

config_cache_size = 8192

enable_heap_monitoring = false

setupPinCode = 20202021
setupDiscriminator = 3840

board = "BL704L-EVB"
module_type = "BL704L"
enable_psram = true
baudrate = 2000000
}

bl_iot_sdk("sdk") {
include_dirs = [
"${chip_root}/src/platform/bouffalolab/BL702L",
"${example_dir}",
"${example_common_dir}",
]

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}",
"OPENTHREAD_CONFIG_PLATFORM_XTAL_ACCURACY=40",
"PRINT_DEBUG=0",
]

if (enable_psram) {
defines += [ "CFG_USE_PSRAM=1" ]
}

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-thread.zap"

zap_pregenerated_dir = "${chip_root}/zzz_generated/lighting-app/zap-generated"
is_server = true
}
bouffalolab_executable("lighting_app") {
output_name = "chip-bl702l-lighting-example.out"
bl_plat_name = "bl702l"

defines = [
"APP_TASK_STACK_SIZE=2044",
"CHIP_UART_BAUDRATE=${baudrate}",
"BL702L_ENABLE",
"START_ENTRY=bl702_main",
]

defines += [ "CFG_USE_PSRAM=1" ]

defines += [ "BOARD_BTN_BOOT_PIN" ]

if ("BL704L" == board) {
defines += [ "XT_ZB6_DevKit" ]
} else if ("BL706-NIGHT-LIGHT" == board) {
defines += [ "BL706_NIGHT_LIGHT" ]
} else if ("BL702-IoT-DVK" == board || "BL706-IoT-DVK" == board) {
defines += [ "BL706_IOT_DVK" ]
}

sources = [
"${example_common_dir}/AppTask.cpp",
"${example_common_dir}/ZclCallbacks.cpp",
"${examples_plat_common_dir}/plat/LEDWidget.cpp",
"${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/providers:device_info_provider",
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload",
"${chip_root}/third_party/openthread/platforms:libopenthread-platform",
"${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils",
]

if (chip_openthread_ftd) {
defines += [ "CHIP_DEVICE_CONFIG_THREAD_FTD=1" ]
deps += [
"${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd",
"${chip_root}/third_party/openthread/repo:libopenthread-ftd",
]
} else {
defines += [ "CHIP_DEVICE_CONFIG_THREAD_FTD=0" ]
deps += [
"${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd",
"${chip_root}/third_party/openthread/repo:libopenthread-mtd",
]
}

include_dirs = [
"${chip_root}/src/platform/bouffalolab/BL702L",
"${example_common_dir}",
"${examples_plat_common_dir}/plat",
]

if (chip_enable_pw_rpc) {
defines += [
"PW_RPC_ENABLED=1",
"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_OTCLI_SERVICE=1",
"PW_RPC_THREAD_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_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",
"${chip_root}/examples/common/pigweed:ot_cli_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:thread_service.nanopb_rpc",
"${examples_plat_common_dir}/rpc/pw_sys_io:pw_sys_io",
]

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=${chip_build_libshell}" ]

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" ]
}

if (chip_enable_ota_requestor) {
defines += [ "OTA_ENABLED" ]
sources += [ "${examples_plat_common_dir}/plat/OTAConfig.cpp" ]
}

if (enable_psram) {
ldscript = "${examples_plat_dir}/ldscripts/psram_flash_rom.ld"
} else {
ldscript = "${examples_plat_dir}/ldscripts/flash_rom.ld"
}

inputs = [ ldscript ]

ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ]
cflags_c = [
"-Wno-unused-variable",
"-Wno-old-style-declaration",
]
cflags = [ "-Wno-unused-variable" ]
if (chip_print_memory_usage) {
ldflags += [
"-Wl,--print-memory-usage",
"-Wl,--defsym=__CACHE_SIZE=${config_cache_size}",
"-fstack-usage",
]
}

output_dir = root_out_dir
}

group("bl702l") {
deps = [ ":lighting_app" ]
}

group("default") {
deps = [ ":bl702l" ]
}
Loading

0 comments on commit 5516321

Please sign in to comment.