Skip to content

Commit

Permalink
Add k32w support into build_examples and use it for CI (#13062)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
andy31415 authored and pull[bot] committed Jan 30, 2022
1 parent ed2c9fa commit 1605900
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 59 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ RUN chown -R $USERNAME:$USERNAME /opt/android/sdk

# AmebaD requires access to change build_info.h
RUN chown -R $USERNAME:$USERNAME /opt/ameba/ambd_sdk_with_chip_non_NDA/

# NXP uses a patch_sdk script to change SDK files
RUN chown -R $USERNAME:$USERNAME /opt/sdk/sdks/
35 changes: 16 additions & 19 deletions .github/workflows/examples-k32w.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,34 +60,31 @@ jobs:
path: |
.environment/gn_out/.ninja_log
.environment/pigweed-venv/*.log
- name: Build example K32W Lock App
timeout-minutes: 5
- name: Build examples
timeout-minutes: 30
run: |
scripts/examples/k32w_example.sh \
examples/lock-app/nxp/k32w/k32w0 out/lock_app_debug
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
k32w k32w061+debug lock-app \
out/lock_app_debug/chip-k32w061-lock-example \
/tmp/bloat_reports/
- name: Build example K32W Shell App
scripts/run_in_build_env.sh "\
./scripts/build/build_examples.py \
--target k32w-light-release \
--target k32w-lock-low-power-release \
--target k32w-shell-release \
build \
--copy-artifacts-to out/artifacts \
"
- name: Get light size stats
timeout-minutes: 5
run: |
scripts/examples/k32w_example.sh \
examples/shell/nxp/k32w/k32w0 out/shell_app_debug no_low_power
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
k32w k32w061+debug shell \
out/shell_app_debug/chip-k32w061-shell-example \
k32w k32w061+release light \
out/artifacts/k32w-light-release/chip-k32w061-light-example \
/tmp/bloat_reports/
- name: Build example K32W Lighting App with Secure Element
- name: Get lock size stats
timeout-minutes: 5
run: |
scripts/examples/k32w_se_example.sh \
examples/lighting-app/nxp/k32w/k32w0 out/lighting_app_se_release
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
k32w k32w061+se05x+release lighting-app \
out/lighting_app_se_release/chip-k32w061-light-example \
k32w k32w061+release lock \
out/artifacts/k32w-lock-low-power-release/chip-k32w061-lock-example \
/tmp/bloat_reports/
- name: Uploading Size Reports
uses: actions/upload-artifact@v2
if: ${{ !env.ACT }}
Expand Down
3 changes: 3 additions & 0 deletions scripts/build/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ pw_python_package("build_examples") {
"build_examples.py",
"builders/__init__.py",
"builders/ameba.py",
"builders/android.py",
"builders/builder.py",
"builders/efr32.py",
"builders/esp32.py",
"builders/gn.py",
"builders/host.py",
"builders/infineon.py",
"builders/k32w.py",
"builders/mbed.py",
"builders/nrf.py",
"builders/qpg.py",
"builders/telink.py",
Expand Down
25 changes: 21 additions & 4 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@
from typing import Any, List
from itertools import combinations

from builders.ameba import AmebaApp, AmebaBoard, AmebaBuilder
from builders.android import AndroidBoard, AndroidApp, AndroidBuilder
from builders.efr32 import Efr32Builder, Efr32App, Efr32Board
from builders.esp32 import Esp32Builder, Esp32Board, Esp32App
from builders.host import HostBuilder, HostApp, HostBoard
from builders.infineon import InfineonBuilder, InfineonApp, InfineonBoard
from builders.k32w import K32WApp, K32WBuilder
from builders.mbed import MbedApp, MbedBoard, MbedProfile, MbedBuilder
from builders.nrf import NrfApp, NrfBoard, NrfConnectBuilder
from builders.qpg import QpgBuilder
from builders.infineon import InfineonBuilder, InfineonApp, InfineonBoard
from builders.telink import TelinkApp, TelinkBoard, TelinkBuilder
from builders.tizen import TizenApp, TizenBoard, TizenBuilder
from builders.ameba import AmebaApp, AmebaBoard, AmebaBuilder
from builders.mbed import MbedApp, MbedBoard, MbedProfile, MbedBuilder


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


def K32WTargets():
target = Target('k32w', K32WBuilder)

# This is for testing only in case debug builds are to be fixed
# Error is LWIP_DEBUG being redefined between 0 and 1 in debug builds in:
# third_party/connectedhomeip/src/lwip/k32w0/lwipopts.h
# gen/include/lwip/lwip_buildconfig.h
yield target.Extend('light', app=K32WApp.LIGHT).GlobBlacklist("Debug builds broken due to LWIP_DEBUG redefition")

yield target.Extend('light-release', app=K32WApp.LIGHT, release=True)
yield target.Extend('shell-release', app=K32WApp.SHELL, release=True)
yield target.Extend('lock-release', app=K32WApp.LOCK, release=True)
yield target.Extend('lock-low-power-release', app=K32WApp.LOCK, low_power=True, release=True).GlobBlacklist("Only on demand build")


ALL = []

target_generators = [
Expand All @@ -345,7 +361,8 @@ def AmebaTargets():
AndroidTargets(),
MbedTargets(),
InfineonTargets(),
AmebaTargets()
AmebaTargets(),
K32WTargets(),
]

for generator in target_generators:
Expand Down
93 changes: 93 additions & 0 deletions scripts/build/builders/k32w.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# 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 os
from enum import Enum, auto

from .gn import GnBuilder


class K32WApp(Enum):
LIGHT = auto()
LOCK = auto()
SHELL = auto()

def ExampleName(self):
if self == K32WApp.LIGHT:
return 'lighting-app'
elif self == K32WApp.LOCK:
return 'lock-app'
elif self == K32WApp.SHELL:
return 'shell'
else:
raise Exception('Unknown app type: %r' % self)

def AppNamePrefix(self):
if self == K32WApp.LIGHT:
return 'chip-k32w061-light-example'
elif self == K32WApp.LOCK:
return 'chip-k32w061-lock-example'
elif self == K32WApp.SHELL:
return 'chip-k32w061-shell-example'
else:
raise Exception('Unknown app type: %r' % self)

def BuildRoot(self, root):
return os.path.join(root, 'examples', self.ExampleName(), 'nxp', 'k32w', 'k32w0')


class K32WBuilder(GnBuilder):

def __init__(self,
root,
runner,
app: K32WApp = K32WApp.LIGHT,
release: bool = False,
low_power: bool = False):
super(K32WBuilder, self).__init__(
root=app.BuildRoot(root),
runner=runner)
self.code_root = root
self.app = app
self.low_power = low_power
self.release = release

def GnBuildArgs(self):
args = [
'k32w0_sdk_root="%s"' % os.environ['NXP_K32W061_SDK_ROOT'],
]

if self.low_power:
args.append('chip_with_low_power=1')
else:
args.append('chip_with_low_power=0')

if self.release:
args.append('is_debug=false')

return args

def generate(self):
self._Execute([os.path.join(
self.code_root, 'third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh')])

super(K32WBuilder, self).generate()

def build_outputs(self):
items = {}
for extension in ["", ".map", ".hex"]:
name = '%s%s' % (self.app.AppNamePrefix(), extension)
items[name] = os.path.join(self.output_dir, name)

return items
1 change: 1 addition & 0 deletions scripts/build/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def build_actual_output(root: str, out: str, args: List[str]) -> List[str]:
'TIZEN_HOME': 'TEST_TIZEN_HOME',
'TELINK_ZEPHYR_SDK_DIR': 'TELINK_ZEPHYR_SDK_DIR',
'SYSROOT_AARCH64': 'SYSROOT_AARCH64',
'NXP_K32W061_SDK_ROOT': 'TEST_NXP_K32W061_SDK_ROOT',
})

retval = subprocess.run([
Expand Down
5 changes: 5 additions & 0 deletions scripts/build/testdata/all_targets_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ esp32-m5stack-all-clusters-rpc-ipv6only
infineon-p6-all-clusters
infineon-p6-light
infineon-p6-lock
k32w-light (NOGLOB: Debug builds broken due to LWIP_DEBUG redefition)
k32w-light-release
k32w-lock-low-power-release (NOGLOB: Only on demand build)
k32w-lock-release
k32w-shell-release
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)
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)
mbed-CY8CPROTO_062_4343W-all-clusters-release
Expand Down
40 changes: 40 additions & 0 deletions scripts/build/testdata/build_all_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,31 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa
# Generating infineon-p6-lock
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

{root}/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh

# Generating k32w-light
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

{root}/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh

# Generating k32w-light-release
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

{root}/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh

# Generating k32w-lock-low-power-release
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

{root}/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh

# Generating k32w-lock-release
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

{root}/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh

# Generating k32w-shell-release
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

# Generating config mbed-CY8CPROTO_062_4343W-all-clusters-debug
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

Expand Down Expand Up @@ -986,6 +1011,21 @@ ninja -C {out}/infineon-p6-light
# Building infineon-p6-lock
ninja -C {out}/infineon-p6-lock

# Building k32w-light
ninja -C {out}/k32w-light

# Building k32w-light-release
ninja -C {out}/k32w-light-release

# Building k32w-lock-low-power-release
ninja -C {out}/k32w-lock-low-power-release

# Building k32w-lock-release
ninja -C {out}/k32w-lock-release

# Building k32w-shell-release
ninja -C {out}/k32w-shell-release

# Remove old artifacts mbed-CY8CPROTO_062_4343W-all-clusters-debug
bash -c 'rm -rf {out}/mbed-CY8CPROTO_062_4343W-all-clusters-debug/chip-*'

Expand Down
3 changes: 3 additions & 0 deletions scripts/build/testdata/glob_star_targets_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ esp32-m5stack-all-clusters-rpc-ipv6only
infineon-p6-all-clusters
infineon-p6-light
infineon-p6-lock
k32w-light-release
k32w-lock-release
k32w-shell-release
mbed-CY8CPROTO_062_4343W-all-clusters-release
mbed-CY8CPROTO_062_4343W-light-release
mbed-CY8CPROTO_062_4343W-lock-release
Expand Down
36 changes: 0 additions & 36 deletions scripts/examples/k32w_example.sh

This file was deleted.

0 comments on commit 1605900

Please sign in to comment.