Skip to content

Commit

Permalink
Merge branch 'master' of github.com:selissia/connectedhomeip into sil…
Browse files Browse the repository at this point in the history
…abs-ota-header
  • Loading branch information
selissia committed Mar 14, 2022
2 parents 0b86a09 + 9e18f9b commit cab0354
Show file tree
Hide file tree
Showing 137 changed files with 2,888 additions and 767 deletions.
5 changes: 5 additions & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ depottools
deps
desc
descheduled
detokenization
detokenizer
dev
devcontainer
devCtrl
Expand Down Expand Up @@ -1035,6 +1037,7 @@ RGB
riscv
rloc
rmw
rodata
Rollershade
rootfs
RPC
Expand Down Expand Up @@ -1178,6 +1181,7 @@ TestCluster
TestConstraints
TestEmptyString
TestGenExample
TestGroupDemoConfig
TestMultiRead
TESTPASSWD
TestPICS
Expand Down Expand Up @@ -1211,6 +1215,7 @@ tngvndl
TODO
toJson
tokenized
tokenizer
toolchain
toolchains
topologies
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/examples-cyw30739.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target-glob 'cyw30739-cyw930739m2evb_01-{light,lock,ota-requestor}' \
--target-glob 'cyw30739-cyw930739m2evb_01-{light,lock,ota-requestor-no-progress-logging}' \
build \
--copy-artifacts-to out/artifacts \
"
Expand All @@ -89,8 +89,8 @@ jobs:
timeout-minutes: 5
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
cyw30739 cyw930739m2evb_01 ota-requestor \
out/artifacts/cyw30739-cyw930739m2evb_01-ota-requestor/chip-cyw30739-ota-requestor-example.elf \
cyw30739 cyw930739m2evb_01 ota-requestor-no-progress-logging \
out/artifacts/cyw30739-cyw930739m2evb_01-ota-requestor-no-progress-logging/chip-cyw30739-ota-requestor-example.elf \
/tmp/bloat_reports/
- name: Uploading Size Reports
uses: actions/upload-artifact@v2
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/examples-k32w.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
scripts/run_in_build_env.sh "\
./scripts/build/build_examples.py \
--target k32w-light-release \
--target k32w-light-tokenizer-release \
--target k32w-lock-low-power-release \
--target k32w-shell-release \
build \
Expand Down
7 changes: 4 additions & 3 deletions .pullapprove.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ overrides:
############################################################
# Required status checks
############################################################
- if: "'*restyle*' not in statuses.successful"
status: failure
explanation: "Style must be inline before reviewing can be complete"
# Disabled given restyled seems broken right now
# - if: "'*restyle*' not in statuses.successful"
# status: failure
# explanation: "Style must be inline before reviewing can be complete"

############################################################
# Fast tracking
Expand Down
38 changes: 38 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach to running process",
"type": "lldb",
"request": "attach",
"pid": "${command:pickProcess}"
},
{
"name": "QRCode Tests",
"type": "cppdbg",
Expand Down Expand Up @@ -349,6 +355,38 @@
],
"runToMain": true, // if true, program will halt at main. Not used for a restart
"showDevDebugOutput": false // When set to true, displays output of GDB.
},

{
"name": "OTA Requestor App (Linux)",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/out/ota-requestor/chip-ota-requestor-app",
"args": [
"--discriminator",
"18",
"--secured-device-port",
"5560",
"--KVS",
"/tmp/chip_kvs_requestor"
],
"cwd": "${workspaceFolder}"
},

{
"name": "OTA Provider App (Linux)",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/out/ota-provider/chip-ota-provider-app",
"args": [
"--discriminator",
"22",
"--KVS",
"/tmp/chip_kvs_provider",
"--filepath",
"/tmp/ota-image.bin"
],
"cwd": "${workspaceFolder}"
}
],
"inputs": [
Expand Down
8 changes: 8 additions & 0 deletions config/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ list(APPEND CHIP_CFLAGS
\"-D__LINUX_ERRNO_EXTENSIONS__=1\"
)

list(APPEND CHIP_CFLAGS
\"-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=<lib/address_resolve/AddressResolve_DefaultImpl.h>\"
)

if (CONFIG_MBED_BSD_SOCKET_TRACE)
list(APPEND CHIP_CFLAGS
\"-DMBED_BSD_SOCKET_TRACE=1\"
Expand Down Expand Up @@ -344,6 +348,10 @@ list(APPEND CHIP_DEFINES
__LINUX_ERRNO_EXTENSIONS__=1
)

list(APPEND CHIP_DEFINES
CHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=<lib/address_resolve/AddressResolve_DefaultImpl.h>
)

if (CONFIG_MBED_BSD_SOCKET_TRACE)
list(APPEND CHIP_DEFINES
MBED_BSD_SOCKET_TRACE=1
Expand Down
3 changes: 3 additions & 0 deletions examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ idf_component_register(PRIV_INCLUDE_DIRS ${PRIV_INCLUDE_DIRS_LIST}

set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
target_compile_options(${COMPONENT_LIB} PRIVATE "-DLWIP_IPV6_SCOPES=0" "-DCHIP_HAVE_CONFIG_H")
target_compile_options(${COMPONENT_LIB} PUBLIC
"-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=<lib/address_resolve/AddressResolve_DefaultImpl.h>"
)

if (CONFIG_ENABLE_PW_RPC)

Expand Down
5 changes: 4 additions & 1 deletion examples/bridge-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ idf_component_register(PRIV_INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-format-localization-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fixed-label-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/user-label-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/user-label-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wifi-network-diagnostics-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server"
Expand All @@ -52,3 +52,6 @@ idf_component_register(PRIV_INCLUDE_DIRS

set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 14)
target_compile_options(${COMPONENT_LIB} PRIVATE "-DLWIP_IPV6_SCOPES=0" "-DCHIP_HAVE_CONFIG_H")
target_compile_options(${COMPONENT_LIB} PUBLIC
"-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=<lib/address_resolve/AddressResolve_DefaultImpl.h>"
)
5 changes: 3 additions & 2 deletions examples/bridge-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <lib/core/CHIPError.h>
#include <lib/support/CHIPMem.h>
#include <lib/support/ZclString.h>
#include <platform/CommissionableDataProvider.h>
#include <setup_payload/QRCodeSetupPayloadGenerator.h>
#include <setup_payload/SetupPayload.h>

Expand Down Expand Up @@ -550,10 +551,10 @@ CHIP_ERROR PrintQRCodeContent()
uint16_t productId;
std::string result;

err = ConfigurationMgr().GetSetupPinCode(setUpPINCode);
err = GetCommissionableDataProvider()->GetSetupPasscode(setUpPINCode);
SuccessOrExit(err);

err = ConfigurationMgr().GetSetupDiscriminator(setUpDiscriminator);
err = GetCommissionableDataProvider()->GetSetupDiscriminator(setUpDiscriminator);
SuccessOrExit(err);

err = ConfigurationMgr().GetVendorId(vendorId);
Expand Down
1 change: 0 additions & 1 deletion examples/chip-tool-darwin/templates/commands.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public:
{{~#*inline "field"}}m{{asUpperCamelCase label}}{{/inline~}}
{{#if isArray}}
{{else if isStruct}}
{{else if (isOctetString type)}}
{{else if (isString type)}}
AddArgument("{{asUpperCamelCase label}}", &{{>field}});
{{else}}
Expand Down
6 changes: 3 additions & 3 deletions examples/chip-tool/commands/common/CredentialIssuerCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ class CredentialIssuerCommands
* @param[in] nodeId The desired NodeId for the generated NOC Chain - May be optional/unused in some implementations.
* @param[in] fabricId The desired FabricId for the generated NOC Chain - May be optional/unused in some implementations.
* @param[in] keypair The desired Keypair for the generated NOC Chain - May be optional/unused in some implementations.
* @param[inout] rcac Buffer to hold the Root Certificate of the generated NOC Chain.
* @param[inout] icac Buffer to hold the Intermediate Certificate of the generated NOC Chain.
* @param[inout] noc Buffer to hold the Leaf Certificate of the generated NOC Chain.
* @param[in,out] rcac Buffer to hold the Root Certificate of the generated NOC Chain.
* @param[in,out] icac Buffer to hold the Intermediate Certificate of the generated NOC Chain.
* @param[in,out] noc Buffer to hold the Leaf Certificate of the generated NOC Chain.
*
* @return CHIP_ERROR CHIP_NO_ERROR on success, or corresponding error code.
*/
Expand Down
10 changes: 6 additions & 4 deletions examples/common/pigweed/rpc_services/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#pragma once

#include <platform/CHIPDeviceConfig.h>
#include <platform/CommissionableDataProvider.h>

#include "app/server/OnboardingCodesUtil.h"
#include "app/server/Server.h"
Expand Down Expand Up @@ -126,14 +127,14 @@ class Device : public pw_rpc::nanopb::Device::Service<Device>
}

uint32_t code;
if (DeviceLayer::ConfigurationMgr().GetSetupPinCode(code) == CHIP_NO_ERROR)
if (DeviceLayer::GetCommissionableDataProvider()->GetSetupPasscode(code) == CHIP_NO_ERROR)
{
response.pairing_info.code = code;
response.has_pairing_info = true;
}

uint16_t discriminator;
if (DeviceLayer::ConfigurationMgr().GetSetupDiscriminator(discriminator) == CHIP_NO_ERROR)
if (DeviceLayer::GetCommissionableDataProvider()->GetSetupDiscriminator(discriminator) == CHIP_NO_ERROR)
{
response.pairing_info.discriminator = static_cast<uint32_t>(discriminator);
response.has_pairing_info = true;
Expand All @@ -158,8 +159,9 @@ class Device : public pw_rpc::nanopb::Device::Service<Device>

virtual pw::Status SetPairingInfo(const chip_rpc_PairingInfo & request, pw_protobuf_Empty & response)
{
if (DeviceLayer::ConfigurationMgr().StoreSetupPinCode(request.code) != CHIP_NO_ERROR ||
DeviceLayer::ConfigurationMgr().StoreSetupDiscriminator(request.discriminator) != CHIP_NO_ERROR)
if (DeviceLayer::GetCommissionableDataProvider()->SetSetupPasscode(request.code) != CHIP_NO_ERROR ||
DeviceLayer::GetCommissionableDataProvider()->SetSetupDiscriminator(request.discriminator) !=
CHIP_NO_ERROR)
{
return pw::Status::Unknown();
}
Expand Down
4 changes: 4 additions & 0 deletions examples/lighting-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,7 @@ idf_component_register(PRIV_INCLUDE_DIRS

set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
target_compile_options(${COMPONENT_LIB} PRIVATE "-DLWIP_IPV6_SCOPES=0" "-DCHIP_HAVE_CONFIG_H")
target_compile_options(${COMPONENT_LIB} PUBLIC
"-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=<lib/address_resolve/AddressResolve_DefaultImpl.h>"
)

18 changes: 18 additions & 0 deletions examples/lighting-app/nxp/k32w/k32w0/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ import("${k32w0_sdk_build_root}/k32w0_executable.gni")
import("${k32w0_sdk_build_root}/k32w0_sdk.gni")

import("${chip_root}/src/crypto/crypto.gni")
import("${chip_root}/src/lib/core/core.gni")
import("${chip_root}/src/platform/device.gni")

if (chip_pw_tokenizer_logging) {
import("//build_overrides/pigweed.gni")
import("$dir_pw_tokenizer/database.gni")
}

assert(current_os == "freertos")

k32w0_platform_dir = "${chip_root}/examples/platform/nxp/k32w/k32w0"
Expand Down Expand Up @@ -105,8 +111,20 @@ k32w0_executable("light_app") {
output_dir = root_out_dir
}

if (chip_pw_tokenizer_logging) {
pw_tokenizer_database("light_app.database") {
database = "$root_build_dir/chip-k32w061-light-example-database.bin"
create = "binary"
deps = [ ":light_app" ]
optional_paths = [ "$root_build_dir/chip-k32w061-light-example" ]
}
}

group("k32w0") {
deps = [ ":light_app" ]
if (chip_pw_tokenizer_logging) {
deps += [ ":light_app.database" ]
}
}

group("default") {
Expand Down
71 changes: 71 additions & 0 deletions examples/lighting-app/nxp/k32w/k32w0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ network.
- [Building](#building)
- [Flashing and debugging](#flashdebug)
- [Testing the example](#testing-the-example)
- [Pigweed Tokenizer](#tokenizer)
- [Detokenizer script](#detokenizer)
- [Notes](#detokenizer-notes)
- [Known issues](#detokenizer-known-issues)

<hr>

Expand Down Expand Up @@ -228,3 +232,70 @@ The app can be deployed against any generic OpenThread Border Router. See the
guide
[Commissioning NXP K32W using Android CHIPTool](../../../docs/guides/nxp_k32w_android_commissioning.md)
for step-by-step instructions.

<a name="tokenizer"></a>

## Pigweed tokenizer

The tokenizer is a pigweed module that allows hashing the strings. This greatly
reduces the flash needed for logs. The module can be enabled by building with
the gn argument _chip_pw_tokenizer_logging=true_. The detokenizer script is
needed for parsing the hashed scripts.

<a name="detokenizer"></a>

### Detokenizer script

The python3 script detokenizer.py is a script that decodes the tokenized logs
either from a file or from a serial port. The script can be used in the
following ways:

```
usage: detokenizer.py serial [-h] -i INPUT -d DATABASE [-o OUTPUT]
usage: detokenizer.py file [-h] -i INPUT -d DATABASE -o OUTPUT
```

The first parameter is either _serial_ or _file_ and it selects between decoding
from a file or from a serial port.

The second parameter is _-i INPUT_ and it must se set to the path of the file or
the serial to decode from.

The third parameter is _-d DATABASE_ and represents the path to the token
database to be used for decoding. The default path is
_out/debug/chip-k32w061-light-example-database.bin_ after a successful build.

The forth parameter is _-o OUTPUT_ and it represents the path to the output file
where the decoded logs will be stored. This parameter is required for file usage
and optional for serial usage. If not provided when used with serial port, it
will show the decoded log only at the stdout and not save it to file.

<a name="detokenizer-notes"></a>

### Notes

The token database is created automatically after building the binary if the
argument _chip_pw_tokenizer_logging=true_ was used.

The detokenizer script must be run inside the example's folder after a
successful run of the _scripts/activate.sh_ script. The pw_tokenizer module used
by the script is loaded by the environment.

<a name="detokenizer-known-issues"></a>

### Known issues

The building process will not update the token database if it already exists. In
case that new strings are added and the database already exists in the output
folder, it must be deleted so that it will be recreated at the next build.

Not all tokens will be decoded. This is due to a gcc/pw_tokenizer issue. The
pw_tokenizer creates special elf sections using attributes where the tokens and
strings will be stored. This sections will be used by the database creation
script. For template C++ functions, gcc ignores these attributes and places all
the strings by default in the .rodata section. As a result the database creation
script won't find them in the special-created sections.

If run, closed and rerun with the serial option on the same serial port, the
detokenization script will get stuck and not show any logs. The solution is to
unplug and plug the board and then rerun the script.
Loading

0 comments on commit cab0354

Please sign in to comment.