Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BL602 pull request #16370

Merged
merged 18 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1451,3 +1451,4 @@ localedef
nameserver
nmcli
tsan
bouffalolab
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,7 @@
[submodule "third_party/efr32_sdk/wiseconnect-wifi-bt-sdk"]
path = third_party/efr32_sdk/wiseconnect-wifi-bt-sdk
url = https://github.com/SiliconLabs/wiseconnect-wifi-bt-sdk
[submodule "third_party/bouffalolab/bl602"]
path = third_party/bouffalolab/bl602_sdk/repo
url = https://github.com/bouffalolab/bl_iot_sdk_matter.git
branch = bl602_release
6 changes: 6 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {

# Set this to true to enable k32w builds by default.
enable_k32w_builds = false

# Set this to true to enable bl602 builds by default.
enable_bl602_builds = false
}

declare_args() {
Expand Down Expand Up @@ -274,6 +277,9 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
# Build the k32w shell app example.
enable_k32w_shell_app_build = enable_k32w_builds

# Build the bl602 lighting app example.
enable_bl602_lighting_app_build = enable_bl602_builds

enable_fake_tests = enable_default_builds && host_os == "linux"
}

Expand Down
2 changes: 2 additions & 0 deletions build/config/BUILDCONFIG.gn
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ if (_chip_defaults.custom_toolchain != "") {
} else if (target_os == "freertos") {
if (target_cpu == "arm") {
_default_toolchain = "${_build_overrides.build_root}/toolchain/arm_gcc"
} else if (target_cpu == "riscv") {
_default_toolchain = "${_build_overrides.build_root}/toolchain/riscv_gcc"
} else {
assert(false, "Unsupported target_cpu: ${target_cpu}")
}
Expand Down
22 changes: 22 additions & 0 deletions build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ if (current_cpu == "arm" || current_cpu == "arm64") {
import("${build_root}/config/arm.gni")
} else if (current_cpu == "x86" || current_cpu == "x86_64") {
import("${build_root}/config/x86.gni")
} else if (current_cpu == "riscv") {
import("${build_root}/config/riscv.gni")
}

config("release") {
Expand Down Expand Up @@ -122,6 +124,26 @@ config("abi_default") {
]
}
}
if (current_cpu == "riscv") {
if (riscv_arch != "") {
cflags += [ "-march=${riscv_arch}" ]
}
if (riscv_cpu != "") {
cflags += [ "-mcpu=${riscv_cpu}" ]
}
if (riscv_tune != "") {
cflags += [ "-mtune=${riscv_tune}" ]
}
if (riscv_abi != "") {
cflags += [ "-mabi=${riscv_abi}" ]
}
if (riscv_fpu != "") {
cflags += [ "-mfpu=${riscv_fpu}" ]
}
if (riscv_float_abi != "") {
cflags += [ "-mfloat-abi=${riscv_float_abi}" ]
}
}
}

asmflags = cflags
Expand Down
64 changes: 64 additions & 0 deletions build/config/riscv.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 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")

if (current_cpu == "riscv") {
declare_args() {
# Build file to import for RISCV defaults.
riscv_platform_config = ""
}

# Allow platforms to override how RISCV architecture flags are chosen by
# providing a file to import.
if (riscv_platform_config != "") {
_platform_defaults = {
import(riscv_platform_config)
}
}

_defaults = {
riscv_arch = ""
riscv_cpu = ""
riscv_tune = ""
riscv_fpu = ""
riscv_float_abi = ""
riscv_abi = ""

# Update defaults with platform values, if any.
if (riscv_platform_config != "") {
forward_variables_from(_platform_defaults, "*")
}
}

declare_args() {
# RISCV architecture (value for -march flag).
riscv_arch = _defaults.riscv_arch

# RISCV CPU (value for -mcpu flag).
riscv_cpu = _defaults.riscv_cpu

# RISCV tuning (value for -mtune flag).
riscv_tune = _defaults.riscv_tune

# RISCV FPU (value for -mfpu flag).
riscv_fpu = _defaults.riscv_fpu

# RISCV float ABI (value for -mfloat-abi flag).
riscv_float_abi = _defaults.riscv_float_abi

# RISCV ABI (value for -mabi flag).
riscv_abi = _defaults.riscv_abi
}
}
21 changes: 21 additions & 0 deletions build/toolchain/riscv_gcc/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2021 The Pigweed Authors
# 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("riscv_toolchain.gni")

riscv_toolchain("riscv_gcc") {
toolchain_args = {
}
}
35 changes: 35 additions & 0 deletions build/toolchain/riscv_gcc/riscv_toolchain.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/bl602_sdk.gni")
import("//build_overrides/build.gni")

import("${build_root}/toolchain/gcc_toolchain.gni")

template("riscv_toolchain") {
gcc_toolchain(target_name) {
_tool_name_root = "${root_build_dir}/../../third_party/bouffalolab/bl602_sdk/repo/toolchain/riscv/Linux/bin/riscv64-unknown-elf-"
ar = _tool_name_root + "ar"
cc = _tool_name_root + "gcc"
cxx = _tool_name_root + "g++"

toolchain_args = {
current_cpu = "riscv"
current_os = invoker.current_os
is_clang = false

forward_variables_from(invoker.toolchain_args, "*")
}
}
}
18 changes: 18 additions & 0 deletions build_overrides/bl602_sdk.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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() {
# Root directory for bl602 SDK build files.
bl602_sdk_build_root = "//third_party/bouffalolab/bl602_sdk"
}
36 changes: 36 additions & 0 deletions config/bouffalolab/bl602/lib/pw_rpc/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 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("//build_overrides/pigweed.gni")
import("$dir_pw_build/target_types.gni")

static_library("pw_rpc") {
output_name = "libPwRpc"

public_configs = [ "${dir_pigweed}/pw_hdlc:default_config" ]

public_deps = [
"$dir_pw_rpc:server",
"$dir_pw_rpc/nanopb:echo_service",
"${chip_root}/examples/platform/bl602/pw_sys_io:pw_sys_io_bl602",
"${dir_pigweed}/pw_hdlc:pw_rpc",
dir_pw_assert,
dir_pw_checksum,
dir_pw_hdlc,
dir_pw_log,
]

output_dir = "${root_out_dir}/lib"
}
28 changes: 28 additions & 0 deletions config/bouffalolab/bl602/lib/pw_rpc/pw_rpc.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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("//build_overrides/pigweed.gni")

pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "$dir_pw_assert_log"
pw_sys_io_BACKEND =
"${chip_root}/examples/platform/bl602/pw_sys_io:pw_sys_io_bl602"

pw_build_LINK_DEPS = [
"$dir_pw_assert:impl",
"$dir_pw_log:impl",
]

dir_pw_third_party_nanopb = "${chip_root}/third_party/nanopb/repo"
39 changes: 39 additions & 0 deletions config/bouffalolab/bl602/toolchain/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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_root}/toolchain/riscv_gcc/riscv_toolchain.gni")

riscv_toolchain("bl602_lock_app") {
toolchain_args = {
current_os = "freertos"
import("${chip_root}/examples/lock-app/bl602/args.gni")
}
}

riscv_toolchain("bl602_lighting_app") {
toolchain_args = {
current_os = "freertos"
import("${chip_root}/examples/lighting-app/bl602/args.gni")
}
}

riscv_toolchain("bl602_window_app") {
toolchain_args = {
current_os = "freertos"
import("${chip_root}/examples/window-app/bl602/args.gni")
}
}
19 changes: 19 additions & 0 deletions examples/build_overrides/bl602_sdk.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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.

declare_args() {
# Root directory for bl602 SDK.
bl602_sdk_build_root =
"//third_party/connectedhomeip/third_party/bouffalolab/bl602_sdk"
}
28 changes: 28 additions & 0 deletions examples/lighting-app/bouffalolab/bl602/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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")

# 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"

import("//args.gni")
}
Loading