Skip to content

Commit

Permalink
Added MW320 to all-clusters-app. (#19302)
Browse files Browse the repository at this point in the history
* Added MW320 to all-clusters-app.

Signed-off-by: David Lin <yu-hao.lin@nxp.com>

* Added draft README for MW320 all clusters app.

Removed some unused files.

Signed-off-by: David Lin <yu-hao.lin@nxp.com>

* Update README.md

Added basic and building information.

* Updated MW320 SDK to commit 3d93e61.

Signed-off-by: David Lin <yu-hao.lin@nxp.com>

* Added image file for README.

Image used to show bring up messages of MW320.

* Update README.md

Added flashing information.

* Update README.md

* Update README.md

Added "$" for commands.

* Update README.md

* Add the private emberAfExternalAttributeReadCallback() to fix the read commission_info error in pairing

Signed-off-by: Chin-Ran Lo <chin-ran.lo@nxp.com>

* Update README.md

* Enable Matter console messages on mw320

* Add binding function to mw320

* Update README.md

* Fixed compile error.

Functin prototype is changed.

Signed-off-by: David Lin <yu-hao.lin@nxp.com>

* Fixed misspelling.

Changed default SSID too.

Signed-off-by: David Lin <yu-hao.lin@nxp.com>

* Restyled by whitespace

* Restyled by clang-format

* Restyled by gn

* Restyled by prettier-markdown

* Added platform "mw320" for MW320 SDK submodule.

Signed-off-by: David Lin <yu-hao.lin@nxp.com>

* - Enhance the parameter checking
    - Change to return the correct value in the exception condition
    - Add the comment for casting the data type

Signed-off-by: Chin-Ran Lo <chin-ran.lo@nxp.com>

* Added mw320 to ALL_PLATFORMS.

Signed-off-by: David Lin <yu-hao.lin@nxp.com>

* Fixed issue on KeyValueStoreManagerImpl::_Get.

Signed-off-by: David Lin <yu-hao.lin@nxp.com>

* Removed unused code.

Signed-off-by: David Lin <yu-hao.lin@nxp.com>

* Fixed remaining issue on KeyValueStoreManagerImpl::_Get.

Signed-off-by: David Lin <yu-hao.lin@nxp.com>

* Restyled by clang-format

* Removed unused image.

Signed-off-by: David Lin <yu-hao.lin@nxp.com>

* Fixed checking error by Lint Action.

Signed-off-by: David Lin <yu-hao.lin@nxp.com>

* Removed unused code.

Signed-off-by: David Lin <yu-hao.lin@nxp.com>

* Fixed merge error.

Signed-off-by: David Lin <yu-hao.lin@nxp.com>

Co-authored-by: Chin-Ran Lo <chin-ran.lo@nxp.com>
Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
3 people authored Jun 24, 2022
1 parent 8a4c025 commit 2d0c529
Show file tree
Hide file tree
Showing 68 changed files with 7,077 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@
url = https://github.com/bouffalolab/bl_iot_sdk_matter.git
branch = bl602_release
platforms = bl602
[submodule "third_party/nxp/mw320_sdk/repo"]
path = third_party/nxp/mw320_sdk/repo
url = https://github.com/nxptest/mw320_sdk
platforms = mw320
[submodule "third_party/nxp/libs/mbedtls/repo"]
path = third_party/nxp/libs/mbedtls/repo
url = https://github.com/NXPmicro/mbedtls.git
Expand Down
12 changes: 12 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {

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

# Set this to true to enable mw320 builds by default.
enable_mw320_builds = false
}

declare_args() {
Expand Down Expand Up @@ -291,6 +294,9 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
# Build the bl602 lighting app example.
enable_bl602_lighting_app_build = enable_bl602_builds

# Build the mw320 shell app example.
enable_mw320_shell_build = enable_mw320_builds

enable_fake_tests = enable_default_builds && host_os == "linux"

enable_tizen_lighting_app = enable_tizen_builds
Expand Down Expand Up @@ -484,6 +490,12 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
}
}

if (enable_mw320_shell_build) {
group("mw320_shell") {
deps = [ "${chip_root}/examples/shell/mw320(${chip_root}/config/mw320/toolchain:mw320_shell)" ]
}
}

group("default") {
deps = []
if (enable_host_clang_build) {
Expand Down
3 changes: 1 addition & 2 deletions build/config/BUILDCONFIG.gn
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ if (_chip_defaults.custom_toolchain != "") {
"${_build_overrides.build_root}/toolchain/tizen:tizen_${target_cpu}"
} else if (target_os == "webos") {
if (target_cpu == "arm" || target_cpu == "arm64") {
_default_toolchain =
"${_build_overrides.build_root}/toolchain/webos"
_default_toolchain = "${_build_overrides.build_root}/toolchain/webos"
} else {
assert(false,
"Unsupported target_cpu: ${current_cpu}. Shall be arm for webOS")
Expand Down
18 changes: 18 additions & 0 deletions build_overrides/mw320_sdk.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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 MW320 SDK.
mw320_sdk_build_root = "//third_party/mw320_sdk"
}
26 changes: 26 additions & 0 deletions examples/all-clusters-app/nxp/mw320/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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.

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

# CHIP uses angle bracket includes.
check_system_includes = true

default_args = {
target_cpu = "arm"
target_os = "freertos"

import("//args.gni")
}
97 changes: 97 additions & 0 deletions examples/all-clusters-app/nxp/mw320/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# 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")
import("//build_overrides/chip.gni")
import("//build_overrides/lwip.gni")
import("//build_overrides/mw320_sdk.gni")

import("${mw320_sdk_build_root}/mw320_executable.gni")
import("${mw320_sdk_build_root}/mw320_sdk.gni")

assert(current_os == "freertos")

examples_plat_dir = "${chip_root}/examples/platform/nxp/mw320"

mw320_sdk("sdk") {
include_dirs = [
"${chip_root}/src/platform/nxp/mw320",
"${examples_plat_dir}/app/project_include",
"${chip_root}/src/app/util",
"${chip_root}/examples/all-clusters-app/nxp/mw320/include",
]

sources = [
"include/CHIPProjectConfig.h",
"include/FreeRTOSConfig.h",
]

defines = []

if (is_debug) {
defines += [ "BUILD_RELEASE=0" ]
} else {
defines += [ "BUILD_RELEASE=1" ]
}
}

mw320_executable("shell_mw320") {
include_dirs = []
defines = []
output_name = "all-cluster-mw320.out"

public_deps = [
":sdk",
"${chip_root}/examples/all-clusters-app/all-clusters-common",
"${chip_root}/examples/shell/shell_common:shell_common",
"${chip_root}/src/lib",
"${chip_root}/src/lib/shell",
"${chip_root}/src/setup_payload",
]

include_dirs = [
"${chip_root}/src/platform/nxp/mw320",
"${examples_plat_dir}/app/project_include",
"${chip_root}/src/app/util",
"${chip_root}/examples/all-clusters-app/all-clusters-common/include",
"${chip_root}/examples/all-clusters-app/nxp/mw320/include",
]
sources = [
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp",
"${chip_root}/src/lib/shell/streamer_mw320.cpp",
"binding-handler.cpp",
"include/CHIPProjectConfig.h",
"include/FreeRTOSConfig.h",
"main.cpp",
]

output_dir = root_out_dir

ldscript = "${examples_plat_dir}/app/ldscripts/88MW320_xx_xxxx_flash.ld"

ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ]
defines = [
"MW320_SHELL_STREAMER",
"SHELL_STREAMER_APP_SPECIFIC",
]
}

group("mw320") {
deps = [ ":shell_mw320" ]
}

group("default") {
deps = [ ":mw320" ]
}
86 changes: 86 additions & 0 deletions examples/all-clusters-app/nxp/mw320/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Matter MW320 All Clusters Example Application

The example is based on
[Matter](https://github.com/project-chip/connectedhomeip) and the NXP MW320 SDK
to demonstrates device commissioning and cluster control over a low-power, WiFi
802.11n network.

<hr>

- [Matter MW320 All Clusters Example Application](#matter-mw320-all-clusters-example-application)
- [Introduction](#introduction)
- [Building](#building)
- [Flashing](#flashing)
- [Testing the example](#testing-the-example)

<hr>

<a name="intro"></a>

## Introduction

![MW320](../../../platform/nxp/mw320/doc/images/mw320.jpg)

The example targets the
[NXP MW320 WiFi Micro controller Soc](https://www.nxp.com/products/wireless/wi-fi-plus-bluetooth/88mw32x-802-11n-wi-fi-microcontroller-soc:88MW32X)
development kit.

<a name="building"></a>

## Building

Building the example application is quite straightforward. It can be done via
following commands:

```
$ git submodule update --init
$ source third_party/connectedhomeip/scripts/activate.sh
$ gn gen out/debug
$ ninja -v -C out/debug
```

Example application binary file "all-cluster-mw320.bin" will be generated under
directory "out/debug".

Note:

1. "git submodule update --init" only needs to be issued for the first time in
order to download MW320 SDK for Matter.
2. "source third_party/connectedhomeip/scripts/activate.sh" can be omitted if
your environment is already setup without issues.

<a name="flashdebug"></a>

## Flashing

Connect MW320 to Ubuntu USB port and open Linux text-based serial port
communications program at second USB interface (/dev/ttyUSB1):

```
$ TERM=linux minicom -D /dev/ttyUSB1 -b 115200
```

Prepare MW320 download firmware image:

```
$ ln -sf third_party/connectedhomeip/third_party/nxp/mw320_sdk/repo mw320_sdk
$ mw320_sdk/tools/mw_img_conv/bin/mw_img_conv mcufw out/debug/all-cluster-mw320.bin out/debug/all-cluster-mw320.mcufw.bin 0x1F010000
$ cp out/debug/all-cluster-mw320.mcufw.bin mw320_sdk/mw320_matter_flash/Matter/.
```

Install OpenOCD (Open On-Chip Debugger):

```
$ sudo apt-get install openocd
```

Flashing firmware image to MW320:

```
$ cd mw320_sdk/mw320_matter_flash
$ sudo python2 flashprog.py -l Matter/layout-4m.txt --boot2 Matter/boot2.bin --wififw Matter/mw32x_uapsta_W14.88.36.p172.bin --mcufw Matter/all-cluster-mw320.mcufw.bin -r
```

After MW320 is reset, console will allow you to enter commands:

![MW320_CONSOLE](../../../platform/nxp/mw320/doc/images/mw320_console.jpg)
22 changes: 22 additions & 0 deletions examples/all-clusters-app/nxp/mw320/args.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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/chip.gni")
import("${chip_root}/examples/platform/nxp/mw320/args.gni")

mw320_sdk_target = get_label_info(":sdk", "label_no_toolchain")

declare_args() {
chip_enable_ota_requestor = true
}
Loading

0 comments on commit 2d0c529

Please sign in to comment.