Skip to content

Commit 3c812bc

Browse files
tx2rxasriot
andauthored
[ASR] add ASR582X & ASR595X support (#26361)
* [ASR] add ASR582X & ASR595X support * Restyled * update wordlist * update asr sdk commit id * remove getenv from gni, use --args;remove asr build example script;remove DOGO wordlist;add asr submodule platforms;update copyright time to 2023 * rename ASRUtils to matter_shell to implement shell function; remove ble and ota config * update build_examples.py build support,update README --------- Co-authored-by: weicheng <weichengxu@asrmicro.com>
1 parent ca49da3 commit 3c812bc

File tree

96 files changed

+10591
-3
lines changed

Some content is hidden

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

96 files changed

+10591
-3
lines changed

.github/.wordlist.txt

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ armv
8888
ASAN
8989
asdk
9090
AssertionError
91+
ASR
9192
AST
9293
ASYNC
9394
atomics

.gitmodules

+10
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,13 @@
298298
path = third_party/imgui/repo
299299
url = https://github.com/ocornut/imgui
300300
platforms = linux
301+
[submodule "third_party/asr/asr582x/asr_sdk"]
302+
path = third_party/asr/asr582x/asr_sdk
303+
url = https://github.com/asriot/ASR582X_Freertos.git
304+
branch = matter
305+
platforms = asr
306+
[submodule "third_party/asr/asr595x/asr_sdk"]
307+
path = third_party/asr/asr595x/asr_sdk
308+
url = https://github.com/asriot/ASR595X_Freertos.git
309+
branch = matter
310+
platforms = asr

build_overrides/asr.gni

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# 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+
15+
declare_args() {
16+
asr_ic_family = "asr582x"
17+
18+
# Root directory for ASR SDK build files.
19+
asr_sdk_build_root = "//third_party/connectedhomeip/third_party/asr/asr582x"
20+
21+
# Root directory for ASR toolchain.
22+
asr_toolchain_root = ""
23+
}

config/asr/toolchain/BUILD.gn

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# 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+
15+
import("//build_overrides/asr.gni")
16+
import("//build_overrides/build.gni")
17+
import("//build_overrides/chip.gni")
18+
19+
assert(asr_ic_family == "asr582x" || asr_ic_family == "asr595x",
20+
"Unsupported ASR IC: ${asr_ic_family}")
21+
22+
if (asr_ic_family == "asr582x") {
23+
import("${build_root}/toolchain/arm_gcc/arm_toolchain.gni")
24+
_tool_name_root = "${asr_toolchain_root}arm-none-eabi-"
25+
}
26+
27+
if (asr_ic_family == "asr595x") {
28+
import("${build_root}/toolchain/riscv_gcc/riscv_toolchain.gni")
29+
_tool_name_root = "${asr_toolchain_root}riscv-asr-elf-"
30+
}
31+
32+
declare_args() {
33+
asr_ar = _tool_name_root + "ar"
34+
asr_cc = _tool_name_root + "gcc"
35+
asr_cxx = _tool_name_root + "g++"
36+
}
37+
38+
gcc_toolchain("asrtoolchain") {
39+
ar = asr_ar
40+
cc = asr_cc
41+
cxx = asr_cxx
42+
43+
toolchain_args = {
44+
current_os = "freertos"
45+
is_clang = false
46+
}
47+
}

examples/build_overrides/asr.gni

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# 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+
15+
declare_args() {
16+
asr_ic_family = "asr582x"
17+
18+
# Root directory for ASR SDK build files.
19+
asr_sdk_build_root = "//third_party/connectedhomeip/third_party/asr/asr582x"
20+
21+
# Root directory for ASR toolchain.
22+
asr_toolchain_root = ""
23+
}

examples/lighting-app/asr/.gn

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# 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+
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 = "arm"
25+
26+
target_os = "freertos"
27+
28+
import("//args.gni")
29+
}

examples/lighting-app/asr/BUILD.gn

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# 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+
15+
import("//build_overrides/asr.gni")
16+
import("//build_overrides/build.gni")
17+
import("//build_overrides/chip.gni")
18+
import("${asr_sdk_build_root}/asr_sdk.gni")
19+
import("${build_root}/config/defaults.gni")
20+
import("${chip_root}/src/lib/lib.gni")
21+
import("${chip_root}/src/platform/device.gni")
22+
import("${chip_root}/third_party/asr/asr_executable.gni")
23+
24+
import("cfg.gni")
25+
26+
assert(current_os == "freertos")
27+
28+
asr_project_dir = "${chip_root}/examples/lighting-app/asr"
29+
examples_plat_dir = "${chip_root}/examples/platform/asr"
30+
31+
declare_args() {
32+
# Dump memory usage at link time.
33+
chip_print_memory_usage = false
34+
}
35+
36+
asr_sdk_sources("lighting_app_sdk_sources") {
37+
include_dirs = [
38+
"${chip_root}/src/platform/ASR",
39+
"${asr_project_dir}/include",
40+
"${examples_plat_dir}",
41+
]
42+
43+
defines = [
44+
"ASR_LOG_ENABLED=1",
45+
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
46+
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
47+
]
48+
49+
if (chip_enable_factory_data) {
50+
defines += [
51+
"CONFIG_ENABLE_ASR_FACTORY_DATA_PROVIDER=1",
52+
"CONFIG_ENABLE_ASR_FACTORY_DEVICE_INFO_PROVIDER=1",
53+
]
54+
}
55+
56+
if (chip_lwip_ip6_hook) {
57+
defines += [
58+
"CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT",
59+
"CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT",
60+
]
61+
}
62+
63+
sources = [ "${asr_project_dir}/include/CHIPProjectConfig.h" ]
64+
65+
public_configs = [ "${asr_sdk_build_root}:asr_sdk_config" ]
66+
}
67+
68+
asr_executable("lighting_app") {
69+
include_dirs = []
70+
defines = []
71+
output_name = "chip-asr-lighting-example.out"
72+
73+
sources = [
74+
"${examples_plat_dir}/CHIPDeviceManager.cpp",
75+
"${examples_plat_dir}/LEDWidget.cpp",
76+
"${examples_plat_dir}/init_Matter.cpp",
77+
"${examples_plat_dir}/init_asrPlatform.cpp",
78+
"${examples_plat_dir}/shell/matter_shell.cpp",
79+
"src/AppTask.cpp",
80+
"src/DeviceCallbacks.cpp",
81+
"src/main.cpp",
82+
]
83+
84+
if (chip_enable_ota_requestor) {
85+
sources += [ "${examples_plat_dir}/init_OTARequestor.cpp" ]
86+
}
87+
88+
deps = [
89+
":lighting_app_sdk_sources",
90+
"${chip_root}/examples/common/QRCode",
91+
"${chip_root}/examples/lighting-app/lighting-common",
92+
"${chip_root}/examples/providers:device_info_provider",
93+
"${chip_root}/src/lib",
94+
"${chip_root}/src/setup_payload",
95+
]
96+
97+
include_dirs += [
98+
"include",
99+
"${examples_plat_dir}",
100+
"${asr_project_dir}/include",
101+
"${chip_root}/src/lib",
102+
]
103+
104+
defines = [ "ASR_NETWORK_LAYER_BLE=${chip_config_network_layer_ble}" ]
105+
106+
if (chip_build_libshell) {
107+
defines += [ "CONFIG_ENABLE_CHIP_SHELL=1" ]
108+
sources += [ "${examples_plat_dir}/shell/launch_shell.cpp" ]
109+
include_dirs += [ "${examples_plat_dir}/shell" ]
110+
}
111+
112+
if (chip_print_memory_usage) {
113+
ldflags += [
114+
"-Wl,--print-memory-usage",
115+
"-fstack-usage",
116+
]
117+
}
118+
119+
output_dir = root_out_dir
120+
}
121+
122+
group("asr") {
123+
deps = [ ":lighting_app" ]
124+
}
125+
126+
group("default") {
127+
deps = [ ":asr" ]
128+
}

examples/lighting-app/asr/README.md

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# CHIP ASR Lighting Example
2+
3+
This example demonstrates the Matter Lighting application on ASR platform.
4+
5+
---
6+
7+
- [CHIP ASR Lighting Example](#chip-asr-lighting-example)
8+
- [Supported Chips](#supported-chips)
9+
- [Building the Example Application](#building-the-example-application)
10+
- [Commissioning](#commissioning)
11+
- [BLE mode](#ble-mode)
12+
- [IP mode](#ip-mode)
13+
- [Cluster Control](#cluster-control)
14+
15+
---
16+
17+
## Supported Chips
18+
19+
The CHIP demo application is supported on:
20+
21+
- ASR582X
22+
- ASR595X
23+
24+
## Building the Example Application
25+
26+
- [Setup CHIP Environment](../../../docs/guides/BUILDING.md)
27+
28+
- Setup toolchain for ASR582X,download gcc-arm-none-eabi-9-2019-q4-major,then
29+
export `ASR_TOOLCHAIN_PATH`:
30+
```
31+
export ASR_TOOLCHAIN_PATH={path-to-toolchain}/gcc-arm-none-eabi-9-2019-q4-major/bin/
32+
```
33+
for ASR595X,download asr_riscv_gnu_toolchain_10.2_ubuntu,then export
34+
`ASR_TOOLCHAIN_PATH`:
35+
```
36+
export ASR_TOOLCHAIN_PATH={path-to-toolchain}/asr_riscv_gnu_toolchain_10.2_ubuntu-16.04/bin/
37+
```
38+
- Setup Chip environment
39+
- for ASR582X:
40+
```
41+
export ASR_BOARD=asr582x
42+
```
43+
- for ASR595X:
44+
```
45+
export ASR_BOARD=asr595x
46+
```
47+
- Building the Application
48+
```
49+
./scripts/build/build_examples.py --target asr-$ASR_BOARD-lighting build
50+
```
51+
- The output image files are stored in the subdirectories under `out`, the
52+
subdirectory name is the same as the argument specified after the option
53+
`--target` when build the examples.
54+
55+
- After building the application, `DOGO` tool is used to flash it to the
56+
board.
57+
58+
## Commissioning
59+
60+
There are two commissioning modes supported by ASR platform:
61+
62+
### BLE mode
63+
64+
1. Build and Flash
65+
2. The example will run automatically after booting the ASR board.
66+
3. Restore factory settings using command `recovery`
67+
4. Commissioning with
68+
[Chip-Tool](https://github.com/project-chip/connectedhomeip/tree/master/examples/chip-tool)
69+
70+
### IP mode
71+
72+
1. Build and Flash
73+
2. The example will run automatically after booting the ASR board.
74+
3. Restore factory settings using command `recovery`
75+
4. Connect to AP using command `wifi_open sta [ssid] [password]`
76+
5. Commissioning with
77+
[Chip-Tool](https://github.com/project-chip/connectedhomeip/tree/master/examples/chip-tool)
78+
79+
## Cluster Control
80+
81+
After successful commissioning, use `chip-tool` to control the board
82+
83+
- OnOff Cluster
84+
```
85+
./chip-tool onoff on <NODE ID> 1
86+
./chip-tool onoff off <NODE ID> 1
87+
./chip-tool onoff toggle <NODE ID> 1
88+
```
89+
- LevelControl Cluster
90+
91+
```
92+
./chip-tool levelcontrol move-to-level 128 10 0 0 <NODE ID> 1
93+
```
94+
95+
- ColorControl Cluster
96+
```
97+
./chip-tool colorcontrol move-to-hue-and-saturation 240 100 0 0 0 <NODE ID> 1
98+
```

0 commit comments

Comments
 (0)