Skip to content

Commit 91a1a5c

Browse files
authored
Add k32w support into build_examples and use it for CI (project-chip#13062)
* Start adding k32w support for build_examples * Fix typo * Make sure vscode user can actually run the nxp patch sdk script * Ensure all targets exported work, fix names for outputs * Switch k32w CI builds to use example_builds * Support release builds as well * Fix build args duplication * Update targets and builds and unit tests. The build logic is a bit off though * Update unit test and run logic * update cloudbuild to use 0.5.40 build images as well * Restyle files * Fix typo in size info naming * Fix yaml indent typo * One more typo fix * Update to only build release on k32w - it turns out debug does not compile * Restyle files * Increase timeout for k32w example builds
1 parent b928fe4 commit 91a1a5c

File tree

10 files changed

+185
-59
lines changed

10 files changed

+185
-59
lines changed

.devcontainer/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,6 @@ RUN chown -R $USERNAME:$USERNAME /opt/android/sdk
6969

7070
# AmebaD requires access to change build_info.h
7171
RUN chown -R $USERNAME:$USERNAME /opt/ameba/ambd_sdk_with_chip_non_NDA/
72+
73+
# NXP uses a patch_sdk script to change SDK files
74+
RUN chown -R $USERNAME:$USERNAME /opt/sdk/sdks/

.github/workflows/examples-k32w.yaml

+16-19
Original file line numberDiff line numberDiff line change
@@ -60,34 +60,31 @@ jobs:
6060
path: |
6161
.environment/gn_out/.ninja_log
6262
.environment/pigweed-venv/*.log
63-
- name: Build example K32W Lock App
64-
timeout-minutes: 5
63+
- name: Build examples
64+
timeout-minutes: 30
6565
run: |
66-
scripts/examples/k32w_example.sh \
67-
examples/lock-app/nxp/k32w/k32w0 out/lock_app_debug
68-
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
69-
k32w k32w061+debug lock-app \
70-
out/lock_app_debug/chip-k32w061-lock-example \
71-
/tmp/bloat_reports/
72-
- name: Build example K32W Shell App
66+
scripts/run_in_build_env.sh "\
67+
./scripts/build/build_examples.py \
68+
--target k32w-light-release \
69+
--target k32w-lock-low-power-release \
70+
--target k32w-shell-release \
71+
build \
72+
--copy-artifacts-to out/artifacts \
73+
"
74+
- name: Get light size stats
7375
timeout-minutes: 5
7476
run: |
75-
scripts/examples/k32w_example.sh \
76-
examples/shell/nxp/k32w/k32w0 out/shell_app_debug no_low_power
7777
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
78-
k32w k32w061+debug shell \
79-
out/shell_app_debug/chip-k32w061-shell-example \
78+
k32w k32w061+release light \
79+
out/artifacts/k32w-light-release/chip-k32w061-light-example \
8080
/tmp/bloat_reports/
81-
- name: Build example K32W Lighting App with Secure Element
81+
- name: Get lock size stats
8282
timeout-minutes: 5
8383
run: |
84-
scripts/examples/k32w_se_example.sh \
85-
examples/lighting-app/nxp/k32w/k32w0 out/lighting_app_se_release
8684
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
87-
k32w k32w061+se05x+release lighting-app \
88-
out/lighting_app_se_release/chip-k32w061-light-example \
85+
k32w k32w061+release lock \
86+
out/artifacts/k32w-lock-low-power-release/chip-k32w061-lock-example \
8987
/tmp/bloat_reports/
90-
9188
- name: Uploading Size Reports
9289
uses: actions/upload-artifact@v2
9390
if: ${{ !env.ACT }}

scripts/build/BUILD.gn

+3
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@ pw_python_package("build_examples") {
3333
"build_examples.py",
3434
"builders/__init__.py",
3535
"builders/ameba.py",
36+
"builders/android.py",
3637
"builders/builder.py",
3738
"builders/efr32.py",
3839
"builders/esp32.py",
3940
"builders/gn.py",
4041
"builders/host.py",
4142
"builders/infineon.py",
43+
"builders/k32w.py",
44+
"builders/mbed.py",
4245
"builders/nrf.py",
4346
"builders/qpg.py",
4447
"builders/telink.py",

scripts/build/build/targets.py

+21-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@
1717
from typing import Any, List
1818
from itertools import combinations
1919

20+
from builders.ameba import AmebaApp, AmebaBoard, AmebaBuilder
2021
from builders.android import AndroidBoard, AndroidApp, AndroidBuilder
2122
from builders.efr32 import Efr32Builder, Efr32App, Efr32Board
2223
from builders.esp32 import Esp32Builder, Esp32Board, Esp32App
2324
from builders.host import HostBuilder, HostApp, HostBoard
25+
from builders.infineon import InfineonBuilder, InfineonApp, InfineonBoard
26+
from builders.k32w import K32WApp, K32WBuilder
27+
from builders.mbed import MbedApp, MbedBoard, MbedProfile, MbedBuilder
2428
from builders.nrf import NrfApp, NrfBoard, NrfConnectBuilder
2529
from builders.qpg import QpgBuilder
26-
from builders.infineon import InfineonBuilder, InfineonApp, InfineonBoard
2730
from builders.telink import TelinkApp, TelinkBoard, TelinkBuilder
2831
from builders.tizen import TizenApp, TizenBoard, TizenBuilder
29-
from builders.ameba import AmebaApp, AmebaBoard, AmebaBuilder
30-
from builders.mbed import MbedApp, MbedBoard, MbedProfile, MbedBuilder
3132

3233

3334
class Target:
@@ -335,6 +336,21 @@ def AmebaTargets():
335336
yield ameba_target.Extend('amebad-light', board=AmebaBoard.AMEBAD, app=AmebaApp.LIGHT)
336337

337338

339+
def K32WTargets():
340+
target = Target('k32w', K32WBuilder)
341+
342+
# This is for testing only in case debug builds are to be fixed
343+
# Error is LWIP_DEBUG being redefined between 0 and 1 in debug builds in:
344+
# third_party/connectedhomeip/src/lwip/k32w0/lwipopts.h
345+
# gen/include/lwip/lwip_buildconfig.h
346+
yield target.Extend('light', app=K32WApp.LIGHT).GlobBlacklist("Debug builds broken due to LWIP_DEBUG redefition")
347+
348+
yield target.Extend('light-release', app=K32WApp.LIGHT, release=True)
349+
yield target.Extend('shell-release', app=K32WApp.SHELL, release=True)
350+
yield target.Extend('lock-release', app=K32WApp.LOCK, release=True)
351+
yield target.Extend('lock-low-power-release', app=K32WApp.LOCK, low_power=True, release=True).GlobBlacklist("Only on demand build")
352+
353+
338354
ALL = []
339355

340356
target_generators = [
@@ -345,7 +361,8 @@ def AmebaTargets():
345361
AndroidTargets(),
346362
MbedTargets(),
347363
InfineonTargets(),
348-
AmebaTargets()
364+
AmebaTargets(),
365+
K32WTargets(),
349366
]
350367

351368
for generator in target_generators:

scripts/build/builders/k32w.py

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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 os
16+
from enum import Enum, auto
17+
18+
from .gn import GnBuilder
19+
20+
21+
class K32WApp(Enum):
22+
LIGHT = auto()
23+
LOCK = auto()
24+
SHELL = auto()
25+
26+
def ExampleName(self):
27+
if self == K32WApp.LIGHT:
28+
return 'lighting-app'
29+
elif self == K32WApp.LOCK:
30+
return 'lock-app'
31+
elif self == K32WApp.SHELL:
32+
return 'shell'
33+
else:
34+
raise Exception('Unknown app type: %r' % self)
35+
36+
def AppNamePrefix(self):
37+
if self == K32WApp.LIGHT:
38+
return 'chip-k32w061-light-example'
39+
elif self == K32WApp.LOCK:
40+
return 'chip-k32w061-lock-example'
41+
elif self == K32WApp.SHELL:
42+
return 'chip-k32w061-shell-example'
43+
else:
44+
raise Exception('Unknown app type: %r' % self)
45+
46+
def BuildRoot(self, root):
47+
return os.path.join(root, 'examples', self.ExampleName(), 'nxp', 'k32w', 'k32w0')
48+
49+
50+
class K32WBuilder(GnBuilder):
51+
52+
def __init__(self,
53+
root,
54+
runner,
55+
app: K32WApp = K32WApp.LIGHT,
56+
release: bool = False,
57+
low_power: bool = False):
58+
super(K32WBuilder, self).__init__(
59+
root=app.BuildRoot(root),
60+
runner=runner)
61+
self.code_root = root
62+
self.app = app
63+
self.low_power = low_power
64+
self.release = release
65+
66+
def GnBuildArgs(self):
67+
args = [
68+
'k32w0_sdk_root="%s"' % os.environ['NXP_K32W061_SDK_ROOT'],
69+
]
70+
71+
if self.low_power:
72+
args.append('chip_with_low_power=1')
73+
else:
74+
args.append('chip_with_low_power=0')
75+
76+
if self.release:
77+
args.append('is_debug=false')
78+
79+
return args
80+
81+
def generate(self):
82+
self._Execute([os.path.join(
83+
self.code_root, 'third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh')])
84+
85+
super(K32WBuilder, self).generate()
86+
87+
def build_outputs(self):
88+
items = {}
89+
for extension in ["", ".map", ".hex"]:
90+
name = '%s%s' % (self.app.AppNamePrefix(), extension)
91+
items[name] = os.path.join(self.output_dir, name)
92+
93+
return items

scripts/build/test.py

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def build_actual_output(root: str, out: str, args: List[str]) -> List[str]:
5050
'TIZEN_HOME': 'TEST_TIZEN_HOME',
5151
'TELINK_ZEPHYR_SDK_DIR': 'TELINK_ZEPHYR_SDK_DIR',
5252
'SYSROOT_AARCH64': 'SYSROOT_AARCH64',
53+
'NXP_K32W061_SDK_ROOT': 'TEST_NXP_K32W061_SDK_ROOT',
5354
})
5455

5556
retval = subprocess.run([

scripts/build/testdata/all_targets_except_host.txt

+5
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ esp32-m5stack-all-clusters-rpc-ipv6only
7373
infineon-p6-all-clusters
7474
infineon-p6-light
7575
infineon-p6-lock
76+
k32w-light (NOGLOB: Debug builds broken due to LWIP_DEBUG redefition)
77+
k32w-light-release
78+
k32w-lock-low-power-release (NOGLOB: Only on demand build)
79+
k32w-lock-release
80+
k32w-shell-release
7681
mbed-CY8CPROTO_062_4343W-all-clusters-debug (NOGLOB: Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html)
7782
mbed-CY8CPROTO_062_4343W-all-clusters-develop (NOGLOB: Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html)
7883
mbed-CY8CPROTO_062_4343W-all-clusters-release

scripts/build/testdata/build_all_except_host.txt

+40
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,31 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa
419419
# Generating infineon-p6-lock
420420
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/p6 '--args=p6_board="CY8CKIT-062S2-43012"' {out}/infineon-p6-lock
421421

422+
{root}/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh
423+
424+
# Generating k32w-light
425+
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/nxp/k32w/k32w0 '--args=k32w0_sdk_root="TEST_NXP_K32W061_SDK_ROOT" chip_with_low_power=0' {out}/k32w-light
426+
427+
{root}/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh
428+
429+
# Generating k32w-light-release
430+
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/nxp/k32w/k32w0 '--args=k32w0_sdk_root="TEST_NXP_K32W061_SDK_ROOT" chip_with_low_power=0 is_debug=false' {out}/k32w-light-release
431+
432+
{root}/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh
433+
434+
# Generating k32w-lock-low-power-release
435+
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/nxp/k32w/k32w0 '--args=k32w0_sdk_root="TEST_NXP_K32W061_SDK_ROOT" chip_with_low_power=1 is_debug=false' {out}/k32w-lock-low-power-release
436+
437+
{root}/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh
438+
439+
# Generating k32w-lock-release
440+
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/nxp/k32w/k32w0 '--args=k32w0_sdk_root="TEST_NXP_K32W061_SDK_ROOT" chip_with_low_power=0 is_debug=false' {out}/k32w-lock-release
441+
442+
{root}/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh
443+
444+
# Generating k32w-shell-release
445+
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/shell/nxp/k32w/k32w0 '--args=k32w0_sdk_root="TEST_NXP_K32W061_SDK_ROOT" chip_with_low_power=0 is_debug=false' {out}/k32w-shell-release
446+
422447
# Generating config mbed-CY8CPROTO_062_4343W-all-clusters-debug
423448
mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/all-clusters-app/mbed -o {out}/mbed-CY8CPROTO_062_4343W-all-clusters-debug --mbed-os-path {root}/third_party/mbed-os/repo
424449

@@ -986,6 +1011,21 @@ ninja -C {out}/infineon-p6-light
9861011
# Building infineon-p6-lock
9871012
ninja -C {out}/infineon-p6-lock
9881013

1014+
# Building k32w-light
1015+
ninja -C {out}/k32w-light
1016+
1017+
# Building k32w-light-release
1018+
ninja -C {out}/k32w-light-release
1019+
1020+
# Building k32w-lock-low-power-release
1021+
ninja -C {out}/k32w-lock-low-power-release
1022+
1023+
# Building k32w-lock-release
1024+
ninja -C {out}/k32w-lock-release
1025+
1026+
# Building k32w-shell-release
1027+
ninja -C {out}/k32w-shell-release
1028+
9891029
# Remove old artifacts mbed-CY8CPROTO_062_4343W-all-clusters-debug
9901030
bash -c 'rm -rf {out}/mbed-CY8CPROTO_062_4343W-all-clusters-debug/chip-*'
9911031

scripts/build/testdata/glob_star_targets_except_host.txt

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ esp32-m5stack-all-clusters-rpc-ipv6only
3131
infineon-p6-all-clusters
3232
infineon-p6-light
3333
infineon-p6-lock
34+
k32w-light-release
35+
k32w-lock-release
36+
k32w-shell-release
3437
mbed-CY8CPROTO_062_4343W-all-clusters-release
3538
mbed-CY8CPROTO_062_4343W-light-release
3639
mbed-CY8CPROTO_062_4343W-lock-release

scripts/examples/k32w_example.sh

-36
This file was deleted.

0 commit comments

Comments
 (0)