Skip to content

Commit 456b8f1

Browse files
wy-hhrestyled-commitsandy31415
committed
[bouffalo lab] add bl616 lighting example with Wi-Fi and Thread suppo… (project-chip#36954)
* [bouffalo lab] add bl616 lighting example with Wi-Fi and Thread supported * Restyled by gn --------- Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Andrei Litvin <andy314@gmail.com>
1 parent 19299cf commit 456b8f1

File tree

76 files changed

+5964
-326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+5964
-326
lines changed

config/bouffalolab/toolchain/riscv_toolchain.gni

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@ import("//build_overrides/chip.gni")
1717

1818
import("//build_overrides/bouffalolab_iot_sdk.gni")
1919
import("${build_root}/toolchain/gcc_toolchain.gni")
20+
import("${chip_root}/src/platform/device.gni")
2021

2122
template("riscv_toolchain") {
2223
gcc_toolchain(target_name) {
2324
_tool_name_root = ""
2425

2526
if ("linux" == host_os) {
26-
_tool_name_root = "${bouffalolab_sdk_root}/toolchain/riscv/Linux/bin/riscv64-unknown-elf-"
27+
if (chip_device_platform == "bl616") {
28+
_tool_name_root = "${bouffalolab_sdk_root}/toolchain/t-head-riscv/gcc_t-head_v2.6.1/bin/riscv64-unknown-elf-"
29+
} else {
30+
_tool_name_root = "${bouffalolab_sdk_root}/toolchain/riscv/Linux/bin/riscv64-unknown-elf-"
31+
}
2732
} else if ("mac" == host_os || "darwin" == host_os) {
2833
_tool_name_root = "${bouffalolab_sdk_root}/toolchain/riscv/Darwin/bin/riscv64-unknown-elf-"
2934
}

examples/lighting-app/bouffalolab/bl602/BUILD.gn

-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ bouffalolab_executable("lighting_app") {
107107
defines += [ "BOOT_PIN_RESET=8" ]
108108
}
109109

110-
defines += [ "CONF_ENABLE_FRAME_PTR=${enable_debug_frame_ptr}" ]
111110
defines +=
112111
[ "CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE=${chip_enable_factory_data}" ]
113112

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2021 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+
17+
# The location of the build configuration file.
18+
buildconfig = "${build_root}/config/BUILDCONFIG.gn"
19+
20+
# CHIP uses angle bracket includes.
21+
check_system_includes = true
22+
23+
default_args = {
24+
target_cpu = "riscv"
25+
target_os = "freertos"
26+
27+
import("//args.gni")
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
# Copyright (c) 2021 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/bouffalolab_iot_sdk.gni")
16+
import("//build_overrides/build.gni")
17+
import("//build_overrides/chip.gni")
18+
19+
import("${bouffalolab_iot_sdk_build_root}/bl616/bouffalo_sdk.gni")
20+
import("${bouffalolab_iot_sdk_build_root}/common/bouffalolab_executable.gni")
21+
import("${build_root}/config/defaults.gni")
22+
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
23+
import("${chip_root}/src/platform/bouffalolab/common/args.gni")
24+
import("${chip_root}/src/platform/device.gni")
25+
26+
import("${chip_root}/src/app/chip_data_model.gni")
27+
28+
if (chip_enable_pw_rpc) {
29+
import("//build_overrides/pigweed.gni")
30+
import("$dir_pw_build/target_types.gni")
31+
}
32+
33+
assert(current_os == "freertos")
34+
35+
example_dir = "${chip_root}/examples/lighting-app/bouffalolab"
36+
examples_plat_dir = "${chip_root}/examples/platform/bouffalolab"
37+
38+
declare_args() {
39+
# Dump memory usage at link time.
40+
chip_print_memory_usage = true
41+
42+
# OTA periodic query timeout in seconds
43+
ota_periodic_query_timeout_seconds = 86400
44+
45+
# reboot delay in seconds to apply new OTA image
46+
ota_auto_reboot_delay_seconds = 5
47+
48+
enable_heap_monitoring = false
49+
enable_reset_counter = false
50+
51+
setupPinCode = 20202021
52+
setupDiscriminator = 3840
53+
54+
board = "BL616DK"
55+
module_type = "BL616"
56+
baudrate = 2000000
57+
}
58+
59+
bouffalo_sdk("sdk") {
60+
include_dirs = [
61+
"${example_dir}/bl616",
62+
"${examples_plat_dir}/bl616",
63+
"${examples_plat_dir}/common/route_hook",
64+
"${chip_root}/src/platform/bouffalolab/BL616",
65+
"${chip_root}/src/platform/bouffalolab/common",
66+
]
67+
68+
defines = [
69+
"INCLUDE_xSemaphoreGetMutexHolder=1",
70+
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
71+
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
72+
"OTA_PERIODIC_TIMEOUT=${ota_periodic_query_timeout_seconds}",
73+
"OTA_AUTO_REBOOT_DELAY=${ota_auto_reboot_delay_seconds}",
74+
"CHIP_UART_BAUDRATE=${baudrate}",
75+
]
76+
77+
defines += [ "PW_RPC_ENABLED=${chip_enable_pw_rpc}" ]
78+
if (chip_enable_pw_rpc) {
79+
include_dirs += [ "${examples_plat_dir}/common/rpc" ]
80+
defines += [ "PW_RPC_ENABLED=1" ]
81+
defines += [ "DISABLE_PRINT=1" ]
82+
} else if (chip_build_libshell) {
83+
include_dirs += [ "${examples_plat_dir}/common/plat" ]
84+
}
85+
86+
if (chip_enable_wifi || chip_enable_ethernet) {
87+
include_dirs += [ "${examples_plat_dir}/bl616/lwipopts" ]
88+
}
89+
}
90+
91+
chip_data_model("bouffalolab-lighting") {
92+
if (chip_enable_openthread) {
93+
zap_file = "${example_dir}/data_model/lighting-app-thread.zap"
94+
} else if (chip_enable_wifi) {
95+
zap_file = "${example_dir}/data_model/lighting-app-wifi.zap"
96+
} else {
97+
zap_file = "${example_dir}/data_model/lighting-app-ethernet.zap"
98+
}
99+
is_server = true
100+
}
101+
102+
bouffalolab_executable("lighting_app") {
103+
output_name = "chip-bl616-lighting-example.out"
104+
bl_plat_name = "bl616"
105+
106+
defines = [
107+
"APP_TASK_STACK_SIZE=4096",
108+
"CHIP_UART_BAUDRATE=${baudrate}",
109+
"BL616_ENABLE",
110+
"START_ENTRY=main",
111+
]
112+
113+
defines +=
114+
[ "CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE=${chip_enable_factory_data}" ]
115+
116+
if (chip_config_network_layer_ble) {
117+
defines += [ "CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE=1" ]
118+
}
119+
120+
if (false == enable_reset_counter) {
121+
defines += [ "BOOT_PIN_RESET=2" ]
122+
}
123+
124+
defines += [ "BL616DK" ]
125+
126+
sources = [
127+
"${chip_root}/examples/providers/DeviceInfoProviderImpl.cpp",
128+
"${example_dir}/common/AppTask.cpp",
129+
"${example_dir}/common/ZclCallbacks.cpp",
130+
"${examples_plat_dir}/common/bouffalo_sdk/demo_pwm.c",
131+
"${examples_plat_dir}/common/bouffalo_sdk/platform_port.cpp",
132+
"${examples_plat_dir}/common/plat/LEDWidget.cpp",
133+
"${examples_plat_dir}/common/plat/OTAConfig.cpp",
134+
"${examples_plat_dir}/common/plat/main.cpp",
135+
"${examples_plat_dir}/common/plat/platform.cpp",
136+
]
137+
138+
deps = [
139+
":bouffalolab-lighting",
140+
":sdk",
141+
"${chip_root}/examples/providers:device_info_provider",
142+
"${chip_root}/src/lib",
143+
"${chip_root}/src/setup_payload",
144+
]
145+
146+
include_dirs = [
147+
"${chip_root}/src/platform/bouffalolab/BL616",
148+
"${example_dir}/common",
149+
"${example_dir}/bl616",
150+
"${examples_plat_dir}/common/plat",
151+
"${examples_plat_dir}/common/bouffalo_sdk",
152+
]
153+
154+
if (chip_enable_wifi || chip_enable_ethernet) {
155+
include_dirs += [ "${examples_plat_dir}/bl616/lwipopts" ]
156+
}
157+
158+
if (chip_enable_wifi || chip_enable_ethernet) {
159+
include_dirs += [ "${examples_plat_dir}/common/route_hook" ]
160+
161+
if (chip_enable_wifi) {
162+
defines += [ "CHIP_DEVICE_CONFIG_ENABLE_WIFI" ]
163+
}
164+
165+
sources += [
166+
"${examples_plat_dir}/common/route_hook/bl_route_hook.c",
167+
"${examples_plat_dir}/common/route_hook/bl_route_table.c",
168+
]
169+
}
170+
171+
if (chip_enable_openthread) {
172+
import("//build_overrides/openthread.gni")
173+
174+
deps += [
175+
"${chip_root}/third_party/openthread/platforms:libopenthread-platform",
176+
"${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils",
177+
]
178+
179+
if (chip_openthread_ftd) {
180+
defines += [ "CHIP_DEVICE_CONFIG_THREAD_FTD=1" ]
181+
deps += [
182+
"${openthread_root}:libopenthread-cli-ftd",
183+
"${openthread_root}:libopenthread-ftd",
184+
]
185+
} else {
186+
defines += [ "CHIP_DEVICE_CONFIG_THREAD_FTD=0" ]
187+
deps += [
188+
"${openthread_root}:libopenthread-cli-mtd",
189+
"${openthread_root}:libopenthread-mtd",
190+
]
191+
}
192+
}
193+
194+
defines += [ "CONFIG_ENABLE_CHIP_SHELL=${chip_build_libshell}" ]
195+
defines += [ "PW_RPC_ENABLED=${chip_enable_pw_rpc}" ]
196+
if (chip_enable_pw_rpc) {
197+
defines += [
198+
"PW_RPC_ENABLED",
199+
"PW_RPC_ATTRIBUTE_SERVICE=1",
200+
"PW_RPC_BUTTON_SERVICE=1",
201+
"PW_RPC_DESCRIPTOR_SERVICE=1",
202+
"PW_RPC_DEVICE_SERVICE=1",
203+
"PW_RPC_LIGHTING_SERVICE=1",
204+
205+
#"PW_RPC_TRACING_SERVICE=1",
206+
]
207+
208+
sources += [
209+
"${chip_root}/examples/common/pigweed/RpcService.cpp",
210+
"${chip_root}/examples/common/pigweed/bouffalolab/PigweedLoggerMutex.cpp",
211+
"${examples_plat_dir}/common/rpc/PigweedLogger.cpp",
212+
"${examples_plat_dir}/common/rpc/Rpc.cpp",
213+
]
214+
215+
deps += [
216+
"$dir_pw_hdlc:rpc_channel_output",
217+
"$dir_pw_kvs:crc16",
218+
"$dir_pw_log",
219+
"$dir_pw_stream:sys_io_stream",
220+
221+
#"$dir_pw_trace",
222+
#"$dir_pw_trace_tokenized",
223+
#"$dir_pw_trace_tokenized:trace_rpc_service",
224+
"${chip_root}/config/bouffalolab/common/lib/pw_rpc:pw_rpc",
225+
"${chip_root}/examples/common/pigweed:attributes_service.nanopb_rpc",
226+
"${chip_root}/examples/common/pigweed:button_service.nanopb_rpc",
227+
"${chip_root}/examples/common/pigweed:descriptor_service.nanopb_rpc",
228+
"${chip_root}/examples/common/pigweed:device_service.nanopb_rpc",
229+
"${chip_root}/examples/common/pigweed:lighting_service.nanopb_rpc",
230+
"${examples_plat_dir}/common/rpc/pw_sys_io:pw_sys_io",
231+
]
232+
233+
if (chip_enable_openthread) {
234+
deps += [
235+
"${chip_root}/examples/common/pigweed:ot_cli_service.nanopb_rpc",
236+
"${chip_root}/examples/common/pigweed:thread_service.nanopb_rpc",
237+
]
238+
}
239+
240+
deps += pw_build_LINK_DEPS
241+
242+
include_dirs += [
243+
"${chip_root}/examples/common",
244+
"${chip_root}/examples/common/pigweed/bouffalolab",
245+
]
246+
} else if (chip_build_libshell) {
247+
if (chip_build_libshell) {
248+
include_dirs += [
249+
"${chip_root}/src/lib/shell",
250+
"${chip_root}/examples/shell/shell_common/include",
251+
]
252+
253+
deps += [ "${chip_root}/examples/shell/shell_common:shell_common" ]
254+
}
255+
}
256+
257+
defines += [ "HEAP_MONITORING=${enable_heap_monitoring}" ]
258+
if (enable_heap_monitoring) {
259+
sources += [ "${examples_plat_dir}/common/plat/MemMonitoring.cpp" ]
260+
}
261+
262+
if (bouffalo_sdk_component_easyflash_enabled) {
263+
defines += [ "BOUFFALO_SDK_COMPONENTS_EASYFLASH_ENABLED=1" ]
264+
} else {
265+
defines += [ "BOUFFALO_SDK_COMPONENTS_EASYFLASH_ENABLED=0" ]
266+
}
267+
268+
print("bouffalo_sdk_root=${bouffalo_sdk_root}")
269+
cflags_c = [ "-Wno-sign-compare" ]
270+
ldscript = "${bouffalo_sdk_root}/bsp/board/bl616dk/bl616_flash.ld"
271+
272+
ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ]
273+
274+
inputs = [ ldscript ]
275+
276+
if (chip_print_memory_usage) {
277+
ldflags += [
278+
"--specs=nano.specs",
279+
"-Wl,--print-memory-usage",
280+
"-fstack-usage",
281+
]
282+
}
283+
284+
output_dir = root_out_dir
285+
}
286+
287+
group("bl616") {
288+
deps = [ ":lighting_app" ]
289+
}
290+
291+
group("default") {
292+
deps = [ ":bl616" ]
293+
}

0 commit comments

Comments
 (0)