From de10e554f3b3123411949b3a640f9eb1a0d29bec Mon Sep 17 00:00:00 2001
From: weicheng <xu.wc@outlook.com>
Date: Mon, 17 Jul 2023 17:25:31 +0800
Subject: [PATCH] [ASR] add asr550x support

---
 .gitmodules                                   |  10 +
 config/asr/toolchain/BUILD.gn                 |   4 +-
 docs/guides/asr_getting_started_guide.md      |   9 +-
 scripts/build/build/targets.py                |   2 +
 scripts/build/builders/asr.py                 |  15 +-
 .../build/testdata/all_targets_linux_x64.txt  |   2 +-
 src/platform/ASR/ASRFactoryDataProvider.cpp   |  86 ++++--
 src/platform/ASR/CHIPDevicePlatformConfig.h   |   1 +
 .../ASR/NetworkCommissioningWiFiDriver.cpp    |   3 +-
 third_party/asr/asr550x/BUILD.gn              | 169 +++++++++++
 third_party/asr/asr550x/asr_sdk               |   1 +
 third_party/asr/asr550x/asr_sdk.gni           | 255 ++++++++++++++++
 third_party/asr/asr582x/BUILD.gn              |  39 +--
 third_party/asr/asr582x/asr_sdk               |   2 +-
 third_party/asr/asr582x/asr_sdk.gni           | 278 ++++++++---------
 third_party/asr/asr595x/BUILD.gn              |  28 +-
 third_party/asr/asr595x/asr_sdk               |   2 +-
 third_party/asr/asr595x/asr_sdk.gni           | 282 +++++++++---------
 third_party/asr/asr_executable.gni            |  11 +-
 third_party/asr/components                    |   1 +
 20 files changed, 861 insertions(+), 339 deletions(-)
 create mode 100755 third_party/asr/asr550x/BUILD.gn
 create mode 160000 third_party/asr/asr550x/asr_sdk
 create mode 100644 third_party/asr/asr550x/asr_sdk.gni
 create mode 160000 third_party/asr/components

diff --git a/.gitmodules b/.gitmodules
index fac9c7aa1afe47..d8f478e1858b72 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -308,3 +308,13 @@
 	url = https://github.com/google/perfetto.git
 	branch = master
 	platforms = linux,android
+[submodule "third_party/asr/components"]
+	path = third_party/asr/components
+	url = https://github.com/asriot/asriot_components.git
+	branch = matter
+	platforms = asr
+[submodule "third_party/asr/asr550x/asr_sdk"]
+	path = third_party/asr/asr550x/asr_sdk
+	url = https://github.com/asriot/ASR550X_Freertos.git
+	branch = matter
+	platforms = asr
diff --git a/config/asr/toolchain/BUILD.gn b/config/asr/toolchain/BUILD.gn
index d13d7e1888f07a..613222bd1ea797 100755
--- a/config/asr/toolchain/BUILD.gn
+++ b/config/asr/toolchain/BUILD.gn
@@ -16,10 +16,10 @@ import("//build_overrides/asr.gni")
 import("//build_overrides/build.gni")
 import("//build_overrides/chip.gni")
 
-assert(asr_ic_family == "asr582x" || asr_ic_family == "asr595x",
+assert(asr_ic_family == "asr582x" || asr_ic_family == "asr595x" || asr_ic_family == "asr550x",
        "Unsupported ASR IC: ${asr_ic_family}")
 
-if (asr_ic_family == "asr582x") {
+if (asr_ic_family == "asr582x" || asr_ic_family == "asr550x") {
   import("${build_root}/toolchain/arm_gcc/arm_toolchain.gni")
   _tool_name_root = "${asr_toolchain_root}arm-none-eabi-"
 }
diff --git a/docs/guides/asr_getting_started_guide.md b/docs/guides/asr_getting_started_guide.md
index 6d6b15230faf4d..e47cc554ef2158 100644
--- a/docs/guides/asr_getting_started_guide.md
+++ b/docs/guides/asr_getting_started_guide.md
@@ -24,6 +24,7 @@ The ASR platform is supported on:
 
 -   [ASR582X](http://www.asrmicro.com/en/goods/proinfo/36.html)
 -   [ASR595X](http://www.asrmicro.com/en/goods/proinfo/42.html)
+-   [ASR550X](http://www.asrmicro.com/en/goods/proinfo/14.html)
 
 ## Matter Example Applications
 
@@ -35,9 +36,8 @@ to speed up development. You can find them in the samples with `/asr` subfolder.
 -   [Setup Matter Environment](./BUILDING.md)
 
 -   Setup toolchain
-    -   for ASR582X
+    -   for ASR582X and ASR550X
         ```
-        cd toolchain
         wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/RC2.1/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
         tar -jxvf gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
         export ASR_TOOLCHAIN_PATH={abs-path-to-toolchain}/gcc-arm-none-eabi-9-2019-q4-major/bin/
@@ -60,6 +60,10 @@ to speed up development. You can find them in the samples with `/asr` subfolder.
         ```
         export ASR_BOARD=asr595x
         ```
+    -   for ASR550X:
+        ```
+        export ASR_BOARD=asr550x
+        ```
 -   Building the Application
 
     If the lighting example is to be built:
@@ -91,6 +95,7 @@ There are two commissioning modes supported by ASR platform:
     ```
     ./chip-tool pairing ble-wifi <node_id> <ssid> <password> <pin_code> <discriminator>
     ```
+5. Only ASR582X and ASR595X support BLE
 
 ### IP mode
 
diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py
index a0024bf5b18946..332e0e2d78b19e 100755
--- a/scripts/build/build/targets.py
+++ b/scripts/build/build/targets.py
@@ -415,6 +415,7 @@ def BuildASRTarget():
     target.AppendFixedTargets([
         TargetPart('asr582x', board=ASRBoard.ASR582X),
         TargetPart('asr595x', board=ASRBoard.ASR595X),
+        TargetPart('asr550x', board=ASRBoard.ASR550X),
     ])
 
     # apps
@@ -436,6 +437,7 @@ def BuildASRTarget():
     target.AppendModifier('no_logging', chip_logging=False)
     target.AppendModifier('factory', enable_factory=True)
     target.AppendModifier('rotating_id', enable_rotating_device_id=True)
+    target.AppendModifier('rio', enable_lwip_ip6_hook=True)
 
     return target
 
diff --git a/scripts/build/builders/asr.py b/scripts/build/builders/asr.py
index 23c9e4294c138a..bf856862e583e9 100644
--- a/scripts/build/builders/asr.py
+++ b/scripts/build/builders/asr.py
@@ -80,12 +80,15 @@ def BuildRoot(self, root):
 class ASRBoard(Enum):
     ASR582X = auto()
     ASR595X = auto()
+    ASR550X = auto()
 
     def GetIC(self):
         if self == ASRBoard.ASR582X:
             return 'asr582x'
         elif self == ASRBoard.ASR595X:
             return 'asr595x'
+        elif self == ASRBoard.ASR550X:
+            return 'asr550x'
         else:
             raise Exception('Unknown board #: %r' % self)
 
@@ -101,7 +104,8 @@ def __init__(self,
                  chip_logging: bool = True,
                  enable_factory: bool = False,
                  enable_rotating_device_id: bool = False,
-                 enable_ota_requestor: bool = False):
+                 enable_ota_requestor: bool = False,
+                 enable_lwip_ip6_hook: bool = False):
         super(ASRBuilder, self).__init__(
             root=app.BuildRoot(root),
             runner=runner)
@@ -118,6 +122,9 @@ def __init__(self,
         elif asr_chip == "asr595x":
             ASR_ARCH = "riscv"
             ASR_SDK_ROOT = "//third_party/connectedhomeip/third_party/asr/asr595x"
+        elif asr_chip == "asr550x":
+            ASR_ARCH = "arm"
+            ASR_SDK_ROOT = "//third_party/connectedhomeip/third_party/asr/asr550x"
         self.extra_gn_options.append('target_cpu="%s"' % ASR_ARCH)
 
         toolchain = os.path.join(root, os.path.split(os.path.realpath(__file__))[0], '../../../config/asr/toolchain')
@@ -132,6 +139,9 @@ def __init__(self,
                 or asr_chip == "asr595x"):
             self.extra_gn_options.append('chip_config_network_layer_ble=true')
 
+        if (asr_chip == "asr550x"):
+            self.extra_gn_options.append('chip_config_network_layer_ble=false')
+
         if enable_ota_requestor:
             self.extra_gn_options.append('chip_enable_ota_requestor=true')
 
@@ -149,6 +159,9 @@ def __init__(self,
             self.extra_gn_options.append('chip_enable_additional_data_advertising=true')
             self.extra_gn_options.append('chip_enable_rotating_device_id=true')
 
+        if enable_lwip_ip6_hook:
+            self.extra_gn_options.append('chip_lwip_ip6_hook=true')
+
         self.extra_gn_options.append('asr_toolchain_root="%s"' % os.environ['ASR_TOOLCHAIN_PATH'])
 
     def GnBuildArgs(self):
diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt
index 00df21821af696..80a08db86717d0 100644
--- a/scripts/build/testdata/all_targets_linux_x64.txt
+++ b/scripts/build/testdata/all_targets_linux_x64.txt
@@ -1,5 +1,5 @@
 ameba-amebad-{all-clusters,all-clusters-minimal,light,light-switch,pigweed}
-asr-{asr582x,asr595x}-{all-clusters,all-clusters-minimal,lighting,light-switch,lock,bridge,temperature-measurement,thermostat,ota-requestor}[-ota][-shell][-no_logging][-factory][-rotating_id]
+asr-{asr582x,asr595x,asr550x}-{all-clusters,all-clusters-minimal,lighting,light-switch,lock,bridge,temperature-measurement,thermostat,ota-requestor}[-ota][-shell][-no_logging][-factory][-rotating_id][-rio]
 android-{arm,arm64,x86,x64,androidstudio-arm,androidstudio-arm64,androidstudio-x86,androidstudio-x64}-{chip-tool,chip-test,tv-server,tv-casting-app,java-matter-controller}[-no-debug]
 bouffalolab-{bl602-iot-matter-v1,bl602-iot-dvk-3s,bl602-night-light,xt-zb6-devkit,bl706-iot-dvk,bl706-night-light,bl704l-dvk}-light[-shell][-115200][-rpc][-cdc][-rotating_device_id]
 cc32xx-lock
diff --git a/src/platform/ASR/ASRFactoryDataProvider.cpp b/src/platform/ASR/ASRFactoryDataProvider.cpp
index d21202af43a1d7..8f79f223a5d7c4 100644
--- a/src/platform/ASR/ASRFactoryDataProvider.cpp
+++ b/src/platform/ASR/ASRFactoryDataProvider.cpp
@@ -424,40 +424,88 @@ CHIP_ERROR ASRFactoryDataProvider::GetProductLabel(char * buf, size_t bufSize)
 
 CHIP_ERROR ASRFactoryDataProvider::GetSerialNumber(char * buf, size_t bufSize)
 {
-    ChipError err = CHIP_NO_ERROR;
+#if !CONFIG_ENABLE_ASR_FACTORY_DEVICE_INFO_PROVIDER
+    ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER), CHIP_ERROR_BUFFER_TOO_SMALL);
+    strcpy(buf, CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER);
+#else
+#define BUFFER_MAX_SIZE 32
+    uint8_t buffer[BUFFER_MAX_SIZE + 1] = { 0 };
+    size_t buffer_len                   = BUFFER_MAX_SIZE + 1;
+    ReturnErrorOnFailure(ASRConfig::ReadFactoryConfigValue(ASR_SERIAL_NUMBER_PARTITION, buffer, buffer_len, buffer_len));
+    ReturnErrorCodeIf(bufSize < buffer_len, CHIP_ERROR_BUFFER_TOO_SMALL);
+    memcpy(buf, buffer, buffer_len);
+    buf[buffer_len] = 0;
+#endif
+    return CHIP_NO_ERROR;
+}
 
-    size_t serialNumLen = 0; // without counting null-terminator
+CHIP_ERROR ASRFactoryDataProvider::GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day)
+{
+    CHIP_ERROR err = CHIP_NO_ERROR;
+    enum
+    {
+        kDateStringLength = 10 // YYYY-MM-DD
+    };
+    char dateStr[kDateStringLength + 1];
+    char * parseEnd;
+#if !CONFIG_ENABLE_ASR_FACTORY_DEVICE_INFO_PROVIDER
+    memcpy(dateStr, CHIP_DEVICE_CONFIG_TEST_MANUFACTURY_DATE, kDateStringLength + 1);
+#else
+    size_t dateLen;
+    err = ASRConfig::ReadFactoryConfigValue(ASR_MANUFACTURY_DATE_PARTITION, (uint8_t *)dateStr, sizeof(dateStr), dateLen);
+    SuccessOrExit(err);
 
-#ifdef CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER
-    if (CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER[0] != 0)
+    VerifyOrExit(dateLen == kDateStringLength, err = CHIP_ERROR_INVALID_ARGUMENT);
+#endif
+    // Cast does not lose information, because we then check that we only parsed
+    // 4 digits, so our number can't be bigger than 9999.
+    year = static_cast<uint16_t>(strtoul(dateStr, &parseEnd, 10));
+    VerifyOrExit(parseEnd == dateStr + 4, err = CHIP_ERROR_INVALID_ARGUMENT);
+
+    // Cast does not lose information, because we then check that we only parsed
+    // 2 digits, so our number can't be bigger than 99.
+    month = static_cast<uint8_t>(strtoul(dateStr + 5, &parseEnd, 10));
+    VerifyOrExit(parseEnd == dateStr + 7, err = CHIP_ERROR_INVALID_ARGUMENT);
+
+    // Cast does not lose information, because we then check that we only parsed
+    // 2 digits, so our number can't be bigger than 99.
+    day = static_cast<uint8_t>(strtoul(dateStr + 8, &parseEnd, 10));
+    VerifyOrExit(parseEnd == dateStr + 10, err = CHIP_ERROR_INVALID_ARGUMENT);
+
+exit:
+    if (err != CHIP_NO_ERROR && err != CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND)
     {
-        ReturnErrorCodeIf(sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER) > bufSize, CHIP_ERROR_BUFFER_TOO_SMALL);
-        memcpy(buf, CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER, sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER));
-        serialNumLen = sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER) - 1;
-        err          = CHIP_NO_ERROR;
+        ChipLogError(DeviceLayer, "Invalid manufacturing date: %s", dateStr);
     }
-#endif // CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER
-
-    ReturnErrorCodeIf(serialNumLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL);
-    ReturnErrorCodeIf(buf[serialNumLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH);
-
     return err;
 }
 
-CHIP_ERROR ASRFactoryDataProvider::GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day)
-{
-    return CHIP_ERROR_NOT_IMPLEMENTED;
-}
-
 CHIP_ERROR ASRFactoryDataProvider::GetHardwareVersion(uint16_t & hardwareVersion)
 {
-    return CHIP_ERROR_NOT_IMPLEMENTED;
+#if !CONFIG_ENABLE_ASR_FACTORY_DEVICE_INFO_PROVIDER
+    hardwareVersion = static_cast<uint16_t>(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION);
+#else
+    uint32_t hardwareVersion32;
+    ReturnErrorOnFailure(ASRConfig::ReadFactoryConfigValue(ASR_HARDWARE_VERSION_PARTITION, hardwareVersion32));
+    hardwareVersion = static_cast<uint16_t>(hardwareVersion32);
+#endif
+    return CHIP_NO_ERROR;
 }
 
 CHIP_ERROR ASRFactoryDataProvider::GetHardwareVersionString(char * buf, size_t bufSize)
 {
+#if !CONFIG_ENABLE_ASR_FACTORY_DEVICE_INFO_PROVIDER
     ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL);
     strcpy(buf, CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING);
+#else
+#define BUFFER_MAX_SIZE 32
+    uint8_t buffer[BUFFER_MAX_SIZE + 1] = { 0 };
+    size_t buffer_len                   = BUFFER_MAX_SIZE + 1;
+    ReturnErrorOnFailure(ASRConfig::ReadFactoryConfigValue(ASR_HARDWARE_VERSION_STR_PARTITION, buffer, buffer_len, buffer_len));
+    ReturnErrorCodeIf(bufSize < buffer_len, CHIP_ERROR_BUFFER_TOO_SMALL);
+    memcpy(buf, buffer, buffer_len);
+    buf[buffer_len] = 0;
+#endif
     return CHIP_NO_ERROR;
 }
 
diff --git a/src/platform/ASR/CHIPDevicePlatformConfig.h b/src/platform/ASR/CHIPDevicePlatformConfig.h
index 581267440fee87..99586196c463e2 100755
--- a/src/platform/ASR/CHIPDevicePlatformConfig.h
+++ b/src/platform/ASR/CHIPDevicePlatformConfig.h
@@ -30,6 +30,7 @@
 #define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 1024 * 8
 #define CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY 1
 #define CHIP_DEVICE_CONFIG_ENABLE_TEST_SETUP_PARAMS 1
+#define CHIP_DEVICE_CONFIG_TEST_MANUFACTURY_DATE "2023-07-07"
 
 #if defined(CFG_PLF_RV32) || defined(CFG_PLF_DUET)
 // ASR582X/ASR595X support Wi-Fi and BLE
diff --git a/src/platform/ASR/NetworkCommissioningWiFiDriver.cpp b/src/platform/ASR/NetworkCommissioningWiFiDriver.cpp
index d7ed6266706c58..a3cdc40dcbae4e 100644
--- a/src/platform/ASR/NetworkCommissioningWiFiDriver.cpp
+++ b/src/platform/ASR/NetworkCommissioningWiFiDriver.cpp
@@ -297,8 +297,7 @@ void ASRWiFiDriver::OnNetworkStatusChange()
     if (staConnected)
     {
         mpStatusChangeCallback->OnNetworkingStatusChange(
-            Status::kSuccess, MakeOptional(ByteSpan(configuredNetwork.networkID, configuredNetwork.networkIDLen)),
-            MakeOptional(GetLastDisconnectReason()));
+            Status::kSuccess, MakeOptional(ByteSpan(configuredNetwork.networkID, configuredNetwork.networkIDLen)), NullOptional);
         return;
     }
     mpStatusChangeCallback->OnNetworkingStatusChange(
diff --git a/third_party/asr/asr550x/BUILD.gn b/third_party/asr/asr550x/BUILD.gn
new file mode 100755
index 00000000000000..443059f44c44d6
--- /dev/null
+++ b/third_party/asr/asr550x/BUILD.gn
@@ -0,0 +1,169 @@
+# Copyright (c) 2023 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/asr.gni")
+import("${asr_sdk_build_root}/asr_sdk.gni")
+import("${chip_root}/src/platform/ASR/args.gni")
+
+declare_args() {
+  # Build target to use for asr SDK. Use this to set global SDK defines.
+  asr_target_project = ""
+}
+
+assert(asr_target_project != "", "asr_target_project must be specified")
+
+# Add includes, cflags, asmflags, etc in config
+config("asr_sdk_config") {
+  _include_dirs = [
+    "${asr_sdk_build_root}/asr_sdk/config",
+    "${asr_sdk_build_root}/asr_sdk/config/lwip_if",
+    "${asr_sdk_build_root}/asr_sdk/matter",
+    "${asr_sdk_build_root}/asr_sdk/lib",
+    "${asr_sdk_build_root}/asr_sdk/lib/security",
+    "${asr_sdk_build_root}/asr_sdk/version",
+    "${asr_sdk_build_root}/asr_sdk/driver/inc",
+    "${asr_sdk_build_root}/asr_sdk/common",
+    "${asr_sdk_build_root}/asr_sdk/common/easylogger",
+    "${asr_sdk_build_root}/asr_sdk/platform/duet",
+    "${asr_sdk_build_root}/asr_sdk/platform/CMSIS/Include",
+    "${asr_sdk_build_root}/asr_sdk/platform/system/include",
+    "${asr_sdk_build_root}/../components/freertos/Source/include",
+    "${asr_sdk_build_root}/../components/freertos/Source/portable/MemMang",
+    "${asr_sdk_build_root}/../components/freertos/Source/portable/GCC/ARM_CM4F",
+    "${asr_sdk_build_root}/../components/lwip_2.1.2/include",
+    "${asr_sdk_build_root}/../components/lwip_2.1.2/port/include",
+    "${asr_sdk_build_root}/../components/lwip_2.1.2/include/lwip",
+    "${asr_sdk_build_root}/../components/lwip_2.1.2/include/lwip/prot",
+    "${asr_sdk_build_root}/../components/lwip_2.1.2/include/netif",
+    "${asr_sdk_build_root}/../components/mbedtls-2.18/include",
+    "${asr_sdk_build_root}/../components/mbedtls-2.18/include/mbedtls",
+    "${asr_sdk_build_root}/../components/mbedtls-2.18/asr_mbedtls/",
+    "${asr_sdk_build_root}/../components/mbedtls-2.18/asr_mbedtls/alt",
+  ]
+
+  # Also add project include path (passed in from project build)
+  proj_path = get_label_info(asr_target_project, "dir")
+  _include_dirs += [ "/" + rebase_path("${proj_path}/include", "/", ".") ]
+
+  cflags = []
+  foreach(include_dir, _include_dirs) {
+    cflags += [ "-isystem" + rebase_path(include_dir, root_build_dir) ]
+  }
+
+  # Pull out defines from generated json
+  defines = [
+    "_SPI_FLASH_120MHz_",
+    "PS_CLOSE_APLL",
+    "LEGA_A0V2",
+    "LEGA_CM4",
+    "_SPI_FLASH_ENABLE_",
+    "SYSTEM_SUPPORT_OS",
+    "WIFI_DEVICE",
+    "CFG_BATX=1",
+    "CFG_BARX=1",
+    "CFG_REORD_BUF=4",
+    "CFG_SPC=4",
+    "CFG_TXDESC0=4",
+    "CFG_TXDESC1=4",
+    "CFG_TXDESC2=4",
+    "CFG_TXDESC3=4",
+    "CFG_TXDESC4=4",
+    "CFG_CMON",
+    "CFG_MDM_VER_V21",
+    "CFG_SOFTAP_SUPPORT",
+    "CFG_SNIFFER_SUPPORT",
+    "CFG_CUS_FRAME",
+    "CFG_DBG=1",
+    "__FPU_PRESENT=1",
+    "DX_CC_TEE",
+    "HASH_SHA_512_SUPPORTED",
+    "CC_HW_VERSION=0xF0",
+    "DLLI_MAX_BUFF_SIZE=0x10000",
+    "SSI_CONFIG_TRNG_MODE=0",
+    "AT_USER_DEBUG",
+    "SYSTEM_RECOVERY",
+    "SYSTEM_COREDUMP",
+    "CFG_IOT_PLT",
+    "CLOUD_AUTH",
+    "CFG_BAIDU",
+    "CFG_OS_VERSION_CHECK",
+    "CFG_SAE",
+    "CFG_SAE_AUTH_OPT",
+    "CFG_MFP",
+    "CONFIG_IEEE80211W",
+    "WFA_CERTIFICATE_N",
+    "USE_SMALL_STACK",
+    "CFG_RESET_OPT",
+    "SYSTEM_RECOVERY",
+    "LWIP_DUALSTACK",
+    "SECURITY_ENGINE_INIT",
+    "MBEDTLS_HW",
+    "MBEDTLS_HW_ECC",
+    "MBEDTLS_HW_AES",
+    "MBEDTLS_HW_HASH",
+    "MBEDTLS_USER_CONFIG_FILE=<mbedtls_user_config.h>",
+    "CONFIG_ENABLE_ASR_LEGA_RTOS=1",
+    "CFG_EASY_LOG_ENABLE=1",
+    "CFG_EASY_LOG_MODULE_EN=1",
+  ]
+
+  cflags_c = [
+    "-mcpu=cortex-m4",
+    "-Os",
+    "-mfloat-abi=softfp",
+    "-mfpu=fpv4-sp-d16",
+    "-mthumb",
+    "-fno-builtin-printf",
+    "-fno-builtin-sprintf",
+    "-fno-builtin-snprintf",
+    "-ffunction-sections",
+    "-fdata-sections",
+    "-g",
+    "-Wall",
+  ]
+
+  cflags_cc = cflags_c
+
+  asmflags = cflags_c
+
+  ldflags = cflags_c
+
+  cflags_c += [
+    "-Wno-sign-compare",
+    "-Wno-unused-function",
+    "-Wno-pointer-sign",
+    "-Wno-type-limits",
+  ]
+
+  ldflags += [
+    "-Wl,--wrap=printf",
+    "-Wl,--wrap=sprintf",
+    "-Wl,--wrap=snprintf",
+    "-Wl,--gc-sections",
+  ]
+
+  libs = [
+    "${chip_root}/third_party/asr/${asr_ic_family}/asr_sdk/lib/libasr_wifi_v6.a",
+    "${chip_root}/third_party/asr/${asr_ic_family}/asr_sdk/lib/security/lib_security.a",
+  ]
+
+  linker_script_flags =
+      "${asr_sdk_build_root}/asr_sdk/demo/ld/gcc.ld"
+  ldflags += [ "-T" + rebase_path(linker_script_flags, root_build_dir) ]
+}
+
+group("asr_build") {
+  public_configs = [ ":asr_sdk_config" ]
+  public_deps = [ asr_target_project ]
+}
diff --git a/third_party/asr/asr550x/asr_sdk b/third_party/asr/asr550x/asr_sdk
new file mode 160000
index 00000000000000..111b5d6fc7a9e9
--- /dev/null
+++ b/third_party/asr/asr550x/asr_sdk
@@ -0,0 +1 @@
+Subproject commit 111b5d6fc7a9e9a8b1708172fc550eb29ab8317a
diff --git a/third_party/asr/asr550x/asr_sdk.gni b/third_party/asr/asr550x/asr_sdk.gni
new file mode 100644
index 00000000000000..d4e12c226871a8
--- /dev/null
+++ b/third_party/asr/asr550x/asr_sdk.gni
@@ -0,0 +1,255 @@
+# Copyright (c) 2023 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/jlink.gni")
+import("//build_overrides/mbedtls.gni")
+
+import("//build_overrides/asr.gni")
+
+# Defines an asr SDK build target.
+#
+# Parameters:
+#   sources - The sources files to build.
+#
+template("asr_sdk_sources") {
+  if (defined(invoker.asr_project_dir)) {
+    asr_project_dir = invoker.asr_project_dir
+  }
+
+  # While most asr sdk includes come from the asr_sdk_config config (in
+  # BUILD.gn), this template gets instantiated by each project each of which
+  # provides a few extra includes/defines. Handle those here.
+  config("project_configs") {
+    include_dirs = []
+    if (defined(invoker.include_dirs)) {
+      include_dirs += invoker.include_dirs
+    }
+    include_dirs += [ "${asr_project_dir}/include" ]
+
+    defines = []
+    if (defined(invoker.defines)) {
+      defines += invoker.defines
+    }
+  }
+
+  sdk_target_name = target_name
+
+  # Add sources here
+  source_set(sdk_target_name) {
+    sources = []
+    if (defined(invoker.sources)) {
+      sources += invoker.sources
+    }
+
+    _third_party_src = [
+      #at
+      "at_cmd/atcmd_comm.c",
+      "at_cmd/atcmd_user.c",
+      "at_cmd/atcmd_matter.c",
+
+      #peripheral
+      "driver/src/lega_flash.c",
+      "driver/src/lega_flash_alg.c",
+      "driver/src/lega_uart.c",
+      "driver/src/lega_wdg.c",
+      "driver/src/lega_i2c.c",
+      "driver/src/lega_timer.c",
+      "driver/src/lega_gpio.c",
+      "driver/src/lega_efuse.c",
+      "driver/src/lega_boot.c",
+      "driver/src/lega_board.c",
+      "driver/src/lega_pwm.c",
+      "driver/src/lega_pinmux.c",
+
+      #platform
+      "platform/sysCalls.c",
+      "platform/soc_init.c",
+      "platform/system_cm4.c",
+      "platform/ethernetif_wifi.c",
+      "platform/startup_cm4.S",
+      "platform/printf_uart.c",
+
+      #rtos
+      "platform/lega_rtos.c",
+      "../../components/freertos/Source/croutine.c",
+      "../../components/freertos/Source/event_groups.c",
+      "../../components/freertos/Source/list.c",
+      "../../components/freertos/Source/queue.c",
+      "../../components/freertos/Source/tasks.c",
+      "../../components/freertos/Source/timers.c",
+      "../../components/freertos/Source/portable/MemMang/heap_4.c",
+      "../../components/freertos/Source/portable/GCC/ARM_CM4F/port.c",
+
+      #matter
+      "matter/asr_factory_config.c",
+
+      #elog
+      "common/easylogger/elog_async.c",
+      "common/easylogger/elog_buf.c",
+      "common/easylogger/elog_module.c",
+      "common/easylogger/elog_port.c",
+      "common/easylogger/elog_utils.c",
+      "common/easylogger/elog.c",
+
+      #lwip
+      "../../components/lwip_2.1.2/netif/ethernet.c",
+      "../../components/lwip_2.1.2/port/sys_arch.c",
+      "../../components/lwip_2.1.2/api/api_lib.c",
+      "../../components/lwip_2.1.2/api/api_msg.c",
+      "../../components/lwip_2.1.2/api/err.c",
+      "../../components/lwip_2.1.2/api/if_api.c",
+      "../../components/lwip_2.1.2/api/netbuf.c",
+      "../../components/lwip_2.1.2/api/netdb.c",
+      "../../components/lwip_2.1.2/api/netifapi.c",
+      "../../components/lwip_2.1.2/api/sockets.c",
+      "../../components/lwip_2.1.2/api/tcpip.c",
+      "../../components/lwip_2.1.2/core/altcp.c",
+      "../../components/lwip_2.1.2/core/altcp_alloc.c",
+      "../../components/lwip_2.1.2/core/altcp_tcp.c",
+      "../../components/lwip_2.1.2/core/def.c",
+      "../../components/lwip_2.1.2/core/dns.c",
+      "../../components/lwip_2.1.2/core/inet_chksum.c",
+      "../../components/lwip_2.1.2/core/init.c",
+      "../../components/lwip_2.1.2/core/ip.c",
+      "../../components/lwip_2.1.2/core/ipv4/autoip.c",
+      "../../components/lwip_2.1.2/core/ipv4/dhcp.c",
+      "../../components/lwip_2.1.2/core/ipv4/etharp.c",
+      "../../components/lwip_2.1.2/core/ipv4/icmp.c",
+      "../../components/lwip_2.1.2/core/ipv4/igmp.c",
+      "../../components/lwip_2.1.2/core/ipv4/ip4.c",
+      "../../components/lwip_2.1.2/core/ipv4/ip4_addr.c",
+      "../../components/lwip_2.1.2/core/ipv4/ip4_frag.c",
+      "../../components/lwip_2.1.2/core/ipv6/dhcp6.c",
+      "../../components/lwip_2.1.2/core/ipv6/ethip6.c",
+      "../../components/lwip_2.1.2/core/ipv6/icmp6.c",
+      "../../components/lwip_2.1.2/core/ipv6/inet6.c",
+      "../../components/lwip_2.1.2/core/ipv6/ip6.c",
+      "../../components/lwip_2.1.2/core/ipv6/ip6_addr.c",
+      "../../components/lwip_2.1.2/core/ipv6/ip6_frag.c",
+      "../../components/lwip_2.1.2/core/ipv6/mld6.c",
+      "../../components/lwip_2.1.2/core/ipv6/nd6.c",
+      "../../components/lwip_2.1.2/core/lwip_hooks.c",
+      "../../components/lwip_2.1.2/core/mem.c",
+      "../../components/lwip_2.1.2/core/memp.c",
+      "../../components/lwip_2.1.2/core/netif.c",
+      "../../components/lwip_2.1.2/core/pbuf.c",
+      "../../components/lwip_2.1.2/core/raw.c",
+      "../../components/lwip_2.1.2/core/stats.c",
+      "../../components/lwip_2.1.2/core/sys.c",
+      "../../components/lwip_2.1.2/core/tcp.c",
+      "../../components/lwip_2.1.2/core/tcp_in.c",
+      "../../components/lwip_2.1.2/core/tcp_out.c",
+      "../../components/lwip_2.1.2/core/timeouts.c",
+      "../../components/lwip_2.1.2/core/udp.c",
+
+      #mbedtls
+      "../../components/mbedtls-2.18/library/aes.c",
+      "../../components/mbedtls-2.18/library/aesni.c",
+      "../../components/mbedtls-2.18/library/arc4.c",
+      "../../components/mbedtls-2.18/library/aria.c",
+      "../../components/mbedtls-2.18/library/asn1parse.c",
+      "../../components/mbedtls-2.18/library/asn1write.c",
+      "../../components/mbedtls-2.18/library/base64.c",
+      "../../components/mbedtls-2.18/library/bignum.c",
+      "../../components/mbedtls-2.18/library/blowfish.c",
+      "../../components/mbedtls-2.18/library/camellia.c",
+      "../../components/mbedtls-2.18/library/ccm.c",
+      "../../components/mbedtls-2.18/library/certs.c",
+      "../../components/mbedtls-2.18/library/chacha20.c",
+      "../../components/mbedtls-2.18/library/chachapoly.c",
+      "../../components/mbedtls-2.18/library/cipher.c",
+      "../../components/mbedtls-2.18/library/cipher_wrap.c",
+      "../../components/mbedtls-2.18/library/cmac.c",
+      "../../components/mbedtls-2.18/library/ctr_drbg.c",
+      "../../components/mbedtls-2.18/library/debug.c",
+      "../../components/mbedtls-2.18/library/des.c",
+      "../../components/mbedtls-2.18/library/dhm.c",
+      "../../components/mbedtls-2.18/library/ecdh.c",
+      "../../components/mbedtls-2.18/library/ecdsa.c",
+      "../../components/mbedtls-2.18/library/ecjpake.c",
+      "../../components/mbedtls-2.18/library/ecp.c",
+      "../../components/mbedtls-2.18/library/ecp_curves.c",
+      "../../components/mbedtls-2.18/library/entropy.c",
+      "../../components/mbedtls-2.18/library/entropy_poll.c",
+      "../../components/mbedtls-2.18/library/error.c",
+      "../../components/mbedtls-2.18/library/gcm.c",
+      "../../components/mbedtls-2.18/library/havege.c",
+      "../../components/mbedtls-2.18/library/hkdf.c",
+      "../../components/mbedtls-2.18/library/hmac_drbg.c",
+      "../../components/mbedtls-2.18/library/md.c",
+      "../../components/mbedtls-2.18/library/md2.c",
+      "../../components/mbedtls-2.18/library/md4.c",
+      "../../components/mbedtls-2.18/library/md5.c",
+      "../../components/mbedtls-2.18/library/md_wrap.c",
+      "../../components/mbedtls-2.18/library/memory_buffer_alloc.c",
+      "../../components/mbedtls-2.18/library/nist_kw.c",
+      "../../components/mbedtls-2.18/library/oid.c",
+      "../../components/mbedtls-2.18/library/padlock.c",
+      "../../components/mbedtls-2.18/library/pem.c",
+      "../../components/mbedtls-2.18/library/pk.c",
+      "../../components/mbedtls-2.18/library/pk_wrap.c",
+      "../../components/mbedtls-2.18/library/pkcs11.c",
+      "../../components/mbedtls-2.18/library/pkcs12.c",
+      "../../components/mbedtls-2.18/library/pkcs5.c",
+      "../../components/mbedtls-2.18/library/pkparse.c",
+      "../../components/mbedtls-2.18/library/pkwrite.c",
+      "../../components/mbedtls-2.18/library/platform.c",
+      "../../components/mbedtls-2.18/library/platform_util.c",
+      "../../components/mbedtls-2.18/library/poly1305.c",
+      "../../components/mbedtls-2.18/library/ripemd160.c",
+      "../../components/mbedtls-2.18/library/rsa.c",
+      "../../components/mbedtls-2.18/library/rsa_internal.c",
+      "../../components/mbedtls-2.18/library/sha1.c",
+      "../../components/mbedtls-2.18/library/sha256.c",
+      "../../components/mbedtls-2.18/library/sha512.c",
+      "../../components/mbedtls-2.18/library/ssl_cache.c",
+      "../../components/mbedtls-2.18/library/ssl_ciphersuites.c",
+      "../../components/mbedtls-2.18/library/ssl_cli.c",
+      "../../components/mbedtls-2.18/library/ssl_cookie.c",
+      "../../components/mbedtls-2.18/library/ssl_srv.c",
+      "../../components/mbedtls-2.18/library/ssl_ticket.c",
+      "../../components/mbedtls-2.18/library/ssl_tls.c",
+      "../../components/mbedtls-2.18/library/threading.c",
+      "../../components/mbedtls-2.18/library/timing.c",
+      "../../components/mbedtls-2.18/library/version.c",
+      "../../components/mbedtls-2.18/library/version_features.c",
+      "../../components/mbedtls-2.18/library/x509.c",
+      "../../components/mbedtls-2.18/library/x509_create.c",
+      "../../components/mbedtls-2.18/library/x509_crl.c",
+      "../../components/mbedtls-2.18/library/x509_crt.c",
+      "../../components/mbedtls-2.18/library/x509_csr.c",
+      "../../components/mbedtls-2.18/library/x509write_crt.c",
+      "../../components/mbedtls-2.18/library/x509write_csr.c",
+      "../../components/mbedtls-2.18/library/xtea.c",
+      "../../components/mbedtls-2.18/asr_mbedtls/alt/entropy_hardware_alt.c",
+      "../../components/mbedtls-2.18/asr_mbedtls/alt/aes_alt.c",
+      "../../components/mbedtls-2.18/asr_mbedtls/alt/sha1_alt.c",
+      "../../components/mbedtls-2.18/asr_mbedtls/alt/sha256_alt.c",
+    ]
+
+    foreach(src, _third_party_src) {
+      sources += [ rebase_path(src,
+                               "${asr_project_dir}",
+                               "${asr_sdk_build_root}/asr_sdk/") ]
+    }
+
+    public_deps = [ "${chip_root}/src/lwip:lwip" ]
+
+    public_configs = [ ":project_configs" ]
+    if (defined(invoker.public_configs)) {
+      public_configs += invoker.public_configs
+    }
+  }
+}
diff --git a/third_party/asr/asr582x/BUILD.gn b/third_party/asr/asr582x/BUILD.gn
index f6d8732420cb25..9f4cc9fd6c468e 100755
--- a/third_party/asr/asr582x/BUILD.gn
+++ b/third_party/asr/asr582x/BUILD.gn
@@ -29,9 +29,6 @@ config("asr_sdk_config") {
     "${asr_sdk_build_root}/asr_sdk/config",
     "${asr_sdk_build_root}/asr_sdk/config/lwip_if",
     "${asr_sdk_build_root}/asr_sdk/matter",
-    "${asr_sdk_build_root}/asr_sdk/freertos/Source/include",
-    "${asr_sdk_build_root}/asr_sdk/freertos/Source/portable/MemMang",
-    "${asr_sdk_build_root}/asr_sdk/freertos/Source/portable/GCC/ARM_CM4F",
     "${asr_sdk_build_root}/asr_sdk/lib/wifi",
     "${asr_sdk_build_root}/asr_sdk/lib/ble",
     "${asr_sdk_build_root}/asr_sdk/lib/sys",
@@ -45,21 +42,19 @@ config("asr_sdk_config") {
     "${asr_sdk_build_root}/asr_sdk/platform/duet/CMSIS/Include",
     "${asr_sdk_build_root}/asr_sdk/platform/duet/system/include",
     "${asr_sdk_build_root}/asr_sdk/platform/duet/kv/include",
-    "${asr_sdk_build_root}/asr_sdk/lwip/lwip_2.1.2/include",
-    "${asr_sdk_build_root}/asr_sdk/lwip/lwip_2.1.2/port/include",
-    "${asr_sdk_build_root}/asr_sdk/lwip/lwip_2.1.2/include/lwip",
-    "${asr_sdk_build_root}/asr_sdk/lwip/lwip_app",
-    "${asr_sdk_build_root}/asr_sdk/lwip/lwip_app/lwip_app_ping",
-    "${asr_sdk_build_root}/asr_sdk/lwip/lwip_2.1.2/include/lwip/prot",
-    "${asr_sdk_build_root}/asr_sdk/lwip/lwip_2.1.2/include/netif",
-    "${asr_sdk_build_root}/asr_sdk/lwip/lwip_app/iperf",
-    "${asr_sdk_build_root}/asr_sdk/lwip/lwip_app/ota",
-    "${asr_sdk_build_root}/asr_sdk/lwip/mbedtls-mbedtls-2.18/include",
-    "${asr_sdk_build_root}/asr_sdk/lwip/mbedtls-mbedtls-2.18/include/mbedtls",
-    "${asr_sdk_build_root}/asr_sdk/lwip/mbedtls-mbedtls-2.18/asr_mbedtls/",
-    "${asr_sdk_build_root}/asr_sdk/lwip/mbedtls-mbedtls-2.18/asr_mbedtls/alt",
     "${asr_sdk_build_root}/asr_sdk/demo/matter_demo/app/ble_demo/duet_hl_matter",
-    "${asr_sdk_build_root}/asr_sdk/platform/duet/kv/include",
+    "${asr_sdk_build_root}/../components/freertos/Source/include",
+    "${asr_sdk_build_root}/../components/freertos/Source/portable/MemMang",
+    "${asr_sdk_build_root}/../components/freertos/Source/portable/GCC/ARM_CM4F",
+    "${asr_sdk_build_root}/../components/lwip_2.1.2/include",
+    "${asr_sdk_build_root}/../components/lwip_2.1.2/port/include",
+    "${asr_sdk_build_root}/../components/lwip_2.1.2/include/lwip",
+    "${asr_sdk_build_root}/../components/lwip_2.1.2/include/lwip/prot",
+    "${asr_sdk_build_root}/../components/lwip_2.1.2/include/netif",
+    "${asr_sdk_build_root}/../components/mbedtls-2.18/include",
+    "${asr_sdk_build_root}/../components/mbedtls-2.18/include/mbedtls",
+    "${asr_sdk_build_root}/../components/mbedtls-2.18/asr_mbedtls/",
+    "${asr_sdk_build_root}/../components/mbedtls-2.18/asr_mbedtls/alt",
   ]
 
   # Also add project include path (passed in from project build)
@@ -144,6 +139,9 @@ config("asr_sdk_config") {
     "-mfloat-abi=softfp",
     "-mfpu=fpv4-sp-d16",
     "-mthumb",
+    "-fno-builtin-printf",
+    "-fno-builtin-sprintf",
+    "-fno-builtin-snprintf",
     "-ffunction-sections",
     "-fdata-sections",
     "-g",
@@ -163,7 +161,12 @@ config("asr_sdk_config") {
     "-Wno-type-limits",
   ]
 
-  ldflags += [ "-Wl,--gc-sections" ]
+  ldflags += [
+    "-Wl,--wrap=printf",
+    "-Wl,--wrap=sprintf",
+    "-Wl,--wrap=snprintf",
+    "-Wl,--gc-sections",
+  ]
 
   libs = [
     "${chip_root}/third_party/asr/${asr_ic_family}/asr_sdk/lib/5822s/libasr_combo_v6.a",
diff --git a/third_party/asr/asr582x/asr_sdk b/third_party/asr/asr582x/asr_sdk
index 5942c485ce3a75..54eee34a8d55a4 160000
--- a/third_party/asr/asr582x/asr_sdk
+++ b/third_party/asr/asr582x/asr_sdk
@@ -1 +1 @@
-Subproject commit 5942c485ce3a75585883abba389a4336c190a86b
+Subproject commit 54eee34a8d55a417192e519ba936065d9025b6a0
diff --git a/third_party/asr/asr582x/asr_sdk.gni b/third_party/asr/asr582x/asr_sdk.gni
index 18a04be42b60fa..188a561856ed4c 100755
--- a/third_party/asr/asr582x/asr_sdk.gni
+++ b/third_party/asr/asr582x/asr_sdk.gni
@@ -88,14 +88,14 @@ template("asr_sdk_sources") {
 
       #rtos
       "platform/duet/lega_rtos.c",
-      "freertos/Source/croutine.c",
-      "freertos/Source/event_groups.c",
-      "freertos/Source/list.c",
-      "freertos/Source/queue.c",
-      "freertos/Source/tasks.c",
-      "freertos/Source/timers.c",
-      "freertos/Source/portable/MemMang/heap_5.c",
-      "freertos/Source/portable/GCC/ARM_CM4F/port.c",
+      "../../components/freertos/Source/croutine.c",
+      "../../components/freertos/Source/event_groups.c",
+      "../../components/freertos/Source/list.c",
+      "../../components/freertos/Source/queue.c",
+      "../../components/freertos/Source/tasks.c",
+      "../../components/freertos/Source/timers.c",
+      "../../components/freertos/Source/portable/MemMang/heap_5.c",
+      "../../components/freertos/Source/portable/GCC/ARM_CM4F/port.c",
 
       #ble
       "demo/matter_demo/app/ble_demo/duet_hl_matter/app.c",
@@ -113,139 +113,139 @@ template("asr_sdk_sources") {
       "common/duet/easylogger/elog.c",
 
       #lwip
-      "lwip/lwip_2.1.2/netif/ethernet.c",
-      "lwip/lwip_2.1.2/port/sys_arch.c",
-      "lwip/lwip_2.1.2/api/api_lib.c",
-      "lwip/lwip_2.1.2/api/api_msg.c",
-      "lwip/lwip_2.1.2/api/err.c",
-      "lwip/lwip_2.1.2/api/if_api.c",
-      "lwip/lwip_2.1.2/api/netbuf.c",
-      "lwip/lwip_2.1.2/api/netdb.c",
-      "lwip/lwip_2.1.2/api/netifapi.c",
-      "lwip/lwip_2.1.2/api/sockets.c",
-      "lwip/lwip_2.1.2/api/tcpip.c",
-      "lwip/lwip_2.1.2/core/altcp.c",
-      "lwip/lwip_2.1.2/core/altcp_alloc.c",
-      "lwip/lwip_2.1.2/core/altcp_tcp.c",
-      "lwip/lwip_2.1.2/core/def.c",
-      "lwip/lwip_2.1.2/core/dns.c",
-      "lwip/lwip_2.1.2/core/inet_chksum.c",
-      "lwip/lwip_2.1.2/core/init.c",
-      "lwip/lwip_2.1.2/core/ip.c",
-      "lwip/lwip_2.1.2/core/ipv4/autoip.c",
-      "lwip/lwip_2.1.2/core/ipv4/dhcp.c",
-      "lwip/lwip_2.1.2/core/ipv4/etharp.c",
-      "lwip/lwip_2.1.2/core/ipv4/icmp.c",
-      "lwip/lwip_2.1.2/core/ipv4/igmp.c",
-      "lwip/lwip_2.1.2/core/ipv4/ip4.c",
-      "lwip/lwip_2.1.2/core/ipv4/ip4_addr.c",
-      "lwip/lwip_2.1.2/core/ipv4/ip4_frag.c",
-      "lwip/lwip_2.1.2/core/ipv6/dhcp6.c",
-      "lwip/lwip_2.1.2/core/ipv6/ethip6.c",
-      "lwip/lwip_2.1.2/core/ipv6/icmp6.c",
-      "lwip/lwip_2.1.2/core/ipv6/inet6.c",
-      "lwip/lwip_2.1.2/core/ipv6/ip6.c",
-      "lwip/lwip_2.1.2/core/ipv6/ip6_addr.c",
-      "lwip/lwip_2.1.2/core/ipv6/ip6_frag.c",
-      "lwip/lwip_2.1.2/core/ipv6/mld6.c",
-      "lwip/lwip_2.1.2/core/ipv6/nd6.c",
-      "lwip/lwip_2.1.2/core/lwip_hooks.c",
-      "lwip/lwip_2.1.2/core/mem.c",
-      "lwip/lwip_2.1.2/core/memp.c",
-      "lwip/lwip_2.1.2/core/netif.c",
-      "lwip/lwip_2.1.2/core/pbuf.c",
-      "lwip/lwip_2.1.2/core/raw.c",
-      "lwip/lwip_2.1.2/core/stats.c",
-      "lwip/lwip_2.1.2/core/sys.c",
-      "lwip/lwip_2.1.2/core/tcp.c",
-      "lwip/lwip_2.1.2/core/tcp_in.c",
-      "lwip/lwip_2.1.2/core/tcp_out.c",
-      "lwip/lwip_2.1.2/core/timeouts.c",
-      "lwip/lwip_2.1.2/core/udp.c",
+      "../../components/lwip_2.1.2/netif/ethernet.c",
+      "../../components/lwip_2.1.2/port/sys_arch.c",
+      "../../components/lwip_2.1.2/api/api_lib.c",
+      "../../components/lwip_2.1.2/api/api_msg.c",
+      "../../components/lwip_2.1.2/api/err.c",
+      "../../components/lwip_2.1.2/api/if_api.c",
+      "../../components/lwip_2.1.2/api/netbuf.c",
+      "../../components/lwip_2.1.2/api/netdb.c",
+      "../../components/lwip_2.1.2/api/netifapi.c",
+      "../../components/lwip_2.1.2/api/sockets.c",
+      "../../components/lwip_2.1.2/api/tcpip.c",
+      "../../components/lwip_2.1.2/core/altcp.c",
+      "../../components/lwip_2.1.2/core/altcp_alloc.c",
+      "../../components/lwip_2.1.2/core/altcp_tcp.c",
+      "../../components/lwip_2.1.2/core/def.c",
+      "../../components/lwip_2.1.2/core/dns.c",
+      "../../components/lwip_2.1.2/core/inet_chksum.c",
+      "../../components/lwip_2.1.2/core/init.c",
+      "../../components/lwip_2.1.2/core/ip.c",
+      "../../components/lwip_2.1.2/core/ipv4/autoip.c",
+      "../../components/lwip_2.1.2/core/ipv4/dhcp.c",
+      "../../components/lwip_2.1.2/core/ipv4/etharp.c",
+      "../../components/lwip_2.1.2/core/ipv4/icmp.c",
+      "../../components/lwip_2.1.2/core/ipv4/igmp.c",
+      "../../components/lwip_2.1.2/core/ipv4/ip4.c",
+      "../../components/lwip_2.1.2/core/ipv4/ip4_addr.c",
+      "../../components/lwip_2.1.2/core/ipv4/ip4_frag.c",
+      "../../components/lwip_2.1.2/core/ipv6/dhcp6.c",
+      "../../components/lwip_2.1.2/core/ipv6/ethip6.c",
+      "../../components/lwip_2.1.2/core/ipv6/icmp6.c",
+      "../../components/lwip_2.1.2/core/ipv6/inet6.c",
+      "../../components/lwip_2.1.2/core/ipv6/ip6.c",
+      "../../components/lwip_2.1.2/core/ipv6/ip6_addr.c",
+      "../../components/lwip_2.1.2/core/ipv6/ip6_frag.c",
+      "../../components/lwip_2.1.2/core/ipv6/mld6.c",
+      "../../components/lwip_2.1.2/core/ipv6/nd6.c",
+      "../../components/lwip_2.1.2/core/lwip_hooks.c",
+      "../../components/lwip_2.1.2/core/mem.c",
+      "../../components/lwip_2.1.2/core/memp.c",
+      "../../components/lwip_2.1.2/core/netif.c",
+      "../../components/lwip_2.1.2/core/pbuf.c",
+      "../../components/lwip_2.1.2/core/raw.c",
+      "../../components/lwip_2.1.2/core/stats.c",
+      "../../components/lwip_2.1.2/core/sys.c",
+      "../../components/lwip_2.1.2/core/tcp.c",
+      "../../components/lwip_2.1.2/core/tcp_in.c",
+      "../../components/lwip_2.1.2/core/tcp_out.c",
+      "../../components/lwip_2.1.2/core/timeouts.c",
+      "../../components/lwip_2.1.2/core/udp.c",
 
       #mbedtls
-      "lwip/mbedtls-mbedtls-2.18/library/aes.c",
-      "lwip/mbedtls-mbedtls-2.18/library/aesni.c",
-      "lwip/mbedtls-mbedtls-2.18/library/arc4.c",
-      "lwip/mbedtls-mbedtls-2.18/library/aria.c",
-      "lwip/mbedtls-mbedtls-2.18/library/asn1parse.c",
-      "lwip/mbedtls-mbedtls-2.18/library/asn1write.c",
-      "lwip/mbedtls-mbedtls-2.18/library/base64.c",
-      "lwip/mbedtls-mbedtls-2.18/library/bignum.c",
-      "lwip/mbedtls-mbedtls-2.18/library/blowfish.c",
-      "lwip/mbedtls-mbedtls-2.18/library/camellia.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ccm.c",
-      "lwip/mbedtls-mbedtls-2.18/library/certs.c",
-      "lwip/mbedtls-mbedtls-2.18/library/chacha20.c",
-      "lwip/mbedtls-mbedtls-2.18/library/chachapoly.c",
-      "lwip/mbedtls-mbedtls-2.18/library/cipher.c",
-      "lwip/mbedtls-mbedtls-2.18/library/cipher_wrap.c",
-      "lwip/mbedtls-mbedtls-2.18/library/cmac.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ctr_drbg.c",
-      "lwip/mbedtls-mbedtls-2.18/library/debug.c",
-      "lwip/mbedtls-mbedtls-2.18/library/des.c",
-      "lwip/mbedtls-mbedtls-2.18/library/dhm.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ecdh.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ecdsa.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ecjpake.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ecp.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ecp_curves.c",
-      "lwip/mbedtls-mbedtls-2.18/library/entropy.c",
-      "lwip/mbedtls-mbedtls-2.18/library/entropy_poll.c",
-      "lwip/mbedtls-mbedtls-2.18/library/error.c",
-      "lwip/mbedtls-mbedtls-2.18/library/gcm.c",
-      "lwip/mbedtls-mbedtls-2.18/library/havege.c",
-      "lwip/mbedtls-mbedtls-2.18/library/hkdf.c",
-      "lwip/mbedtls-mbedtls-2.18/library/hmac_drbg.c",
-      "lwip/mbedtls-mbedtls-2.18/library/md.c",
-      "lwip/mbedtls-mbedtls-2.18/library/md2.c",
-      "lwip/mbedtls-mbedtls-2.18/library/md4.c",
-      "lwip/mbedtls-mbedtls-2.18/library/md5.c",
-      "lwip/mbedtls-mbedtls-2.18/library/md_wrap.c",
-      "lwip/mbedtls-mbedtls-2.18/library/memory_buffer_alloc.c",
-      "lwip/mbedtls-mbedtls-2.18/library/nist_kw.c",
-      "lwip/mbedtls-mbedtls-2.18/library/oid.c",
-      "lwip/mbedtls-mbedtls-2.18/library/padlock.c",
-      "lwip/mbedtls-mbedtls-2.18/library/pem.c",
-      "lwip/mbedtls-mbedtls-2.18/library/pk.c",
-      "lwip/mbedtls-mbedtls-2.18/library/pk_wrap.c",
-      "lwip/mbedtls-mbedtls-2.18/library/pkcs11.c",
-      "lwip/mbedtls-mbedtls-2.18/library/pkcs12.c",
-      "lwip/mbedtls-mbedtls-2.18/library/pkcs5.c",
-      "lwip/mbedtls-mbedtls-2.18/library/pkparse.c",
-      "lwip/mbedtls-mbedtls-2.18/library/pkwrite.c",
-      "lwip/mbedtls-mbedtls-2.18/library/platform.c",
-      "lwip/mbedtls-mbedtls-2.18/library/platform_util.c",
-      "lwip/mbedtls-mbedtls-2.18/library/poly1305.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ripemd160.c",
-      "lwip/mbedtls-mbedtls-2.18/library/rsa.c",
-      "lwip/mbedtls-mbedtls-2.18/library/rsa_internal.c",
-      "lwip/mbedtls-mbedtls-2.18/library/sha1.c",
-      "lwip/mbedtls-mbedtls-2.18/library/sha256.c",
-      "lwip/mbedtls-mbedtls-2.18/library/sha512.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ssl_cache.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ssl_ciphersuites.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ssl_cli.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ssl_cookie.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ssl_srv.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ssl_ticket.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ssl_tls.c",
-      "lwip/mbedtls-mbedtls-2.18/library/threading.c",
-      "lwip/mbedtls-mbedtls-2.18/library/timing.c",
-      "lwip/mbedtls-mbedtls-2.18/library/version.c",
-      "lwip/mbedtls-mbedtls-2.18/library/version_features.c",
-      "lwip/mbedtls-mbedtls-2.18/library/x509.c",
-      "lwip/mbedtls-mbedtls-2.18/library/x509_create.c",
-      "lwip/mbedtls-mbedtls-2.18/library/x509_crl.c",
-      "lwip/mbedtls-mbedtls-2.18/library/x509_crt.c",
-      "lwip/mbedtls-mbedtls-2.18/library/x509_csr.c",
-      "lwip/mbedtls-mbedtls-2.18/library/x509write_crt.c",
-      "lwip/mbedtls-mbedtls-2.18/library/x509write_csr.c",
-      "lwip/mbedtls-mbedtls-2.18/library/xtea.c",
-      "lwip/mbedtls-mbedtls-2.18/asr_mbedtls/alt/entropy_hardware_alt.c",
-      "lwip/mbedtls-mbedtls-2.18/asr_mbedtls/alt/aes_alt.c",
-      "lwip/mbedtls-mbedtls-2.18/asr_mbedtls/alt/sha1_alt.c",
-      "lwip/mbedtls-mbedtls-2.18/asr_mbedtls/alt/sha256_alt.c",
+      "../../components/mbedtls-2.18/library/aes.c",
+      "../../components/mbedtls-2.18/library/aesni.c",
+      "../../components/mbedtls-2.18/library/arc4.c",
+      "../../components/mbedtls-2.18/library/aria.c",
+      "../../components/mbedtls-2.18/library/asn1parse.c",
+      "../../components/mbedtls-2.18/library/asn1write.c",
+      "../../components/mbedtls-2.18/library/base64.c",
+      "../../components/mbedtls-2.18/library/bignum.c",
+      "../../components/mbedtls-2.18/library/blowfish.c",
+      "../../components/mbedtls-2.18/library/camellia.c",
+      "../../components/mbedtls-2.18/library/ccm.c",
+      "../../components/mbedtls-2.18/library/certs.c",
+      "../../components/mbedtls-2.18/library/chacha20.c",
+      "../../components/mbedtls-2.18/library/chachapoly.c",
+      "../../components/mbedtls-2.18/library/cipher.c",
+      "../../components/mbedtls-2.18/library/cipher_wrap.c",
+      "../../components/mbedtls-2.18/library/cmac.c",
+      "../../components/mbedtls-2.18/library/ctr_drbg.c",
+      "../../components/mbedtls-2.18/library/debug.c",
+      "../../components/mbedtls-2.18/library/des.c",
+      "../../components/mbedtls-2.18/library/dhm.c",
+      "../../components/mbedtls-2.18/library/ecdh.c",
+      "../../components/mbedtls-2.18/library/ecdsa.c",
+      "../../components/mbedtls-2.18/library/ecjpake.c",
+      "../../components/mbedtls-2.18/library/ecp.c",
+      "../../components/mbedtls-2.18/library/ecp_curves.c",
+      "../../components/mbedtls-2.18/library/entropy.c",
+      "../../components/mbedtls-2.18/library/entropy_poll.c",
+      "../../components/mbedtls-2.18/library/error.c",
+      "../../components/mbedtls-2.18/library/gcm.c",
+      "../../components/mbedtls-2.18/library/havege.c",
+      "../../components/mbedtls-2.18/library/hkdf.c",
+      "../../components/mbedtls-2.18/library/hmac_drbg.c",
+      "../../components/mbedtls-2.18/library/md.c",
+      "../../components/mbedtls-2.18/library/md2.c",
+      "../../components/mbedtls-2.18/library/md4.c",
+      "../../components/mbedtls-2.18/library/md5.c",
+      "../../components/mbedtls-2.18/library/md_wrap.c",
+      "../../components/mbedtls-2.18/library/memory_buffer_alloc.c",
+      "../../components/mbedtls-2.18/library/nist_kw.c",
+      "../../components/mbedtls-2.18/library/oid.c",
+      "../../components/mbedtls-2.18/library/padlock.c",
+      "../../components/mbedtls-2.18/library/pem.c",
+      "../../components/mbedtls-2.18/library/pk.c",
+      "../../components/mbedtls-2.18/library/pk_wrap.c",
+      "../../components/mbedtls-2.18/library/pkcs11.c",
+      "../../components/mbedtls-2.18/library/pkcs12.c",
+      "../../components/mbedtls-2.18/library/pkcs5.c",
+      "../../components/mbedtls-2.18/library/pkparse.c",
+      "../../components/mbedtls-2.18/library/pkwrite.c",
+      "../../components/mbedtls-2.18/library/platform.c",
+      "../../components/mbedtls-2.18/library/platform_util.c",
+      "../../components/mbedtls-2.18/library/poly1305.c",
+      "../../components/mbedtls-2.18/library/ripemd160.c",
+      "../../components/mbedtls-2.18/library/rsa.c",
+      "../../components/mbedtls-2.18/library/rsa_internal.c",
+      "../../components/mbedtls-2.18/library/sha1.c",
+      "../../components/mbedtls-2.18/library/sha256.c",
+      "../../components/mbedtls-2.18/library/sha512.c",
+      "../../components/mbedtls-2.18/library/ssl_cache.c",
+      "../../components/mbedtls-2.18/library/ssl_ciphersuites.c",
+      "../../components/mbedtls-2.18/library/ssl_cli.c",
+      "../../components/mbedtls-2.18/library/ssl_cookie.c",
+      "../../components/mbedtls-2.18/library/ssl_srv.c",
+      "../../components/mbedtls-2.18/library/ssl_ticket.c",
+      "../../components/mbedtls-2.18/library/ssl_tls.c",
+      "../../components/mbedtls-2.18/library/threading.c",
+      "../../components/mbedtls-2.18/library/timing.c",
+      "../../components/mbedtls-2.18/library/version.c",
+      "../../components/mbedtls-2.18/library/version_features.c",
+      "../../components/mbedtls-2.18/library/x509.c",
+      "../../components/mbedtls-2.18/library/x509_create.c",
+      "../../components/mbedtls-2.18/library/x509_crl.c",
+      "../../components/mbedtls-2.18/library/x509_crt.c",
+      "../../components/mbedtls-2.18/library/x509_csr.c",
+      "../../components/mbedtls-2.18/library/x509write_crt.c",
+      "../../components/mbedtls-2.18/library/x509write_csr.c",
+      "../../components/mbedtls-2.18/library/xtea.c",
+      "../../components/mbedtls-2.18/asr_mbedtls/alt/entropy_hardware_alt.c",
+      "../../components/mbedtls-2.18/asr_mbedtls/alt/aes_alt.c",
+      "../../components/mbedtls-2.18/asr_mbedtls/alt/sha1_alt.c",
+      "../../components/mbedtls-2.18/asr_mbedtls/alt/sha256_alt.c",
     ]
 
     foreach(src, _third_party_src) {
diff --git a/third_party/asr/asr595x/BUILD.gn b/third_party/asr/asr595x/BUILD.gn
index c4f40e04acc066..aecf90a3ae10d3 100755
--- a/third_party/asr/asr595x/BUILD.gn
+++ b/third_party/asr/asr595x/BUILD.gn
@@ -32,22 +32,22 @@ config("asr_sdk_config") {
     "${asr_sdk_build_root}/asr_sdk/at_cmd",
     "${asr_sdk_build_root}/asr_sdk/common/alto/inc",
     "${asr_sdk_build_root}/asr_sdk/common/alto/easylogger",
-    "${asr_sdk_build_root}/asr_sdk/freertos",
-    "${asr_sdk_build_root}/asr_sdk/freertos/Source/include",
-    "${asr_sdk_build_root}/asr_sdk/freertos/Source/portable/GCC",
+    "${asr_sdk_build_root}/../components/freertos_10.3.1",
+    "${asr_sdk_build_root}/../components/freertos_10.3.1/Source/include",
+    "${asr_sdk_build_root}/../components/freertos_10.3.1/Source/portable/GCC",
     "${asr_sdk_build_root}/asr_sdk/legartos",
     "${asr_sdk_build_root}/asr_sdk/lib/ble",
     "${asr_sdk_build_root}/asr_sdk/lib/security",
     "${asr_sdk_build_root}/asr_sdk/lib/sys",
     "${asr_sdk_build_root}/asr_sdk/lib/wifi",
-    "${asr_sdk_build_root}/asr_sdk/lwip/lwip_2.1.2/include",
-    "${asr_sdk_build_root}/asr_sdk/lwip/lwip_2.1.2/include/lwip",
-    "${asr_sdk_build_root}/asr_sdk/lwip/lwip_2.1.2/include/lwip/prot",
-    "${asr_sdk_build_root}/asr_sdk/lwip/lwip_2.1.2/include/netif",
-    "${asr_sdk_build_root}/asr_sdk/lwip/lwip_2.1.2/port/include",
-    "${asr_sdk_build_root}/asr_sdk/lwip/mbedtls-mbedtls-2.18/include",
-    "${asr_sdk_build_root}/asr_sdk/lwip/mbedtls-mbedtls-2.18/asr_mbedtls",
-    "${asr_sdk_build_root}/asr_sdk/lwip/mbedtls-mbedtls-2.18/asr_mbedtls/alt",
+    "${asr_sdk_build_root}/../components/lwip_2.1.2/include",
+    "${asr_sdk_build_root}/../components/lwip_2.1.2/include/lwip",
+    "${asr_sdk_build_root}/../components/lwip_2.1.2/include/lwip/prot",
+    "${asr_sdk_build_root}/../components/lwip_2.1.2/include/netif",
+    "${asr_sdk_build_root}/../components/lwip_2.1.2/port/include",
+    "${asr_sdk_build_root}/../components/mbedtls-2.18/include",
+    "${asr_sdk_build_root}/../components/mbedtls-2.18/asr_mbedtls",
+    "${asr_sdk_build_root}/../components/mbedtls-2.18/asr_mbedtls/alt",
     "${asr_sdk_build_root}/asr_sdk/peripheral/asr/inc",
     "${asr_sdk_build_root}/asr_sdk/peripheral/asr/inc/alto",
     "${asr_sdk_build_root}/asr_sdk/peripheral/asr/inc/alto/alto",
@@ -157,6 +157,9 @@ config("asr_sdk_config") {
     "-fno-omit-frame-pointer",
     "-fshort-enums",
     "-fno-common",
+    "-fno-builtin-printf",
+    "-fno-builtin-sprintf",
+    "-fno-builtin-snprintf",
     "-ffunction-sections",
     "-fdata-sections",
     "-g",
@@ -183,6 +186,9 @@ config("asr_sdk_config") {
     "-Wall",
     "-lstdc++",
     "-nostartfiles",
+    "-Wl,--wrap=printf",
+    "-Wl,--wrap=sprintf",
+    "-Wl,--wrap=snprintf",
     "-Wl,--gc-sections",
   ]
 
diff --git a/third_party/asr/asr595x/asr_sdk b/third_party/asr/asr595x/asr_sdk
index 9161981339b656..d0feec9ef35079 160000
--- a/third_party/asr/asr595x/asr_sdk
+++ b/third_party/asr/asr595x/asr_sdk
@@ -1 +1 @@
-Subproject commit 9161981339b656ba6ea39eed13b7e0b78950bbe9
+Subproject commit d0feec9ef35079fac2b964b7379c6f5ea03668fa
diff --git a/third_party/asr/asr595x/asr_sdk.gni b/third_party/asr/asr595x/asr_sdk.gni
index 6c30da58d7c032..45a7913ba5074a 100755
--- a/third_party/asr/asr595x/asr_sdk.gni
+++ b/third_party/asr/asr595x/asr_sdk.gni
@@ -67,17 +67,17 @@ template("asr_sdk_sources") {
       "common/alto/src/GCC/intexc_hbird.S",
 
       #rtos
-      "freertos/Source/croutine.c",
-      "freertos/Source/event_groups.c",
-      "freertos/Source/list.c",
-      "freertos/Source/portable/GCC/port.c",
-      "freertos/Source/portable/GCC/portasm.S",
-      "freertos/Source/portable/MemMang/heap_5.c",
-      "freertos/Source/queue.c",
-      "freertos/Source/stream_buffer.c",
-      "freertos/Source/tasks.c",
-      "freertos/Source/timers.c",
       "legartos/lega_rtos.c",
+      "../../components/freertos_10.3.1/Source/croutine.c",
+      "../../components/freertos_10.3.1/Source/event_groups.c",
+      "../../components/freertos_10.3.1/Source/list.c",
+      "../../components/freertos_10.3.1/Source/portable/GCC/port.c",
+      "../../components/freertos_10.3.1/Source/portable/GCC/portasm.S",
+      "../../components/freertos_10.3.1/Source/portable/MemMang/heap_5.c",
+      "../../components/freertos_10.3.1/Source/queue.c",
+      "../../components/freertos_10.3.1/Source/stream_buffer.c",
+      "../../components/freertos_10.3.1/Source/tasks.c",
+      "../../components/freertos_10.3.1/Source/timers.c",
 
       #peripheral
       "peripheral/asr/src/alto/asr_alto_apll_rf.c",
@@ -127,139 +127,139 @@ template("asr_sdk_sources") {
       "matter/asr_factory_config.c",
 
       #lwip
-      "lwip/lwip_2.1.2/netif/ethernet.c",
-      "lwip/lwip_2.1.2/port/sys_arch.c",
-      "lwip/lwip_2.1.2/api/api_lib.c",
-      "lwip/lwip_2.1.2/api/api_msg.c",
-      "lwip/lwip_2.1.2/api/err.c",
-      "lwip/lwip_2.1.2/api/if_api.c",
-      "lwip/lwip_2.1.2/api/netbuf.c",
-      "lwip/lwip_2.1.2/api/netdb.c",
-      "lwip/lwip_2.1.2/api/netifapi.c",
-      "lwip/lwip_2.1.2/api/sockets.c",
-      "lwip/lwip_2.1.2/api/tcpip.c",
-      "lwip/lwip_2.1.2/core/altcp.c",
-      "lwip/lwip_2.1.2/core/altcp_alloc.c",
-      "lwip/lwip_2.1.2/core/altcp_tcp.c",
-      "lwip/lwip_2.1.2/core/def.c",
-      "lwip/lwip_2.1.2/core/dns.c",
-      "lwip/lwip_2.1.2/core/inet_chksum.c",
-      "lwip/lwip_2.1.2/core/init.c",
-      "lwip/lwip_2.1.2/core/ip.c",
-      "lwip/lwip_2.1.2/core/ipv4/autoip.c",
-      "lwip/lwip_2.1.2/core/ipv4/dhcp.c",
-      "lwip/lwip_2.1.2/core/ipv4/etharp.c",
-      "lwip/lwip_2.1.2/core/ipv4/icmp.c",
-      "lwip/lwip_2.1.2/core/ipv4/igmp.c",
-      "lwip/lwip_2.1.2/core/ipv4/ip4.c",
-      "lwip/lwip_2.1.2/core/ipv4/ip4_addr.c",
-      "lwip/lwip_2.1.2/core/ipv4/ip4_frag.c",
-      "lwip/lwip_2.1.2/core/ipv6/dhcp6.c",
-      "lwip/lwip_2.1.2/core/ipv6/ethip6.c",
-      "lwip/lwip_2.1.2/core/ipv6/icmp6.c",
-      "lwip/lwip_2.1.2/core/ipv6/inet6.c",
-      "lwip/lwip_2.1.2/core/ipv6/ip6.c",
-      "lwip/lwip_2.1.2/core/ipv6/ip6_addr.c",
-      "lwip/lwip_2.1.2/core/ipv6/ip6_frag.c",
-      "lwip/lwip_2.1.2/core/ipv6/mld6.c",
-      "lwip/lwip_2.1.2/core/ipv6/nd6.c",
-      "lwip/lwip_2.1.2/core/lwip_hooks.c",
-      "lwip/lwip_2.1.2/core/mem.c",
-      "lwip/lwip_2.1.2/core/memp.c",
-      "lwip/lwip_2.1.2/core/netif.c",
-      "lwip/lwip_2.1.2/core/pbuf.c",
-      "lwip/lwip_2.1.2/core/raw.c",
-      "lwip/lwip_2.1.2/core/stats.c",
-      "lwip/lwip_2.1.2/core/sys.c",
-      "lwip/lwip_2.1.2/core/tcp.c",
-      "lwip/lwip_2.1.2/core/tcp_in.c",
-      "lwip/lwip_2.1.2/core/tcp_out.c",
-      "lwip/lwip_2.1.2/core/timeouts.c",
-      "lwip/lwip_2.1.2/core/udp.c",
+      "../../components/lwip_2.1.2/netif/ethernet.c",
+      "../../components/lwip_2.1.2/port/sys_arch.c",
+      "../../components/lwip_2.1.2/api/api_lib.c",
+      "../../components/lwip_2.1.2/api/api_msg.c",
+      "../../components/lwip_2.1.2/api/err.c",
+      "../../components/lwip_2.1.2/api/if_api.c",
+      "../../components/lwip_2.1.2/api/netbuf.c",
+      "../../components/lwip_2.1.2/api/netdb.c",
+      "../../components/lwip_2.1.2/api/netifapi.c",
+      "../../components/lwip_2.1.2/api/sockets.c",
+      "../../components/lwip_2.1.2/api/tcpip.c",
+      "../../components/lwip_2.1.2/core/altcp.c",
+      "../../components/lwip_2.1.2/core/altcp_alloc.c",
+      "../../components/lwip_2.1.2/core/altcp_tcp.c",
+      "../../components/lwip_2.1.2/core/def.c",
+      "../../components/lwip_2.1.2/core/dns.c",
+      "../../components/lwip_2.1.2/core/inet_chksum.c",
+      "../../components/lwip_2.1.2/core/init.c",
+      "../../components/lwip_2.1.2/core/ip.c",
+      "../../components/lwip_2.1.2/core/ipv4/autoip.c",
+      "../../components/lwip_2.1.2/core/ipv4/dhcp.c",
+      "../../components/lwip_2.1.2/core/ipv4/etharp.c",
+      "../../components/lwip_2.1.2/core/ipv4/icmp.c",
+      "../../components/lwip_2.1.2/core/ipv4/igmp.c",
+      "../../components/lwip_2.1.2/core/ipv4/ip4.c",
+      "../../components/lwip_2.1.2/core/ipv4/ip4_addr.c",
+      "../../components/lwip_2.1.2/core/ipv4/ip4_frag.c",
+      "../../components/lwip_2.1.2/core/ipv6/dhcp6.c",
+      "../../components/lwip_2.1.2/core/ipv6/ethip6.c",
+      "../../components/lwip_2.1.2/core/ipv6/icmp6.c",
+      "../../components/lwip_2.1.2/core/ipv6/inet6.c",
+      "../../components/lwip_2.1.2/core/ipv6/ip6.c",
+      "../../components/lwip_2.1.2/core/ipv6/ip6_addr.c",
+      "../../components/lwip_2.1.2/core/ipv6/ip6_frag.c",
+      "../../components/lwip_2.1.2/core/ipv6/mld6.c",
+      "../../components/lwip_2.1.2/core/ipv6/nd6.c",
+      "../../components/lwip_2.1.2/core/lwip_hooks.c",
+      "../../components/lwip_2.1.2/core/mem.c",
+      "../../components/lwip_2.1.2/core/memp.c",
+      "../../components/lwip_2.1.2/core/netif.c",
+      "../../components/lwip_2.1.2/core/pbuf.c",
+      "../../components/lwip_2.1.2/core/raw.c",
+      "../../components/lwip_2.1.2/core/stats.c",
+      "../../components/lwip_2.1.2/core/sys.c",
+      "../../components/lwip_2.1.2/core/tcp.c",
+      "../../components/lwip_2.1.2/core/tcp_in.c",
+      "../../components/lwip_2.1.2/core/tcp_out.c",
+      "../../components/lwip_2.1.2/core/timeouts.c",
+      "../../components/lwip_2.1.2/core/udp.c",
 
       #mbedtls
-      "lwip/mbedtls-mbedtls-2.18/library/aes.c",
-      "lwip/mbedtls-mbedtls-2.18/library/aesni.c",
-      "lwip/mbedtls-mbedtls-2.18/library/arc4.c",
-      "lwip/mbedtls-mbedtls-2.18/library/aria.c",
-      "lwip/mbedtls-mbedtls-2.18/library/asn1parse.c",
-      "lwip/mbedtls-mbedtls-2.18/library/asn1write.c",
-      "lwip/mbedtls-mbedtls-2.18/library/base64.c",
-      "lwip/mbedtls-mbedtls-2.18/library/bignum.c",
-      "lwip/mbedtls-mbedtls-2.18/library/blowfish.c",
-      "lwip/mbedtls-mbedtls-2.18/library/camellia.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ccm.c",
-      "lwip/mbedtls-mbedtls-2.18/library/certs.c",
-      "lwip/mbedtls-mbedtls-2.18/library/chacha20.c",
-      "lwip/mbedtls-mbedtls-2.18/library/chachapoly.c",
-      "lwip/mbedtls-mbedtls-2.18/library/cipher.c",
-      "lwip/mbedtls-mbedtls-2.18/library/cipher_wrap.c",
-      "lwip/mbedtls-mbedtls-2.18/library/cmac.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ctr_drbg.c",
-      "lwip/mbedtls-mbedtls-2.18/library/debug.c",
-      "lwip/mbedtls-mbedtls-2.18/library/des.c",
-      "lwip/mbedtls-mbedtls-2.18/library/dhm.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ecdh.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ecdsa.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ecjpake.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ecp.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ecp_curves.c",
-      "lwip/mbedtls-mbedtls-2.18/library/entropy.c",
-      "lwip/mbedtls-mbedtls-2.18/library/entropy_poll.c",
-      "lwip/mbedtls-mbedtls-2.18/library/error.c",
-      "lwip/mbedtls-mbedtls-2.18/library/gcm.c",
-      "lwip/mbedtls-mbedtls-2.18/library/havege.c",
-      "lwip/mbedtls-mbedtls-2.18/library/hkdf.c",
-      "lwip/mbedtls-mbedtls-2.18/library/hmac_drbg.c",
-      "lwip/mbedtls-mbedtls-2.18/library/md.c",
-      "lwip/mbedtls-mbedtls-2.18/library/md2.c",
-      "lwip/mbedtls-mbedtls-2.18/library/md4.c",
-      "lwip/mbedtls-mbedtls-2.18/library/md5.c",
-      "lwip/mbedtls-mbedtls-2.18/library/md_wrap.c",
-      "lwip/mbedtls-mbedtls-2.18/library/memory_buffer_alloc.c",
-      "lwip/mbedtls-mbedtls-2.18/library/nist_kw.c",
-      "lwip/mbedtls-mbedtls-2.18/library/oid.c",
-      "lwip/mbedtls-mbedtls-2.18/library/padlock.c",
-      "lwip/mbedtls-mbedtls-2.18/library/pem.c",
-      "lwip/mbedtls-mbedtls-2.18/library/pk.c",
-      "lwip/mbedtls-mbedtls-2.18/library/pk_wrap.c",
-      "lwip/mbedtls-mbedtls-2.18/library/pkcs11.c",
-      "lwip/mbedtls-mbedtls-2.18/library/pkcs12.c",
-      "lwip/mbedtls-mbedtls-2.18/library/pkcs5.c",
-      "lwip/mbedtls-mbedtls-2.18/library/pkparse.c",
-      "lwip/mbedtls-mbedtls-2.18/library/pkwrite.c",
-      "lwip/mbedtls-mbedtls-2.18/library/platform.c",
-      "lwip/mbedtls-mbedtls-2.18/library/platform_util.c",
-      "lwip/mbedtls-mbedtls-2.18/library/poly1305.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ripemd160.c",
-      "lwip/mbedtls-mbedtls-2.18/library/rsa.c",
-      "lwip/mbedtls-mbedtls-2.18/library/rsa_internal.c",
-      "lwip/mbedtls-mbedtls-2.18/library/sha1.c",
-      "lwip/mbedtls-mbedtls-2.18/library/sha256.c",
-      "lwip/mbedtls-mbedtls-2.18/library/sha512.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ssl_cache.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ssl_ciphersuites.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ssl_cli.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ssl_cookie.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ssl_srv.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ssl_ticket.c",
-      "lwip/mbedtls-mbedtls-2.18/library/ssl_tls.c",
-      "lwip/mbedtls-mbedtls-2.18/library/threading.c",
-      "lwip/mbedtls-mbedtls-2.18/library/timing.c",
-      "lwip/mbedtls-mbedtls-2.18/library/version.c",
-      "lwip/mbedtls-mbedtls-2.18/library/version_features.c",
-      "lwip/mbedtls-mbedtls-2.18/library/x509.c",
-      "lwip/mbedtls-mbedtls-2.18/library/x509_create.c",
-      "lwip/mbedtls-mbedtls-2.18/library/x509_crl.c",
-      "lwip/mbedtls-mbedtls-2.18/library/x509_crt.c",
-      "lwip/mbedtls-mbedtls-2.18/library/x509_csr.c",
-      "lwip/mbedtls-mbedtls-2.18/library/x509write_crt.c",
-      "lwip/mbedtls-mbedtls-2.18/library/x509write_csr.c",
-      "lwip/mbedtls-mbedtls-2.18/library/xtea.c",
-      "lwip/mbedtls-mbedtls-2.18/asr_mbedtls/alt/entropy_hardware_alt.c",
-      "lwip/mbedtls-mbedtls-2.18/asr_mbedtls/alt/aes_alt.c",
-      "lwip/mbedtls-mbedtls-2.18/asr_mbedtls/alt/sha1_alt.c",
-      "lwip/mbedtls-mbedtls-2.18/asr_mbedtls/alt/sha256_alt.c",
+      "../../components/mbedtls-2.18/library/aes.c",
+      "../../components/mbedtls-2.18/library/aesni.c",
+      "../../components/mbedtls-2.18/library/arc4.c",
+      "../../components/mbedtls-2.18/library/aria.c",
+      "../../components/mbedtls-2.18/library/asn1parse.c",
+      "../../components/mbedtls-2.18/library/asn1write.c",
+      "../../components/mbedtls-2.18/library/base64.c",
+      "../../components/mbedtls-2.18/library/bignum.c",
+      "../../components/mbedtls-2.18/library/blowfish.c",
+      "../../components/mbedtls-2.18/library/camellia.c",
+      "../../components/mbedtls-2.18/library/ccm.c",
+      "../../components/mbedtls-2.18/library/certs.c",
+      "../../components/mbedtls-2.18/library/chacha20.c",
+      "../../components/mbedtls-2.18/library/chachapoly.c",
+      "../../components/mbedtls-2.18/library/cipher.c",
+      "../../components/mbedtls-2.18/library/cipher_wrap.c",
+      "../../components/mbedtls-2.18/library/cmac.c",
+      "../../components/mbedtls-2.18/library/ctr_drbg.c",
+      "../../components/mbedtls-2.18/library/debug.c",
+      "../../components/mbedtls-2.18/library/des.c",
+      "../../components/mbedtls-2.18/library/dhm.c",
+      "../../components/mbedtls-2.18/library/ecdh.c",
+      "../../components/mbedtls-2.18/library/ecdsa.c",
+      "../../components/mbedtls-2.18/library/ecjpake.c",
+      "../../components/mbedtls-2.18/library/ecp.c",
+      "../../components/mbedtls-2.18/library/ecp_curves.c",
+      "../../components/mbedtls-2.18/library/entropy.c",
+      "../../components/mbedtls-2.18/library/entropy_poll.c",
+      "../../components/mbedtls-2.18/library/error.c",
+      "../../components/mbedtls-2.18/library/gcm.c",
+      "../../components/mbedtls-2.18/library/havege.c",
+      "../../components/mbedtls-2.18/library/hkdf.c",
+      "../../components/mbedtls-2.18/library/hmac_drbg.c",
+      "../../components/mbedtls-2.18/library/md.c",
+      "../../components/mbedtls-2.18/library/md2.c",
+      "../../components/mbedtls-2.18/library/md4.c",
+      "../../components/mbedtls-2.18/library/md5.c",
+      "../../components/mbedtls-2.18/library/md_wrap.c",
+      "../../components/mbedtls-2.18/library/memory_buffer_alloc.c",
+      "../../components/mbedtls-2.18/library/nist_kw.c",
+      "../../components/mbedtls-2.18/library/oid.c",
+      "../../components/mbedtls-2.18/library/padlock.c",
+      "../../components/mbedtls-2.18/library/pem.c",
+      "../../components/mbedtls-2.18/library/pk.c",
+      "../../components/mbedtls-2.18/library/pk_wrap.c",
+      "../../components/mbedtls-2.18/library/pkcs11.c",
+      "../../components/mbedtls-2.18/library/pkcs12.c",
+      "../../components/mbedtls-2.18/library/pkcs5.c",
+      "../../components/mbedtls-2.18/library/pkparse.c",
+      "../../components/mbedtls-2.18/library/pkwrite.c",
+      "../../components/mbedtls-2.18/library/platform.c",
+      "../../components/mbedtls-2.18/library/platform_util.c",
+      "../../components/mbedtls-2.18/library/poly1305.c",
+      "../../components/mbedtls-2.18/library/ripemd160.c",
+      "../../components/mbedtls-2.18/library/rsa.c",
+      "../../components/mbedtls-2.18/library/rsa_internal.c",
+      "../../components/mbedtls-2.18/library/sha1.c",
+      "../../components/mbedtls-2.18/library/sha256.c",
+      "../../components/mbedtls-2.18/library/sha512.c",
+      "../../components/mbedtls-2.18/library/ssl_cache.c",
+      "../../components/mbedtls-2.18/library/ssl_ciphersuites.c",
+      "../../components/mbedtls-2.18/library/ssl_cli.c",
+      "../../components/mbedtls-2.18/library/ssl_cookie.c",
+      "../../components/mbedtls-2.18/library/ssl_srv.c",
+      "../../components/mbedtls-2.18/library/ssl_ticket.c",
+      "../../components/mbedtls-2.18/library/ssl_tls.c",
+      "../../components/mbedtls-2.18/library/threading.c",
+      "../../components/mbedtls-2.18/library/timing.c",
+      "../../components/mbedtls-2.18/library/version.c",
+      "../../components/mbedtls-2.18/library/version_features.c",
+      "../../components/mbedtls-2.18/library/x509.c",
+      "../../components/mbedtls-2.18/library/x509_create.c",
+      "../../components/mbedtls-2.18/library/x509_crl.c",
+      "../../components/mbedtls-2.18/library/x509_crt.c",
+      "../../components/mbedtls-2.18/library/x509_csr.c",
+      "../../components/mbedtls-2.18/library/x509write_crt.c",
+      "../../components/mbedtls-2.18/library/x509write_csr.c",
+      "../../components/mbedtls-2.18/library/xtea.c",
+      "../../components/mbedtls-2.18/asr_mbedtls/alt/entropy_hardware_alt.c",
+      "../../components/mbedtls-2.18/asr_mbedtls/alt/aes_alt.c",
+      "../../components/mbedtls-2.18/asr_mbedtls/alt/sha1_alt.c",
+      "../../components/mbedtls-2.18/asr_mbedtls/alt/sha256_alt.c",
     ]
 
     foreach(src, _third_party_src) {
diff --git a/third_party/asr/asr_executable.gni b/third_party/asr/asr_executable.gni
index 5303a7ca12137e..e6acec9d257986 100644
--- a/third_party/asr/asr_executable.gni
+++ b/third_party/asr/asr_executable.gni
@@ -58,7 +58,7 @@ template("asr_executable") {
         "REMAPPING",
         "-r",
       ]
-    } else {
+    } else if (asr_ic_family == "asr582x") {
       args = [
         _ota_tool_path,
         _image_path,
@@ -68,6 +68,15 @@ template("asr_executable") {
         "REMAPPING",
         "-r",
       ]
+    } else {
+      args = [
+        _ota_tool_path,
+        _image_path,
+        "-d",
+        "LEGA_A0V2",
+        "-b",
+        "COMPRESS",
+      ]
     }
 
     deps = [ ":$flash_target_name" ]
diff --git a/third_party/asr/components b/third_party/asr/components
new file mode 160000
index 00000000000000..005e5ab51aaa3c
--- /dev/null
+++ b/third_party/asr/components
@@ -0,0 +1 @@
+Subproject commit 005e5ab51aaa3c080d3f827630619dad611834ac