[NXP] Update K32W build examples support (#32662)
* [NXP][CI] Update K32W build_examples support
Rename all related files from k32w to nxp. Support for other
platforms should be added in BuildNxpTarget.
Signed-off-by: marius-alex-tache <marius.tache@nxp.com>
* [NXP][CI] Add board constraints to the app targets
Supported targets should be constrained by the board using OnlyIfRe calls.
Signed-off-by: marius-alex-tache <marius.tache@nxp.com>
* [NXP][CI] Update all targets linux x64 test data
Signed-off-by: marius-alex-tache <marius.tache@nxp.com>
* Restyled by autopep8
---------
Signed-off-by: marius-alex-tache <marius.tache@nxp.com>
Co-authored-by: Restyled.io <commits@restyled.io>
diff --git a/.github/workflows/examples-k32w.yaml b/.github/workflows/examples-nxp.yaml
similarity index 69%
rename from .github/workflows/examples-k32w.yaml
rename to .github/workflows/examples-nxp.yaml
index 4121768..9a8a7b8 100644
--- a/.github/workflows/examples-k32w.yaml
+++ b/.github/workflows/examples-nxp.yaml
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-name: Build example - K32W
+name: Build example - NXP
on:
push:
@@ -58,33 +58,36 @@
run: |
scripts/run_in_build_env.sh "\
./scripts/build/build_examples.py \
- --target k32w-k32w0-light-crypto-platform-tokenizer \
- --target k32w-k32w0-contact-crypto-platform-tokenizer \
- --target k32w-k32w0-contact-crypto-platform-low-power-nologs \
- --target k32w-k32w1-light-crypto-platform-openthread-ftd \
- --target k32w-k32w1-contact-crypto-platform-low-power-nologs \
+ --target nxp-k32w0-lighting \
+ --target nxp-k32w0-lighting-factory \
+ --target nxp-k32w0-lighting-rotating-id \
+ --target nxp-k32w0-contact-sensor \
+ --target nxp-k32w0-contact-sensor-low-power \
+ --target nxp-k32w0-contact-sensor-low-power-factory \
+ --target nxp-k32w1-lighting \
+ --target nxp-k32w1-contact-sensor-low-power \
build \
--copy-artifacts-to out/artifacts \
"
- - name: Get light size stats
+ - name: Get lighting app size stats
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
- k32w k32w0+release light \
- out/artifacts/k32w-k32w0-light-crypto-platform-tokenizer/chip-k32w0x-light-example.elf \
+ nxp k32w0+release light \
+ out/artifacts/nxp-k32w0-lighting/chip-k32w0x-light-example.elf \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
- k32w k32w1+release light \
- out/artifacts/k32w-k32w1-light-crypto-platform-openthread-ftd/chip-k32w1-light-example.elf \
+ nxp k32w1+release light \
+ out/artifacts/nxp-k32w1-lighting/chip-k32w1-light-example.elf \
/tmp/bloat_reports/
- - name: Get contact size stats
+ - name: Get contact sensor size stats
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
- k32w k32w0+release contact \
- out/artifacts/k32w-k32w0-contact-crypto-platform-tokenizer/chip-k32w0x-contact-example.elf \
+ nxp k32w0+release contact \
+ out/artifacts/nxp-k32w0-contact-sensor-low-power/chip-k32w0x-contact-example.elf \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
- k32w k32w1+release contact \
- out/artifacts/k32w-k32w1-contact-crypto-platform-low-power-nologs/chip-k32w1-contact-example.elf \
+ nxp k32w1+release contact \
+ out/artifacts/nxp-k32w1-contact-sensor-low-power/chip-k32w1-contact-example.elf \
/tmp/bloat_reports/
- name: Uploading Size Reports
uses: ./.github/actions/upload-size-reports
diff --git a/scripts/build/BUILD.gn b/scripts/build/BUILD.gn
index 6b13a8c..1818160 100644
--- a/scripts/build/BUILD.gn
+++ b/scripts/build/BUILD.gn
@@ -53,10 +53,10 @@
"builders/host.py",
"builders/imx.py",
"builders/infineon.py",
- "builders/k32w.py",
"builders/mbed.py",
"builders/mw320.py",
"builders/nrf.py",
+ "builders/nxp.py",
"builders/openiotsdk.py",
"builders/qpg.py",
"builders/rw61x.py",
diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py
index 0ebb5f4..e2ec1f2 100755
--- a/scripts/build/build/targets.py
+++ b/scripts/build/build/targets.py
@@ -24,10 +24,10 @@
from builders.host import HostApp, HostBoard, HostBuilder, HostCryptoLibrary, HostFuzzingType
from builders.imx import IMXApp, IMXBuilder
from builders.infineon import InfineonApp, InfineonBoard, InfineonBuilder
-from builders.k32w import K32WApp, K32WBoard, K32WBuilder
from builders.mbed import MbedApp, MbedBoard, MbedBuilder, MbedProfile
from builders.mw320 import MW320App, MW320Builder
from builders.nrf import NrfApp, NrfBoard, NrfConnectBuilder
+from builders.nxp import NxpApp, NxpBoard, NxpBuilder
from builders.openiotsdk import OpenIotSdkApp, OpenIotSdkBuilder, OpenIotSdkCryptoBackend
from builders.qpg import QpgApp, QpgBoard, QpgBuilder
from builders.rw61x import RW61XApp, RW61XBuilder
@@ -469,32 +469,29 @@
return target
-def BuildK32WTarget():
- target = BuildTarget('k32w', K32WBuilder)
+def BuildNxpTarget():
+ target = BuildTarget('nxp', NxpBuilder)
# boards
target.AppendFixedTargets([
- TargetPart('k32w0', board=K32WBoard.K32W0),
- TargetPart('k32w1', board=K32WBoard.K32W1)
+ TargetPart('k32w0', board=NxpBoard.K32W0),
+ TargetPart('k32w1', board=NxpBoard.K32W1)
])
# apps
target.AppendFixedTargets([
- TargetPart('light', app=K32WApp.LIGHT, release=True),
- TargetPart('shell', app=K32WApp.SHELL, release=True),
- TargetPart('lock', app=K32WApp.LOCK, release=True),
- TargetPart('contact', app=K32WApp.CONTACT, release=True)
+ TargetPart('lighting', app=NxpApp.LIGHTING).OnlyIfRe('(k32w0|k32w1)'),
+ TargetPart('contact-sensor', app=NxpApp.CONTACT).OnlyIfRe('(k32w0|k32w1)')
])
- target.AppendModifier(name="se05x", se05x=True)
- target.AppendModifier(name="no-ble", disable_ble=True)
- target.AppendModifier(name="no-ota", disable_ota=True)
- target.AppendModifier(name="low-power", low_power=True).OnlyIfRe("-nologs")
- target.AppendModifier(name="nologs", disable_logs=True)
- target.AppendModifier(name="crypto-platform", crypto_platform=True)
- target.AppendModifier(
- name="tokenizer", tokenizer=True).ExceptIfRe("-nologs")
- target.AppendModifier(name="openthread-ftd", openthread_ftd=True)
+ target.AppendModifier(name="factory", enable_factory_data=True)
+ target.AppendModifier(name="low-power", low_power=True).OnlyIfRe('contact-sensor')
+ target.AppendModifier(name="lit", enable_lit=True).OnlyIfRe('contact-sensor')
+ target.AppendModifier(name="fro32k", use_fro32k=True).OnlyIfRe('k32w0')
+ target.AppendModifier(name="smu2", smu2=True).OnlyIfRe('k32w1-lighting')
+ target.AppendModifier(name="dac-conversion", convert_dac_pk=True).OnlyIfRe('factory').ExceptIfRe('k32w0')
+ target.AppendModifier(name="rotating-id", enable_rotating_id=True)
+ target.AppendModifier(name="sw-v2", has_sw_version_2=True)
return target
@@ -804,7 +801,7 @@
BuildIMXTarget(),
BuildInfineonTarget(),
BuildRW61XTarget(),
- BuildK32WTarget(),
+ BuildNxpTarget(),
BuildMbedTarget(),
BuildMW320Target(),
BuildNrfTarget(),
diff --git a/scripts/build/builders/k32w.py b/scripts/build/builders/k32w.py
deleted file mode 100644
index 86ba552..0000000
--- a/scripts/build/builders/k32w.py
+++ /dev/null
@@ -1,157 +0,0 @@
-# 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 K32WBoard(Enum):
- K32W0 = auto()
- K32W1 = auto()
-
- def Name(self):
- if self == K32WBoard.K32W0:
- return 'k32w0x'
- elif self == K32WBoard.K32W1:
- return 'k32w1'
- else:
- raise Exception('Unknown board type: %r' % self)
-
- def FolderName(self):
- if self == K32WBoard.K32W0:
- return 'k32w/k32w0'
- elif self == K32WBoard.K32W1:
- return 'k32w/k32w1'
- else:
- raise Exception('Unknown board type: %r' % self)
-
-
-class K32WApp(Enum):
- LIGHT = auto()
- LOCK = auto()
- SHELL = auto()
- CONTACT = auto()
-
- def ExampleName(self):
- if self == K32WApp.LIGHT:
- return 'lighting-app'
- elif self == K32WApp.LOCK:
- return 'lock-app'
- elif self == K32WApp.SHELL:
- return 'shell'
- elif self == K32WApp.CONTACT:
- return "contact-sensor-app"
- else:
- raise Exception('Unknown app type: %r' % self)
-
- def NameSuffix(self):
- if self == K32WApp.LIGHT:
- return 'light-example'
- elif self == K32WApp.LOCK:
- return 'lock-example'
- elif self == K32WApp.SHELL:
- return 'shell-example'
- elif self == K32WApp.CONTACT:
- return 'contact-example'
- else:
- raise Exception('Unknown app type: %r' % self)
-
- def BuildRoot(self, root, board):
- return os.path.join(root, 'examples', self.ExampleName(), 'nxp', board.FolderName())
-
-
-class K32WBuilder(GnBuilder):
-
- def __init__(self,
- root,
- runner,
- app: K32WApp = K32WApp.LIGHT,
- board: K32WBoard = K32WBoard.K32W0,
- release: bool = False,
- low_power: bool = False,
- tokenizer: bool = False,
- disable_ble: bool = False,
- disable_ota: bool = False,
- disable_logs: bool = False,
- se05x: bool = False,
- tinycrypt: bool = False,
- crypto_platform: bool = False,
- openthread_ftd: bool = False):
- super(K32WBuilder, self).__init__(
- root=app.BuildRoot(root, board),
- runner=runner)
- self.code_root = root
- self.app = app
- self.board = board
- self.low_power = low_power
- self.tokenizer = tokenizer
- self.release = release
- self.disable_ble = disable_ble
- self.disable_ota = disable_ota
- self.disable_logs = disable_logs
- self.se05x = se05x
- self.tinycrypt = tinycrypt
- self.crypto_platform = crypto_platform
- self.openthread_ftd = openthread_ftd
-
- def GnBuildArgs(self):
- args = []
-
- if self.low_power:
- args.append('chip_with_low_power=1 chip_logging=false')
- if self.board == K32WBoard.K32W0:
- args.append('chip_pw_tokenizer_logging=false chip_with_OM15082=0')
- else:
- args.append('chip_with_low_power=0')
-
- if self.tokenizer:
- args.append('chip_pw_tokenizer_logging=true')
-
- if self.release:
- args.append('is_debug=false')
-
- if self.disable_ble:
- args.append('chip_enable_ble=false')
-
- if self.disable_ota:
- args.append('chip_enable_ota_requestor=false')
-
- if self.disable_logs:
- args.append('chip_logging=false')
-
- if self.se05x:
- args.append('chip_with_se05x=true')
-
- if self.tinycrypt:
- args.append('chip_crypto=\"platform\" chip_crypto_flavor=\"tinycrypt\"')
-
- if self.crypto_platform:
- args.append('chip_crypto=\"platform\"')
-
- if self.openthread_ftd:
- args.append('chip_openthread_ftd=true')
-
- return args
-
- def generate(self):
- super(K32WBuilder, self).generate()
-
- def build_outputs(self):
- name = 'chip-%s-%s' % (self.board.Name(), self.app.NameSuffix())
- return {
- '%s.elf' % name: os.path.join(self.output_dir, name),
- '%s.map' % name: os.path.join(self.output_dir, '%s.map' % name)
- }
diff --git a/scripts/build/builders/nxp.py b/scripts/build/builders/nxp.py
new file mode 100644
index 0000000..9f0dcfd
--- /dev/null
+++ b/scripts/build/builders/nxp.py
@@ -0,0 +1,135 @@
+# 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 NxpBoard(Enum):
+ K32W0 = auto()
+ K32W1 = auto()
+
+ def Name(self):
+ if self == NxpBoard.K32W0:
+ return 'k32w0x'
+ elif self == NxpBoard.K32W1:
+ return 'k32w1'
+ else:
+ raise Exception('Unknown board type: %r' % self)
+
+ def FolderName(self):
+ if self == NxpBoard.K32W0:
+ return 'k32w/k32w0'
+ elif self == NxpBoard.K32W1:
+ return 'k32w/k32w1'
+ else:
+ raise Exception('Unknown board type: %r' % self)
+
+
+class NxpApp(Enum):
+ LIGHTING = auto()
+ CONTACT = auto()
+
+ def ExampleName(self):
+ if self == NxpApp.LIGHTING:
+ return 'lighting-app'
+ elif self == NxpApp.CONTACT:
+ return "contact-sensor-app"
+ else:
+ raise Exception('Unknown app type: %r' % self)
+
+ def NameSuffix(self):
+ if self == NxpApp.LIGHTING:
+ return 'light-example'
+ elif self == NxpApp.CONTACT:
+ return 'contact-example'
+ else:
+ raise Exception('Unknown app type: %r' % self)
+
+ def BuildRoot(self, root, board):
+ return os.path.join(root, 'examples', self.ExampleName(), 'nxp', board.FolderName())
+
+
+class NxpBuilder(GnBuilder):
+
+ def __init__(self,
+ root,
+ runner,
+ app: NxpApp = NxpApp.LIGHTING,
+ board: NxpBoard = NxpBoard.K32W0,
+ low_power: bool = False,
+ smu2: bool = False,
+ enable_factory_data: bool = False,
+ convert_dac_pk: bool = False,
+ use_fro32k: bool = False,
+ enable_lit: bool = False,
+ enable_rotating_id: bool = False,
+ has_sw_version_2: bool = False):
+ super(NxpBuilder, self).__init__(
+ root=app.BuildRoot(root, board),
+ runner=runner)
+ self.code_root = root
+ self.app = app
+ self.board = board
+ self.low_power = low_power
+ self.smu2 = smu2
+ self.enable_factory_data = enable_factory_data
+ self.convert_dac_pk = convert_dac_pk
+ self.use_fro32k = use_fro32k
+ self.enable_lit = enable_lit
+ self.enable_rotating_id = enable_rotating_id
+ self.has_sw_version_2 = has_sw_version_2
+
+ def GnBuildArgs(self):
+ args = []
+
+ if self.low_power:
+ args.append('chip_with_low_power=1 chip_logging=false')
+ if self.board == NxpBoard.K32W0:
+ args.append('chip_pw_tokenizer_logging=false chip_with_OM15082=0')
+
+ if self.smu2:
+ args.append('use_smu2_static=true use_smu2_dynamic=true')
+
+ if self.enable_factory_data:
+ args.append('chip_with_factory_data=1')
+
+ if self.convert_dac_pk:
+ args.append('chip_convert_dac_private_key=1')
+
+ if self.use_fro32k:
+ args.append('use_fro_32k=1')
+
+ if self.enable_lit:
+ args.append('chip_enable_icd_lit=true')
+
+ if self.enable_rotating_id:
+ args.append('chip_enable_rotating_device_id=1 chip_enable_additional_data_advertising=1')
+
+ if self.has_sw_version_2:
+ args.append('nxp_software_version=2')
+
+ return args
+
+ def generate(self):
+ super(NxpBuilder, self).generate()
+
+ def build_outputs(self):
+ name = 'chip-%s-%s' % (self.board.Name(), self.app.NameSuffix())
+ return {
+ '%s.elf' % name: os.path.join(self.output_dir, name),
+ '%s.map' % name: os.path.join(self.output_dir, '%s.map' % name)
+ }
diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt
index fd200d8..cba8fe6 100644
--- a/scripts/build/testdata/all_targets_linux_x64.txt
+++ b/scripts/build/testdata/all_targets_linux_x64.txt
@@ -15,7 +15,7 @@
imx-{chip-tool,lighting-app,thermostat,all-clusters-app,all-clusters-minimal-app,ota-provider-app}[-release]
infineon-psoc6-{lock,light,all-clusters,all-clusters-minimal}[-ota][-updateimage]
rw61x-{all-clusters-app,thermostat,laundry-washer}[-ota][-wifi][-thread][-factory-data][-matter-shell]
-k32w-{k32w0,k32w1}-{light,shell,lock,contact}[-se05x][-no-ble][-no-ota][-low-power][-nologs][-crypto-platform][-tokenizer][-openthread-ftd]
+nxp-{k32w0,k32w1}-{lighting,contact-sensor}[-factory][-low-power][-lit][-fro32k][-smu2][-dac-conversion][-rotating-id][-sw-v2]
mbed-cy8cproto_062_4343w-{lock,light,all-clusters,all-clusters-minimal,pigweed,ota-requestor,shell}[-release][-develop][-debug]
mw320-all-clusters-app
nrf-{nrf5340dk,nrf52840dk,nrf52840dongle}-{all-clusters,all-clusters-minimal,lock,light,light-switch,shell,pump,pump-controller,window-covering}[-rpc]