diff --git a/.github/workflows/examples-cc13x2x7_26x2x7.yaml b/.github/workflows/examples-cc13x2x7_26x2x7.yaml index 26d8caad09da2b..fec23e0bb9274b 100644 --- a/.github/workflows/examples-cc13x2x7_26x2x7.yaml +++ b/.github/workflows/examples-cc13x2x7_26x2x7.yaml @@ -106,6 +106,13 @@ jobs: cc13x2_26x2 LP_CC2652R7 all-clusters-app \ out/artifacts/cc13x2x7_26x2x7-all-clusters/chip-LP_CC2652R7-all-clusters-example.out \ /tmp/bloat_reports/ + - name: Get Shell App size stats + timeout-minutes: 5 + run: | + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + cc13x2_26x2 LP_CC2652R7 shell \ + out/artifacts/cc13x2x7_26x2x7-shell/chip-LP_CC2652R7-shell-example.out \ + /tmp/bloat_reports/ - name: Uploading Size Reports uses: actions/upload-artifact@v2 if: ${{ !env.ACT }} diff --git a/examples/all-clusters-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h b/examples/all-clusters-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h index 35977ee29593fa..a7d7e9beb24e73 100644 --- a/examples/all-clusters-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h +++ b/examples/all-clusters-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h @@ -87,6 +87,8 @@ */ #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512) +#define MATTER_CC13X2_26X2_PLATFORM_LOG_ENABLED 1 + /** * CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT * diff --git a/examples/lock-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h b/examples/lock-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h index f6e0a88b752edb..41408256519952 100644 --- a/examples/lock-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h +++ b/examples/lock-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h @@ -89,6 +89,8 @@ */ #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512) +#define MATTER_CC13X2_26X2_PLATFORM_LOG_ENABLED 1 + /** * CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT * diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h b/examples/pump-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h index 06dbef7ace465e..72cf56e6c06545 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h +++ b/examples/pump-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h @@ -82,6 +82,8 @@ */ #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512) +#define MATTER_CC13X2_26X2_PLATFORM_LOG_ENABLED 1 + /** * CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT * diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h index 3302d966457c7c..9eb1e8a7fb05de 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h @@ -82,6 +82,8 @@ */ #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512) +#define MATTER_CC13X2_26X2_PLATFORM_LOG_ENABLED 1 + /** * CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT * diff --git a/examples/shell/cc13x2x7_26x2x7/.gn b/examples/shell/cc13x2x7_26x2x7/.gn new file mode 100644 index 00000000000000..540d01ce0b2bfd --- /dev/null +++ b/examples/shell/cc13x2x7_26x2x7/.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2022 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("//build_overrides/build.gni") + +# The location of the build configuration file. +buildconfig = "${build_root}/config/BUILDCONFIG.gn" + +# CHIP uses angle bracket includes. +check_system_includes = true + +default_args = { + target_cpu = "arm" + target_os = "freertos" + + import("//args.gni") +} diff --git a/examples/shell/cc13x2x7_26x2x7/BUILD.gn b/examples/shell/cc13x2x7_26x2x7/BUILD.gn new file mode 100644 index 00000000000000..6f2a97d401f582 --- /dev/null +++ b/examples/shell/cc13x2x7_26x2x7/BUILD.gn @@ -0,0 +1,120 @@ +# Copyright (c) 2022 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("//build_overrides/build.gni") +import("//build_overrides/chip.gni") +import("//build_overrides/openthread.gni") +import("//build_overrides/ti_simplelink_sdk.gni") + +import("${build_root}/config/defaults.gni") + +import("${chip_root}/src/platform/device.gni") + +import("${ti_simplelink_sdk_build_root}/ti_simplelink_executable.gni") +import("${ti_simplelink_sdk_build_root}/ti_simplelink_sdk.gni") + +assert(current_os == "freertos") + +ti_simplelink_sdk("sdk") { + include_dirs = [ "include" ] + + defines = [] +} + +ti_sysconfig("sysconfig") { + sources = [ "chip.syscfg" ] + + outputs = [ + "ti_radio_config.c", + "ti_radio_config.h", + "ti_drivers_config.c", + "ti_drivers_config.h", + "ti_ble_config.c", + "ti_ble_config.h", + "ti_dmm_application_policy.c", + "ti_dmm_application_policy.h", + + # disabled until upstream generation is aligned + #"tiop_config.h", + #"tiop_config.c", + + # not traditional source files + #"ti_utils_build_linker.cmd.genlibs", + #"syscfg_c.rov.xs", + #"ti_utils_runtime_model.gv", + #"ti_utils_runtime_Makefile", + #"ti_ble_app_config.opt", + #"ti_build_config.opt", + ] + + public_configs = [ ":sdk_dmm_config" ] + + cflags = [ + "-Wno-comment", + "@" + rebase_path("${target_gen_dir}/sysconfig/ti_ble_app_config.opt", + root_build_dir), + "@" + rebase_path("${target_gen_dir}/sysconfig/ti_build_config.opt", + root_build_dir), + ] +} + +ti_simplelink_executable("shell_app") { + output_name = "chip-${ti_simplelink_board}-shell-example.out" + + sources = [ + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", + "main/AppTask.cpp", + "main/main.cpp", + ] + + deps = [ + ":sdk", + ":sysconfig", + "${chip_root}/examples/all-clusters-app/all-clusters-common", + "${chip_root}/examples/shell/shell_common:shell_common", + "${chip_root}/src/lib", + "${chip_root}/src/lib/shell:shell", + "${chip_root}/src/setup_payload", + ] + + if (chip_openthread_ftd) { + deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-ftd" ] + } else { + deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-mtd" ] + } + + include_dirs = [ + "include", + "main", + "${chip_root}/examples/all-clusters-app/all-clusters-common/include", + ] + + cflags = [ + "-Wno-implicit-fallthrough", + "-Wno-sign-compare", + "-Wconversion", + ] + + output_dir = root_out_dir +} + +group("cc13x2x7_26x2x7") { + deps = [ ":shell_app" ] +} + +group("default") { + deps = [ ":cc13x2x7_26x2x7" ] +} diff --git a/examples/shell/cc13x2x7_26x2x7/README.md b/examples/shell/cc13x2x7_26x2x7/README.md new file mode 100644 index 00000000000000..4b42e5b6ac5eea --- /dev/null +++ b/examples/shell/cc13x2x7_26x2x7/README.md @@ -0,0 +1,169 @@ +# Matter CC1352 CC2652 Shell Application + +A [chip-shell](../README.md) project on the Texas Instruments CC13X2_26X2 family +of Wireless MCUs. + +## Building + +### Preparation + +Some initial setup is necessary for preparing the build environment. This +section will need to be done when migrating to new versions of the SDK. This +guide assumes that the environment is linux based, and recommends Ubuntu 20.04. + +- Download and install [SysConfig][sysconfig] ([recommended + version][sysconfig_recommended]). This can be done simply with the following + commands. + + ``` + $ cd ~ + $ wget https://software-dl.ti.com/ccs/esd/sysconfig/sysconfig-1.11.0_2225-setup.run + $ chmod +x sysconfig-1.11.0_2225-setup.run + $ ./sysconfig-1.11.0_2225-setup.run + ``` + +- Run the bootstrap script to setup the build environment. + + ``` + $ cd ~/connectedhomeip + $ source ./scripts/bootstrap.sh + + ``` + +### Compilation + +It is necessary to activate the environment in every new shell. Then run GN and +Ninja to build the executable. + +- Activate the build environment with the repository activate script. + + ``` + $ cd ~/connectedhomeip + $ source ./scripts/activate.sh + + ``` + +- Run the build to produce a default executable. By default on Linux both the + TI SimpleLink SDK and Sysconfig are located in a `ti` folder in the user's + home directory, and you must provide the absolute path to them. For example + `/home/username/ti/sysconfig_1.11.0`. On Windows the default directory is + `C:\ti`. Take note of this install path, as it will be used in the next + step. + + ``` + $ cd ~/connectedhomeip/examples/all-clusters-app/cc13x2x7_26x2x7 + $ gn gen out/debug --args="ti_sysconfig_root=\"$HOME/ti/sysconfig_1.11.0\"" + $ ninja -C out/debug + + ``` + +## Programming + +Loading the built image onto a LaunchPad is supported through two methods; +Uniflash and Code Composer Studio (CCS). UniFlash can be used to load the image. +Code Composer Studio can be used to load the image and debug the source code. + +### Code Composer Studio + +Programming with CCS will allow for a full debug environment within the IDE. +This is accomplished by creating a target connection to the XDS110 debugger and +starting a project-less debug session. The CCS IDE will attempt to find the +source files on the local machine based on the debug information embedded within +the ELF. CCS may prompt you to find the source code if the image was built on +another machine or the source code is located in a different location than is +recorded within the ELF. + +Download and install [Code Composer Studio][ccs]. + +First open CCS and create a new workspace. + +Create a target connection (sometimes called the CCXML) for your target SoC and +debugger as described in the [Manual Method][ccs_manual_method] section of the +CCS User's Guide. + +Next initiate a project-less debug session as described in the [Manual +Launch][ccs_manual_launch] section of the CCS User's Guide. + +CCS should switch to the debug view described in the [After +Launch][ccs_after_launch] section of the User's Guide. The SoC core will likely +be disconnected and symbols will not be loaded. Connect to the core as described +in the [Debug View][ccs_debug_view] section of the User's Guide. Once the core +is connected, use the `Load` button on the toolbar to load the ELF image. + +Note that the default configuration of the CCXML uses 2-wire cJTAG instead of +the full 4-wire JTAG connection to match the default jumper configuration of the +LaunchPad. + +### UniFlash + +Uniflash is Texas Instrument's uniform programming tool for embedded processors. +This will allow you to erase, flash, and inspect the SoC without setting up a +debugging environment. + +Download and install [UniFlash][uniflash]. + +First open UniFlash. Debug probes connected to the computer will usually be +displayed under the Detected Devices due to the automatic device detection +feature. If your device does not show up in this view it my be disconnected, or +you may have to create a New Configuration. If you already have a CCXML for your +SoC and debug connection you can use that in the section at the bottom. Once +your device is selected, click the `Start` button within the section to launch +the session. + +Select the ELF image to load on the device with the `Browse` button. This file +is placed in the `out/debug` folder by this guide and ends with the `*.out` file +extension. + +Finally click the `Load Image` button to load the executable image onto the +device. You should be able to see the log output over the XDS110 User UART. + +Note that programming the device through JTAG sets the Halt-in-Boot flag and may +cause issues when performing a software reset. This flag can be reset by +power-cycling the LaunchPad. + +## Running the Example + +By default the log output will be sent to the Application/User UART. Open a +terminal emulator to that port to see the output with the following options: + +| Parameter | Value | +| ------------ | -------- | +| Speed (baud) | `115200` | +| Data bits | `8` | +| Stop bits | `1` | +| Parity | `None` | +| Flow control | `None` | + +## Running the Example + +Once a device has been flashed with this example, it can now join and operate in +an existing Thread network. The following sections assume that a Thread network +is already active, and has at least one [OpenThread Border +Router][ot_border_router_setup]. + +For insight into what other components are needed to run this example, please +refer to our [Matter Getting Started Guide][matter-e2e-faq]. + +For help with the shell itself, refer to the +[shell example README](../README.md). + +## TI Support + +For technical support, please consider creating a post on TI's [E2E forum][e2e]. +Additionally, we welcome any feedback. + +[ccs]: https://www.ti.com/tool/CCSTUDIO +[ccs_after_launch]: + https://software-dl.ti.com/ccs/esd/documents/users_guide/ccs_debug-main.html?configuration#after-launch +[ccs_debug_view]: + https://software-dl.ti.com/ccs/esd/documents/users_guide/ccs_debug-main.html?configuration#debug-view +[ccs_manual_launch]: + https://software-dl.ti.com/ccs/esd/documents/users_guide/ccs_debug-main.html?configuration#manual-launch +[ccs_manual_method]: + https://software-dl.ti.com/ccs/esd/documents/users_guide/ccs_debug-main.html?configuration#manual-method +[e2e]: https://e2e.ti.com/support/wireless-connectivity/zigbee-and-thread +[sysconfig]: https://www.ti.com/tool/SYSCONFIG +[sysconfig_recommended]: + https://software-dl.ti.com/ccs/esd/sysconfig/sysconfig-1.10.0_2163-setup.run +[ti_cc13x2_26x2_r7_matter_request]: https://ti.com/chip_sdk +[uniflash]: https://www.ti.com/tool/download/UNIFLASH diff --git a/examples/shell/cc13x2x7_26x2x7/args.gni b/examples/shell/cc13x2x7_26x2x7/args.gni new file mode 100644 index 00000000000000..fabd6f02341f04 --- /dev/null +++ b/examples/shell/cc13x2x7_26x2x7/args.gni @@ -0,0 +1,50 @@ +# Copyright (c) 2022 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("//build_overrides/chip.gni") +import("${chip_root}/examples/platform/cc13x2_26x2/args.gni") + +ti_simplelink_sdk_target = get_label_info(":sdk", "label_no_toolchain") +ti_simplelink_sysconfig_target = + get_label_info(":sysconfig", "label_no_toolchain") + +ti_simplelink_board = "LP_CC2652R7" + +# Size Optimizations +# use -Os instead of -Og, LWIP release build +is_debug = false + +chip_enable_ota_requestor = true + +# Disable FTD Build for all-clusters app to save Flash +chip_openthread_ftd = false + +# Disable CHIP Logging +chip_progress_logging = false +chip_detail_logging = false +chip_automation_logging = false + +# BLE options +chip_config_network_layer_ble = true + +chip_build_libshell = true + +# Disable lock tracking, since our FreeRTOS configuration does not set +# INCLUDE_xSemaphoreGetMutexHolder +chip_stack_lock_tracking = "none" + +matter_device_vid = "0xFFF1" +matter_device_pid = "0x8006" +matter_software_ver = "0x0001" +matter_software_ver_str = "1.0d1" diff --git a/examples/shell/cc13x2x7_26x2x7/build_overrides b/examples/shell/cc13x2x7_26x2x7/build_overrides new file mode 120000 index 00000000000000..e578e73312ebd1 --- /dev/null +++ b/examples/shell/cc13x2x7_26x2x7/build_overrides @@ -0,0 +1 @@ +../../build_overrides \ No newline at end of file diff --git a/examples/shell/cc13x2x7_26x2x7/chip.syscfg b/examples/shell/cc13x2x7_26x2x7/chip.syscfg new file mode 100644 index 00000000000000..32701817cf1a0c --- /dev/null +++ b/examples/shell/cc13x2x7_26x2x7/chip.syscfg @@ -0,0 +1,160 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020 Texas Instruments Incorporated + * All rights reserved. + * + * 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. + */ + + + +/* Modules */ +var AESCCM = scripting.addModule("/ti/drivers/AESCCM"); +var AESECB = scripting.addModule("/ti/drivers/AESECB"); +var ECJPAKE = scripting.addModule("/ti/drivers/ECJPAKE"); +var NVS = scripting.addModule("/ti/drivers/NVS"); +var RF = scripting.addModule("/ti/drivers/RF"); +var RFDesign = scripting.addModule("ti/devices/radioconfig/rfdesign"); +var RTOS = scripting.addModule("/ti/drivers/RTOS"); +var TRNG = scripting.addModule("/ti/drivers/TRNG"); +var Thread = scripting.addModule("/ti/thread/thread"); +var SHA2 = scripting.addModule("/ti/drivers/SHA2"); +var UART = scripting.addModule("/ti/drivers/UART"); +var ble = scripting.addModule("/ti/ble5stack/ble"); +var dmm = scripting.addModule("/ti/dmm/dmm"); +var AESCTRDRBG = scripting.addModule("/ti/drivers/AESCTRDRBG"); +var ECDH = scripting.addModule("/ti/drivers/ECDH"); + +/* Instances */ +var AESCCM1 = AESCCM.addInstance(); +var AESECB1 = AESECB.addInstance(); +var AESECB2 = AESECB.addInstance(); +var ECJPAKE = ECJPAKE.addInstance(); +var NVS1 = NVS.addInstance(); +var NVS2 = NVS.addInstance(); +var SHA21 = SHA2.addInstance(); +var TRNG1 = TRNG.addInstance(); +var TRNG2 = TRNG.addInstance(); +var TRNG3 = TRNG.addInstance(); +var UART1 = UART.addInstance(); +var AESCTRDRBG1 = AESCTRDRBG.addInstance(); +var ECDH1 = ECDH.addInstance(); + +AESCTRDRBG1.$name = "CONFIG_AESCTRDRBG_0"; +AESCTRDRBG1.aesctrObject.$name = "CONFIG_AESCTR_0"; + +AESCCM1.$name = "CONFIG_AESCCM0"; + +AESECB1.$name = "CONFIG_AESECB0"; +AESECB2.$name = "CONFIG_AESECB_1"; + +ECDH1.$name = "CONFIG_ECDH0"; + +/* ======== CCFG ======== */ +var CCFG = scripting.addModule("/ti/devices/CCFG"); +const ccfgSettings = system.getScript("/ti/common/lprf_ccfg_settings.js").ccfgSettings; +for(var setting in ccfgSettings) +{ + CCFG[setting] = ccfgSettings[setting]; +} + +// Disable CCFG generation, this is added by the BIM project +CCFG.enableCodeGeneration = false; + +/* NVS */ +NVS1.$name = "CONFIG_NVSINTERNAL"; +NVS1.internalFlash.regionBase = 0xAA000; +NVS1.internalFlash.regionSize = 0x4000; + +NVS2.$name = "CONFIG_NVSEXTERNAL"; +NVS2.nvsType = "External"; // NVS Region Type +NVS2.$hardware = system.deviceData.board.components.MX25R8035F; + +/* RF */ +/* if an antenna component exists, assign it to the rf instance */ +if (system.deviceData.board && system.deviceData.board.components.RF) { + RF.$hardware = system.deviceData.board.components.RF; +} + +const rfDesignSettings = system.getScript("/ti/common/lprf_rf_design_settings.js").rfDesignSettings; +for(var setting in rfDesignSettings) +{ + RFDesign[setting] = rfDesignSettings[setting]; +} + +/* Streamer UART */ +UART1.$hardware = system.deviceData.board.components.XDS110UART; +UART1.$name = "CONFIG_UART_STREAMER"; + +/* TRNG */ +TRNG1.$name = "CONFIG_TRNG_0"; +TRNG2.$name = "CONFIG_TRNG_1"; +TRNG3.$name = "CONFIG_TRNG_APP"; + +RTOS.name = "FreeRTOS"; + +/* BLE */ +ble.addressMode = "ADDRMODE_RP_WITH_PUBLIC_ID"; +ble.maxConnNum = 1; +ble.numOfAdvSets = 1; +ble.lockProject = true; +ble.oneLibSizeOpt = true; +ble.maxPDUSize = 255; +ble.radioConfig.codeExportConfig.$name = "ti_devices_radioconfig_code_export_param1"; +ble.connUpdateParamsPeripheral.$name = "ti_ble5stack_general_ble_conn_update_params0"; +ble.connUpdateParamsPeripheral.reqMinConnInt = 30; +ble.connUpdateParamsPeripheral.reqMaxConnInt = 50; + +ble.advSet1.$name = "ti_ble5stack_broadcaster_advertisement_set0"; +ble.advSet1.advParam1.$name = "ti_ble5stack_broadcaster_advertisement_params0"; +ble.advSet1.advParam1.primIntMin = 100; +ble.advSet1.advParam1.primIntMax = 200; + +/* DMM */ +dmm.project = "ti_thread_thermostat_remote_display"; +dmm.stackRoles = ["blePeripheral","threadFTD"]; +dmm.lockStackRoles = true; +dmm.numApplicationStates = 10; +dmm.applicationState0 = "ANY"; +dmm.applicationState1 = "DMMPOLICY_BLE_IDLE"; +dmm.applicationState2 = "DMMPOLICY_BLE_ADV"; +dmm.applicationState3 = "DMMPOLICY_BLE_CONNECTING"; +dmm.applicationState4 = "DMMPOLICY_BLE_HIGH_BANDWIDTH"; +dmm.applicationState5 = "DMMPOLICY_BLE_CONNECTED"; +dmm.applicationState6 = "DMMPOLICY_BLE_OAD"; +dmm.applicationState7 = "DMMPOLICY_THREAD_IDLE"; +dmm.applicationState8 = "DMMPOLICY_THREAD_LINK_EST"; +dmm.applicationState9 = "DMMPOLICY_THREAD_DATA"; +dmm.policyArray.create(4); +dmm.policyArray[0].$name = "ti_dmm_policy_dmm_policy0"; +dmm.policyArray[0].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble0"; +dmm.policyArray[0].blePeripheral.applicationStates = ["applicationState6"]; +dmm.policyArray[0].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread0"; +dmm.policyArray[0].threadFTD.pause = "DMMPOLICY_PAUSED"; +dmm.policyArray[1].$name = "ti_dmm_policy_dmm_policy1"; +dmm.policyArray[1].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble1"; +dmm.policyArray[1].blePeripheral.applicationStates = ["applicationState3","applicationState4"]; +dmm.policyArray[1].blePeripheral.weight = 25; +dmm.policyArray[1].blePeripheral.appliedActivity = ["DMMPOLICY_APPLIED_ACTIVITY_BLE_CONNECTION"]; +dmm.policyArray[1].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread1"; +dmm.policyArray[2].$name = "ti_dmm_policy_dmm_policy2"; +dmm.policyArray[2].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble2"; +dmm.policyArray[2].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread2"; +dmm.policyArray[2].threadFTD.weight = 30; +dmm.policyArray[2].threadFTD.applicationStates = ["applicationState8"]; +dmm.policyArray[2].threadFTD.appliedActivity = ["DMMPOLICY_APPLIED_ACTIVITY_ALL"]; +dmm.policyArray[3].$name = "ti_dmm_policy_dmm_policy3"; +dmm.policyArray[3].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble3"; +dmm.policyArray[3].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread3"; +dmm.policyArray[3].threadFTD.weight = 1; diff --git a/examples/shell/cc13x2x7_26x2x7/include/AppTask.h b/examples/shell/cc13x2x7_26x2x7/include/AppTask.h new file mode 100644 index 00000000000000..3fe4f972427717 --- /dev/null +++ b/examples/shell/cc13x2x7_26x2x7/include/AppTask.h @@ -0,0 +1,47 @@ +/* + * + * Copyright (c) 2022 Texas Instruments Incorporated + * All rights reserved. + * + * 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. + */ + +#pragma once + +#include +#include + +#include "FreeRTOS.h" +#include "semphr.h" +#include "task.h" + +#include + +class AppTask +{ +public: + CHIP_ERROR StartAppTask(); + static void AppTaskMain(void * pvParameter); + +private: + friend AppTask & GetAppTask(void); + + CHIP_ERROR Init(); + + static AppTask sAppTask; +}; + +inline AppTask & GetAppTask(void) +{ + return AppTask::sAppTask; +} diff --git a/examples/shell/cc13x2x7_26x2x7/include/CHIPProjectConfig.h b/examples/shell/cc13x2x7_26x2x7/include/CHIPProjectConfig.h new file mode 100644 index 00000000000000..10f39015f988f7 --- /dev/null +++ b/examples/shell/cc13x2x7_26x2x7/include/CHIPProjectConfig.h @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2022 Texas Instruments Incorporated + * All rights reserved. + * + * 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. + */ + +/** + * @file + * Example project configuration file for CHIP. + * + * This is a place to put application or project-specific overrides + * to the default configuration values for general CHIP features. + * + */ + +#pragma once + +// Use a default pairing code if one hasn't been provisioned in flash. +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 + +// Use a default pairing code if one hasn't been provisioned in flash. +#define CHIP_DEVICE_CONFIG_USE_TEST_PAIRING_CODE "CHIPUS" + +/** + * CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER + * + * Enables the use of a hard-coded default serial number if none + * is found in CHIP NV storage. + */ +#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN" + +/** + * CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION + * + * The hardware version number assigned to device or product by the device vendor. This + * number is scoped to the device product id, and typically corresponds to a revision of the + * physical device, a change to its packaging, and/or a change to its marketing presentation. + * This value is generally *not* incremented for device software versions. + */ +#ifndef CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION +#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1 +#endif + +/** + * Values set by args.gni: + * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID + * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID + * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING + * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION + */ + +/** + * CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE + * + * Enable support for CHIP-over-BLE (CHIPOBLE). + */ +#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 1 + +/** + * CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC + * + * Enables synchronizing the device's real time clock with a remote CHIP Time service + * using the CHIP Time Sync protocol. + */ +//#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1 + +/** + * CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE + * + * A size, in bytes, of the individual debug event logging buffer. + */ +#define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512) + +#define MATTER_CC13X2_26X2_PLATFORM_LOG_ENABLED 0 + +/** + * CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + * + * Enable the OpenThread SRP client to allow for CHIP device discovery. + */ +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 1 + +/** + * CHIP_CONFIG_EVENT_LOGGING_DEFAULT_IMPORTANCE + * + * For a development build, set the default importance of events to be logged as Debug. + * Since debug is the lowest importance level, this means all standard, critical, info and + * debug importance level vi events get logged. + */ +#if BUILD_RELEASE +#define CHIP_CONFIG_EVENT_LOGGING_DEFAULT_IMPORTANCE chip::Profiles::DataManagement::Production +#else +#define CHIP_CONFIG_EVENT_LOGGING_DEFAULT_IMPORTANCE chip::Profiles::DataManagement::Debug +#endif // BUILD_RELEASE + +#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 + +/** + * @def CHIP_IM_MAX_NUM_COMMAND_HANDLER + * + * @brief Defines the maximum number of CommandHandler, limits the number of active commands transactions on server. + */ +#define CHIP_IM_MAX_NUM_COMMAND_HANDLER 2 + +/** + * @def CHIP_IM_MAX_NUM_WRITE_HANDLER + * + * @brief Defines the maximum number of WriteHandler, limits the number of active write transactions on server. + */ +#define CHIP_IM_MAX_NUM_WRITE_HANDLER 2 diff --git a/examples/shell/cc13x2x7_26x2x7/include/OpenThreadConfig.h b/examples/shell/cc13x2x7_26x2x7/include/OpenThreadConfig.h new file mode 100644 index 00000000000000..2c37beedb2b2db --- /dev/null +++ b/examples/shell/cc13x2x7_26x2x7/include/OpenThreadConfig.h @@ -0,0 +1,28 @@ +/* + * + * Copyright (c) 2022 Texas Instruments Incorporated + * All rights reserved. + * + * 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. + */ + +/** + * @file + * Overrides to default OpenThread configuration. + * + */ + +#pragma once + +// Use the TI-supplied default platform configuration for remainder +#include "openthread-core-cc13x2_26x2-config.h" diff --git a/examples/shell/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/shell/cc13x2x7_26x2x7/main/AppTask.cpp new file mode 100644 index 00000000000000..d47e99de140931 --- /dev/null +++ b/examples/shell/cc13x2x7_26x2x7/main/AppTask.cpp @@ -0,0 +1,166 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * Copyright (c) 2020 Texas Instruments Incorporated + * All rights reserved. + * + * 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. + */ + +#include "AppTask.h" +#include +#include + +#include "FreeRTOS.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/* syscfg */ +#include + +#define APP_TASK_STACK_SIZE (4096) +#define APP_TASK_PRIORITY 4 + +using namespace ::chip; +using namespace ::chip::Credentials; +using namespace ::chip::DeviceLayer; +using chip::Shell::Engine; + +AppTask AppTask::sAppTask; + +static TaskHandle_t sAppTaskHandle; + +// Logging +extern "C" { +int cc13x2_26x2LogInit(void); +} + +static DefaultOTARequestor sRequestorCore; +static DefaultOTARequestorStorage sRequestorStorage; +static DefaultOTARequestorDriver sRequestorUser; +static BDXDownloader sDownloader; +static OTAImageProcessorImpl sImageProcessor; + +void InitializeOTARequestor(void) +{ + // Initialize and interconnect the Requestor and Image Processor objects + SetRequestorInstance(&sRequestorCore); + + sRequestorStorage.Init(Server::GetInstance().GetPersistentStorage()); + sRequestorCore.Init(Server::GetInstance(), sRequestorStorage, sRequestorUser, sDownloader); + sImageProcessor.SetOTADownloader(&sDownloader); + sDownloader.SetImageProcessorDelegate(&sImageProcessor); + sRequestorUser.Init(&sRequestorCore, &sImageProcessor); +} + +CHIP_ERROR AppTask::StartAppTask() +{ + CHIP_ERROR err = CHIP_NO_ERROR; + + // Start App task. + if (xTaskCreate(AppTaskMain, "APP", APP_TASK_STACK_SIZE / sizeof(StackType_t), NULL, APP_TASK_PRIORITY, &sAppTaskHandle) != + pdPASS) + { + while (1) + ; + } + + return err; +} + +CHIP_ERROR AppTask::Init() +{ + CHIP_ERROR err = CHIP_NO_ERROR; + + cc13x2_26x2LogInit(); + + // Init Chip memory management before the stack + Platform::MemoryInit(); + + Engine::Root().Init(); + + CHIP_ERROR ret = PlatformMgr().InitChipStack(); + if (ret != CHIP_NO_ERROR) + { + while (1) + ; + } + + ret = ThreadStackMgr().InitThreadStack(); + if (ret != CHIP_NO_ERROR) + { + while (1) + ; + } + + ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); + if (ret != CHIP_NO_ERROR) + { + while (1) + ; + } + + ret = PlatformMgr().StartEventLoopTask(); + if (ret != CHIP_NO_ERROR) + { + while (1) + ; + } + + ret = ThreadStackMgrImpl().StartThreadTask(); + if (ret != CHIP_NO_ERROR) + { + while (1) + ; + } + + // Init ZCL Data Model and start server + static chip::CommonCaseDeviceServerInitParams initParams; + (void) initParams.InitializeStaticResourcesBeforeServerInit(); + chip::Server::GetInstance().Init(initParams); + + // Initialize device attestation config + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); + + InitializeOTARequestor(); + + return err; +} + +void AppTask::AppTaskMain(void * pvParameter) +{ + CHIP_ERROR err = sAppTask.Init(); + if (err != CHIP_NO_ERROR) + { + while (1) + ; + } + + Engine::Root().RunMainLoop(); +} diff --git a/examples/shell/cc13x2x7_26x2x7/main/main.cpp b/examples/shell/cc13x2x7_26x2x7/main/main.cpp new file mode 100644 index 00000000000000..600b67a3fe4ecf --- /dev/null +++ b/examples/shell/cc13x2x7_26x2x7/main/main.cpp @@ -0,0 +1,101 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * Copyright (c) 2020 Texas Instruments Incorporated + * + * 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. + */ + +#include +#include + +#include + +#include + +#include + +/* Driver Header files */ +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#define TOTAL_ICALL_HEAP_SIZE (0xc800) + +using namespace ::chip; +using namespace ::chip::Inet; +using namespace ::chip::DeviceLayer; + +__attribute__((section(".heap"))) uint8_t GlobalHeapZoneBuffer[TOTAL_ICALL_HEAP_SIZE]; +uint32_t heapSize = TOTAL_ICALL_HEAP_SIZE; + +// ================================================================================ +// FreeRTOS Callbacks +// ================================================================================ +extern "C" void vApplicationStackOverflowHook(void) +{ + while (1) + { + ; + } +} + +// ================================================================================ +// Main Code +// ================================================================================ +int main(void) +{ + CHIP_ERROR err; + + Board_init(); + bpool((void *) GlobalHeapZoneBuffer, TOTAL_ICALL_HEAP_SIZE); + + GPIO_init(); + + NVS_init(); + + UART_init(); + + ECDH_init(); + + ECDSA_init(); + + ECJPAKE_init(); + + AESECB_init(); + + SHA2_init(); + + err = GetAppTask().StartAppTask(); + if (err != CHIP_NO_ERROR) + { + // can't log until the kernel is started + // PLAT_LOG("GetAppTask().StartAppTask() failed"); + while (1) + ; + } + + vTaskStartScheduler(); + + // Should never get here. + while (1) + ; +} diff --git a/examples/shell/cc13x2x7_26x2x7/third_party/connectedhomeip b/examples/shell/cc13x2x7_26x2x7/third_party/connectedhomeip new file mode 120000 index 00000000000000..c866b86874994d --- /dev/null +++ b/examples/shell/cc13x2x7_26x2x7/third_party/connectedhomeip @@ -0,0 +1 @@ +../../../.. \ No newline at end of file diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index da0d39837ceb7e..b6ee9a58d141d9 100644 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -492,6 +492,7 @@ def cc13x2x7_26x2x7Targets(): yield target.Extend('pump', app=cc13x2x7_26x2x7App.PUMP) yield target.Extend('pump-controller', app=cc13x2x7_26x2x7App.PUMP_CONTROLLER) yield target.Extend('all-clusters', app=cc13x2x7_26x2x7App.ALL_CLUSTERS) + yield target.Extend('shell', app=cc13x2x7_26x2x7App.SHELL) def Cyw30739Targets(): diff --git a/scripts/build/builders/cc13x2x7_26x2x7.py b/scripts/build/builders/cc13x2x7_26x2x7.py index 125653bf6b5cee..80afb5d66ce54f 100644 --- a/scripts/build/builders/cc13x2x7_26x2x7.py +++ b/scripts/build/builders/cc13x2x7_26x2x7.py @@ -23,6 +23,7 @@ class cc13x2x7_26x2x7App(Enum): PUMP = auto() PUMP_CONTROLLER = auto() ALL_CLUSTERS = auto() + SHELL = auto() def ExampleName(self): if self == cc13x2x7_26x2x7App.LOCK: @@ -33,6 +34,8 @@ def ExampleName(self): return 'pump-controller-app' elif self == cc13x2x7_26x2x7App.ALL_CLUSTERS: return 'all-clusters-app' + elif self == cc13x2x7_26x2x7App.SHELL: + return 'shell' else: raise Exception('Unknown app type: %r' % self) @@ -45,6 +48,8 @@ def AppNamePrefix(self): return 'chip-LP_CC2652R7-pump-controller-example' elif self == cc13x2x7_26x2x7App.ALL_CLUSTERS: return 'chip-LP_CC2652R7-all-clusters-example' + elif self == cc13x2x7_26x2x7App.SHELL: + return 'chip-LP_CC2652R7-shell-example' else: raise Exception('Unknown app type: %r' % self) diff --git a/scripts/build/testdata/all_targets_except_host.txt b/scripts/build/testdata/all_targets_except_host.txt index a97608af99fef6..4da893bf329f05 100644 --- a/scripts/build/testdata/all_targets_except_host.txt +++ b/scripts/build/testdata/all_targets_except_host.txt @@ -22,6 +22,7 @@ cc13x2x7_26x2x7-lock-ftd cc13x2x7_26x2x7-lock-mtd cc13x2x7_26x2x7-pump cc13x2x7_26x2x7-pump-controller +cc13x2x7_26x2x7-shell cyw30739-cyw930739m2evb_01-light cyw30739-cyw930739m2evb_01-lock cyw30739-cyw930739m2evb_01-ota-requestor (NOGLOB: Running out of XIP flash space) diff --git a/scripts/build/testdata/build_all_except_host.txt b/scripts/build/testdata/build_all_except_host.txt index 1a7820ebc89b7f..4f997c533a1e58 100644 --- a/scripts/build/testdata/build_all_except_host.txt +++ b/scripts/build/testdata/build_all_except_host.txt @@ -163,6 +163,9 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa # Generating cc13x2x7_26x2x7-pump-controller gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/pump-controller-app/cc13x2x7_26x2x7 '--args=ti_sysconfig_root="TEST_TI_SYSCONFIG_ROOT"' {out}/cc13x2x7_26x2x7-pump-controller +# Generating cc13x2x7_26x2x7-shell +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/shell/cc13x2x7_26x2x7 '--args=ti_sysconfig_root="TEST_TI_SYSCONFIG_ROOT"' {out}/cc13x2x7_26x2x7-shell + # Generating cyw30739-cyw930739m2evb_01-light gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/cyw30739 {out}/cyw30739-cyw930739m2evb_01-light @@ -1259,6 +1262,9 @@ ninja -C {out}/cc13x2x7_26x2x7-pump # Building cc13x2x7_26x2x7-pump-controller ninja -C {out}/cc13x2x7_26x2x7-pump-controller +# Building cc13x2x7_26x2x7-shell +ninja -C {out}/cc13x2x7_26x2x7-shell + # Building cyw30739-cyw930739m2evb_01-light ninja -C {out}/cyw30739-cyw930739m2evb_01-light diff --git a/scripts/build/testdata/glob_star_targets_except_host.txt b/scripts/build/testdata/glob_star_targets_except_host.txt index 8783e163a04bf8..beb0d999fb0011 100644 --- a/scripts/build/testdata/glob_star_targets_except_host.txt +++ b/scripts/build/testdata/glob_star_targets_except_host.txt @@ -22,6 +22,7 @@ cc13x2x7_26x2x7-lock-ftd cc13x2x7_26x2x7-lock-mtd cc13x2x7_26x2x7-pump cc13x2x7_26x2x7-pump-controller +cc13x2x7_26x2x7-shell cyw30739-cyw930739m2evb_01-light cyw30739-cyw930739m2evb_01-lock cyw30739-cyw930739m2evb_01-ota-requestor-no-progress-logging diff --git a/src/lib/shell/BUILD.gn b/src/lib/shell/BUILD.gn index 622645279600dc..c1e1de92b25f85 100644 --- a/src/lib/shell/BUILD.gn +++ b/src/lib/shell/BUILD.gn @@ -79,6 +79,11 @@ static_library("shell") { "MainLoopDefault.cpp", "streamer_bl602.cpp", ] + } else if (chip_device_platform == "cc13x2_26x2") { + sources += [ + "MainLoopDefault.cpp", + "streamer_cc13x2_26x2.cpp", + ] } else { sources += [ "MainLoopDefault.cpp" ] } diff --git a/src/lib/shell/streamer_cc13x2_26x2.cpp b/src/lib/shell/streamer_cc13x2_26x2.cpp new file mode 100644 index 00000000000000..7e5aeeb57b0169 --- /dev/null +++ b/src/lib/shell/streamer_cc13x2_26x2.cpp @@ -0,0 +1,111 @@ +/* + * + * Copyright (c) 2022 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. + */ + +/** + * @file + * Source implementation of an input / output stream for cc13x2_26x2 targets + */ + +#include "streamer.h" +#include +#include +#include +#include + +#include "ti_drivers_config.h" + +#include + +namespace chip { +namespace Shell { + +#ifndef SHELL_STREAMER_APP_SPECIFIC + +UART_Handle sStreamUartHandle = NULL; + +#if !MATTER_CC13X2_26X2_PLATFORM_LOG_ENABLED +extern "C" int cc13x2_26x2LogInit(void) +{ + return 0; +} + +extern "C" void cc13x2_26x2VLog(const char * msg, va_list v) +{ + if (NULL != sStreamUartHandle) + { + static char sDebugUartBuffer[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE]; + size_t ret; + + ret = vsnprintf(sDebugUartBuffer, sizeof(sDebugUartBuffer), msg, v); + if (0 < ret) + { + // PuTTY likes \r\n + size_t len = (ret + 2U) < sizeof(sDebugUartBuffer) ? (ret + 2) : sizeof(sDebugUartBuffer); + sDebugUartBuffer[len - 2] = '\r'; + sDebugUartBuffer[len - 1] = '\n'; + + UART_write(sStreamUartHandle, sDebugUartBuffer, len); + } + } +} +#endif // !MATTER_CC13X2_26X2_PLATFORM_LOG_ENABLED + +int streamer_cc13x2_26x2_init(streamer_t * streamer) +{ + UART_Params uartParams; + + UART_init(); + + UART_Params_init(&uartParams); + // Most params can be default because we only send data, we don't receive + uartParams.baudRate = 115200; + // unclear why the UART driver sticks in writing sometimes + uartParams.writeTimeout = 10000; // ticks + // Immediate return from the read function + // uartParams.readTimeout = 0; // ticks + + sStreamUartHandle = UART_open(CONFIG_UART_STREAMER, &uartParams); + return 0; +} + +ssize_t streamer_cc13x2_26x2_read(streamer_t * streamer, char * buf, size_t len) +{ + (void) streamer; + return UART_read(sStreamUartHandle, buf, len); +} + +ssize_t streamer_cc13x2_26x2_write(streamer_t * streamer, const char * buf, size_t len) +{ + (void) streamer; + return UART_write(sStreamUartHandle, buf, len); +} + +static streamer_t streamer_cc13x2_26x2 = { + .init_cb = streamer_cc13x2_26x2_init, + .read_cb = streamer_cc13x2_26x2_read, + .write_cb = streamer_cc13x2_26x2_write, +}; + +streamer_t * streamer_get() +{ + return &streamer_cc13x2_26x2; +} + +#endif //#ifndef SHELL_STREAMER_APP_SPECIFIC + +} // namespace Shell +} // namespace chip diff --git a/src/platform/cc13x2_26x2/Logging.cpp b/src/platform/cc13x2_26x2/Logging.cpp index 6d0e932708119c..1fb240c2c10d44 100644 --- a/src/platform/cc13x2_26x2/Logging.cpp +++ b/src/platform/cc13x2_26x2/Logging.cpp @@ -18,6 +18,7 @@ UART_Handle sDebugUartHandle; char sDebugUartBuffer[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE]; +#if MATTER_CC13X2_26X2_PLATFORM_LOG_ENABLED extern "C" int cc13x2_26x2LogInit(void) { UART_Params uartParams; @@ -50,6 +51,14 @@ extern "C" void cc13x2_26x2VLog(const char * msg, va_list v) } } +#else + +/* log functins defined somewhere else */ +extern "C" int cc13x2_26x2LogInit(void); +extern "C" void cc13x2_26x2VLog(const char * msg, va_list v); + +#endif // MATTER_CC13X2_26X2_PLATFORM_LOG_ENABLED + namespace chip { namespace DeviceLayer { @@ -81,6 +90,7 @@ void LogV(const char * module, uint8_t category, const char * msg, va_list v) } // namespace Logging } // namespace chip +#if CHIP_SYSTEM_CONFIG_USE_LWIP /** * LwIP log output function. */ @@ -95,6 +105,7 @@ extern "C" void LwIPLog(const char * msg, ...) chip::DeviceLayer::OnLogOutput(); va_end(v); } +#endif // #if CHIP_SYSTEM_CONFIG_USE_LWIP /** * Platform log output function. diff --git a/third_party/pigweed/repo b/third_party/pigweed/repo index 2e14574efe7d02..e33c83a70798ee 160000 --- a/third_party/pigweed/repo +++ b/third_party/pigweed/repo @@ -1 +1 @@ -Subproject commit 2e14574efe7d022966fc971151f0dfbbd81c85dc +Subproject commit e33c83a70798ee121dd5b004b09022ae32cd73ab