Skip to content

Commit

Permalink
[ASR] add ASR582X & ASR595X support
Browse files Browse the repository at this point in the history
  • Loading branch information
asriot committed May 4, 2023
1 parent f1096a5 commit a91d456
Show file tree
Hide file tree
Showing 93 changed files with 10,514 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,11 @@
path = third_party/imgui/repo
url = https://github.com/ocornut/imgui
platforms = linux
[submodule "third_party/asr/asr582x/asr_sdk"]
path = third_party/asr/asr582x/asr_sdk
url = https://github.com/asriot/ASR582X_Freertos.git
branch = matter
[submodule "third_party/asr/asr595x/asr_sdk"]
path = third_party/asr/asr595x/asr_sdk
url = https://github.com/asriot/ASR595X_Freertos.git
branch = matter
42 changes: 42 additions & 0 deletions build_overrides/asr.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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.

declare_args() {
# ASR IC family.
asr_ic_family = ""
# Root directory for ASR SDK build files.
asr_sdk_build_root = ""
# Root directory for ASR toolchain.
asr_toolchain_root = ""
}

if (asr_ic_family == "") {
asr_ic_family = getenv("ASR_IC")
}

assert(asr_ic_family != "", "ASR_IC must be specified")

if (asr_ic_family == "asr582x") {
asr_sdk_build_root = "//third_party/connectedhomeip/third_party/asr/asr582x"
}

if (asr_ic_family == "asr595x") {
asr_sdk_build_root = "//third_party/connectedhomeip/third_party/asr/asr595x"
}

if (asr_toolchain_root == "") {
asr_toolchain_root = getenv("ASR_TOOLCHAIN_PATH")
}

assert(asr_toolchain_root != "", "ASR_TOOLCHAIN_PATH must be specified")
34 changes: 34 additions & 0 deletions config/asr/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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/asr.gni")
import("//build_overrides/build.gni")
import("//build_overrides/chip.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 = {
if (asr_ic_family == "asr595x") {
target_cpu = "riscv"
}
if (asr_ic_family == "asr582x") {
target_cpu = "arm"
}
target_os = "freertos"

import("//args.gni")
}
35 changes: 35 additions & 0 deletions config/asr/args.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 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/chip.gni")
import("//examples/platform/asr/args.gni")
asr_sdk_target = get_label_info(":sdk", "label_no_toolchain")

chip_device_platform = "asr"

is_debug = false
chip_enable_openthread = false
chip_enable_nfc = false
chip_build_tests = false
chip_monolithic_tests = false

chip_project_config_include_dirs =
[ "//examples/platform/asr/project_include/" ]
chip_project_config_include = "<CHIPProjectConfig.h>"
chip_system_project_config_include = "<CHIPProjectConfig.h>"
chip_ble_project_config_include = ""

custom_toolchain = "//config/asr/toolchain:asrtoolchain"

pw_build_PIP_CONSTRAINTS = [ "//scripts/constraints.txt" ]
44 changes: 44 additions & 0 deletions config/asr/toolchain/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 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/asr.gni")
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")

if (asr_ic_family == "asr582x") {
import("${build_root}/toolchain/arm_gcc/arm_toolchain.gni")
_tool_name_root = "${asr_toolchain_root}arm-none-eabi-"
}

if (asr_ic_family == "asr595x") {
import("${build_root}/toolchain/riscv_gcc/riscv_toolchain.gni")
_tool_name_root = "${asr_toolchain_root}riscv-asr-elf-"
}

declare_args() {
asr_ar = _tool_name_root + "ar"
asr_cc = _tool_name_root + "gcc"
asr_cxx = _tool_name_root + "g++"
}

gcc_toolchain("asrtoolchain") {
ar = asr_ar
cc = asr_cc
cxx = asr_cxx

toolchain_args = {
current_os = "freertos"
is_clang = false
}
}
43 changes: 43 additions & 0 deletions examples/build_overrides/asr.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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.

declare_args() {
# ASR IC family.
asr_ic_family = ""
# Root directory for ASR SDK build files.
asr_sdk_build_root = ""
# Root directory for ASR toolchain.
asr_toolchain_root = ""
}

if (asr_ic_family == "") {
asr_ic_family = getenv("ASR_IC")
}

assert(asr_ic_family != "", "ASR_IC must be specified")

if (asr_ic_family == "asr582x") {
asr_sdk_build_root = "//third_party/connectedhomeip/third_party/asr/asr582x"
}

if (asr_ic_family == "asr595x") {
asr_sdk_build_root = "//third_party/connectedhomeip/third_party/asr/asr595x"
}

if (asr_toolchain_root == "") {
asr_toolchain_root = getenv("ASR_TOOLCHAIN_PATH")
}

assert(asr_toolchain_root != "", "ASR_TOOLCHAIN_PATH must be specified")

34 changes: 34 additions & 0 deletions examples/lighting-app/asr/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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/build.gni")
import("//build_overrides/asr.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 = {
if (asr_ic_family == "asr582x") {
target_cpu = "arm"
}
if (asr_ic_family == "asr595x") {
target_cpu = "riscv"
}
target_os = "freertos"

import("//args.gni")
}
131 changes: 131 additions & 0 deletions examples/lighting-app/asr/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# 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/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/asr.gni")
import("${chip_root}/src/lib/lib.gni")
import("${build_root}/config/defaults.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/third_party/asr/asr_executable.gni")
import("${asr_sdk_build_root}/asr_sdk.gni")

import("cfg.gni")

assert(current_os == "freertos")

asr_project_dir = "${chip_root}/examples/lighting-app/asr"
examples_plat_dir = "${chip_root}/examples/platform/asr"

declare_args() {
# Dump memory usage at link time.
chip_print_memory_usage = false
}

asr_sdk_sources("lighting_app_sdk_sources") {
include_dirs = [
"${chip_root}/src/platform/ASR",
"${asr_project_dir}/include",
"${examples_plat_dir}",
]

defines = [
"BOARD_ID=${asr_board}",
"ASR_LOG_ENABLED=1",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
]

if (chip_use_factory) {
defines += [
"CONFIG_ENABLE_ASR_FACTORY_DATA_PROVIDER=1",
# "CONFIG_ENABLE_ASR_FACTORY_DEVICE_INFO_PROVIDER=1",
]
}

if (chip_lwip_ip6_hook) {
defines += [
"CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT",
"CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT"
]
}

sources = [ "${asr_project_dir}/include/CHIPProjectConfig.h" ]

public_configs = [ "${chip_root}/third_party/asr/${asr_ic_family}:asr_sdk_config" ]
}

asr_executable("lighting_app") {
include_dirs = []
defines = []
output_name = "chip-asr-lighting-example.out"

sources = [
"${examples_plat_dir}/LEDWidget.cpp",
"${examples_plat_dir}/ASRUtils.cpp",
"${examples_plat_dir}/init_asrPlatform.cpp",
"${examples_plat_dir}/init_Matter.cpp",
"${examples_plat_dir}/CHIPDeviceManager.cpp",
"src/AppTask.cpp",
"src/DeviceCallbacks.cpp",
"src/main.cpp",
]

if (chip_enable_ota_requestor) {
sources += [ "${examples_plat_dir}/init_OTARequestor.cpp" ]
}

deps = [
":lighting_app_sdk_sources",
"${chip_root}/examples/common/QRCode",
"${chip_root}/examples/lighting-app/lighting-common",
"${chip_root}/examples/providers:device_info_provider",
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload"
]

include_dirs += [
"include",
"${examples_plat_dir}",
"${asr_project_dir}/include",
"${chip_root}/src/lib",
]

defines = [
"ASR_NETWORK_LAYER_BLE=${chip_config_network_layer_ble}"
]

if (chip_build_libshell) {
defines += [ "CONFIG_ENABLE_CHIP_SHELL=1" ]
sources += [ "${examples_plat_dir}/shell/launch_shell.cpp" ]
include_dirs += [ "${examples_plat_dir}/shell" ]
}

if (chip_print_memory_usage) {
ldflags += [
"-Wl,--print-memory-usage",
"-fstack-usage",
]
}

output_dir = root_out_dir
}

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

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

0 comments on commit a91d456

Please sign in to comment.