Skip to content

Commit 8fc1edb

Browse files
committed
[Realtek] Add build target for realtek examples
1 parent 776df66 commit 8fc1edb

File tree

7 files changed

+195
-44
lines changed

7 files changed

+195
-44
lines changed

examples/light-switch-app/realtek_bee/README.md

+16-11
Original file line numberDiff line numberDiff line change
@@ -46,34 +46,39 @@ sudo apt-get install git gcc g++ pkg-config libssl-dev libdbus-1-dev libglib2.0-
4646

4747
- Step 1: checkout Realtek specific submodules only
4848

49-
```
50-
user@ubuntu:~/Desktop/git/connectedhomeip$ scripts/checkout_submodules.py --shallow --platform realtek_bee --recursive
49+
```bash
50+
$ scripts/checkout_submodules.py --shallow --platform realtek_bee --recursive
5151
```
5252

5353
- Step 1: Init REALTEK SDK
5454

55-
```
56-
cd ./third_party/openthread/ot-realtek
57-
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/openthread/ot-realtek$ git submodule update --init --recursive
55+
```bash
56+
$ git submodule update --init --recursive third_party/openthread/ot-realtek
5857
```
5958

6059
- Step 3: activate local environment
6160

62-
```
63-
user@ubuntu:~/Desktop/git/connectedhomeip$ source scripts/activate.sh
61+
```bash
62+
$ source ./scripts/activate.sh
6463
```
6564

6665
If the script says the environment is out of date, you can update it by
6766
running the following command:
6867

69-
```
70-
user@ubuntu:~/Desktop/git/connectedhomeip$ source scripts/bootstrap.sh
68+
```bash
69+
$ source ./scripts/bootstrap.sh
7170
```
7271

7372
## Building
7473

75-
user@ubuntu:~/Desktop/git/connectedhomeip$ cd ./third_party/openthread/ot-realtek
76-
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/openthread/ot-realtek$ OT_CMAKE_NINJA_TARGET="matter-cli-mtd" ./Realtek/build bee4 sdk rtl8777g light-switch-app
74+
- To build the demo application:
75+
76+
```bash
77+
$ ./scripts/build/build_examples.py --target realtek-rtl8777g-light-switch build
78+
```
79+
80+
You can find the target built file called **_matter-cli-mtd_bank0_MP_dev_*.bin_** under the
81+
`out/realtek-rtl8777g-light-switch/bin` directory.
7782

7883
## More information
7984

examples/lighting-app/realtek_bee/README.md

+17-11
Original file line numberDiff line numberDiff line change
@@ -46,34 +46,40 @@ sudo apt-get install git gcc g++ pkg-config libssl-dev libdbus-1-dev libglib2.0-
4646

4747
- Step 1: checkout Realtek specific submodules only
4848

49-
```
50-
user@ubuntu:~/Desktop/git/connectedhomeip$ scripts/checkout_submodules.py --shallow --platform realtek_bee --recursive
49+
```bash
50+
$ scripts/checkout_submodules.py --shallow --platform realtek_bee --recursive
5151
```
5252

5353
- Step 1: Init REALTEK SDK
5454

55-
```
56-
cd ./third_party/openthread/ot-realtek
57-
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/openthread/ot-realtek$ git submodule update --init --recursive
55+
```bash
56+
$ git submodule update --init --recursive third_party/openthread/ot-realtek
5857
```
5958

6059
- Step 3: activate local environment
6160

62-
```
63-
user@ubuntu:~/Desktop/git/connectedhomeip$ source scripts/activate.sh
61+
```bash
62+
$ source ./scripts/activate.sh
6463
```
6564

6665
If the script says the environment is out of date, you can update it by
6766
running the following command:
6867

69-
```
70-
user@ubuntu:~/Desktop/git/connectedhomeip$ source scripts/bootstrap.sh
68+
```bash
69+
$ source ./scripts/bootstrap.sh
7170
```
7271

7372
## Building
7473

75-
user@ubuntu:~/Desktop/git/connectedhomeip$ cd ./third_party/openthread/ot-realtek
76-
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/openthread/ot-realtek$ OT_CMAKE_NINJA_TARGET="matter-cli-ftd" ./Realtek/build bee4 sdk rtl8777g lighting-app
74+
- To build the demo application:
75+
76+
```bash
77+
$ ./scripts/build/build_examples.py --target realtek-rtl8777g-light build
78+
```
79+
80+
You can find the target built file called
81+
**_matter-cli-ftd_bank0_MP_dev_\*.bin\_** under the
82+
`out/realtek-rtl8777g-light/bin` directory.
7783

7884
## More information
7985

examples/lock-app/realtek_bee/README.md

+17-11
Original file line numberDiff line numberDiff line change
@@ -46,34 +46,40 @@ sudo apt-get install git gcc g++ pkg-config libssl-dev libdbus-1-dev libglib2.0-
4646

4747
- Step 1: checkout Realtek specific submodules only
4848

49-
```
50-
user@ubuntu:~/Desktop/git/connectedhomeip$ scripts/checkout_submodules.py --shallow --platform realtek_bee --recursive
49+
```bash
50+
$ scripts/checkout_submodules.py --shallow --platform realtek_bee --recursive
5151
```
5252

5353
- Step 1: Init REALTEK SDK
5454

55-
```
56-
cd ./third_party/openthread/ot-realtek
57-
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/openthread/ot-realtek$ git submodule update --init --recursive
55+
```bash
56+
$ git submodule update --init --recursive third_party/openthread/ot-realtek
5857
```
5958

6059
- Step 3: activate local environment
6160

62-
```
63-
user@ubuntu:~/Desktop/git/connectedhomeip$ source scripts/activate.sh
61+
```bash
62+
$ source ./scripts/activate.sh
6463
```
6564

6665
If the script says the environment is out of date, you can update it by
6766
running the following command:
6867

69-
```
70-
user@ubuntu:~/Desktop/git/connectedhomeip$ source scripts/bootstrap.sh
68+
```bash
69+
$ source ./scripts/bootstrap.sh
7170
```
7271

7372
## Building
7473

75-
user@ubuntu:~/Desktop/git/connectedhomeip$cd ./third_party/openthread/ot-realtek
76-
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/openthread/ot-realtek$OT_CMAKE_NINJA_TARGET="matter-cli-mtd" ./Realtek/build bee4 sdk rtl8777g lock-app
74+
- To build the demo application:
75+
76+
```bash
77+
$ ./scripts/build/build_examples.py --target realtek-rtl8777g-lock build
78+
```
79+
80+
You can find the target built file called
81+
**_matter-cli-ftd_bank0_MP_dev_\*.bin\_** under the
82+
`out/realtek-rtl8777g-lock/bin` directory.
7783

7884
## More information
7985

examples/window-app/realtek_bee/README.md

+17-11
Original file line numberDiff line numberDiff line change
@@ -46,34 +46,40 @@ sudo apt-get install git gcc g++ pkg-config libssl-dev libdbus-1-dev libglib2.0-
4646

4747
- Step 1: checkout Realtek specific submodules only
4848

49-
```
50-
user@ubuntu:~/Desktop/git/connectedhomeip$ scripts/checkout_submodules.py --shallow --platform realtek_bee --recursive
49+
```bash
50+
$ scripts/checkout_submodules.py --shallow --platform realtek_bee --recursive
5151
```
5252

5353
- Step 1: Init REALTEK SDK
5454

55-
```
56-
cd ./third_party/openthread/ot-realtek
57-
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/openthread/ot-realtek$ git submodule update --init --recursive
55+
```bash
56+
$ git submodule update --init --recursive third_party/openthread/ot-realtek
5857
```
5958

6059
- Step 3: activate local environment
6160

62-
```
63-
user@ubuntu:~/Desktop/git/connectedhomeip$ source scripts/activate.sh
61+
```bash
62+
$ source ./scripts/activate.sh
6463
```
6564

6665
If the script says the environment is out of date, you can update it by
6766
running the following command:
6867

69-
```
70-
user@ubuntu:~/Desktop/git/connectedhomeip$ source scripts/bootstrap.sh
68+
```bash
69+
$ source ./scripts/bootstrap.sh
7170
```
7271

7372
## Building
7473

75-
user@ubuntu:~/Desktop/git/connectedhomeip$cd ./third_party/openthread/ot-realtek
76-
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/openthread/ot-realtek$OT_CMAKE_NINJA_TARGET="matter-cli-mtd" ./Realtek/build bee4 sdk rtl8777g window-app
74+
- To build the demo application:
75+
76+
```bash
77+
$ ./scripts/build/build_examples.py --target realtek-rtl8777g-window build
78+
```
79+
80+
You can find the target built file called
81+
**_matter-cli-mtd_bank0_MP_dev_\*.bin\_** under the
82+
`out/realtek-rtl8777g-window/bin` directory.
7783

7884
## More information
7985

scripts/build/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pw_python_package("build_examples") {
5858
"builders/nxp.py",
5959
"builders/openiotsdk.py",
6060
"builders/qpg.py",
61+
"builders/realtek.py",
6162
"builders/telink.py",
6263
"builders/tizen.py",
6364
"runner/__init__.py",

scripts/build/build/targets.py

+21
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from builders.nxp import NxpApp, NxpBoard, NxpBoardVariant, NxpBuilder, NxpBuildSystem, NxpLogLevel, NxpOsUsed
3232
from builders.openiotsdk import OpenIotSdkApp, OpenIotSdkBuilder, OpenIotSdkCryptoBackend
3333
from builders.qpg import QpgApp, QpgBoard, QpgBuilder
34+
from builders.realtek import RealtekApp, RealtekBoard, RealtekBuilder
3435
from builders.stm32 import stm32App, stm32Board, stm32Builder
3536
from builders.telink import TelinkApp, TelinkBoard, TelinkBuilder
3637
from builders.ti import TIApp, TIBoard, TIBuilder
@@ -815,6 +816,25 @@ def BuildTelinkTarget():
815816
return target
816817

817818

819+
def BuildRealtekTarget():
820+
target = BuildTarget('realtek', RealtekBuilder)
821+
822+
# board
823+
target.AppendFixedTargets([
824+
TargetPart('rtl8777g', board=RealtekBoard.RTL8777G),
825+
])
826+
827+
# apps
828+
target.AppendFixedTargets([
829+
TargetPart('light', app=RealtekApp.LIGHT),
830+
TargetPart('light-switch', app=RealtekApp.LIGHT_SWITCH),
831+
TargetPart('lock', app=RealtekApp.LOCK),
832+
TargetPart('window', app=RealtekApp.WINDOW),
833+
])
834+
835+
return target
836+
837+
818838
def BuildOpenIotSdkTargets():
819839
target = BuildTarget('openiotsdk', OpenIotSdkBuilder)
820840

@@ -853,6 +873,7 @@ def BuildOpenIotSdkTargets():
853873
BuildNrfNativeTarget(),
854874
BuildNuttXTarget(),
855875
BuildQorvoTarget(),
876+
BuildRealtekTarget(),
856877
BuildStm32Target(),
857878
BuildTizenTarget(),
858879
BuildTelinkTarget(),

scripts/build/builders/realtek.py

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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 logging
16+
import os
17+
from enum import Enum, auto
18+
19+
from .builder import Builder, BuilderOutput
20+
21+
22+
class RealtekBoard(Enum):
23+
RTL8777G = auto()
24+
25+
@property
26+
def BoardName(self):
27+
return 'rtl8777g'
28+
29+
30+
class RealtekApp(Enum):
31+
LIGHT = auto()
32+
LIGHT_SWITCH = auto()
33+
LOCK = auto()
34+
WINDOW = auto()
35+
36+
@property
37+
def ExampleName(self):
38+
if self == RealtekApp.LIGHT:
39+
return 'lighting-app'
40+
elif self == RealtekApp.LIGHT_SWITCH:
41+
return 'light-switch-app'
42+
elif self == RealtekApp.LOCK:
43+
return 'lock-app'
44+
elif self == RealtekApp.WINDOW:
45+
return 'window-app'
46+
else:
47+
raise Exception('Unknown app type: %r' % self)
48+
49+
@property
50+
def TargetName(self):
51+
if self == RealtekApp.LIGHT:
52+
return 'matter-cli-ftd'
53+
elif self == RealtekApp.LIGHT_SWITCH:
54+
return 'matter-cli-mtd'
55+
elif self == RealtekApp.LOCK:
56+
return 'matter-cli-ftd'
57+
elif self == RealtekApp.WINDOW:
58+
return 'matter-cli-mtd'
59+
else:
60+
raise Exception('Unknown app type: %r' % self)
61+
62+
@property
63+
def AppNamePrefix(self):
64+
if self == RealtekApp.LIGHT:
65+
return 'chip-rtl8777g-lighting-app'
66+
elif self == RealtekApp.LIGHT_SWITCH:
67+
return 'chip-rtl8777g-light-switch-app'
68+
elif self == RealtekApp.LOCK:
69+
return 'chip-rtl8777g-lock-app'
70+
elif self == RealtekApp.WINDOW:
71+
return 'chip-rtl8777g-window-app'
72+
else:
73+
raise Exception('Unknown app type: %r' % self)
74+
75+
76+
class RealtekBuilder(Builder):
77+
78+
def __init__(self,
79+
root,
80+
runner,
81+
board: RealtekBoard = RealtekBoard.RTL8777G,
82+
app: RealtekApp = RealtekApp.LIGHT):
83+
super(RealtekBuilder, self).__init__(root, runner)
84+
self.board = board
85+
self.app = app
86+
87+
def generate(self):
88+
logging.info('generate %s', self.output_dir)
89+
90+
def _build(self):
91+
cmd = 'third_party/openthread/ot-realtek/Realtek/build.sh {out_folder} {board} {app} {target} '.format(
92+
out_folder=self.output_dir.strip(),
93+
board=self.board.BoardName,
94+
app=self.app.ExampleName,
95+
target=self.app.TargetName
96+
)
97+
98+
# <build root> <build_system> <output_directory> <application>
99+
cmd += ' '.join([self.root, 'ninja', self.output_dir,
100+
self.app.ExampleName])
101+
102+
self._Execute(['bash', '-c', cmd],
103+
title='Generating ' + self.identifier)
104+
105+
def build_outputs(self):
106+
logging.info('build_outputs %s', self.output_dir)

0 commit comments

Comments
 (0)