diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a28673eb47440b..2bed35daf190ea 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -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/ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3daabb694fb026..3740ac511ff36f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,7 +17,7 @@ "build": { "dockerfile": "Dockerfile", "args": { - "BUILD_VERSION": "0.5.33" + "BUILD_VERSION": "0.5.40" } }, "remoteUser": "vscode", diff --git a/.github/workflows/examples-k32w.yaml b/.github/workflows/examples-k32w.yaml index 198af15b87de4f..a5e0f7878d8a43 100644 --- a/.github/workflows/examples-k32w.yaml +++ b/.github/workflows/examples-k32w.yaml @@ -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 }} diff --git a/scripts/build/BUILD.gn b/scripts/build/BUILD.gn index a85fb3fba7dbc5..127430285611b1 100644 --- a/scripts/build/BUILD.gn +++ b/scripts/build/BUILD.gn @@ -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", diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 47a4b538c8e29c..3dbaa16ea89e83 100644 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -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: @@ -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 = [ @@ -345,7 +361,8 @@ def AmebaTargets(): AndroidTargets(), MbedTargets(), InfineonTargets(), - AmebaTargets() + AmebaTargets(), + K32WTargets(), ] for generator in target_generators: diff --git a/scripts/build/builders/k32w.py b/scripts/build/builders/k32w.py new file mode 100644 index 00000000000000..aef1bff6cc5e28 --- /dev/null +++ b/scripts/build/builders/k32w.py @@ -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 diff --git a/scripts/build/test.py b/scripts/build/test.py index 8128ad28525f63..0e5e01706dc1a6 100644 --- a/scripts/build/test.py +++ b/scripts/build/test.py @@ -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([ diff --git a/scripts/build/testdata/all_targets_except_host.txt b/scripts/build/testdata/all_targets_except_host.txt index ea4a929c3be31c..8c803ff3f2a1da 100644 --- a/scripts/build/testdata/all_targets_except_host.txt +++ b/scripts/build/testdata/all_targets_except_host.txt @@ -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 diff --git a/scripts/build/testdata/build_all_except_host.txt b/scripts/build/testdata/build_all_except_host.txt index 139966e0a740c1..cbe3c7d9d98b0c 100644 --- a/scripts/build/testdata/build_all_except_host.txt +++ b/scripts/build/testdata/build_all_except_host.txt @@ -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 @@ -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-*' diff --git a/scripts/build/testdata/glob_star_targets_except_host.txt b/scripts/build/testdata/glob_star_targets_except_host.txt index 32f0e5e91dc31c..9e7403d0f346c7 100644 --- a/scripts/build/testdata/glob_star_targets_except_host.txt +++ b/scripts/build/testdata/glob_star_targets_except_host.txt @@ -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 diff --git a/scripts/examples/k32w_example.sh b/scripts/examples/k32w_example.sh deleted file mode 100755 index 0a8fc8d92d1dbb..00000000000000 --- a/scripts/examples/k32w_example.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash - -# -# 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. -# - -set -e - -# Build script for K32W examples GitHub workflow. - -source "$(dirname "$0")/../../scripts/activate.sh" - -set -x -env - -"$(dirname "$0")"/../../third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh - -if [ -z "$3" ]; then - gn gen --check --fail-on-unused-args --root="$1" "$2" --args="k32w0_sdk_root=\"$NXP_K32W061_SDK_ROOT\" is_debug=false chip_with_low_power=1" -else - gn gen --check --fail-on-unused-args --root="$1" "$2" --args="k32w0_sdk_root=\"$NXP_K32W061_SDK_ROOT\" is_debug=false chip_with_low_power=0" -fi - -ninja -C "$2"