[Infineon]Add All-Clusters example app for P6 platform (#11300)

* [Infineon]Add All-Clusters example app for P6 platform

* Address code review comments on zcl callbacks
diff --git a/.github/workflows/examples-infineon.yaml b/.github/workflows/examples-infineon.yaml
index 7c8e2ed..f74b980 100644
--- a/.github/workflows/examples-infineon.yaml
+++ b/.github/workflows/examples-infineon.yaml
@@ -59,11 +59,18 @@
               timeout-minutes: 10
               run: |
                 scripts/run_in_build_env.sh \
-                  "scripts/build/build_examples.py --no-log-timestamps --target-glob 'infineon-*' build"
+                  "scripts/build/build_examples.py --no-log-timestamps --target 'infineon-p6-lock' build"
                 .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
                     p6 default lock-app \
                     out/infineon-p6-lock/chip-p6-lock-example.out
-
+            - name: Build all-clusters-app example
+              timeout-minutes: 10
+              run: |
+                scripts/run_in_build_env.sh \
+                  "scripts/build/build_examples.py --no-log-timestamps --target 'infineon-p6-all-clusters' build"
+                .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
+                    p6 default all-clusters-app \
+                    out/infineon-p6-all-clusters/chip-p6-clusters-example.out
             - name: Uploading Size Reports
               uses: actions/upload-artifact@v2
               if: ${{ !env.ACT }}
@@ -71,3 +78,4 @@
                   name: Size,P6-Examples,${{ env.GH_EVENT_PR }},${{ env.GH_EVENT_HASH }},${{ env.GH_EVENT_PARENT }}
                   path: |
                     out/infineon-p6-lock/p6-default-lock-app-sizes.json
+                    out/infineon-p6-all-clusters/p6-default-all-clusters-app-sizes.json
diff --git a/.gitmodules b/.gitmodules
index f6e1af9..bee8a74 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -163,3 +163,6 @@
 	path = third_party/pybind11/repo
 	url = https://github.com/pybind/pybind11
 	branch  = stable
+[submodule "p6/lwip"]
+	path = third_party/p6/p6_sdk/libs/lwip
+	url = https://git.savannah.nongnu.org/git/lwip
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index b44986d..9599514 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -235,6 +235,7 @@
                 "esp32-devkitc-temperature-measurement",
                 "esp32-m5stack-all-clusters",
                 "esp32-m5stack-all-clusters-rpc",
+                "infineon-p6-all-clusters",
                 "infineon-p6-lock",
                 "linux-arm64-all-clusters",
                 "linux-arm64-all-clusters-ipv6only",
diff --git a/examples/all-clusters-app/p6/.gn b/examples/all-clusters-app/p6/.gn
new file mode 100644
index 0000000..81cec9d
--- /dev/null
+++ b/examples/all-clusters-app/p6/.gn
@@ -0,0 +1,28 @@
+# 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("//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/all-clusters-app/p6/BUILD.gn b/examples/all-clusters-app/p6/BUILD.gn
new file mode 100644
index 0000000..3a15688
--- /dev/null
+++ b/examples/all-clusters-app/p6/BUILD.gn
@@ -0,0 +1,109 @@
+# 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("//build_overrides/build.gni")
+import("//build_overrides/chip.gni")
+import("//build_overrides/p6.gni")
+
+import("${build_root}/config/defaults.gni")
+import("${p6_sdk_build_root}/p6_executable.gni")
+import("${p6_sdk_build_root}/p6_sdk.gni")
+
+assert(current_os == "freertos")
+
+p6_project_dir = "${chip_root}/examples/all-clusters-app/p6"
+examples_plat_dir = "${chip_root}/examples/platform/p6"
+
+declare_args() {
+  # Dump memory usage at link time.
+  chip_print_memory_usage = false
+
+  # PIN code for PASE session establishment.
+  setup_pin_code = 20202021
+
+  # Monitor & log memory usage at runtime.
+  enable_heap_monitoring = false
+}
+
+p6_sdk_sources("all_clusters_app_sdk_sources") {
+  include_dirs = [
+    "${chip_root}/src/platform/P6",
+    "${p6_project_dir}/include",
+    "${examples_plat_dir}",
+  ]
+
+  defines = [
+    "BOARD_ID=${p6_board}",
+    "P6_LOG_ENABLED=1",
+    "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setup_pin_code}",
+  ]
+
+  sources = [ "${p6_project_dir}/include/CHIPProjectConfig.h" ]
+
+  public_configs = [ "${chip_root}/third_party/p6:p6_sdk_config" ]
+}
+
+p6_executable("clusters_app") {
+  include_dirs = []
+  defines = []
+  output_name = "chip-p6-clusters-example.out"
+
+  sources = [
+    "${examples_plat_dir}/LEDWidget.cpp",
+    "${examples_plat_dir}/init_p6Platform.cpp",
+    "src/AppTask.cpp",
+    "src/ButtonHandler.cpp",
+    "src/ClusterManager.cpp",
+    "src/ZclCallbacks.cpp",
+    "src/main.cpp",
+  ]
+
+  deps = [
+    ":all_clusters_app_sdk_sources",
+    "${chip_root}/examples/all-clusters-app/all-clusters-common",
+    "${chip_root}/examples/common/QRCode",
+    "${chip_root}/src/lib",
+    "${chip_root}/src/setup_payload",
+  ]
+
+  include_dirs += [
+    "include",
+    "${examples_plat_dir}",
+    "${p6_project_dir}/include",
+  ]
+
+  defines = []
+
+  if (enable_heap_monitoring) {
+    sources += [ "${examples_plat_dir}/MemMonitoring.cpp" ]
+    defines += [ "HEAP_MONITORING" ]
+  }
+
+  if (chip_print_memory_usage) {
+    ldflags += [
+      "-Wl,--print-memory-usage",
+      "-fstack-usage",
+    ]
+  }
+
+  output_dir = root_out_dir
+}
+
+group("p6") {
+  deps = [ ":clusters_app" ]
+}
+
+group("default") {
+  deps = [ ":p6" ]
+}
diff --git a/examples/all-clusters-app/p6/README.md b/examples/all-clusters-app/p6/README.md
new file mode 100644
index 0000000..b874e97
--- /dev/null
+++ b/examples/all-clusters-app/p6/README.md
@@ -0,0 +1,138 @@
+#CHIP P6 All Clusters Example
+
+An example showing the use of Matter on the Infineon CY8CKIT-062S2-43012 board.
+
+<hr>
+
+-   [Matter P6 All Clusters Example](#chip-p6-clusters-example)
+    -   [Introduction](#introduction)
+    -   [Building](#building)
+    -   [Flashing the Application](#flashing-the-application)
+    -   [Commissioning and cluster control](#commissioning-and-cluster-control)
+        -   [Setting up Python Controller](#setting-up-python-controller)
+        -   [Commissioning over BLE](#commissioning-over-ble)
+            -   [Notes](#notes)
+
+<hr>
+
+<a name="intro"></a>
+
+## Introduction
+
+The P6 clusters example provides a baseline demonstration of a Cluster control
+device, built using Matter and the Infineon Modustoolbox SDK. It can be
+controlled by Matter controller over Wi-Fi network.
+
+The P6 device can be commissioned over Bluetooth Low Energy where the device and
+the Matter controller will exchange security information with the Rendezvous
+procedure. Wi-Fi Network credentials are then provided to the P6 device which
+will then join the network.
+
+<a name="building"></a>
+
+## Building
+
+-   [Modustoolbox Software](https://www.cypress.com/products/modustoolbox)
+
+    Refer to `integrations/docker/images/chip-build-infineon/Dockerfile` or
+    `scripts/examples/gn_p6_example.sh` for downloading the Software and related
+    tools.
+
+-   Install some additional tools (likely already present for Matter
+    developers): \$ sudo apt install gcc g++ clang ninja-build python
+    python3-venv libssl-dev libavahi-client-dev libglib2.0-dev git cmake
+    python3-pip
+
+-   Supported hardware:
+    [CY8CKIT-062S2-43012](https://www.cypress.com/CY8CKIT-062S2-43012)
+
+*   Build the example application:
+
+          $ ./scripts/examples/gn_p6_example.sh ./examples/all-clusters-app/p6 out/clusters_app_p6
+
+-   To delete generated executable, libraries and object files use:
+
+          $ cd ~/connectedhomeip
+          $ rm -rf out/
+
+<a name="flashing"></a>
+
+## Flashing the Application
+
+-   Put CY8CKIT-062S2-43012 board on KitProg3 CMSIS-DAP Mode by pressing the
+    `MODE SELECT` button. `KITPROG3 STATUS` LED is ON confirms board is in
+    proper mode.
+
+-   On the command line:
+
+          $ cd ~/connectedhomeip
+          $ python3 out/clusters_app_p6/chip-p6-clusters-example.flash.py
+
+<a name="Commissioning and cluster control"></a>
+
+## Commissioning and cluster control
+
+Commissioning can be carried out using BLE.
+
+<a name="Setting up Python Controller"></a>
+
+### Setting up Python Controller
+
+Once P6 is up and running, we need to set up a device controller on Raspberry Pi
+4 to perform commissioning and cluster control.
+
+-   Set up python controller.
+
+           $ cd {path-to-connectedhomeip}
+           $ ./scripts/build_python.sh -m platform
+
+-   Execute the controller.
+
+           $ source ./out/python_env/bin/activate
+           $ chip-device-ctrl
+
+<a name="Commissioning over BLE"></a>
+
+### Commissioning over BLE
+
+-   Establish the secure session over BLE.
+
+         - chip-device-ctrl > ble-scan
+         - chip-device-ctrl > connect -ble 3840 20202021 1234
+
+         Parameters:
+         1. Discriminator: 3840
+         2. Setup-pin-code: 20202021
+         3. Node ID: Optional.
+            If not passed in this command, then it is auto-generated by the controller and
+            displayed in the output of connect.
+            The same value should be used in the next commands.
+            We have chosen a random node ID which is 1234.
+
+-   Add credentials of the Wi-Fi network you want the P6 to connect to, using
+    the `AddWiFiNetwork` command and then enable the P6 to connect to it using
+    `EnableWiFiNetwork` command. In this example, we have used `WIFI_SSID` and
+    `WIFI_PASSWORD` as the SSID and passphrase respectively.
+
+         - chip-device-ctrl > zcl NetworkCommissioning AddWiFiNetwork 1234 0 0 ssid=str:WIFI_SSID credentials=str:WIFI_PASSWORD breadcrumb=0 timeoutMs=1000
+
+         - chip-device-ctrl > zcl NetworkCommissioning EnableNetwork 1234 0 0 networkID=str:WIFI_SSID breadcrumb=0 timeoutMs=1000
+
+-   Close the BLE connection to P6, as it is not required hereafter.
+
+         - chip-device-ctrl > close-ble
+
+-   Resolve DNS-SD name and update address of the node in the device controller.
+
+         - chip-device-ctrl > resolve 1234
+
+<a name="Notes"></a>
+
+#### Notes
+
+Raspberry Pi 4 BLE connection issues can be avoided by running the following
+commands. These power cycle the BlueTooth hardware and disable BR/EDR mode.
+
+          $ sudo btmgmt -i hci0 power off
+          $ sudo btmgmt -i hci0 bredr off
+          $ sudo btmgmt -i hci0 power on
diff --git a/examples/all-clusters-app/p6/args.gni b/examples/all-clusters-app/p6/args.gni
new file mode 100644
index 0000000..2a93385
--- /dev/null
+++ b/examples/all-clusters-app/p6/args.gni
@@ -0,0 +1,20 @@
+# 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("//build_overrides/chip.gni")
+import("//build_overrides/pigweed.gni")
+import("${chip_root}/src/platform/P6/args.gni")
+
+p6_target_project =
+    get_label_info(":all_clusters_app_sdk_sources", "label_no_toolchain")
diff --git a/examples/all-clusters-app/p6/build_overrides b/examples/all-clusters-app/p6/build_overrides
new file mode 120000
index 0000000..194ee0b
--- /dev/null
+++ b/examples/all-clusters-app/p6/build_overrides
@@ -0,0 +1 @@
+../../build_overrides/
\ No newline at end of file
diff --git a/examples/all-clusters-app/p6/include/AppConfig.h b/examples/all-clusters-app/p6/include/AppConfig.h
new file mode 100644
index 0000000..8e9ebe2
--- /dev/null
+++ b/examples/all-clusters-app/p6/include/AppConfig.h
@@ -0,0 +1,62 @@
+/*
+ *
+ *    Copyright (c) 2021 Project CHIP Authors
+ *    Copyright (c) 2019 Google LLC.
+ *    Copyright 2021, Cypress Semiconductor Corporation (an Infineon company)
+ *    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 "cybsp.h"
+#include "cyhal.h"
+
+// ---- Lighting Example App Config ----
+
+#define APP_TASK_NAME "APP"
+
+#define APP_LIGHT_BUTTON_IDX 0
+#define APP_LIGHT_BUTTON CYBSP_USER_BTN1
+#define APP_BUTTON_DEBOUNCE_PERIOD_MS 50
+
+#define APP_BUTTON_PRESSED 0
+#define APP_BUTTON_RELEASED 1
+
+#define SYSTEM_STATE_LED CYBSP_USER_LED1
+#define LIGHT_LED CYBSP_USER_LED2
+
+// Time it takes in ms for the simulated actuator to move from one
+// state to another.
+#define ACTUATOR_MOVEMENT_PERIOS_MS 2000
+
+// ---- Thread Polling Config ----
+#define THREAD_ACTIVE_POLLING_INTERVAL_MS 100
+#define THREAD_INACTIVE_POLLING_INTERVAL_MS 1000
+
+// P6 Logging
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void appError(int err);
+void P6Log(const char * aFormat, ...);
+#define P6_LOG(...) P6Log(__VA_ARGS__)
+
+#ifdef __cplusplus
+}
+
+#include <lib/core/CHIPError.h>
+void appError(CHIP_ERROR error);
+#endif
diff --git a/examples/all-clusters-app/p6/include/AppEvent.h b/examples/all-clusters-app/p6/include/AppEvent.h
new file mode 100644
index 0000000..671a1be
--- /dev/null
+++ b/examples/all-clusters-app/p6/include/AppEvent.h
@@ -0,0 +1,52 @@
+/*
+ *
+ *    Copyright (c) 2021 Project CHIP Authors
+ *    Copyright (c) 2018 Nest Labs, Inc.
+ *    Copyright 2021, Cypress Semiconductor Corporation (an Infineon company)
+ *    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
+
+struct AppEvent;
+typedef void (*EventHandler)(AppEvent *);
+
+struct AppEvent
+{
+    enum AppEventTypes
+    {
+        kEventType_Button = 0,
+        kEventType_Timer,
+        kEventType_Light,
+        kEventType_Install,
+    };
+
+    uint16_t Type;
+
+    union
+    {
+        struct
+        {
+            uint8_t ButtonIdx;
+            uint8_t Action;
+        } ButtonEvent;
+        struct
+        {
+            void * Context;
+        } TimerEvent;
+    };
+
+    EventHandler Handler;
+};
diff --git a/examples/all-clusters-app/p6/include/AppTask.h b/examples/all-clusters-app/p6/include/AppTask.h
new file mode 100644
index 0000000..29c06f0
--- /dev/null
+++ b/examples/all-clusters-app/p6/include/AppTask.h
@@ -0,0 +1,63 @@
+/*
+ *
+ *    Copyright (c) 2021 Project CHIP Authors
+ *    Copyright (c) 2019 Google LLC.
+ *    Copyright 2021, Cypress Semiconductor Corporation (an Infineon company)
+ *    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 <stdbool.h>
+#include <stdint.h>
+
+#include "AppEvent.h"
+#include "FreeRTOS.h"
+#include "timers.h" // provides FreeRTOS timer support
+#include <ble/BLEEndPoint.h>
+#include <platform/CHIPDeviceLayer.h>
+
+// Application-defined error codes in the CHIP_ERROR space.
+#define APP_ERROR_EVENT_QUEUE_FAILED CHIP_APPLICATION_ERROR(0x01)
+#define APP_ERROR_CREATE_TASK_FAILED CHIP_APPLICATION_ERROR(0x02)
+#define APP_ERROR_UNHANDLED_EVENT CHIP_APPLICATION_ERROR(0x03)
+#define APP_ERROR_CREATE_TIMER_FAILED CHIP_APPLICATION_ERROR(0x04)
+#define APP_ERROR_START_TIMER_FAILED CHIP_APPLICATION_ERROR(0x05)
+#define APP_ERROR_STOP_TIMER_FAILED CHIP_APPLICATION_ERROR(0x06)
+
+class AppTask
+{
+
+public:
+    CHIP_ERROR StartAppTask();
+    static void AppTaskMain(void * pvParameter);
+    static void LightActionEventHandler(AppEvent * aEvent);
+    void ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction);
+    void PostEvent(const AppEvent * event);
+
+private:
+    friend AppTask & GetAppTask(void);
+
+    CHIP_ERROR Init();
+
+    static AppTask sAppTask;
+    void DispatchEvent(AppEvent * event);
+    static void OnOffUpdateClusterState(void);
+};
+
+inline AppTask & GetAppTask(void)
+{
+    return AppTask::sAppTask;
+}
diff --git a/examples/all-clusters-app/p6/include/ButtonHandler.h b/examples/all-clusters-app/p6/include/ButtonHandler.h
new file mode 100644
index 0000000..85dcdb5
--- /dev/null
+++ b/examples/all-clusters-app/p6/include/ButtonHandler.h
@@ -0,0 +1,40 @@
+/*
+ *
+ *    Copyright (c) 2021 Project CHIP Authors
+ *    Copyright (c) 2019 Google LLC.
+ *    Copyright 2021, Cypress Semiconductor Corporation (an Infineon company)
+ *    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 <stdint.h>
+
+#include "FreeRTOS.h"
+#include "cyhal.h"
+#include "timers.h" // provides FreeRTOS timer support
+
+#define GPIO_INTERRUPT_PRIORITY (5)
+
+class ButtonHandler
+{
+public:
+    static void Init(void);
+
+private:
+    static void GpioInit(void);
+    static void lightbuttonIsr(void * handler_arg, cyhal_gpio_event_t event);
+    static void TimerCallback(TimerHandle_t xTimer);
+};
diff --git a/examples/all-clusters-app/p6/include/CHIPProjectConfig.h b/examples/all-clusters-app/p6/include/CHIPProjectConfig.h
new file mode 100644
index 0000000..23fcc5f
--- /dev/null
+++ b/examples/all-clusters-app/p6/include/CHIPProjectConfig.h
@@ -0,0 +1,115 @@
+/*
+ *
+ *    Copyright (c) 2021 Project CHIP Authors
+ *    Copyright (c) 2019 Google LLC.
+ *    Copyright 2021, Cypress Semiconductor Corporation (an Infineon company)
+ *    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
+
+/**
+ * CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY
+ *
+ * Enables the use of a hard-coded default Chip device id and credentials if no device id
+ * is found in Chip NV storage.
+ *
+ * This option is for testing only and should be disabled in production releases.
+ */
+#define CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY 34
+
+// Use a default pairing code if one hasn't been provisioned in flash.
+#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE
+#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021
+#endif
+
+#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR
+#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00
+#endif
+
+// For convenience, Chip Security Test Mode can be enabled and the
+// requirement for authentication in various protocols can be disabled.
+//
+//    WARNING: These options make it possible to circumvent basic Chip security functionality,
+//    including message encryption. Because of this they MUST NEVER BE ENABLED IN PRODUCTION BUILDS.
+//
+#define CHIP_CONFIG_SECURITY_TEST_MODE 0
+#define CHIP_CONFIG_REQUIRE_AUTH 1
+
+/**
+ * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION
+ *
+ * The product revision 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 revisions.
+ */
+#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION 1
+
+/**
+ * CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING
+ *
+ * A string identifying the firmware revision running on the device.
+ * CHIP service currently expects the firmware version to be in the format
+ * {MAJOR_VERSION}.0d{MINOR_VERSION}
+ */
+#ifndef CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING
+#define CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING "0.1ALPHA"
+#endif
+/**
+ * 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 0
+
+/**
+ * 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_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS
+ *
+ * Enable recording UTC timestamps.
+ */
+#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 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)
diff --git a/examples/all-clusters-app/p6/include/ClusterManager.h b/examples/all-clusters-app/p6/include/ClusterManager.h
new file mode 100644
index 0000000..1f7e073
--- /dev/null
+++ b/examples/all-clusters-app/p6/include/ClusterManager.h
@@ -0,0 +1,55 @@
+/*
+ *
+ *    Copyright (c) 2021 Project CHIP Authors
+ *    Copyright 2021, Cypress Semiconductor Corporation (an Infineon company)
+ *    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 ClusterManager.h
+ *
+ * Implementations for the DeviceManager callbacks for this application
+ *
+ **/
+
+#pragma once
+
+#include "LEDWidget.h"
+#include <app/util/af-types.h>
+#include <app/util/basic-types.h>
+#include <platform/CHIPDeviceLayer.h>
+
+extern LEDWidget sStatusLED;
+extern LEDWidget sLightLED;
+extern LEDWidget sClusterLED;
+
+class ClusterManager
+{
+public:
+    void OnOnOffPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value);
+    void OnLevelControlAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value);
+    void OnColorControlAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value);
+    void OnIdentifyPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value);
+
+private:
+    friend ClusterManager & ClusterMgr(void);
+    bool mEndpointOnOffState[2];
+    static ClusterManager sCluster;
+};
+
+inline ClusterManager & ClusterMgr(void)
+{
+    return ClusterManager::sCluster;
+}
diff --git a/examples/all-clusters-app/p6/src/AppTask.cpp b/examples/all-clusters-app/p6/src/AppTask.cpp
new file mode 100644
index 0000000..9dbb22f
--- /dev/null
+++ b/examples/all-clusters-app/p6/src/AppTask.cpp
@@ -0,0 +1,235 @@
+/*
+ *
+ *    Copyright (c) 2021 Project CHIP Authors
+ *    Copyright (c) 2019 Google LLC.
+ *    Copyright 2021, Cypress Semiconductor Corporation (an Infineon company)
+ *    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 "AppConfig.h"
+#include "AppEvent.h"
+#include "ButtonHandler.h"
+#include "LEDWidget.h"
+#include "qrcodegen.h"
+#include <app-common/zap-generated/attribute-id.h>
+#include <app-common/zap-generated/attribute-type.h>
+#include <app-common/zap-generated/attributes/Accessors.h>
+#include <app-common/zap-generated/cluster-id.h>
+#include <app/server/Dnssd.h>
+#include <app/server/OnboardingCodesUtil.h>
+#include <app/server/Server.h>
+#include <app/util/attribute-storage.h>
+#include <assert.h>
+#include <credentials/DeviceAttestationCredsProvider.h>
+#include <credentials/examples/DeviceAttestationCredsExample.h>
+#include <cy_wcm.h>
+#include <platform/CHIPDeviceLayer.h>
+#include <setup_payload/QRCodeSetupPayloadGenerator.h>
+#include <setup_payload/SetupPayload.h>
+
+#define APP_EVENT_QUEUE_SIZE 10
+#define APP_TASK_STACK_SIZE (4096)
+#define APP_WAIT_LOOP 1000
+
+LEDWidget sStatusLED;
+LEDWidget sLightLED;
+LEDWidget sClusterLED;
+
+namespace {
+
+TaskHandle_t sAppTaskHandle;
+QueueHandle_t sAppEventQueue;
+
+uint8_t sAppEventQueueBuffer[APP_EVENT_QUEUE_SIZE * sizeof(AppEvent)];
+StaticQueue_t sAppEventQueueStruct;
+
+StackType_t appStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)];
+StaticTask_t appTaskStruct;
+} // namespace
+
+using namespace chip::TLV;
+using namespace ::chip::Credentials;
+using namespace ::chip::DeviceLayer;
+using namespace ::chip::app::Clusters;
+
+AppTask AppTask::sAppTask;
+
+CHIP_ERROR AppTask::StartAppTask()
+{
+    sAppEventQueue = xQueueCreateStatic(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent), sAppEventQueueBuffer, &sAppEventQueueStruct);
+    if (sAppEventQueue == NULL)
+    {
+        P6_LOG("Failed to allocate app event queue");
+        appError(APP_ERROR_EVENT_QUEUE_FAILED);
+    }
+    // Start App task.
+    sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), NULL, 1, appStack, &appTaskStruct);
+    return (sAppTaskHandle == nullptr) ? APP_ERROR_CREATE_TASK_FAILED : CHIP_NO_ERROR;
+}
+
+CHIP_ERROR AppTask::Init()
+{
+    CHIP_ERROR err = CHIP_NO_ERROR;
+
+    // Register the callback to init the MDNS server when connectivity is available
+    PlatformMgr().AddEventHandler(
+        [](const ChipDeviceEvent * event, intptr_t arg) {
+            // Restart the server whenever an ip address is renewed
+            if (event->Type == DeviceEventType::kInternetConnectivityChange)
+            {
+                if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established ||
+                    event->InternetConnectivityChange.IPv6 == kConnectivity_Established)
+                {
+                    chip::app::DnssdServer::Instance().StartServer();
+                }
+            }
+        },
+        0);
+    // Init ZCL Data Model
+    chip::Server::GetInstance().Init();
+
+    // Initialize device attestation config
+    SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
+
+    // Initialise WSTK buttons PB0 and PB1 (including debounce).
+    ButtonHandler::Init();
+
+    P6_LOG("Current Firmware Version: %s", CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING);
+
+    // Initialize LEDs
+    sStatusLED.Init(SYSTEM_STATE_LED);
+    sLightLED.Init(LIGHT_LED);
+    sClusterLED.RGB_init();
+
+    ConfigurationMgr().LogDeviceConfig();
+
+    // Print setup info
+    PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
+
+    return err;
+}
+
+void AppTask::AppTaskMain(void * pvParameter)
+{
+    AppEvent event;
+    CHIP_ERROR err = sAppTask.Init();
+    if (err != CHIP_NO_ERROR)
+    {
+        P6_LOG("AppTask.Init() failed");
+        appError(err);
+    }
+
+    P6_LOG("App Task started");
+
+    while (true)
+    {
+        BaseType_t eventReceived = xQueueReceive(sAppEventQueue, &event, pdMS_TO_TICKS(10));
+        while (eventReceived == pdTRUE)
+        {
+            sAppTask.DispatchEvent(&event);
+            eventReceived = xQueueReceive(sAppEventQueue, &event, 0);
+        }
+    }
+}
+
+void AppTask::LightActionEventHandler(AppEvent * aEvent)
+{
+    /* ON/OFF Light Led based on Button interrupt */
+    sLightLED.Invert();
+
+    /* Update OnOff Cluster state */
+    sAppTask.OnOffUpdateClusterState();
+}
+
+void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction)
+{
+    if (btnIdx != APP_LIGHT_BUTTON_IDX)
+    {
+        return;
+    }
+
+    AppEvent button_event              = {};
+    button_event.Type                  = AppEvent::kEventType_Button;
+    button_event.ButtonEvent.ButtonIdx = btnIdx;
+    button_event.ButtonEvent.Action    = btnAction;
+
+    if ((btnIdx == APP_LIGHT_BUTTON_IDX) && (btnAction == APP_BUTTON_RELEASED))
+    {
+        button_event.Handler = LightActionEventHandler;
+        sAppTask.PostEvent(&button_event);
+    }
+}
+
+void AppTask::PostEvent(const AppEvent * aEvent)
+{
+    if (sAppEventQueue != NULL)
+    {
+        BaseType_t status;
+        if (xPortIsInsideInterrupt())
+        {
+            BaseType_t higherPrioTaskWoken = pdFALSE;
+            status                         = xQueueSendFromISR(sAppEventQueue, aEvent, &higherPrioTaskWoken);
+
+#ifdef portYIELD_FROM_ISR
+            portYIELD_FROM_ISR(higherPrioTaskWoken);
+#elif portEND_SWITCHING_ISR // portYIELD_FROM_ISR or portEND_SWITCHING_ISR
+            portEND_SWITCHING_ISR(higherPrioTaskWoken);
+#else                       // portYIELD_FROM_ISR or portEND_SWITCHING_ISR
+#error "Must have portYIELD_FROM_ISR or portEND_SWITCHING_ISR"
+#endif // portYIELD_FROM_ISR or portEND_SWITCHING_ISR
+        }
+        else
+        {
+            status = xQueueSend(sAppEventQueue, aEvent, 1);
+        }
+
+        if (!status)
+            P6_LOG("Failed to post event to app task event queue");
+    }
+    else
+    {
+        P6_LOG("Event Queue is NULL should never happen");
+    }
+}
+
+void AppTask::DispatchEvent(AppEvent * aEvent)
+{
+    if (aEvent->Handler)
+    {
+        aEvent->Handler(aEvent);
+    }
+    else
+    {
+        P6_LOG("Event received with no handler. Dropping event.");
+    }
+}
+
+void AppTask::OnOffUpdateClusterState(void)
+{
+    uint8_t newValue = sLightLED.Get();
+
+    // write the new on/off value
+    EmberAfStatus status = OnOff::Attributes::OnOff::Set(2, newValue);
+    if (status != EMBER_ZCL_STATUS_SUCCESS)
+    {
+        P6_LOG("ERR: updating on/off %x", status);
+    }
+}
+
+bool lowPowerClusterSleep()
+{
+    return true;
+}
diff --git a/examples/all-clusters-app/p6/src/ButtonHandler.cpp b/examples/all-clusters-app/p6/src/ButtonHandler.cpp
new file mode 100644
index 0000000..6c768e4
--- /dev/null
+++ b/examples/all-clusters-app/p6/src/ButtonHandler.cpp
@@ -0,0 +1,84 @@
+/*
+ *
+ *    Copyright (c) 2021 Project CHIP Authors
+ *    Copyright (c) 2019 Google LLC.
+ *    Copyright 2021, Cypress Semiconductor Corporation (an Infineon company)
+ *    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 "ButtonHandler.h"
+#include "AppConfig.h"
+#include "AppTask.h"
+
+namespace {
+
+TimerHandle_t buttonTimer; // FreeRTOS timers used for debouncing buttons
+
+} // namespace
+
+void ButtonHandler::Init(void)
+{
+    GpioInit();
+
+    buttonTimer = xTimerCreate("BtnTmr",                            // Just a text name, not used by the RTOS kernel
+                               APP_BUTTON_DEBOUNCE_PERIOD_MS,       // timer period
+                               false,                               // no timer reload (==one-shot)
+                               (void *) (int) APP_LIGHT_BUTTON_IDX, // init timer id = button index
+                               TimerCallback                        // timer callback handler (all buttons use
+                                                                    // the same timer cn function)
+    );
+}
+
+void ButtonHandler::GpioInit(void)
+{
+    cy_rslt_t result = CY_RSLT_SUCCESS;
+    // Set up button GPIOs to input with pullups.
+    result = cyhal_gpio_init(APP_LIGHT_BUTTON, CYHAL_GPIO_DIR_INPUT, CYHAL_GPIO_DRIVE_PULLUP, CYBSP_BTN_OFF);
+    if (result != CY_RSLT_SUCCESS)
+    {
+        printf(" cyhal_gpio_init failed for APP_LIGHT_BUTTON\r\n");
+    }
+
+    /* Configure GPIO interrupt. */
+    cyhal_gpio_register_callback(APP_LIGHT_BUTTON, lightbuttonIsr, NULL);
+    cyhal_gpio_enable_event(APP_LIGHT_BUTTON, CYHAL_GPIO_IRQ_FALL, GPIO_INTERRUPT_PRIORITY, true);
+}
+
+void ButtonHandler::lightbuttonIsr(void * handler_arg, cyhal_gpio_event_t event)
+{
+    portBASE_TYPE taskWoken = pdFALSE;
+    xTimerStartFromISR(buttonTimer, &taskWoken);
+}
+
+void ButtonHandler::TimerCallback(TimerHandle_t xTimer)
+{
+    // Get the button index of the expired timer and call button event helper.
+    uint32_t timerId;
+    uint8_t buttonevent = 0;
+    timerId             = (uint32_t) pvTimerGetTimerID(xTimer);
+
+    switch (timerId)
+    {
+    case APP_LIGHT_BUTTON_IDX:
+        buttonevent = cyhal_gpio_read(APP_LIGHT_BUTTON);
+        break;
+
+    default:
+        P6_LOG("Unhandled TimerID: %d", timerId);
+        break;
+    }
+
+    GetAppTask().ButtonEventHandler(timerId, (buttonevent) ? APP_BUTTON_PRESSED : APP_BUTTON_RELEASED);
+}
diff --git a/examples/all-clusters-app/p6/src/ClusterManager.cpp b/examples/all-clusters-app/p6/src/ClusterManager.cpp
new file mode 100644
index 0000000..9a0f2fc
--- /dev/null
+++ b/examples/all-clusters-app/p6/src/ClusterManager.cpp
@@ -0,0 +1,156 @@
+/*
+ *
+ *    Copyright (c) 2021 Project CHIP Authors
+ *    Copyright 2021, Cypress Semiconductor Corporation (an Infineon company)
+ *
+ *    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
+ *   This file implements the handler for data model messages.
+ */
+
+#include "ClusterManager.h"
+#include "AppConfig.h"
+#include "LEDWidget.h"
+#include <app-common/zap-generated/attribute-id.h>
+#include <app-common/zap-generated/attributes/Accessors.h>
+#include <app-common/zap-generated/cluster-id.h>
+#include <app/Command.h>
+#include <app/server/Dnssd.h>
+#include <app/util/basic-types.h>
+#include <app/util/util.h>
+#include <lib/dnssd/Advertiser.h>
+#include <lib/support/CodeUtils.h>
+#include <lib/support/logging/CHIPLogging.h>
+
+using namespace ::chip;
+using namespace ::chip::Inet;
+using namespace ::chip::System;
+using namespace ::chip::DeviceLayer;
+using namespace ::chip::app::Clusters;
+
+#define ENDPOINT_FIRST_IDX 1
+#define ENDPOINT_SECOND_IDX 2
+
+uint32_t identifyTimerCount;
+constexpr uint32_t kIdentifyTimerDelayMS = 250;
+ClusterManager ClusterManager::sCluster;
+
+void ClusterManager::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value)
+{
+    VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID,
+                 P6_LOG("Unhandled Attribute ID: '" ChipLogFormatMEI "'", ChipLogValueMEI(attributeId)));
+    VerifyOrExit(endpointId == ENDPOINT_FIRST_IDX || endpointId == ENDPOINT_SECOND_IDX,
+                 P6_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId));
+
+    // At this point we can assume that value points to a bool value.
+    mEndpointOnOffState[endpointId - 1] = *value;
+
+    // On/Off Cluster LED for endpoint 1 and Light Led for endpoint 2
+    endpointId == ENDPOINT_FIRST_IDX ? sClusterLED.RGB_set(*value) : sLightLED.Set(*value);
+
+exit:
+    return;
+}
+
+void ClusterManager::OnLevelControlAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value)
+{
+    bool onOffState    = mEndpointOnOffState[endpointId - 1];
+    uint8_t brightness = onOffState ? *value : 0;
+
+    VerifyOrExit(attributeId == ZCL_CURRENT_LEVEL_ATTRIBUTE_ID,
+                 P6_LOG("Unhandled Attribute ID: '" ChipLogFormatMEI "'", ChipLogValueMEI(attributeId)));
+    VerifyOrExit(endpointId == ENDPOINT_FIRST_IDX || endpointId == ENDPOINT_SECOND_IDX,
+                 P6_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId));
+
+    endpointId == ENDPOINT_FIRST_IDX ? sClusterLED.SetBrightness(brightness) : sLightLED.SetBrightness(brightness);
+
+exit:
+    return;
+}
+
+void ClusterManager::OnColorControlAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value)
+{
+    VerifyOrExit(attributeId == ColorControl::Attributes::CurrentHue::Id ||
+                     attributeId == ColorControl::Attributes::CurrentSaturation::Id,
+                 P6_LOG("Unhandled Attribute ID: '" ChipLogFormatMEI "'", ChipLogValueMEI(attributeId)));
+    VerifyOrExit(endpointId == ENDPOINT_FIRST_IDX || endpointId == ENDPOINT_SECOND_IDX,
+                 P6_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId));
+    if (endpointId == 1)
+    {
+        uint8_t hue, saturation;
+        /* If the Current Attribute is ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID, read the saturation value and
+         * set the color on Cluster LED using both Saturation and Hue.
+         */
+        if (attributeId == ColorControl::Attributes::CurrentHue::Id)
+        {
+            hue = *value;
+            /* Read Current Saturation value when Attribute change callback for HUE Attribute */
+            ColorControl::Attributes::CurrentSaturation::Get(endpointId, &saturation);
+        }
+        else
+        {
+            /* If the Current Attribute is ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, read the Hue value and
+             * set the color on Cluster LED using both Saturation and Hue.
+             */
+            saturation = *value;
+            /* Read Current Hue value when Attribute change callback for SATURATION Attribute */
+            ColorControl::Attributes::CurrentHue::Get(endpointId, &hue);
+        }
+        /* Set RGB Color on Cluster Indication LED */
+        sClusterLED.SetColor(hue, saturation);
+    }
+exit:
+    return;
+}
+
+/* Identify Cluster puts device into identification mode like flashing a device
+ * This function blinks LED by running timer every 500ms as expected by
+ * IdentifyTimer Attribute
+ */
+
+void IdentifyTimerHandler(Layer * systemLayer, void * appState)
+{
+    /* Status LED On/Off based on Blink Configuration */
+    sStatusLED.Animate();
+
+    if (identifyTimerCount)
+    {
+        systemLayer->StartTimer(Clock::Milliseconds32(kIdentifyTimerDelayMS), IdentifyTimerHandler, appState);
+        // Decrement the timer count.
+        identifyTimerCount--;
+    }
+}
+
+void ClusterManager::OnIdentifyPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value)
+{
+    VerifyOrExit(attributeId == Identify::Attributes::IdentifyTime::Id,
+                 P6_LOG("Unhandled Attribute ID: '" ChipLogFormatMEI "'", ChipLogValueMEI(attributeId)));
+    VerifyOrExit(endpointId == ENDPOINT_FIRST_IDX, P6_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId));
+
+    /* IdentifyTime Attribute Spec mentions "flashing a light with a period of 0.5 seconds" */
+    sStatusLED.Blink(kIdentifyTimerDelayMS * 2);
+
+    // timerCount represents the number of callback executions before we stop the timer.
+    // value is expressed in seconds and the timer is fired every 250ms, so just multiply value by 4.
+    // Also, we want timerCount to be odd number, so the light state ends in the same state it starts.
+    identifyTimerCount = (*value) * 4;
+
+    DeviceLayer::SystemLayer().CancelTimer(IdentifyTimerHandler, this);
+    DeviceLayer::SystemLayer().StartTimer(Clock::Milliseconds32(kIdentifyTimerDelayMS), IdentifyTimerHandler, this);
+
+exit:
+    return;
+}
diff --git a/examples/all-clusters-app/p6/src/ZclCallbacks.cpp b/examples/all-clusters-app/p6/src/ZclCallbacks.cpp
new file mode 100644
index 0000000..2191da0
--- /dev/null
+++ b/examples/all-clusters-app/p6/src/ZclCallbacks.cpp
@@ -0,0 +1,88 @@
+/*
+ *
+ *    Copyright (c) 2021 Project CHIP Authors
+ *    Copyright 2021, Cypress Semiconductor Corporation (an Infineon company)
+ *
+ *    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
+ *   This file implements the handler for data model messages.
+ */
+
+#include "AppConfig.h"
+#include <lib/support/logging/CHIPLogging.h>
+
+#include "ClusterManager.h"
+
+#include <app-common/zap-generated/attribute-id.h>
+#include <app-common/zap-generated/cluster-id.h>
+#include <app-common/zap-generated/ids/Attributes.h>
+#include <app-common/zap-generated/ids/Clusters.h>
+#include <app/util/af-types.h>
+
+using namespace ::chip;
+using namespace ::chip::app::Clusters;
+
+void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t mask, uint8_t type,
+                                       uint16_t size, uint8_t * value)
+{
+    EndpointId endpoint     = attributePath.mEndpointId;
+    ClusterId clusterId     = attributePath.mClusterId;
+    AttributeId attributeId = attributePath.mAttributeId;
+    P6_LOG("MatterPostAttributeChangeCallback - Cluster ID: " ChipLogFormatMEI
+           ", EndPoint ID: '0x%02x', Attribute ID: " ChipLogFormatMEI,
+           ChipLogValueMEI(clusterId), endpoint, ChipLogValueMEI(attributeId));
+
+    switch (clusterId)
+    {
+    case OnOff::Id:
+        ClusterMgr().OnOnOffPostAttributeChangeCallback(endpoint, attributeId, value);
+        break;
+
+    case Identify::Id:
+        ClusterMgr().OnIdentifyPostAttributeChangeCallback(endpoint, attributeId, value);
+        break;
+
+    case LevelControl::Id:
+        ClusterMgr().OnLevelControlAttributeChangeCallback(endpoint, attributeId, value);
+        break;
+
+    case ColorControl::Id:
+        ClusterMgr().OnColorControlAttributeChangeCallback(endpoint, attributeId, value);
+        break;
+    default:
+        P6_LOG("Unhandled cluster ID: " ChipLogFormatMEI, ChipLogValueMEI(clusterId));
+        break;
+    }
+}
+/** @brief OnOff Cluster Init
+ *
+ * This function is called when a specific cluster is initialized. It gives the
+ * application an opportunity to take care of cluster initialization procedures.
+ * It is called exactly once for each endpoint where cluster is present.
+ *
+ * @param endpoint   Ver.: always
+ *
+ * TODO Issue #3841
+ * emberAfOnOffClusterInitCallback happens before the stack initialize the cluster
+ * attributes to the default value.
+ * The logic here expects something similar to the deprecated Plugins callback
+ * emberAfPluginOnOffClusterServerPostInitCallback.
+ *
+ */
+void emberAfOnOffClusterInitCallback(EndpointId endpoint)
+{
+    // TODO: implement any additional Cluster Server init actions
+}
diff --git a/examples/all-clusters-app/p6/src/main.cpp b/examples/all-clusters-app/p6/src/main.cpp
new file mode 100644
index 0000000..68446f6
--- /dev/null
+++ b/examples/all-clusters-app/p6/src/main.cpp
@@ -0,0 +1,129 @@
+/*
+ *
+ *    Copyright (c) 2021 Project CHIP Authors
+ *    Copyright (c) 2019 Google LLC.
+ *    Copyright 2021, Cypress Semiconductor Corporation (an Infineon company)
+ *    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 <stdio.h>
+#include <stdlib.h>
+
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+#include <FreeRTOS.h>
+
+#include <lib/support/CHIPMem.h>
+#include <lib/support/CHIPPlatformMemory.h>
+#include <platform/CHIPDeviceLayer.h>
+#include <platform/KeyValueStoreManager.h>
+
+#include <AppTask.h>
+
+#include "AppConfig.h"
+#include "init_p6Platform.h"
+#include <app/server/Server.h>
+
+#ifdef HEAP_MONITORING
+#include "MemMonitoring.h"
+#endif
+
+using namespace ::chip;
+using namespace ::chip::Inet;
+using namespace ::chip::DeviceLayer;
+
+volatile int apperror_cnt;
+// ================================================================================
+// App Error
+//=================================================================================
+void appError(int err)
+{
+    P6_LOG("!!!!!!!!!!!! App Critical Error: %d !!!!!!!!!!!", err);
+    portDISABLE_INTERRUPTS();
+    while (1)
+        ;
+}
+
+void appError(CHIP_ERROR error)
+{
+    appError(static_cast<int>(error.AsInteger()));
+}
+
+// ================================================================================
+// FreeRTOS Callbacks
+// ================================================================================
+extern "C" void vApplicationIdleHook(void)
+{
+    // FreeRTOS Idle callback
+}
+
+// ================================================================================
+// Main Code
+// ================================================================================
+int main(void)
+{
+    init_p6Platform();
+
+#ifdef HEAP_MONITORING
+    MemMonitoring::startHeapMonitoring();
+#endif
+
+    P6_LOG("==================================================\r\n");
+    P6_LOG("chip-p6-all-clusters-example starting\r\n");
+    P6_LOG("==================================================\r\n");
+
+    // Init Chip memory management before the stack
+    chip::Platform::MemoryInit();
+
+    CHIP_ERROR ret = PlatformMgr().InitChipStack();
+    if (ret != CHIP_NO_ERROR)
+    {
+        P6_LOG("PlatformMgr().InitChipStack() failed");
+        appError(ret);
+    }
+
+    ret = chip::DeviceLayer::ConnectivityMgr().SetBLEDeviceName("P6_CLUSTERS");
+    if (ret != CHIP_NO_ERROR)
+    {
+        P6_LOG("ConnectivityMgr().SetBLEDeviceName() failed");
+        appError(ret);
+    }
+
+    P6_LOG("Starting Platform Manager Event Loop");
+    ret = PlatformMgr().StartEventLoopTask();
+    if (ret != CHIP_NO_ERROR)
+    {
+        P6_LOG("PlatformMgr().StartEventLoopTask() failed");
+        appError(ret);
+    }
+    ret = GetAppTask().StartAppTask();
+    if (ret != CHIP_NO_ERROR)
+    {
+        P6_LOG("GetAppTask().Init() failed");
+        appError(ret);
+    }
+    /* Start the FreeRTOS scheduler */
+    vTaskStartScheduler();
+
+    chip::Platform::MemoryShutdown();
+    PlatformMgr().StopEventLoopTask();
+    PlatformMgr().Shutdown();
+
+    // Should never get here.
+    P6_LOG("vTaskStartScheduler() failed");
+    appError(ret);
+}
diff --git a/examples/all-clusters-app/p6/third_party/connectedhomeip b/examples/all-clusters-app/p6/third_party/connectedhomeip
new file mode 120000
index 0000000..11a54ed
--- /dev/null
+++ b/examples/all-clusters-app/p6/third_party/connectedhomeip
@@ -0,0 +1 @@
+../../../../
\ No newline at end of file
diff --git a/examples/platform/p6/LEDWidget.cpp b/examples/platform/p6/LEDWidget.cpp
index cae7a64..4b91402 100644
--- a/examples/platform/p6/LEDWidget.cpp
+++ b/examples/platform/p6/LEDWidget.cpp
@@ -2,6 +2,7 @@
  *
  *    Copyright (c) 2021 Project CHIP Authors
  *    Copyright (c) 2019 Google LLC.
+ *    Copyright 2021, Cypress Semiconductor Corporation (an Infineon company)
  *    All rights reserved.
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,15 +24,42 @@
 #include "cyhal.h"
 #include <platform/CHIPDeviceLayer.h>
 
+/*******************************************************************************
+ * Macro Definitions
+ *******************************************************************************/
+/* Allowed TCPWM compare value for maximum brightness */
+#define LED_MAX_BRIGHTNESS (100u)
+
+/* Allowed TCPWM compare value for minimum brightness*/
+#define LED_MIN_BRIGHTNESS (1u)
+
+#define PWM_LED_FREQ_HZ (1000000u) /* in Hz */
+
+/* subtracting from 100 since the LED is connected in active low configuration */
+#define GET_DUTY_CYCLE(x) (100 - x)
+
+// PWM period in micro seconds
+#define CY_RGB_LED_PWM_PERIOD_US (255u)
+
+// Clock instance
+static cyhal_clock_t clk_pwm;
+
 void LEDWidget::Init(int ledNum)
 {
     mLastChangeTimeMS = 0;
     mBlinkOnTimeMS    = 0;
     mBlinkOffTimeMS   = 0;
     mLedNum           = ledNum;
-    mState            = CYBSP_LED_STATE_OFF;
-
-    cyhal_gpio_init((cyhal_gpio_t) ledNum, CYHAL_GPIO_DIR_OUTPUT, CYHAL_GPIO_DRIVE_STRONG, CYBSP_LED_STATE_OFF);
+    mState            = 0;
+    mbrightness       = LED_MAX_BRIGHTNESS;
+    if (CY_RSLT_SUCCESS != cyhal_pwm_init(&pwm_led, (cyhal_gpio_t) ledNum, NULL))
+    {
+        printf("LED PWM Init failed!");
+    }
+    if (CY_RSLT_SUCCESS != cyhal_pwm_set_duty_cycle(&pwm_led, GET_DUTY_CYCLE(LED_MAX_BRIGHTNESS), PWM_LED_FREQ_HZ))
+    {
+        printf("PWM failed to set dutycycle!");
+    }
 }
 
 void LEDWidget::Invert(void)
@@ -45,6 +73,11 @@
     DoSet(state);
 }
 
+bool LEDWidget::Get()
+{
+    return mState;
+}
+
 void LEDWidget::Blink(uint32_t changeRateMS)
 {
     Blink(changeRateMS, changeRateMS);
@@ -77,7 +110,204 @@
 {
     if (mState != state)
     {
-        cyhal_gpio_write((cyhal_gpio_t) mLedNum, ((state) ? CYBSP_LED_STATE_ON : CYBSP_LED_STATE_OFF));
+        (state) ? PWM_start() : PWM_stop();
     }
     mState = state;
 }
+
+void LEDWidget::RGB_init()
+{
+    cy_rslt_t result = CY_RSLT_SUCCESS;
+    // Allocate and assign the clock for TCPWMs for RGB LED control
+    result = cyhal_clock_allocate(&clk_pwm, CYHAL_CLOCK_BLOCK_PERIPHERAL_16BIT);
+    if (result == CY_RSLT_SUCCESS)
+    {
+        result = cyhal_clock_set_frequency(&clk_pwm, PWM_LED_FREQ_HZ, NULL);
+    }
+
+    if (result == CY_RSLT_SUCCESS)
+    {
+        result = cyhal_clock_set_enabled(&clk_pwm, true, true);
+    }
+
+    if (CY_RSLT_SUCCESS != cyhal_pwm_init(&pwm_red, CYBSP_LED_RGB_RED, &clk_pwm))
+    {
+        printf("PWM Init failed for RBG Red LED!");
+    }
+    if (CY_RSLT_SUCCESS != cyhal_pwm_init(&pwm_green, CYBSP_LED_RGB_GREEN, &clk_pwm))
+    {
+        printf("PWM Init failed for RBG Green LED!");
+    }
+    if (CY_RSLT_SUCCESS != cyhal_pwm_init(&pwm_blue, CYBSP_LED_RGB_BLUE, &clk_pwm))
+    {
+        printf("PWM Init failed for RBG blue LED!");
+    }
+
+    if (CY_RSLT_SUCCESS != cyhal_pwm_set_duty_cycle(&pwm_red, GET_DUTY_CYCLE(LED_MAX_BRIGHTNESS), PWM_LED_FREQ_HZ))
+    {
+        printf("PWM failed to set dutycycle for RBG Red LED!");
+    }
+    if (CY_RSLT_SUCCESS != cyhal_pwm_set_duty_cycle(&pwm_green, GET_DUTY_CYCLE(LED_MAX_BRIGHTNESS), PWM_LED_FREQ_HZ))
+    {
+        printf("PWM failed to set dutycycle for RBG Green LED!");
+    }
+    if (CY_RSLT_SUCCESS != cyhal_pwm_set_duty_cycle(&pwm_blue, GET_DUTY_CYCLE(LED_MAX_BRIGHTNESS), PWM_LED_FREQ_HZ))
+    {
+        printf("PWM failed to set dutycycle for RBG Blue LED!");
+    }
+
+    mState      = 0;
+    mbrightness = LED_MAX_BRIGHTNESS;
+    mHue        = 0;
+    mSaturation = 0;
+}
+
+void LEDWidget::PWM_start()
+{
+    if (!mState)
+    {
+        /* Start PWM to turn the LED on */
+        if (CY_RSLT_SUCCESS != cyhal_pwm_start(&pwm_led))
+        {
+            printf("PWM failed to start!");
+        }
+        mState = 1;
+    }
+}
+
+void LEDWidget::PWM_stop()
+{
+    if (mState)
+    {
+        /* Stop PWM to turn the LED off */
+        if (CY_RSLT_SUCCESS != cyhal_pwm_stop(&pwm_led))
+        {
+            printf("PWM failed to stop!");
+        }
+        mState = 0;
+    }
+}
+
+void LEDWidget::RGB_set(bool state)
+{
+    if (mState != state)
+    {
+        if (state)
+        {
+            if (CY_RSLT_SUCCESS != cyhal_pwm_start(&pwm_red))
+            {
+                printf("PWM failed to start!");
+            }
+            if (CY_RSLT_SUCCESS != cyhal_pwm_start(&pwm_green))
+            {
+                printf("PWM failed to start!");
+            }
+            if (CY_RSLT_SUCCESS != cyhal_pwm_start(&pwm_blue))
+            {
+                printf("PWM failed to start!");
+            }
+            mState = 1;
+        }
+        else
+        {
+            if (CY_RSLT_SUCCESS != cyhal_pwm_stop(&pwm_red))
+            {
+                printf("PWM failed to start!");
+            }
+            if (CY_RSLT_SUCCESS != cyhal_pwm_stop(&pwm_green))
+            {
+                printf("PWM failed to start!");
+            }
+            if (CY_RSLT_SUCCESS != cyhal_pwm_stop(&pwm_blue))
+            {
+                printf("PWM failed to start!");
+            }
+            mState = 0;
+        }
+    }
+}
+void LEDWidget::SetBrightness(uint32_t led_brightness)
+{
+    mbrightness = (led_brightness < LED_MIN_BRIGHTNESS) ? LED_MIN_BRIGHTNESS
+                                                        : static_cast<uint16_t>(led_brightness) * 100 / CY_RGB_LED_PWM_PERIOD_US;
+
+    /* Set Brightness for RGB LED */
+    if (pwm_red.pin)
+    {
+        HSB2rgb(mHue, mSaturation, mbrightness);
+    }
+    else
+    {
+        /* Drive the LED with brightness */
+        if (CY_RSLT_SUCCESS != cyhal_pwm_set_duty_cycle(&pwm_led, GET_DUTY_CYCLE(mbrightness), PWM_LED_FREQ_HZ))
+        {
+            printf("PWM failed to set dutycycle!");
+        }
+        PWM_start();
+    }
+}
+
+void LEDWidget::SetColor(uint8_t Hue, uint8_t Saturation)
+{
+    uint8_t brightness = (mState) ? mbrightness : 0;
+
+    mHue        = static_cast<uint16_t>(Hue) * 360 / 254;        // mHue [0, 360]
+    mSaturation = static_cast<uint16_t>(Saturation) * 100 / 254; // mSaturation [0 , 100]
+
+    HSB2rgb(mHue, mSaturation, brightness);
+}
+
+void LEDWidget::HSB2rgb(uint16_t Hue, uint8_t Saturation, uint8_t brightness)
+{
+    uint8_t red, green, blue;
+    uint16_t i       = Hue / 60;
+    brightness       = static_cast<uint16_t>(brightness) * CY_RGB_LED_PWM_PERIOD_US / 100;
+    uint16_t rgb_max = brightness;
+    uint16_t rgb_min = rgb_max * (100 - Saturation) / 100;
+    uint16_t diff    = Hue % 60;
+    uint16_t rgb_adj = (rgb_max - rgb_min) * diff / 60;
+
+    switch (i)
+    {
+    case 0:
+        red   = rgb_max;
+        green = rgb_min + rgb_adj;
+        blue  = rgb_min;
+        break;
+    case 1:
+        red   = rgb_max - rgb_adj;
+        green = rgb_max;
+        blue  = rgb_min;
+        break;
+    case 2:
+        red   = rgb_min;
+        green = rgb_max;
+        blue  = rgb_min + rgb_adj;
+        break;
+    case 3:
+        red   = rgb_min;
+        green = rgb_max - rgb_adj;
+        blue  = rgb_max;
+        break;
+    case 4:
+        red   = rgb_min + rgb_adj;
+        green = rgb_min;
+        blue  = rgb_max;
+        break;
+    default:
+        red   = rgb_max;
+        green = rgb_min;
+        blue  = rgb_max - rgb_adj;
+        break;
+    }
+
+    /* LED is configured as ACTIVE LOW */
+    red   = CY_RGB_LED_PWM_PERIOD_US - red;
+    green = CY_RGB_LED_PWM_PERIOD_US - green;
+    blue  = CY_RGB_LED_PWM_PERIOD_US - blue;
+
+    /* Set Period to control color setting */
+    cyhal_pwm_set_period(&pwm_red, CY_RGB_LED_PWM_PERIOD_US, red);
+    cyhal_pwm_set_period(&pwm_green, CY_RGB_LED_PWM_PERIOD_US, green);
+    cyhal_pwm_set_period(&pwm_blue, CY_RGB_LED_PWM_PERIOD_US, blue);
+}
diff --git a/examples/platform/p6/LEDWidget.h b/examples/platform/p6/LEDWidget.h
index bd99d88..05e3d65 100644
--- a/examples/platform/p6/LEDWidget.h
+++ b/examples/platform/p6/LEDWidget.h
@@ -28,17 +28,31 @@
     static void InitGpio(void);
     void Init(int ledNum);
     void Set(bool state);
+    bool Get(void);
     void Invert(void);
     void Blink(uint32_t changeRateMS);
     void Blink(uint32_t onTimeMS, uint32_t offTimeMS);
     void Animate();
+    void PWM_start();
+    void PWM_stop();
+    void RGB_init();
+    void RGB_set(bool state);
+    void SetBrightness(uint32_t led_brightness);
+    void SetColor(uint8_t Hue, uint8_t Saturation);
+    void HSB2rgb(uint16_t Hue, uint8_t Saturation, uint8_t brightness);
 
 private:
     uint64_t mLastChangeTimeMS = 0;
     uint32_t mBlinkOnTimeMS    = 0;
     uint32_t mBlinkOffTimeMS   = 0;
     int mLedNum                = 0;
-    bool mState                = CYBSP_LED_STATE_OFF;
-
+    bool mState                = 0;
+    uint8_t mbrightness        = 0;
+    uint16_t mHue;
+    uint8_t mSaturation;
+    cyhal_pwm_t pwm_red;
+    cyhal_pwm_t pwm_green;
+    cyhal_pwm_t pwm_blue;
+    cyhal_pwm_t pwm_led;
     void DoSet(bool state);
 };
diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py
index d839e7c..da3a2a8 100644
--- a/scripts/build/build/targets.py
+++ b/scripts/build/build/targets.py
@@ -216,6 +216,13 @@
         yield target.Extend('debug', profile=MbedProfile.DEBUG).GlobBlacklist('Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html')
 
 
+def InfineonTargets():
+    target = Target('infineon', InfineonBuilder)
+
+    yield target.Extend('p6-lock', board=InfineonBoard.P6BOARD, app=InfineonApp.LOCK)
+    yield target.Extend('p6-all-clusters', board=InfineonBoard.P6BOARD, app=InfineonApp.ALL_CLUSTERS)
+
+
 ALL = []
 
 target_generators = [
@@ -224,7 +231,9 @@
     Efr32Targets(),
     NrfTargets(),
     AndroidTargets(),
-    MbedTargets()
+    MbedTargets(),
+    InfineonTargets()
+
 ]
 
 for generator in target_generators:
@@ -235,8 +244,6 @@
 ALL.append(Target('qpg-qpg6100-lock', QpgBuilder))
 ALL.append(Target('telink-tlsr9518adk80d-light', TelinkBuilder,
                   board=TelinkBoard.TLSR9518ADK80D, app=TelinkApp.LIGHT))
-ALL.append(Target('infineon-p6-lock', InfineonBuilder,
-                  board=InfineonBoard.P6BOARD, app=InfineonApp.LOCK))
 ALL.append(Target('tizen-arm-light', TizenBuilder,
                   board=TizenBoard.ARM, app=TizenApp.LIGHT))
 ALL.append(Target('ameba-amebad-all-clusters', AmebaBuilder,
diff --git a/scripts/build/builders/infineon.py b/scripts/build/builders/infineon.py
index 1a8afbb..c7e23fc 100644
--- a/scripts/build/builders/infineon.py
+++ b/scripts/build/builders/infineon.py
@@ -20,16 +20,21 @@
 
 class InfineonApp(Enum):
     LOCK = auto()
+    ALL_CLUSTERS = auto()
 
     def ExampleName(self):
         if self == InfineonApp.LOCK:
             return 'lock-app'
+        elif self == InfineonApp.ALL_CLUSTERS:
+            return 'all-clusters-app'
         else:
             raise Exception('Unknown app type: %r' % self)
 
     def AppNamePrefix(self):
         if self == InfineonApp.LOCK:
             return 'chip-p6-lock-example'
+        elif self == InfineonApp.ALL_CLUSTERS:
+            return 'chip-p6-all-clusters-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 275483b..7324824 100644
--- a/scripts/build/testdata/all_targets_except_host.txt
+++ b/scripts/build/testdata/all_targets_except_host.txt
@@ -24,6 +24,7 @@
 esp32-m5stack-all-clusters-ipv6only
 esp32-m5stack-all-clusters-rpc
 esp32-m5stack-all-clusters-rpc-ipv6only
+infineon-p6-all-clusters
 infineon-p6-lock
 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)
diff --git a/scripts/build/testdata/build_all_except_host.txt b/scripts/build/testdata/build_all_except_host.txt
index 182bc63..f928f42 100644
--- a/scripts/build/testdata/build_all_except_host.txt
+++ b/scripts/build/testdata/build_all_except_host.txt
@@ -263,6 +263,9 @@
 export SDKCONFIG_DEFAULTS={out}/esp32-m5stack-all-clusters-rpc-ipv6only/sdkconfig.defaults
 idf.py -C examples/all-clusters-app/esp32 -B {out}/esp32-m5stack-all-clusters-rpc-ipv6only reconfigure'
 
+# Generating infineon-p6-all-clusters
+gn gen --check --fail-on-unused-args --root={root}/examples/all-clusters-app/p6 '--args=p6_board="CY8CKIT-062S2-43012"' {out}/infineon-p6-all-clusters
+
 # Generating infineon-p6-lock
 gn gen --check --fail-on-unused-args --root={root}/examples/lock-app/p6 '--args=p6_board="CY8CKIT-062S2-43012"' {out}/infineon-p6-lock
 
@@ -683,6 +686,9 @@
 export SDKCONFIG_DEFAULTS={out}/esp32-m5stack-all-clusters-rpc-ipv6only/sdkconfig.defaults
 idf.py -C examples/all-clusters-app/esp32 -B {out}/esp32-m5stack-all-clusters-rpc-ipv6only build'
 
+# Building infineon-p6-all-clusters
+ninja -C {out}/infineon-p6-all-clusters
+
 # Building infineon-p6-lock
 ninja -C {out}/infineon-p6-lock
 
diff --git a/scripts/build/testdata/glob_star_targets_except_host.txt b/scripts/build/testdata/glob_star_targets_except_host.txt
index de84e94..8ef6876 100644
--- a/scripts/build/testdata/glob_star_targets_except_host.txt
+++ b/scripts/build/testdata/glob_star_targets_except_host.txt
@@ -24,6 +24,7 @@
 esp32-m5stack-all-clusters-ipv6only
 esp32-m5stack-all-clusters-rpc
 esp32-m5stack-all-clusters-rpc-ipv6only
+infineon-p6-all-clusters
 infineon-p6-lock
 mbed-CY8CPROTO_062_4343W-all-clusters-release
 mbed-CY8CPROTO_062_4343W-light-release
diff --git a/src/app/clusters/barrier-control-server/barrier-control-server.cpp b/src/app/clusters/barrier-control-server/barrier-control-server.cpp
index df4823f..e665f78 100644
--- a/src/app/clusters/barrier-control-server/barrier-control-server.cpp
+++ b/src/app/clusters/barrier-control-server/barrier-control-server.cpp
@@ -318,7 +318,7 @@
         state.currentPosition = getCurrentPosition(endpoint);
         state.targetPosition  = percentOpen;
         state.delayMs         = calculateDelayMs(endpoint, state.targetPosition, &state.increasing);
-        emberAfBarrierControlClusterPrintln("Scheduling barrier move from %d to %d with %dms delay", state.currentPosition,
+        emberAfBarrierControlClusterPrintln("Scheduling barrier move from %d to %d with %" PRIu32 "ms delay", state.currentPosition,
                                             state.targetPosition, state.delayMs);
         emberAfScheduleServerTick(endpoint, BarrierControl::Id, state.delayMs);
 
diff --git a/src/app/clusters/door-lock-server/door-lock-server-core.cpp b/src/app/clusters/door-lock-server/door-lock-server-core.cpp
index f08020c..3593bc6 100644
--- a/src/app/clusters/door-lock-server/door-lock-server-core.cpp
+++ b/src/app/clusters/door-lock-server/door-lock-server-core.cpp
@@ -98,7 +98,8 @@
                                                            (uint8_t *) &data[i].value, ZCL_INT16U_ATTRIBUTE_TYPE);
         if (status != EMBER_ZCL_STATUS_SUCCESS)
         {
-            emberAfDoorLockClusterPrintln("Failed to write %s attribute 0x%2X: 0x%X", description, data[i].id, status);
+            emberAfDoorLockClusterPrintln("Failed to write %s attribute " ChipLogFormatMEI ": 0x%X", description,
+                                          ChipLogValueMEI(data[i].id), status);
         }
     }
 }
diff --git a/src/app/util/util.cpp b/src/app/util/util.cpp
index 82994a6..676c0de 100644
--- a/src/app/util/util.cpp
+++ b/src/app/util/util.cpp
@@ -420,7 +420,8 @@
     else if ((cmd->type == EMBER_INCOMING_MULTICAST || cmd->type == EMBER_INCOMING_MULTICAST_LOOPBACK) &&
              !emberAfGroupsClusterEndpointInGroupCallback(cmd->apsFrame->destinationEndpoint, cmd->apsFrame->groupId))
     {
-        emberAfDebugPrint("Drop cluster 0x%2x command 0x%x", cmd->apsFrame->clusterId, cmd->commandId);
+        emberAfDebugPrint("Drop cluster " ChipLogFormatMEI " command " ChipLogFormatMEI, ChipLogValueMEI(cmd->apsFrame->clusterId),
+                          ChipLogValueMEI(cmd->commandId));
         emberAfDebugPrint(" for endpoint 0x%x due to wrong %s: ", cmd->apsFrame->destinationEndpoint, "group");
         emberAfDebugPrintln("0x%02x", cmd->apsFrame->groupId);
         return false;
diff --git a/src/inet/IPAddress.cpp b/src/inet/IPAddress.cpp
index 2005359..dc65dce 100644
--- a/src/inet/IPAddress.cpp
+++ b/src/inet/IPAddress.cpp
@@ -72,8 +72,8 @@
 
 IPAddress::IPAddress(const ip6_addr_t & ipv6Addr)
 {
-    static_assert(sizeof(ip6_addr_t) == sizeof(Addr), "ip6_addr_t size mismatch");
-    memcpy(Addr, &ipv6Addr, sizeof(ipv6Addr));
+    static_assert(sizeof(ipv6Addr.addr) == sizeof(Addr), "ip6_addr_t size mismatch");
+    memcpy(Addr, &ipv6Addr.addr, sizeof(ipv6Addr.addr));
 }
 
 #if INET_CONFIG_ENABLE_IPV4 || LWIP_IPV4
@@ -178,8 +178,8 @@
 ip6_addr_t IPAddress::ToIPv6() const
 {
     ip6_addr_t ipAddr;
-    static_assert(sizeof(ipAddr) == sizeof(Addr), "ip6_addr_t size mismatch");
-    memcpy(&ipAddr, Addr, sizeof(ipAddr));
+    static_assert(sizeof(ipAddr.addr) == sizeof(Addr), "ip6_addr_t size mismatch");
+    memcpy(&ipAddr.addr, Addr, sizeof(ipAddr.addr));
     return ipAddr;
 }
 
diff --git a/src/lwip/BUILD.gn b/src/lwip/BUILD.gn
index 30ef9d3..e6a9b4f 100644
--- a/src/lwip/BUILD.gn
+++ b/src/lwip/BUILD.gn
@@ -81,6 +81,16 @@
   group("all") {
     deps = [ ":lwip" ]
   }
+} else if (lwip_platform == "p6") {
+  group("lwip") {
+    public_deps = [ ":lwip_buildconfig" ]
+    public_configs = [ "${chip_root}/src:includes" ]
+    public_configs += [ "${p6_sdk_build_root}:p6_sdk_config" ]
+  }
+
+  group("all") {
+    deps = [ ":lwip" ]
+  }
 } else {
   config("lwip_config") {
     include_dirs = [ lwip_platform ]
@@ -127,9 +137,5 @@
       ":lwip_config",
       "${chip_root}/src:includes",
     ]
-
-    if (lwip_platform == "p6") {
-      public_configs += [ "${p6_sdk_build_root}:p6_sdk_config" ]
-    }
   }
 }
diff --git a/src/lwip/p6/arch/cc.h b/src/lwip/p6/arch/cc.h
deleted file mode 100644
index f239eca..0000000
--- a/src/lwip/p6/arch/cc.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- *
- *    Copyright (c) 2021 Project CHIP Authors
- *    Copyright (c) 2019 Nest Labs, Inc.
- *
- *   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.
- *
- */
-
-#ifndef CHIP_LWIP_FREERTOS_ARCH_CC_H
-#define CHIP_LWIP_FREERTOS_ARCH_CC_H
-
-#include <assert.h>
-#include <errno.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/time.h>
-
-#if CHIP_CONFIG_MEMORY_MGMT_MALLOC
-#include <malloc.h>
-#endif
-
-#if __cplusplus
-extern "C" {
-#endif
-
-#ifndef LWIP_NOASSERT
-#ifdef DEBUG
-#define LWIP_PLATFORM_ASSERT(MSG) assert(MSG);
-#else
-#define LWIP_PLATFORM_ASSERT(MSG)
-#endif
-#else
-#define LWIP_PLATFORM_ASSERT(message)
-#endif
-
-#ifndef BYTE_ORDER
-#if defined(__LITTLE_ENDIAN__)
-#define BYTE_ORDER LITTLE_ENDIAN
-#elif defined(__BIG_ENDIAN__)
-#define BYTE_ORDER BIG_ENDIAN
-#elif defined(__BYTE_ORDER__)
-#define BYTE_ORDER __BYTE_ORDER__
-#endif
-#endif // BYTE_ORDER
-
-#define PACK_STRUCT_STRUCT __attribute__((__packed__))
-#define PACK_STRUCT_FIELD(x) x
-
-extern void LwIPLog(const char * fmt, ...);
-#define LWIP_PLATFORM_DIAG(x)                                                                                                      \
-    do                                                                                                                             \
-    {                                                                                                                              \
-        LwIPLog x;                                                                                                                 \
-    } while (0)
-
-// Place LwIP pools into their own subsections of .bss to make it easier to see
-// their sizes in the linker map file.
-extern uint8_t __attribute__((section(".bss.lwip_ND6_QUEUE"))) memp_memory_ND6_QUEUE_base[];
-extern uint8_t __attribute__((section(".bss.lwip_IP6_REASSDATA"))) memp_memory_IP6_REASSDATA_base[];
-extern uint8_t __attribute__((section(".bss.lwip_RAW_PCB"))) memp_memory_RAW_PCB_base[];
-extern uint8_t __attribute__((section(".bss.lwip_TCP_SEG"))) memp_memory_TCP_SEG_base[];
-extern uint8_t __attribute__((section(".bss.lwip_PBUF_POOL"))) memp_memory_PBUF_POOL_base[];
-extern uint8_t __attribute__((section(".bss.lwip_FRAG_PBUF"))) memp_memory_FRAG_PBUF_base[];
-extern uint8_t __attribute__((section(".bss.lwip_PBUF"))) memp_memory_PBUF_base[];
-extern uint8_t __attribute__((section(".bss.lwip_TCP_PCB_LISTEN"))) memp_memory_TCP_PCB_LISTEN_base[];
-extern uint8_t __attribute__((section(".bss.lwip_REASSDATA"))) memp_memory_REASSDATA_base[];
-extern uint8_t __attribute__((section(".bss.lwip_UDP_PCB"))) memp_memory_UDP_PCB_base[];
-extern uint8_t __attribute__((section(".bss.lwip_MLD6_GROUP"))) memp_memory_MLD6_GROUP_base[];
-extern uint8_t __attribute__((section(".bss.lwip_IGMP_GROUP"))) memp_memory_IGMP_GROUP_base[];
-extern uint8_t __attribute__((section(".bss.lwip_TCP_PCB"))) memp_memory_TCP_PCB_base[];
-extern uint8_t __attribute__((section(".bss.lwip_SYS_TIMEOUT"))) memp_memory_SYS_TIMEOUT_base[];
-
-#if __cplusplus
-}
-#endif
-
-#endif /* CHIP_LWIP_FREERTOS_ARCH_CC_H */
diff --git a/src/lwip/p6/arch/perf.h b/src/lwip/p6/arch/perf.h
deleted file mode 100644
index 2b75106..0000000
--- a/src/lwip/p6/arch/perf.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- *
- *    Copyright (c) 2021 Project CHIP Authors
- *    Copyright (c) 2019 Nest Labs, Inc.
- *
- *   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.
- *
- */
-
-#ifndef CHIP_LWIP_FREERTOS_ARCH_PERF_H
-#define CHIP_LWIP_FREERTOS_ARCH_PERF_H
-
-#define PERF_START
-#define PERF_STOP(s)
-
-#endif /* CHIP_LWIP_FREERTOS_ARCH_PERF_H */
diff --git a/src/lwip/p6/lwipopts.h b/src/lwip/p6/lwipopts.h
deleted file mode 100644
index a652ac7..0000000
--- a/src/lwip/p6/lwipopts.h
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- *
- *    Copyright (c) 2021 Project CHIP Authors
- *    Copyright (c) 2019 Nest Labs, Inc.
- *
- *    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
- *      Compile-time configuration for LwIP on EFR32 platforms using the
- *      Silicon Labs EFR32 SDK.
- *
- */
-
-#ifndef __LWIPOPTS_H__
-#define __LWIPOPTS_H__
-
-#if CHIP_HAVE_CONFIG_H
-#include <lwip/lwip_buildconfig.h>
-#endif
-
-#include <stdlib.h>
-
-#include <whd_types.h>
-
-#define NO_SYS 0
-#define MEM_ALIGNMENT (4)
-#define MEMP_NUM_TCP_SEG (TCP_SND_QUEUELEN + 1)
-#define LWIP_TIMEVAL_PRIVATE (0)
-#define MEM_LIBC_MALLOC (1)
-#define LWIP_COMPAT_MUTEX (0)
-#define SYS_LIGHTWEIGHT_PROT (1)
-#define LWIP_AUTOIP (0)
-#define LWIP_DHCP_AUTOIP_COOP (0)
-#define LWIP_SOCKET_SET_ERRNO 1
-#define IP_REASS_MAX_PBUFS 0
-#define IP_REASSEMBLY 0
-#define MEMP_NUM_REASSDATA 0
-#define LWIP_SO_RCVTIMEO 1
-#define LWIP_SO_RCVBUF 1
-#define SO_REUSE (1)
-#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS (1)
-#define LWIP_STATS (0)
-#define LWIP_TCPIP_CORE_LOCKING 1
-#define TCP_QUEUE_OOSEQ 0
-#define ARP_QUEUEING (0)
-#define LWIP_TCP_KEEPALIVE (0)
-
-#define LWIP_SOCKET 1
-#define LWIP_NETCONN (1)
-
-#define LWIP_FREERTOS_USE_STATIC_TCPIP_TASK 0
-
-// TODO: seems like this is unnecessary on Thread-only platforms
-#define LWIP_RAW 1
-#define MEMP_NUM_RAW_PCB (5)
-
-// TODO: verify count
-#define MEMP_NUM_UDP_PCB (7)
-
-#define LWIP_HAVE_LOOPIF (0)
-
-#define LWIP_NETIF_API 1
-// TODO: not sure why this is disabled
-#define LWIP_NETIF_LOOPBACK (0)
-#define PBUF_LINK_HLEN (WHD_PHYSICAL_HEADER)
-
-#define MEMP_NUM_NETCONN (16)
-
-#define ETHARP_SUPPORT_STATIC_ENTRIES 1
-
-#define LWIP_IPV4 1
-#define LWIP_IPV6 1
-#define LWIP_ARP (1)
-#define LWIP_DNS (1)
-#define LWIP_ICMP (1)
-#define LWIP_TCP (1)
-#define LWIP_UDP (1)
-#define LWIP_IGMP (1)
-#define LWIP_DHCP (1)
-#define LWIP_IPV6_REASS (0)
-#define LWIP_IPV6_DHCP6 0
-#define LWIP_IPV6_AUTOCONFIG (1)
-#define LWIP_IPV6_ROUTER_SUPPORT 0
-#define LWIP_ND6_LISTEN_RA 0
-
-#define LWIP_SO_SNDTIMEO (1)
-
-#define LWIP_ND6_NUM_NEIGHBORS (0)
-#define LWIP_ND6_NUM_DESTINATIONS (0)
-#define LWIP_ND6_NUM_PREFIXES (0)
-#define LWIP_ND6_NUM_ROUTERS (0)
-#define LWIP_ND6_MAX_MULTICAST_SOLICIT (0)
-#define LWIP_ND6_MAX_UNICAST_SOLICIT (0)
-#define LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT (0)
-#define LWIP_ND6_TCP_REACHABILITY_HINTS (0)
-
-#ifdef CHIP_CONFIG_EFR32MG21_PBUF_POOLS
-#define MEMP_SEPARATE_POOLS (1)
-#define LWIP_PBUF_FROM_CUSTOM_POOLS (0)
-#define MEMP_USE_CUSTOM_POOLS (0)
-#define PBUF_POOL_SIZE (4)
-#define PBUF_POOL_BUFSIZE (1500)
-#define PBUF_POOL_SIZE_LARGE (1)
-#define PBUF_POOL_SIZE_MEDIUM (2)
-#define PBUF_POOL_SIZE_SMALL (2)
-#define PBUF_POOL_BUFSIZE_LARGE (1280)
-#define PBUF_POOL_BUFSIZE_MEDIUM (640)
-#define PBUF_POOL_BUFSIZE_SMALL (256)
-#define PBUF_CUSTOM_POOL_IDX_START (MEMP_PBUF_POOL_SMALL)
-#define PBUF_CUSTOM_POOL_IDX_END (MEMP_PBUF_POOL_LARGE)
-#else
-#define MEMP_SEPARATE_POOLS (1)
-#define LWIP_PBUF_FROM_CUSTOM_POOLS (0)
-#define MEMP_USE_CUSTOM_POOLS (0)
-#define PBUF_POOL_SIZE (8)
-#define PBUF_POOL_BUFSIZE (1500)
-#define PBUF_POOL_SIZE_LARGE (3)
-#define PBUF_POOL_SIZE_MEDIUM (4)
-#define PBUF_POOL_SIZE_SMALL (5)
-#define PBUF_POOL_BUFSIZE_LARGE (1280)
-#define PBUF_POOL_BUFSIZE_MEDIUM (640)
-#define PBUF_POOL_BUFSIZE_SMALL (256)
-#define PBUF_CUSTOM_POOL_IDX_START (MEMP_PBUF_POOL_SMALL)
-#define PBUF_CUSTOM_POOL_IDX_END (MEMP_PBUF_POOL_LARGE)
-#endif
-
-#define TCP_MSS (1152)
-#define TCP_SND_BUF (4 * TCP_MSS)
-#define TCP_LISTEN_BACKLOG (1)
-
-#define ETH_PAD_SIZE (0)
-#define SUB_ETHERNET_HEADER_SPACE (0)
-
-#define TCPIP_THREAD_STACKSIZE (4096)
-#define TCPIP_THREAD_PRIO (2)
-
-#define NETIF_MAX_HWADDR_LEN 8U
-
-#define LWIP_IPV6_NUM_ADDRESSES 5
-
-#define LWIP_IPV6_ND 1
-#define LWIP_ND6_QUEUEING 0
-
-#define LWIP_MULTICAST_PING 0
-
-#define TCPIP_MBOX_SIZE 6
-#define DEFAULT_RAW_RECVMBOX_SIZE 6
-#define DEFAULT_UDP_RECVMBOX_SIZE 6
-#define DEFAULT_TCP_RECVMBOX_SIZE 6
-
-#ifndef LWIP_DEBUG
-#define LWIP_DEBUG 1
-#endif
-
-#define MEMP_OVERFLOW_CHECK (0)
-#define MEMP_SANITY_CHECK (0)
-#define MEM_DEBUG (LWIP_DBG_OFF)
-#define MEMP_DEBUG (LWIP_DBG_OFF)
-#define PBUF_DEBUG (LWIP_DBG_OFF)
-#define API_LIB_DEBUG (LWIP_DBG_OFF)
-#define API_MSG_DEBUG (LWIP_DBG_OFF)
-#define TCPIP_DEBUG (LWIP_DBG_OFF)
-#define NETIF_DEBUG (LWIP_DBG_OFF)
-#define SOCKETS_DEBUG (LWIP_DBG_OFF)
-#define DEMO_DEBUG (LWIP_DBG_OFF)
-#define DHCP_DEBUG (LWIP_DBG_OFF)
-#define AUTOIP_DEBUG (LWIP_DBG_OFF)
-#define ETHARP_DEBUG (LWIP_DBG_OFF)
-#define IP_DEBUG (LWIP_DBG_OFF)
-#define IP_REASS_DEBUG (LWIP_DBG_OFF)
-#define IP6_DEBUG (LWIP_DBG_OFF)
-#define RAW_DEBUG (LWIP_DBG_OFF)
-#define ICMP_DEBUG (LWIP_DBG_OFF)
-#define UDP_DEBUG (LWIP_DBG_OFF)
-#define TCP_DEBUG (LWIP_DBG_OFF)
-#define TCP_INPUT_DEBUG (LWIP_DBG_OFF)
-#define TCP_OUTPUT_DEBUG (LWIP_DBG_OFF)
-#define TCP_RTO_DEBUG (LWIP_DBG_OFF)
-#define TCP_CWND_DEBUG (LWIP_DBG_OFF)
-#define TCP_WND_DEBUG (LWIP_DBG_OFF)
-#define TCP_FR_DEBUG (LWIP_DBG_OFF)
-#define TCP_QLEN_DEBUG (LWIP_DBG_OFF)
-#define TCP_RST_DEBUG (LWIP_DBG_OFF)
-#define PPP_DEBUG (LWIP_DBG_OFF)
-
-#define LWIP_DBG_TYPES_ON                                                                                                          \
-    (LWIP_DBG_ON | LWIP_DBG_TRACE) /* (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT) */
-
-#define LWIP_RAND rand
-#define LWIP_NETIF_LINK_CALLBACK 1
-#define LWIP_NETIF_STATUS_CALLBACK 1
-#define LWIP_NETIF_EXT_STATUS_CALLBACK 1
-#define LWIP_NETIF_REMOVE_CALLBACK 1
-#define netifapi_dhcp_release_and_stop(n) netifapi_dhcp_release(n)
-
-#endif /* __LWIPOPTS_H__ */
diff --git a/src/lwip/p6/lwippools.h b/src/lwip/p6/lwippools.h
deleted file mode 100644
index 91c285f..0000000
--- a/src/lwip/p6/lwippools.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- *   Copyright (c) 2021 Project CHIP Authors
- *   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.
- *
- */
diff --git a/src/platform/P6/cy_wcm.h b/src/platform/P6/cy_wcm.h
deleted file mode 100644
index 0e987f1..0000000
--- a/src/platform/P6/cy_wcm.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef CY_WCM_SHIM
-#define CY_WCM_SHIM
-
-// Shim to get cy wcm code to compile using the (older) CHIP-provided lwip.
-struct ifreq
-{
-    char ifr_name[6];
-};
-
-#define SO_BINDTODEVICE 42
-
-// Include the real cy_wcm.h
-#include "libs/wifi-connection-manager/include/cy_wcm.h"
-
-#endif
diff --git a/third_party/p6/p6_sdk/Makefile b/third_party/p6/p6_sdk/Makefile
old mode 100644
new mode 100755
diff --git a/third_party/p6/p6_sdk/arch/cc.h b/third_party/p6/p6_sdk/arch/cc.h
new file mode 100644
index 0000000..ae3ab0d
--- /dev/null
+++ b/third_party/p6/p6_sdk/arch/cc.h
@@ -0,0 +1,14 @@
+#pragma once

+

+#include <errno.h>

+#include <time.h>

+#define LWIP_PLATFORM_ASSERT(x)                                                                                                    \

+    do                                                                                                                             \

+    {                                                                                                                              \

+        printf("Assertion \"%s\" failed at line %d in %s\n", x, __LINE__, __FILE__);                                               \

+        abort();                                                                                                                   \

+    } while (0)

+

+#ifdef __ICCARM__

+#define PACK_STRUCT_BEGIN __packed

+#endif

diff --git a/third_party/p6/p6_sdk/arch/sys_arch.c b/third_party/p6/p6_sdk/arch/sys_arch.c
new file mode 100644
index 0000000..95c81ba
--- /dev/null
+++ b/third_party/p6/p6_sdk/arch/sys_arch.c
@@ -0,0 +1,612 @@
+/*

+ * Copyright (c) 2017 Simon Goldschmidt

+ * All rights reserved.

+ *

+ * Redistribution and use in source and binary forms, with or without modification,

+ * are permitted provided that the following conditions are met:

+ *

+ * 1. Redistributions of source code must retain the above copyright notice,

+ *    this list of conditions and the following disclaimer.

+ * 2. Redistributions in binary form must reproduce the above copyright notice,

+ *    this list of conditions and the following disclaimer in the documentation

+ *    and/or other materials provided with the distribution.

+ * 3. The name of the author may not be used to endorse or promote products

+ *    derived from this software without specific prior written permission.

+ *

+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED

+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF

+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT

+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,

+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT

+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING

+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY

+ * OF SUCH DAMAGE.

+ *

+ * This file is part of the lwIP TCP/IP stack.

+ *

+ * Author: Simon Goldschmidt <goldsimon@gmx.de>

+ *

+ */

+

+/* lwIP includes. */

+#include "FreeRTOS.h"

+#include "lwip/debug.h"

+#include "lwip/def.h"

+#include "lwip/mem.h"

+#include "lwip/stats.h"

+#include "lwip/sys.h"

+#include "lwip/tcpip.h"

+#include "semphr.h"

+#include "task.h"

+

+/** Set this to 1 if you want the stack size passed to sys_thread_new() to be

+ * interpreted as number of stack words (FreeRTOS-like).

+ * Default is that they are interpreted as byte count (lwIP-like).

+ */

+#ifndef LWIP_FREERTOS_THREAD_STACKSIZE_IS_STACKWORDS

+#define LWIP_FREERTOS_THREAD_STACKSIZE_IS_STACKWORDS 0

+#endif

+

+/** Set this to 1 to use a mutex for SYS_ARCH_PROTECT() critical regions.

+ * Default is 0 and locks interrupts/scheduler for SYS_ARCH_PROTECT().

+ */

+#ifndef LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX

+#define LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX 0

+#endif

+

+/** Set this to 1 to include a sanity check that SYS_ARCH_PROTECT() and

+ * SYS_ARCH_UNPROTECT() are called matching.

+ */

+#ifndef LWIP_FREERTOS_SYS_ARCH_PROTECT_SANITY_CHECK

+#define LWIP_FREERTOS_SYS_ARCH_PROTECT_SANITY_CHECK 0

+#endif

+

+/** Set this to 1 to let sys_mbox_free check that queues are empty when freed */

+#ifndef LWIP_FREERTOS_CHECK_QUEUE_EMPTY_ON_FREE

+#define LWIP_FREERTOS_CHECK_QUEUE_EMPTY_ON_FREE 0

+#endif

+

+/** Set this to 1 to enable core locking check functions in this port.

+ * For this to work, you'll have to define LWIP_ASSERT_CORE_LOCKED()

+ * and LWIP_MARK_TCPIP_THREAD() correctly in your lwipopts.h! */

+#ifndef LWIP_FREERTOS_CHECK_CORE_LOCKING

+#define LWIP_FREERTOS_CHECK_CORE_LOCKING 1

+#endif

+

+/** Set this to 0 to implement sys_now() yourself, e.g. using a hw timer.

+ * Default is 1, where FreeRTOS ticks are used to calculate back to ms.

+ */

+#ifndef LWIP_FREERTOS_SYS_NOW_FROM_FREERTOS

+#define LWIP_FREERTOS_SYS_NOW_FROM_FREERTOS 1

+#endif

+

+#if !configSUPPORT_DYNAMIC_ALLOCATION

+#error "lwIP FreeRTOS port requires configSUPPORT_DYNAMIC_ALLOCATION"

+#endif

+#if !INCLUDE_vTaskDelay

+#error "lwIP FreeRTOS port requires INCLUDE_vTaskDelay"

+#endif

+#if !INCLUDE_vTaskSuspend

+#error "lwIP FreeRTOS port requires INCLUDE_vTaskSuspend"

+#endif

+#if LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX || !LWIP_COMPAT_MUTEX

+#if !configUSE_MUTEXES

+#error "lwIP FreeRTOS port requires configUSE_MUTEXES"

+#endif

+#endif

+

+#if SYS_LIGHTWEIGHT_PROT && LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX

+static SemaphoreHandle_t sys_arch_protect_mutex;

+#endif

+#if SYS_LIGHTWEIGHT_PROT && LWIP_FREERTOS_SYS_ARCH_PROTECT_SANITY_CHECK

+static sys_prot_t sys_arch_protect_nesting;

+#endif

+

+/* Initialize this module (see description in sys.h) */

+void sys_init(void)

+{

+#if SYS_LIGHTWEIGHT_PROT && LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX

+    /* initialize sys_arch_protect global mutex */

+    sys_arch_protect_mutex = xSemaphoreCreateRecursiveMutex();

+    LWIP_ASSERT("failed to create sys_arch_protect mutex", sys_arch_protect_mutex != NULL);

+#endif /* SYS_LIGHTWEIGHT_PROT && LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX */

+}

+

+#if configUSE_16_BIT_TICKS == 1

+#error This port requires 32 bit ticks or timer overflow will fail

+#endif

+

+#if LWIP_FREERTOS_SYS_NOW_FROM_FREERTOS

+u32_t sys_now(void)

+{

+    return xTaskGetTickCount() * portTICK_PERIOD_MS;

+}

+#endif

+

+u32_t sys_jiffies(void)

+{

+    return xTaskGetTickCount();

+}

+

+#if SYS_LIGHTWEIGHT_PROT

+

+sys_prot_t sys_arch_protect(void)

+{

+#if LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX

+    BaseType_t ret;

+    LWIP_ASSERT("sys_arch_protect_mutex != NULL", sys_arch_protect_mutex != NULL);

+

+    ret = xSemaphoreTakeRecursive(sys_arch_protect_mutex, portMAX_DELAY);

+    LWIP_ASSERT("sys_arch_protect failed to take the mutex", ret == pdTRUE);

+#else  /* LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX */

+    taskENTER_CRITICAL();

+#endif /* LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX */

+#if LWIP_FREERTOS_SYS_ARCH_PROTECT_SANITY_CHECK

+    {

+        /* every nested call to sys_arch_protect() returns an increased number */

+        sys_prot_t ret = sys_arch_protect_nesting;

+        sys_arch_protect_nesting++;

+        LWIP_ASSERT("sys_arch_protect overflow", sys_arch_protect_nesting > ret);

+        return ret;

+    }

+#else

+    return 1;

+#endif

+}

+

+void sys_arch_unprotect(sys_prot_t pval)

+{

+#if LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX

+    BaseType_t ret;

+#endif

+#if LWIP_FREERTOS_SYS_ARCH_PROTECT_SANITY_CHECK

+    LWIP_ASSERT("unexpected sys_arch_protect_nesting", sys_arch_protect_nesting > 0);

+    sys_arch_protect_nesting--;

+    LWIP_ASSERT("unexpected sys_arch_protect_nesting", sys_arch_protect_nesting == pval);

+#endif

+

+#if LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX

+    LWIP_ASSERT("sys_arch_protect_mutex != NULL", sys_arch_protect_mutex != NULL);

+

+    ret = xSemaphoreGiveRecursive(sys_arch_protect_mutex);

+    LWIP_ASSERT("sys_arch_unprotect failed to give the mutex", ret == pdTRUE);

+#else  /* LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX */

+    taskEXIT_CRITICAL();

+#endif /* LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX */

+    LWIP_UNUSED_ARG(pval);

+}

+

+#endif /* SYS_LIGHTWEIGHT_PROT */

+

+void sys_arch_msleep(u32_t delay_ms)

+{

+    TickType_t delay_ticks = delay_ms / portTICK_PERIOD_MS;

+    vTaskDelay(delay_ticks);

+}

+

+#if !LWIP_COMPAT_MUTEX

+

+/* Create a new mutex*/

+err_t sys_mutex_new(sys_mutex_t * mutex)

+{

+    LWIP_ASSERT("mutex != NULL", mutex != NULL);

+

+    mutex->mut = xSemaphoreCreateRecursiveMutex();

+    if (mutex->mut == NULL)

+    {

+        SYS_STATS_INC(mutex.err);

+        return ERR_MEM;

+    }

+    SYS_STATS_INC_USED(mutex);

+    return ERR_OK;

+}

+

+void sys_mutex_lock(sys_mutex_t * mutex)

+{

+    BaseType_t ret;

+    LWIP_ASSERT("mutex != NULL", mutex != NULL);

+    LWIP_ASSERT("mutex->mut != NULL", mutex->mut != NULL);

+

+    ret = xSemaphoreTakeRecursive(mutex->mut, portMAX_DELAY);

+    LWIP_ASSERT("failed to take the mutex", ret == pdTRUE);

+}

+

+void sys_mutex_unlock(sys_mutex_t * mutex)

+{

+    BaseType_t ret;

+    LWIP_ASSERT("mutex != NULL", mutex != NULL);

+    LWIP_ASSERT("mutex->mut != NULL", mutex->mut != NULL);

+

+    ret = xSemaphoreGiveRecursive(mutex->mut);

+    LWIP_ASSERT("failed to give the mutex", ret == pdTRUE);

+}

+

+void sys_mutex_free(sys_mutex_t * mutex)

+{

+    LWIP_ASSERT("mutex != NULL", mutex != NULL);

+    LWIP_ASSERT("mutex->mut != NULL", mutex->mut != NULL);

+

+    SYS_STATS_DEC(mutex.used);

+    vSemaphoreDelete(mutex->mut);

+    mutex->mut = NULL;

+}

+

+#endif /* !LWIP_COMPAT_MUTEX */

+

+err_t sys_sem_new(sys_sem_t * sem, u8_t initial_count)

+{

+    LWIP_ASSERT("sem != NULL", sem != NULL);

+    LWIP_ASSERT("initial_count invalid (not 0 or 1)", (initial_count == 0) || (initial_count == 1));

+

+    sem->sem = xSemaphoreCreateBinary();

+    if (sem->sem == NULL)

+    {

+        SYS_STATS_INC(sem.err);

+        return ERR_MEM;

+    }

+    SYS_STATS_INC_USED(sem);

+

+    if (initial_count == 1)

+    {

+        BaseType_t ret = xSemaphoreGive(sem->sem);

+        LWIP_ASSERT("sys_sem_new: initial give failed", ret == pdTRUE);

+    }

+    return ERR_OK;

+}

+

+void sys_sem_signal(sys_sem_t * sem)

+{

+    BaseType_t ret;

+    LWIP_ASSERT("sem != NULL", sem != NULL);

+    LWIP_ASSERT("sem->sem != NULL", sem->sem != NULL);

+

+    ret = xSemaphoreGive(sem->sem);

+    /* queue full is OK, this is a signal only... */

+    LWIP_ASSERT("sys_sem_signal: sane return value", (ret == pdTRUE) || (ret == errQUEUE_FULL));

+}

+

+u32_t sys_arch_sem_wait(sys_sem_t * sem, u32_t timeout_ms)

+{

+    BaseType_t ret;

+    LWIP_ASSERT("sem != NULL", sem != NULL);

+    LWIP_ASSERT("sem->sem != NULL", sem->sem != NULL);

+

+    if (!timeout_ms)

+    {

+        /* wait infinite */

+        ret = xSemaphoreTake(sem->sem, portMAX_DELAY);

+        LWIP_ASSERT("taking semaphore failed", ret == pdTRUE);

+    }

+    else

+    {

+        TickType_t timeout_ticks = timeout_ms / portTICK_PERIOD_MS;

+        ret                      = xSemaphoreTake(sem->sem, timeout_ticks);

+        if (ret == errQUEUE_EMPTY)

+        {

+            /* timed out */

+            return SYS_ARCH_TIMEOUT;

+        }

+        LWIP_ASSERT("taking semaphore failed", ret == pdTRUE);

+    }

+

+    /* Old versions of lwIP required us to return the time waited.

+       This is not the case any more. Just returning != SYS_ARCH_TIMEOUT

+       here is enough. */

+    return 1;

+}

+

+void sys_sem_free(sys_sem_t * sem)

+{

+    LWIP_ASSERT("sem != NULL", sem != NULL);

+    LWIP_ASSERT("sem->sem != NULL", sem->sem != NULL);

+

+    SYS_STATS_DEC(sem.used);

+    vSemaphoreDelete(sem->sem);

+    sem->sem = NULL;

+}

+

+err_t sys_mbox_new(sys_mbox_t * mbox, int size)

+{

+    LWIP_ASSERT("mbox != NULL", mbox != NULL);

+    LWIP_ASSERT("size > 0", size > 0);

+

+    /*

+     *  FALSE-POSITIVE: CID 34515: Wrong sizeof argument

+     *  Reason:

+     *     sizeof(void *) is used intentionally to find the size of a pointer.

+     */

+    mbox->mbx = (void *) xQueueCreate((UBaseType_t) size, sizeof(void *));

+    if (mbox->mbx == NULL)

+    {

+        SYS_STATS_INC(mbox.err);

+        return ERR_MEM;

+    }

+    SYS_STATS_INC_USED(mbox);

+    return ERR_OK;

+}

+

+void sys_mbox_post(sys_mbox_t * mbox, void * msg)

+{

+    BaseType_t ret;

+    LWIP_ASSERT("mbox != NULL", mbox != NULL);

+    LWIP_ASSERT("mbox->mbx != NULL", mbox->mbx != NULL);

+

+    ret = xQueueSendToBack(mbox->mbx, &msg, portMAX_DELAY);

+    LWIP_ASSERT("mbox post failed", ret == pdTRUE);

+}

+

+err_t sys_mbox_trypost(sys_mbox_t * mbox, void * msg)

+{

+    BaseType_t ret;

+    LWIP_ASSERT("mbox != NULL", mbox != NULL);

+    LWIP_ASSERT("mbox->mbx != NULL", mbox->mbx != NULL);

+

+    ret = xQueueSendToBack(mbox->mbx, &msg, 0);

+    if (ret == pdTRUE)

+    {

+        return ERR_OK;

+    }

+    else

+    {

+        LWIP_ASSERT("mbox trypost failed", ret == errQUEUE_FULL);

+        SYS_STATS_INC(mbox.err);

+        return ERR_MEM;

+    }

+}

+

+err_t sys_mbox_trypost_fromisr(sys_mbox_t * mbox, void * msg)

+{

+    BaseType_t ret;

+    BaseType_t xHigherPriorityTaskWoken = pdFALSE;

+    LWIP_ASSERT("mbox != NULL", mbox != NULL);

+    LWIP_ASSERT("mbox->mbx != NULL", mbox->mbx != NULL);

+

+    ret = xQueueSendToBackFromISR(mbox->mbx, &msg, &xHigherPriorityTaskWoken);

+    if (ret == pdTRUE)

+    {

+        if (xHigherPriorityTaskWoken == pdTRUE)

+        {

+            return ERR_NEED_SCHED;

+        }

+        return ERR_OK;

+    }

+    else

+    {

+        LWIP_ASSERT("mbox trypost failed", ret == errQUEUE_FULL);

+        SYS_STATS_INC(mbox.err);

+        return ERR_MEM;

+    }

+}

+

+u32_t sys_arch_mbox_fetch(sys_mbox_t * mbox, void ** msg, u32_t timeout_ms)

+{

+    BaseType_t ret;

+    void * msg_dummy;

+    LWIP_ASSERT("mbox != NULL", mbox != NULL);

+    LWIP_ASSERT("mbox->mbx != NULL", mbox->mbx != NULL);

+

+    if (!msg)

+    {

+        msg = &msg_dummy;

+    }

+

+    if (!timeout_ms)

+    {

+        /* wait infinite */

+        ret = xQueueReceive(mbox->mbx, &(*msg), portMAX_DELAY);

+        LWIP_ASSERT("mbox fetch failed", ret == pdTRUE);

+    }

+    else

+    {

+        TickType_t timeout_ticks = timeout_ms / portTICK_PERIOD_MS;

+        ret                      = xQueueReceive(mbox->mbx, &(*msg), timeout_ticks);

+        if (ret == errQUEUE_EMPTY)

+        {

+            /* timed out */

+            *msg = NULL;

+            return SYS_ARCH_TIMEOUT;

+        }

+        LWIP_ASSERT("mbox fetch failed", ret == pdTRUE);

+    }

+

+    /* Old versions of lwIP required us to return the time waited.

+       This is not the case any more. Just returning != SYS_ARCH_TIMEOUT

+       here is enough. */

+    return 1;

+}

+

+u32_t sys_arch_mbox_tryfetch(sys_mbox_t * mbox, void ** msg)

+{

+    BaseType_t ret;

+    void * msg_dummy;

+    LWIP_ASSERT("mbox != NULL", mbox != NULL);

+    LWIP_ASSERT("mbox->mbx != NULL", mbox->mbx != NULL);

+

+    if (!msg)

+    {

+        msg = &msg_dummy;

+    }

+

+    ret = xQueueReceive(mbox->mbx, &(*msg), 0);

+    if (ret == errQUEUE_EMPTY)

+    {

+        *msg = NULL;

+        return SYS_MBOX_EMPTY;

+    }

+    LWIP_ASSERT("mbox fetch failed", ret == pdTRUE);

+

+    /* Old versions of lwIP required us to return the time waited.

+       This is not the case any more. Just returning != SYS_ARCH_TIMEOUT

+       here is enough. */

+    return 1;

+}

+

+void sys_mbox_free(sys_mbox_t * mbox)

+{

+    LWIP_ASSERT("mbox != NULL", mbox != NULL);

+    LWIP_ASSERT("mbox->mbx != NULL", mbox->mbx != NULL);

+

+#if LWIP_FREERTOS_CHECK_QUEUE_EMPTY_ON_FREE

+    {

+        UBaseType_t msgs_waiting = uxQueueMessagesWaiting(mbox->mbx);

+        LWIP_ASSERT("mbox quence not empty", msgs_waiting == 0);

+

+        if (msgs_waiting != 0)

+        {

+            SYS_STATS_INC(mbox.err);

+        }

+    }

+#endif

+

+    vQueueDelete(mbox->mbx);

+

+    SYS_STATS_DEC(mbox.used);

+}

+

+sys_thread_t sys_thread_new(const char * name, lwip_thread_fn thread, void * arg, int stacksize, int prio)

+{

+    TaskHandle_t rtos_task;

+    BaseType_t ret;

+    sys_thread_t lwip_thread;

+    size_t rtos_stacksize;

+

+    LWIP_ASSERT("invalid stacksize", stacksize > 0);

+#if LWIP_FREERTOS_THREAD_STACKSIZE_IS_STACKWORDS

+    rtos_stacksize = (size_t) stacksize;

+#else

+    rtos_stacksize = (size_t) stacksize / sizeof(StackType_t);

+#endif

+

+    /* lwIP's lwip_thread_fn matches FreeRTOS' TaskFunction_t, so we can pass the

+       thread function without adaption here. */

+    ret = xTaskCreate(thread, name, (configSTACK_DEPTH_TYPE) rtos_stacksize, arg, prio, &rtos_task);

+    LWIP_ASSERT("task creation failed", ret == pdTRUE);

+

+    lwip_thread.thread_handle = rtos_task;

+    return lwip_thread;

+}

+

+#if LWIP_NETCONN_SEM_PER_THREAD

+#if configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0

+

+sys_sem_t * sys_arch_netconn_sem_get(void)

+{

+    void * ret;

+    TaskHandle_t task = xTaskGetCurrentTaskHandle();

+    LWIP_ASSERT("task != NULL", task != NULL);

+

+    ret = pvTaskGetThreadLocalStoragePointer(task, 0);

+    return ret;

+}

+

+void sys_arch_netconn_sem_alloc(void)

+{

+    void * ret;

+    TaskHandle_t task = xTaskGetCurrentTaskHandle();

+    LWIP_ASSERT("task != NULL", task != NULL);

+

+    ret = pvTaskGetThreadLocalStoragePointer(task, 0);

+    if (ret == NULL)

+    {

+        sys_sem_t * sem;

+        err_t err;

+        /* need to allocate the memory for this semaphore */

+        sem = mem_malloc(sizeof(sys_sem_t));

+        LWIP_ASSERT("sem != NULL", sem != NULL);

+        err = sys_sem_new(sem, 0);

+        LWIP_ASSERT("err == ERR_OK", err == ERR_OK);

+        LWIP_ASSERT("sem invalid", sys_sem_valid(sem));

+        vTaskSetThreadLocalStoragePointer(task, 0, sem);

+    }

+}

+

+void sys_arch_netconn_sem_free(void)

+{

+    void * ret;

+    TaskHandle_t task = xTaskGetCurrentTaskHandle();

+    LWIP_ASSERT("task != NULL", task != NULL);

+

+    ret = pvTaskGetThreadLocalStoragePointer(task, 0);

+    if (ret != NULL)

+    {

+        sys_sem_t * sem = ret;

+        sys_sem_free(sem);

+        mem_free(sem);

+        vTaskSetThreadLocalStoragePointer(task, 0, NULL);

+    }

+}

+

+#else /* configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 */

+#error LWIP_NETCONN_SEM_PER_THREAD needs configNUM_THREAD_LOCAL_STORAGE_POINTERS

+#endif /* configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 */

+

+#endif /* LWIP_NETCONN_SEM_PER_THREAD */

+

+#if LWIP_FREERTOS_CHECK_CORE_LOCKING

+#if LWIP_TCPIP_CORE_LOCKING

+

+/** Flag the core lock held. A counter for recursive locks. */

+static u8_t lwip_core_lock_count;

+static TaskHandle_t lwip_core_lock_holder_thread;

+

+void sys_lock_tcpip_core(void)

+{

+    sys_mutex_lock(&lock_tcpip_core);

+    if (lwip_core_lock_count == 0)

+    {

+        lwip_core_lock_holder_thread = xTaskGetCurrentTaskHandle();

+    }

+    lwip_core_lock_count++;

+}

+

+void sys_unlock_tcpip_core(void)

+{

+    lwip_core_lock_count--;

+    if (lwip_core_lock_count == 0)

+    {

+        lwip_core_lock_holder_thread = 0;

+    }

+    sys_mutex_unlock(&lock_tcpip_core);

+}

+

+#endif /* LWIP_TCPIP_CORE_LOCKING */

+

+#if !NO_SYS

+static TaskHandle_t lwip_tcpip_thread;

+#endif

+

+void sys_mark_tcpip_thread(void)

+{

+#if !NO_SYS

+    lwip_tcpip_thread = xTaskGetCurrentTaskHandle();

+#endif

+}

+

+void sys_check_core_locking(void)

+{

+    /* Embedded systems should check we are NOT in an interrupt context here */

+    /* E.g. core Cortex-M3/M4 ports:

+           configASSERT( ( portNVIC_INT_CTRL_REG & portVECTACTIVE_MASK ) == 0 );

+

+       Instead, we use more generic FreeRTOS functions here, which should fail from ISR: */

+    taskENTER_CRITICAL();

+    taskEXIT_CRITICAL();

+

+#if !NO_SYS

+    if (lwip_tcpip_thread != 0)

+    {

+        TaskHandle_t current_thread = xTaskGetCurrentTaskHandle();

+

+#if LWIP_TCPIP_CORE_LOCKING

+        LWIP_ASSERT("Function called without core lock",

+                    current_thread == lwip_core_lock_holder_thread && lwip_core_lock_count > 0);

+#else  /* LWIP_TCPIP_CORE_LOCKING */

+        LWIP_ASSERT("Function called from wrong thread", current_thread == lwip_tcpip_thread);

+#endif /* LWIP_TCPIP_CORE_LOCKING */

+    }

+#endif /* !NO_SYS */

+}

+

+#endif /* LWIP_FREERTOS_CHECK_CORE_LOCKING*/

diff --git a/third_party/p6/p6_sdk/arch/sys_arch.h b/third_party/p6/p6_sdk/arch/sys_arch.h
new file mode 100644
index 0000000..4bda66d
--- /dev/null
+++ b/third_party/p6/p6_sdk/arch/sys_arch.h
@@ -0,0 +1,99 @@
+/*

+ * Copyright (c) 2017 Simon Goldschmidt

+ * All rights reserved.

+ *

+ * Redistribution and use in source and binary forms, with or without modification,

+ * are permitted provided that the following conditions are met:

+ *

+ * 1. Redistributions of source code must retain the above copyright notice,

+ *    this list of conditions and the following disclaimer.

+ * 2. Redistributions in binary form must reproduce the above copyright notice,

+ *    this list of conditions and the following disclaimer in the documentation

+ *    and/or other materials provided with the distribution.

+ * 3. The name of the author may not be used to endorse or promote products

+ *    derived from this software without specific prior written permission.

+ *

+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED

+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF

+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT

+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,

+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT

+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING

+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY

+ * OF SUCH DAMAGE.

+ *

+ * This file is part of the lwIP TCP/IP stack.

+ *

+ * Author: Simon Goldschmdit <goldsimon@gmx.de>

+ *

+ */

+#ifndef LWIP_ARCH_SYS_ARCH_H

+#define LWIP_ARCH_SYS_ARCH_H

+

+#include "lwip/arch.h"

+#include "lwip/opt.h"

+

+/** This is returned by _fromisr() sys functions to tell the outermost function

+ * that a higher priority task was woken and the scheduler needs to be invoked.

+ */

+#define ERR_NEED_SCHED 123

+

+/* This port includes FreeRTOS headers in sys_arch.c only.

+ *  FreeRTOS uses pointers as object types. We use wrapper structs instead of

+ * void pointers directly to get a tiny bit of type safety.

+ */

+

+void sys_arch_msleep(u32_t delay_ms);

+#define sys_msleep(ms) sys_arch_msleep(ms)

+

+#if SYS_LIGHTWEIGHT_PROT

+typedef u32_t sys_prot_t;

+#endif /* SYS_LIGHTWEIGHT_PROT */

+

+#if !LWIP_COMPAT_MUTEX

+struct _sys_mut

+{

+    void * mut;

+};

+typedef struct _sys_mut sys_mutex_t;

+#define sys_mutex_valid_val(mutex) ((mutex).mut != NULL)

+#define sys_mutex_valid(mutex) (((mutex) != NULL) && sys_mutex_valid_val(*(mutex)))

+#define sys_mutex_set_invalid(mutex) ((mutex)->mut = NULL)

+#endif /* !LWIP_COMPAT_MUTEX */

+

+struct _sys_sem

+{

+    void * sem;

+};

+typedef struct _sys_sem sys_sem_t;

+#define sys_sem_valid_val(sema) ((sema).sem != NULL)

+#define sys_sem_valid(sema) (((sema) != NULL) && sys_sem_valid_val(*(sema)))

+#define sys_sem_set_invalid(sema) ((sema)->sem = NULL)

+

+struct _sys_mbox

+{

+    void * mbx;

+};

+typedef struct _sys_mbox sys_mbox_t;

+#define sys_mbox_valid_val(mbox) ((mbox).mbx != NULL)

+#define sys_mbox_valid(mbox) (((mbox) != NULL) && sys_mbox_valid_val(*(mbox)))

+#define sys_mbox_set_invalid(mbox) ((mbox)->mbx = NULL)

+

+struct _sys_thread

+{

+    void * thread_handle;

+};

+typedef struct _sys_thread sys_thread_t;

+

+#if LWIP_NETCONN_SEM_PER_THREAD

+sys_sem_t * sys_arch_netconn_sem_get(void);

+void sys_arch_netconn_sem_alloc(void);

+void sys_arch_netconn_sem_free(void);

+#define LWIP_NETCONN_THREAD_SEM_GET() sys_arch_netconn_sem_get()

+#define LWIP_NETCONN_THREAD_SEM_ALLOC() sys_arch_netconn_sem_alloc()

+#define LWIP_NETCONN_THREAD_SEM_FREE() sys_arch_netconn_sem_free()

+#endif /* LWIP_NETCONN_SEM_PER_THREAD */

+

+#endif /* LWIP_ARCH_SYS_ARCH_H */

diff --git a/third_party/p6/p6_sdk/build/CY8CKIT-062S2-43012/Debug/GCC_ARM.json b/third_party/p6/p6_sdk/build/CY8CKIT-062S2-43012/Debug/GCC_ARM.json
index 36d5568..106edbd 100644
--- a/third_party/p6/p6_sdk/build/CY8CKIT-062S2-43012/Debug/GCC_ARM.json
+++ b/third_party/p6/p6_sdk/build/CY8CKIT-062S2-43012/Debug/GCC_ARM.json
@@ -74,6 +74,7 @@
         "-I./configs",
         "-I.",
         "-I./configs",
+        "-I./arch",
         "-I./libs",
         "-I./libs/TARGET_CY8CKIT-062S2-43012",
         "-I./libs/TARGET_CY8CKIT-062S2-43012/COMPONENT_BSP_DESIGN_MODUS",
@@ -106,6 +107,15 @@
         "-I./libs/freertos/Source/portable/COMPONENT_CM4",
         "-I./libs/freertos/Source/portable/COMPONENT_CM4/TOOLCHAIN_GCC_ARM",
         "-I./libs/kv-store",
+        "-I./libs/lwip",
+        "-I./libs/lwip/src",
+        "-I./libs/lwip/src/include",
+        "-I./libs/lwip/src/include/lwip/apps",
+        "-I./libs/lwip/src/include/lwip/priv",
+        "-I./libs/lwip/src/include/lwip/prot",
+        "-I./libs/lwip/src/include/netif",
+        "-I./libs/lwip/src/include/netif/ppp",
+        "-I./libs/lwip/src/include/netif/ppp/polarssl",
         "-I./libs/mbedtls",
         "-I./libs/mbedtls/include",
         "-I./libs/mbedtls/include/mbedtls",
@@ -130,6 +140,8 @@
         "-I./libs/retarget-io",
         "-I./libs/secure-sockets",
         "-I./libs/secure-sockets/include",
+        "-I./libs/secure-sockets/include/COMPONENT_FREERTOS",
+        "-I./libs/secure-sockets/source",
         "-I./libs/whd-bsp-integration",
         "-I./libs/wifi-connection-manager",
         "-I./libs/wifi-connection-manager/include",
@@ -149,8 +161,7 @@
         "-I./libs/wifi-host-driver/WiFi_Host_Driver/src/bus_protocols",
         "-I./libs/wifi-host-driver/WiFi_Host_Driver/src/include",
         "-I./libs/wifi-mw-core",
-        "-I./libs/wifi-mw-core/lwip-whd-port",
-        "-I./libs/wifi-mw-core/lwip-whd-port/COMPONENT_FREERTOS"
+        "-I./libs/wifi-mw-core/lwip-whd-port"
     ],
     "defines": [
         "-DMBEDTLS_USER_CONFIG_FILE=<mbedtls_user_config.h>",
@@ -210,6 +221,56 @@
         "./libs/freertos/Source/tasks.c",
         "./libs/freertos/Source/timers.c",
         "./libs/kv-store/mtb_kvstore.c",
+        "./libs/lwip/src/api/api_lib.c",
+        "./libs/lwip/src/api/api_msg.c",
+        "./libs/lwip/src/api/err.c",
+        "./libs/lwip/src/api/if_api.c",
+        "./libs/lwip/src/api/netbuf.c",
+        "./libs/lwip/src/api/netdb.c",
+        "./libs/lwip/src/api/netifapi.c",
+        "./libs/lwip/src/api/sockets.c",
+        "./libs/lwip/src/api/tcpip.c",
+        "./libs/lwip/src/core/altcp.c",
+        "./libs/lwip/src/core/altcp_alloc.c",
+        "./libs/lwip/src/core/altcp_tcp.c",
+        "./libs/lwip/src/core/def.c",
+        "./libs/lwip/src/core/dns.c",
+        "./libs/lwip/src/core/inet_chksum.c",
+        "./libs/lwip/src/core/init.c",
+        "./libs/lwip/src/core/ip.c",
+        "./libs/lwip/src/core/ipv4/autoip.c",
+        "./libs/lwip/src/core/ipv4/dhcp.c",
+        "./libs/lwip/src/core/ipv4/etharp.c",
+        "./libs/lwip/src/core/ipv4/icmp.c",
+        "./libs/lwip/src/core/ipv4/igmp.c",
+        "./libs/lwip/src/core/ipv4/ip4.c",
+        "./libs/lwip/src/core/ipv4/ip4_addr.c",
+        "./libs/lwip/src/core/ipv4/ip4_frag.c",
+        "./libs/lwip/src/core/ipv6/dhcp6.c",
+        "./libs/lwip/src/core/ipv6/ethip6.c",
+        "./libs/lwip/src/core/ipv6/icmp6.c",
+        "./libs/lwip/src/core/ipv6/inet6.c",
+        "./libs/lwip/src/core/ipv6/ip6.c",
+        "./libs/lwip/src/core/ipv6/ip6_addr.c",
+        "./libs/lwip/src/core/ipv6/ip6_frag.c",
+        "./libs/lwip/src/core/ipv6/mld6.c",
+        "./libs/lwip/src/core/ipv6/nd6.c",
+        "./libs/lwip/src/core/mem.c",
+        "./libs/lwip/src/core/memp.c",
+        "./libs/lwip/src/core/netif.c",
+        "./libs/lwip/src/core/pbuf.c",
+        "./libs/lwip/src/core/raw.c",
+        "./libs/lwip/src/core/stats.c",
+        "./libs/lwip/src/core/sys.c",
+        "./libs/lwip/src/core/tcp.c",
+        "./libs/lwip/src/core/tcp_in.c",
+        "./libs/lwip/src/core/tcp_out.c",
+        "./libs/lwip/src/core/timeouts.c",
+        "./libs/lwip/src/core/udp.c",
+        "./libs/lwip/src/netif/bridgeif.c",
+        "./libs/lwip/src/netif/bridgeif_fdb.c",
+        "./libs/lwip/src/netif/ethernet.c",
+        "./libs/lwip/src/netif/zepif.c",
         "./libs/mbedtls/library/aes.c",
         "./libs/mbedtls/library/aesni.c",
         "./libs/mbedtls/library/arc4.c",
@@ -492,7 +553,8 @@
         "./libs/wifi-host-driver/WiFi_Host_Driver/resources/firmware/COMPONENT_43012/43012C0-mfgtest_bin.c",
         "./libs/wifi-host-driver/WiFi_Host_Driver/resources/firmware/COMPONENT_43012/43012C0-mfgtest_clm_blob.c",
         "./libs/wifi-host-driver/WiFi_Host_Driver/resources/firmware/COMPONENT_43012/43012C0_bin.c",
-        "./libs/wifi-host-driver/WiFi_Host_Driver/resources/firmware/COMPONENT_43012/43012C0_clm_blob.c"
+        "./libs/wifi-host-driver/WiFi_Host_Driver/resources/firmware/COMPONENT_43012/43012C0_clm_blob.c",
+        "./arch/sys_arch.c"
     ],
     "cxx_source": [],
     "asm_source": [
diff --git a/third_party/p6/p6_sdk/build/CY8CKIT-062S2-43012/Release/GCC_ARM.json b/third_party/p6/p6_sdk/build/CY8CKIT-062S2-43012/Release/GCC_ARM.json
index 961c6ae..c744905 100644
--- a/third_party/p6/p6_sdk/build/CY8CKIT-062S2-43012/Release/GCC_ARM.json
+++ b/third_party/p6/p6_sdk/build/CY8CKIT-062S2-43012/Release/GCC_ARM.json
@@ -74,6 +74,7 @@
         "-I./configs",
         "-I.",
         "-I./configs",
+        "-I./arch",
         "-I./libs",
         "-I./libs/TARGET_CY8CKIT-062S2-43012",
         "-I./libs/TARGET_CY8CKIT-062S2-43012/COMPONENT_BSP_DESIGN_MODUS",
@@ -106,6 +107,15 @@
         "-I./libs/freertos/Source/portable/COMPONENT_CM4",
         "-I./libs/freertos/Source/portable/COMPONENT_CM4/TOOLCHAIN_GCC_ARM",
         "-I./libs/kv-store",
+        "-I./libs/lwip",
+        "-I./libs/lwip/src",
+        "-I./libs/lwip/src/include",
+        "-I./libs/lwip/src/include/lwip/apps",
+        "-I./libs/lwip/src/include/lwip/priv",
+        "-I./libs/lwip/src/include/lwip/prot",
+        "-I./libs/lwip/src/include/netif",
+        "-I./libs/lwip/src/include/netif/ppp",
+        "-I./libs/lwip/src/include/netif/ppp/polarssl",
         "-I./libs/mbedtls",
         "-I./libs/mbedtls/include",
         "-I./libs/mbedtls/include/mbedtls",
@@ -130,6 +140,8 @@
         "-I./libs/retarget-io",
         "-I./libs/secure-sockets",
         "-I./libs/secure-sockets/include",
+        "-I./libs/secure-sockets/include/COMPONENT_FREERTOS",
+        "-I./libs/secure-sockets/source",
         "-I./libs/whd-bsp-integration",
         "-I./libs/wifi-connection-manager",
         "-I./libs/wifi-connection-manager/include",
@@ -149,8 +161,7 @@
         "-I./libs/wifi-host-driver/WiFi_Host_Driver/src/bus_protocols",
         "-I./libs/wifi-host-driver/WiFi_Host_Driver/src/include",
         "-I./libs/wifi-mw-core",
-        "-I./libs/wifi-mw-core/lwip-whd-port",
-        "-I./libs/wifi-mw-core/lwip-whd-port/COMPONENT_FREERTOS"
+        "-I./libs/wifi-mw-core/lwip-whd-port"
     ],
     "defines": [
         "-DMBEDTLS_USER_CONFIG_FILE=<mbedtls_user_config.h>",
@@ -210,6 +221,56 @@
         "./libs/freertos/Source/tasks.c",
         "./libs/freertos/Source/timers.c",
         "./libs/kv-store/mtb_kvstore.c",
+        "./libs/lwip/src/api/api_lib.c",
+        "./libs/lwip/src/api/api_msg.c",
+        "./libs/lwip/src/api/err.c",
+        "./libs/lwip/src/api/if_api.c",
+        "./libs/lwip/src/api/netbuf.c",
+        "./libs/lwip/src/api/netdb.c",
+        "./libs/lwip/src/api/netifapi.c",
+        "./libs/lwip/src/api/sockets.c",
+        "./libs/lwip/src/api/tcpip.c",
+        "./libs/lwip/src/core/altcp.c",
+        "./libs/lwip/src/core/altcp_alloc.c",
+        "./libs/lwip/src/core/altcp_tcp.c",
+        "./libs/lwip/src/core/def.c",
+        "./libs/lwip/src/core/dns.c",
+        "./libs/lwip/src/core/inet_chksum.c",
+        "./libs/lwip/src/core/init.c",
+        "./libs/lwip/src/core/ip.c",
+        "./libs/lwip/src/core/ipv4/autoip.c",
+        "./libs/lwip/src/core/ipv4/dhcp.c",
+        "./libs/lwip/src/core/ipv4/etharp.c",
+        "./libs/lwip/src/core/ipv4/icmp.c",
+        "./libs/lwip/src/core/ipv4/igmp.c",
+        "./libs/lwip/src/core/ipv4/ip4.c",
+        "./libs/lwip/src/core/ipv4/ip4_addr.c",
+        "./libs/lwip/src/core/ipv4/ip4_frag.c",
+        "./libs/lwip/src/core/ipv6/dhcp6.c",
+        "./libs/lwip/src/core/ipv6/ethip6.c",
+        "./libs/lwip/src/core/ipv6/icmp6.c",
+        "./libs/lwip/src/core/ipv6/inet6.c",
+        "./libs/lwip/src/core/ipv6/ip6.c",
+        "./libs/lwip/src/core/ipv6/ip6_addr.c",
+        "./libs/lwip/src/core/ipv6/ip6_frag.c",
+        "./libs/lwip/src/core/ipv6/mld6.c",
+        "./libs/lwip/src/core/ipv6/nd6.c",
+        "./libs/lwip/src/core/mem.c",
+        "./libs/lwip/src/core/memp.c",
+        "./libs/lwip/src/core/netif.c",
+        "./libs/lwip/src/core/pbuf.c",
+        "./libs/lwip/src/core/raw.c",
+        "./libs/lwip/src/core/stats.c",
+        "./libs/lwip/src/core/sys.c",
+        "./libs/lwip/src/core/tcp.c",
+        "./libs/lwip/src/core/tcp_in.c",
+        "./libs/lwip/src/core/tcp_out.c",
+        "./libs/lwip/src/core/timeouts.c",
+        "./libs/lwip/src/core/udp.c",
+        "./libs/lwip/src/netif/bridgeif.c",
+        "./libs/lwip/src/netif/bridgeif_fdb.c",
+        "./libs/lwip/src/netif/ethernet.c",
+        "./libs/lwip/src/netif/zepif.c",
         "./libs/mbedtls/library/aes.c",
         "./libs/mbedtls/library/aesni.c",
         "./libs/mbedtls/library/arc4.c",
@@ -492,7 +553,8 @@
         "./libs/wifi-host-driver/WiFi_Host_Driver/resources/firmware/COMPONENT_43012/43012C0-mfgtest_bin.c",
         "./libs/wifi-host-driver/WiFi_Host_Driver/resources/firmware/COMPONENT_43012/43012C0-mfgtest_clm_blob.c",
         "./libs/wifi-host-driver/WiFi_Host_Driver/resources/firmware/COMPONENT_43012/43012C0_bin.c",
-        "./libs/wifi-host-driver/WiFi_Host_Driver/resources/firmware/COMPONENT_43012/43012C0_clm_blob.c"
+        "./libs/wifi-host-driver/WiFi_Host_Driver/resources/firmware/COMPONENT_43012/43012C0_clm_blob.c",
+        "./arch/sys_arch.c"
     ],
     "cxx_source": [],
     "asm_source": [
diff --git a/third_party/p6/p6_sdk/configs/lwipopts.h b/third_party/p6/p6_sdk/configs/lwipopts.h
new file mode 100644
index 0000000..86e5736
--- /dev/null
+++ b/third_party/p6/p6_sdk/configs/lwipopts.h
@@ -0,0 +1,292 @@
+/*
+ *
+ *    Copyright (c) 2021 Project CHIP Authors
+ *    Copyright (c) 2019 Nest Labs, Inc.
+ *
+ *    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
+ *      Compile-time configuration for LwIP on P6 platforms using the
+ *      P6 SDK.
+ *
+ */
+
+#ifndef __LWIPOPTS_H__
+#define __LWIPOPTS_H__
+
+#if CHIP_HAVE_CONFIG_H
+#include <lwip/lwip_buildconfig.h>
+#endif
+
+#include <stdlib.h>
+
+#include <whd_types.h>
+
+#define MEM_ALIGNMENT (4)
+
+#define LWIP_RAW (1)
+
+//
+// Enable IPV4 networking
+//
+#define LWIP_IPV4 (1)
+
+//
+// Enable IPV6 networking
+//
+#define LWIP_IPV6 (1)
+
+#define ETHARP_SUPPORT_STATIC_ENTRIES (1)
+
+//
+// Enable IPV4 networking
+//
+#define LWIP_ICMP (1)
+#define LWIP_TCP (1)
+#define LWIP_UDP (1)
+#define LWIP_IGMP (1)
+
+//
+// Use malloc to allocate any memory blocks instead of the
+// malloc that is part of LWIP
+//
+#define MEM_LIBC_MALLOC (1)
+
+#if defined(__GNUC__) && !defined(__ARMCC_VERSION)
+//
+// Use the timeval from the GCC library, not the one
+// from LWIP
+//
+#define LWIP_TIMEVAL_PRIVATE (0)
+#endif
+
+//
+// Make sure DHCP is part of the stack
+//
+#define LWIP_DHCP (1)
+
+//
+// Enable LwIP send timeout
+//
+#define LWIP_SO_SNDTIMEO (1)
+
+//
+// Enable LwIP receive timeout
+//
+#define LWIP_SO_RCVTIMEO (1)
+
+//
+// Enable SO_REUSEADDR option
+//
+#define SO_REUSE (1)
+
+//
+// Enable TCP Keep-alive
+//
+#define LWIP_TCP_KEEPALIVE (0)
+
+//
+// The amount of space to leave before the packet when allocating a pbuf. Needs to
+// be enough for the link layer data and the WHD header
+//
+#define PBUF_LINK_HLEN (WHD_PHYSICAL_HEADER)
+
+//
+// TCP Maximum segment size
+//
+#define TCP_MSS (WHD_PAYLOAD_MTU)
+
+#define LWIP_CHECKSUM_CTRL_PER_NETIF 1
+#define CHECKSUM_GEN_IP 1
+#define CHECKSUM_GEN_UDP 1
+#define CHECKSUM_GEN_TCP 1
+#define CHECKSUM_GEN_ICMP 1
+#define CHECKSUM_GEN_ICMP6 1
+#define CHECKSUM_CHECK_IP 1
+#define CHECKSUM_CHECK_UDP 1
+#define CHECKSUM_CHECK_TCP 1
+#define CHECKSUM_CHECK_ICMP 1
+#define CHECKSUM_CHECK_ICMP6 1
+#define LWIP_CHECKSUM_ON_COPY 1
+
+//
+// Enable the thread safe NETCONN interface layer
+//
+#define LWIP_NETCONN (1)
+
+/**
+ * TCP_SND_BUF: TCP sender buffer space (bytes).
+ * To achieve good performance, this should be at least 2 * TCP_MSS.
+ */
+#define TCP_SND_BUF (4 * TCP_MSS)
+
+/**
+ * TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least
+ * as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work.
+ */
+#define TCP_SND_QUEUELEN ((6 * (TCP_SND_BUF) + (TCP_MSS - 1)) / (TCP_MSS))
+
+//
+// Taken from WICED to speed things up
+//
+#define DHCP_DOES_ARP_CHECK (0)
+
+//
+// Light weight protection for things that may be clobbered by interrupts
+//
+#define SYS_LIGHTWEIGHT_PROT (1)
+#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT (1)
+
+#define LWIP_SO_RCVBUF (128)
+
+#define LWIP_SOCKET (1)
+#define LWIP_NETCONN (1)
+#define DEFAULT_TCP_RECVMBOX_SIZE (6)
+#define TCPIP_MBOX_SIZE (6)
+#define TCPIP_THREAD_STACKSIZE (2 * 1024)
+#define TCPIP_THREAD_PRIO (2)
+#define DEFAULT_RAW_RECVMBOX_SIZE (6)
+#define DEFAULT_UDP_RECVMBOX_SIZE (6)
+#define DEFAULT_ACCEPTMBOX_SIZE (6)
+#define TCPIP_THREAD_NAME "LWIP"
+
+/**
+ * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
+ * per active UDP "connection".
+ * (requires the LWIP_UDP option)
+ */
+#define MEMP_NUM_UDP_PCB 8
+
+/**
+ * MEMP_NUM_TCP_PCB: the number of simultaneously active TCP connections.
+ * (requires the LWIP_TCP option)
+ */
+#define MEMP_NUM_TCP_PCB 8
+
+/**
+ * MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections.
+ * (requires the LWIP_TCP option)
+ */
+#define MEMP_NUM_TCP_PCB_LISTEN 1
+
+/**
+ * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments.
+ * (requires the LWIP_TCP option)
+ */
+#define MEMP_NUM_TCP_SEG 27
+
+/**
+ * MEMP_NUM_SYS_TIMEOUT: the number of simultaneously active timeouts.
+ */
+#define MEMP_NUM_SYS_TIMEOUT 12
+
+/**
+ * PBUF_POOL_SIZE: the number of buffers in the pbuf pool.
+ */
+#define PBUF_POOL_SIZE 24
+
+/**
+ * MEMP_NUM_NETBUF: the number of struct netbufs.
+ * (only needed if you use the sequential API, like api_lib.c)
+ */
+#define MEMP_NUM_NETBUF 8
+
+/**
+ * MEMP_NUM_NETCONN: the number of struct netconns.
+ * (only needed if you use the sequential API, like api_lib.c)
+ */
+#define MEMP_NUM_NETCONN 16
+
+/**
+ * LWIP_TCPIP_CORE_LOCKING
+ * Creates a global mutex that is held during TCPIP thread operations.
+ * Can be locked by client code to perform lwIP operations without changing
+ * into TCPIP thread using callbacks. See LOCK_TCPIP_CORE() and
+ * UNLOCK_TCPIP_CORE().
+ * Your system should provide mutexes supporting priority inversion to use this.
+ */
+#define LWIP_TCPIP_CORE_LOCKING 1
+
+/**
+ * LWIP_TCPIP_CORE_LOCKING_INPUT: when LWIP_TCPIP_CORE_LOCKING is enabled,
+ * this lets tcpip_input() grab the mutex for input packets as well,
+ * instead of allocating a message and passing it to tcpip_thread.
+ *
+ * ATTENTION: this does not work when tcpip_input() is called from
+ * interrupt context!
+ */
+#define LWIP_TCPIP_CORE_LOCKING_INPUT 1
+
+/**
+ * LWIP_NETIF_API==1: Support netif api (in netifapi.c)
+ */
+#define LWIP_NETIF_API 1
+
+#define LWIP_DNS (1)
+
+#define LWIP_NETIF_TX_SINGLE_PBUF (1)
+
+#define LWIP_RAND rand
+
+#define LWIP_FREERTOS_CHECK_CORE_LOCKING (1)
+
+#define LWIP_NETIF_STATUS_CALLBACK (1)
+#define LWIP_NETIF_LINK_CALLBACK (1)
+#define LWIP_NETIF_REMOVE_CALLBACK (1)
+
+#define LWIP_CHKSUM_ALGORITHM (3)
+
+#define LWIP_NETIF_EXT_STATUS_CALLBACK 1
+#define netifapi_dhcp_release_and_stop(n) netifapi_dhcp_release(n)
+
+#ifndef LWIP_DEBUG
+#define LWIP_DEBUG 1
+#endif
+#define LWIP_STATS (0)
+
+#define MEMP_OVERFLOW_CHECK (0)
+#define MEMP_SANITY_CHECK (0)
+#define MEM_DEBUG (LWIP_DBG_OFF)
+#define MEMP_DEBUG (LWIP_DBG_OFF)
+#define PBUF_DEBUG (LWIP_DBG_OFF)
+#define API_LIB_DEBUG (LWIP_DBG_OFF)
+#define API_MSG_DEBUG (LWIP_DBG_OFF)
+#define TCPIP_DEBUG (LWIP_DBG_OFF)
+#define NETIF_DEBUG (LWIP_DBG_OFF)
+#define SOCKETS_DEBUG (LWIP_DBG_OFF)
+#define DEMO_DEBUG (LWIP_DBG_OFF)
+#define DHCP_DEBUG (LWIP_DBG_OFF)
+#define AUTOIP_DEBUG (LWIP_DBG_OFF)
+#define ETHARP_DEBUG (LWIP_DBG_OFF)
+#define IP_DEBUG (LWIP_DBG_OFF)
+#define IP_REASS_DEBUG (LWIP_DBG_OFF)
+#define IP6_DEBUG (LWIP_DBG_OFF)
+#define RAW_DEBUG (LWIP_DBG_OFF)
+#define ICMP_DEBUG (LWIP_DBG_OFF)
+#define UDP_DEBUG (LWIP_DBG_OFF)
+#define TCP_DEBUG (LWIP_DBG_OFF)
+#define TCP_INPUT_DEBUG (LWIP_DBG_OFF)
+#define TCP_OUTPUT_DEBUG (LWIP_DBG_OFF)
+#define TCP_RTO_DEBUG (LWIP_DBG_OFF)
+#define TCP_CWND_DEBUG (LWIP_DBG_OFF)
+#define TCP_WND_DEBUG (LWIP_DBG_OFF)
+#define TCP_FR_DEBUG (LWIP_DBG_OFF)
+#define TCP_QLEN_DEBUG (LWIP_DBG_OFF)
+#define TCP_RST_DEBUG (LWIP_DBG_OFF)
+#define PPP_DEBUG (LWIP_DBG_OFF)
+
+#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON | LWIP_DBG_TRACE)
+
+#endif /* __LWIPOPTS_H__ */
diff --git a/third_party/p6/p6_sdk/libs/lwip b/third_party/p6/p6_sdk/libs/lwip
new file mode 160000
index 0000000..018c64a
--- /dev/null
+++ b/third_party/p6/p6_sdk/libs/lwip
@@ -0,0 +1 @@
+Subproject commit 018c64ab948f61ab574fc9e388bb266148f270f0