Skip to content

Commit e9df402

Browse files
authored
[ASR] add asr550x support, fix some platform issue (#27987)
* [ASR] add asr550x support * update CI with all build options * add Identify implementation example
1 parent 7a815f6 commit e9df402

22 files changed

+912
-346
lines changed

.github/workflows/examples-asr.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ jobs:
5050
"./scripts/build/build_examples.py \
5151
--target asr-asr582x-all-clusters \
5252
--target asr-asr582x-all-clusters-minimal \
53-
--target asr-asr582x-lighting \
54-
--target asr-asr582x-light-switch \
55-
--target asr-asr582x-lock \
53+
--target asr-asr582x-lighting-ota \
54+
--target asr-asr582x-light-switch-shell \
55+
--target asr-asr582x-lock-no_logging \
5656
--target asr-asr582x-ota-requestor \
57-
--target asr-asr582x-bridge \
58-
--target asr-asr582x-temperature-measurement \
59-
--target asr-asr582x-thermostat \
57+
--target asr-asr582x-bridge-factory \
58+
--target asr-asr582x-temperature-measurement-rotating_id \
59+
--target asr-asr582x-thermostat-rio \
6060
build \
6161
"

.gitmodules

+10
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,13 @@
308308
url = https://github.com/google/perfetto.git
309309
branch = master
310310
platforms = linux,android
311+
[submodule "third_party/asr/components"]
312+
path = third_party/asr/components
313+
url = https://github.com/asriot/asriot_components.git
314+
branch = matter
315+
platforms = asr
316+
[submodule "third_party/asr/asr550x/asr_sdk"]
317+
path = third_party/asr/asr550x/asr_sdk
318+
url = https://github.com/asriot/ASR550X_Freertos.git
319+
branch = matter
320+
platforms = asr

config/asr/toolchain/BUILD.gn

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ import("//build_overrides/asr.gni")
1616
import("//build_overrides/build.gni")
1717
import("//build_overrides/chip.gni")
1818

19-
assert(asr_ic_family == "asr582x" || asr_ic_family == "asr595x",
19+
assert(asr_ic_family == "asr582x" || asr_ic_family == "asr595x" ||
20+
asr_ic_family == "asr550x",
2021
"Unsupported ASR IC: ${asr_ic_family}")
2122

22-
if (asr_ic_family == "asr582x") {
23+
if (asr_ic_family == "asr582x" || asr_ic_family == "asr550x") {
2324
import("${build_root}/toolchain/arm_gcc/arm_toolchain.gni")
2425
_tool_name_root = "${asr_toolchain_root}arm-none-eabi-"
2526
}

docs/guides/asr_getting_started_guide.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The ASR platform is supported on:
2424

2525
- [ASR582X](http://www.asrmicro.com/en/goods/proinfo/36.html)
2626
- [ASR595X](http://www.asrmicro.com/en/goods/proinfo/42.html)
27+
- [ASR550X](http://www.asrmicro.com/en/goods/proinfo/14.html)
2728

2829
## Matter Example Applications
2930

@@ -35,9 +36,8 @@ to speed up development. You can find them in the samples with `/asr` subfolder.
3536
- [Setup Matter Environment](./BUILDING.md)
3637

3738
- Setup toolchain
38-
- for ASR582X
39+
- for ASR582X and ASR550X
3940
```
40-
cd toolchain
4141
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
4242
tar -jxvf gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
4343
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.
6060
```
6161
export ASR_BOARD=asr595x
6262
```
63+
- for ASR550X:
64+
```
65+
export ASR_BOARD=asr550x
66+
```
6367
- Building the Application
6468
6569
If the lighting example is to be built:
@@ -91,6 +95,7 @@ There are two commissioning modes supported by ASR platform:
9195
```
9296
./chip-tool pairing ble-wifi <node_id> <ssid> <password> <pin_code> <discriminator>
9397
```
98+
5. Only ASR582X and ASR595X support BLE
9499
95100
### IP mode
96101

examples/platform/asr/CHIPDeviceManager.cpp

+44
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@
3131
#include <support/CodeUtils.h>
3232
#include <support/ErrorStr.h>
3333

34+
#ifdef EMBER_AF_PLUGIN_IDENTIFY_SERVER
35+
#include <app/clusters/identify-server/identify-server.h>
36+
#endif
37+
3438
using namespace ::chip;
39+
using namespace ::chip::app;
3540

3641
namespace chip {
3742

@@ -74,3 +79,42 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
7479
cb->PostAttributeChangeCallback(path.mEndpointId, path.mClusterId, path.mAttributeId, type, size, value);
7580
}
7681
}
82+
83+
#ifdef EMBER_AF_PLUGIN_IDENTIFY_SERVER
84+
void OnIdentifyStart(Identify *)
85+
{
86+
ChipLogProgress(Zcl, "OnIdentifyStart");
87+
}
88+
89+
void OnIdentifyStop(Identify *)
90+
{
91+
ChipLogProgress(Zcl, "OnIdentifyStop");
92+
}
93+
94+
void OnTriggerEffect(Identify * identify)
95+
{
96+
switch (identify->mCurrentEffectIdentifier)
97+
{
98+
case Clusters::Identify::EffectIdentifierEnum::kBlink:
99+
ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kBlink");
100+
break;
101+
case Clusters::Identify::EffectIdentifierEnum::kBreathe:
102+
ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kBreathe");
103+
break;
104+
case Clusters::Identify::EffectIdentifierEnum::kOkay:
105+
ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kOkay");
106+
break;
107+
case Clusters::Identify::EffectIdentifierEnum::kChannelChange:
108+
ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kChannelChange");
109+
break;
110+
default:
111+
ChipLogProgress(Zcl, "No identifier effect");
112+
return;
113+
}
114+
}
115+
116+
static Identify gIdentify1 = {
117+
chip::EndpointId{ 1 }, OnIdentifyStart, OnIdentifyStop, Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator,
118+
OnTriggerEffect,
119+
};
120+
#endif

scripts/build/build/targets.py

+2
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ def BuildASRTarget():
415415
target.AppendFixedTargets([
416416
TargetPart('asr582x', board=ASRBoard.ASR582X),
417417
TargetPart('asr595x', board=ASRBoard.ASR595X),
418+
TargetPart('asr550x', board=ASRBoard.ASR550X),
418419
])
419420

420421
# apps
@@ -436,6 +437,7 @@ def BuildASRTarget():
436437
target.AppendModifier('no_logging', chip_logging=False)
437438
target.AppendModifier('factory', enable_factory=True)
438439
target.AppendModifier('rotating_id', enable_rotating_device_id=True)
440+
target.AppendModifier('rio', enable_lwip_ip6_hook=True)
439441

440442
return target
441443

scripts/build/builders/asr.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,15 @@ def BuildRoot(self, root):
8080
class ASRBoard(Enum):
8181
ASR582X = auto()
8282
ASR595X = auto()
83+
ASR550X = auto()
8384

8485
def GetIC(self):
8586
if self == ASRBoard.ASR582X:
8687
return 'asr582x'
8788
elif self == ASRBoard.ASR595X:
8889
return 'asr595x'
90+
elif self == ASRBoard.ASR550X:
91+
return 'asr550x'
8992
else:
9093
raise Exception('Unknown board #: %r' % self)
9194

@@ -101,7 +104,8 @@ def __init__(self,
101104
chip_logging: bool = True,
102105
enable_factory: bool = False,
103106
enable_rotating_device_id: bool = False,
104-
enable_ota_requestor: bool = False):
107+
enable_ota_requestor: bool = False,
108+
enable_lwip_ip6_hook: bool = False):
105109
super(ASRBuilder, self).__init__(
106110
root=app.BuildRoot(root),
107111
runner=runner)
@@ -118,6 +122,9 @@ def __init__(self,
118122
elif asr_chip == "asr595x":
119123
ASR_ARCH = "riscv"
120124
ASR_SDK_ROOT = "//third_party/connectedhomeip/third_party/asr/asr595x"
125+
elif asr_chip == "asr550x":
126+
ASR_ARCH = "arm"
127+
ASR_SDK_ROOT = "//third_party/connectedhomeip/third_party/asr/asr550x"
121128
self.extra_gn_options.append('target_cpu="%s"' % ASR_ARCH)
122129

123130
toolchain = os.path.join(root, os.path.split(os.path.realpath(__file__))[0], '../../../config/asr/toolchain')
@@ -132,6 +139,9 @@ def __init__(self,
132139
or asr_chip == "asr595x"):
133140
self.extra_gn_options.append('chip_config_network_layer_ble=true')
134141

142+
if (asr_chip == "asr550x"):
143+
self.extra_gn_options.append('chip_config_network_layer_ble=false')
144+
135145
if enable_ota_requestor:
136146
self.extra_gn_options.append('chip_enable_ota_requestor=true')
137147

@@ -149,6 +159,9 @@ def __init__(self,
149159
self.extra_gn_options.append('chip_enable_additional_data_advertising=true')
150160
self.extra_gn_options.append('chip_enable_rotating_device_id=true')
151161

162+
if enable_lwip_ip6_hook:
163+
self.extra_gn_options.append('chip_lwip_ip6_hook=true')
164+
152165
self.extra_gn_options.append('asr_toolchain_root="%s"' % os.environ['ASR_TOOLCHAIN_PATH'])
153166

154167
def GnBuildArgs(self):

scripts/build/testdata/all_targets_linux_x64.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ameba-amebad-{all-clusters,all-clusters-minimal,light,light-switch,pigweed}
2-
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]
2+
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]
33
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]
44
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]
55
cc32xx-lock

src/platform/ASR/ASRFactoryDataProvider.cpp

+68-20
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ CHIP_ERROR ASRFactoryDataProvider::GetProductId(uint16_t & productId)
402402
#else
403403
uint32_t productId32;
404404
ReturnErrorOnFailure(ASRConfig::ReadFactoryConfigValue(ASR_PRODUCT_ID_PARTITION, productId32));
405-
productId = static_cast<uint16_t>(productId32);
405+
productId = static_cast<uint16_t>(productId32);
406406
#endif
407407
return CHIP_NO_ERROR;
408408
}
@@ -424,40 +424,88 @@ CHIP_ERROR ASRFactoryDataProvider::GetProductLabel(char * buf, size_t bufSize)
424424

425425
CHIP_ERROR ASRFactoryDataProvider::GetSerialNumber(char * buf, size_t bufSize)
426426
{
427-
ChipError err = CHIP_NO_ERROR;
427+
#if !CONFIG_ENABLE_ASR_FACTORY_DEVICE_INFO_PROVIDER
428+
ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER), CHIP_ERROR_BUFFER_TOO_SMALL);
429+
strcpy(buf, CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER);
430+
#else
431+
#define BUFFER_MAX_SIZE 32
432+
uint8_t buffer[BUFFER_MAX_SIZE + 1] = { 0 };
433+
size_t buffer_len = BUFFER_MAX_SIZE + 1;
434+
ReturnErrorOnFailure(ASRConfig::ReadFactoryConfigValue(ASR_SERIAL_NUMBER_PARTITION, buffer, buffer_len, buffer_len));
435+
ReturnErrorCodeIf(bufSize < buffer_len, CHIP_ERROR_BUFFER_TOO_SMALL);
436+
memcpy(buf, buffer, buffer_len);
437+
buf[buffer_len] = 0;
438+
#endif
439+
return CHIP_NO_ERROR;
440+
}
428441

429-
size_t serialNumLen = 0; // without counting null-terminator
442+
CHIP_ERROR ASRFactoryDataProvider::GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day)
443+
{
444+
CHIP_ERROR err = CHIP_NO_ERROR;
445+
enum
446+
{
447+
kDateStringLength = 10 // YYYY-MM-DD
448+
};
449+
char dateStr[kDateStringLength + 1];
450+
char * parseEnd;
451+
#if !CONFIG_ENABLE_ASR_FACTORY_DEVICE_INFO_PROVIDER
452+
memcpy(dateStr, CHIP_DEVICE_CONFIG_TEST_MANUFACTURY_DATE, kDateStringLength + 1);
453+
#else
454+
size_t dateLen;
455+
err = ASRConfig::ReadFactoryConfigValue(ASR_MANUFACTURY_DATE_PARTITION, (uint8_t *) dateStr, sizeof(dateStr), dateLen);
456+
SuccessOrExit(err);
430457

431-
#ifdef CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER
432-
if (CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER[0] != 0)
458+
VerifyOrExit(dateLen == kDateStringLength, err = CHIP_ERROR_INVALID_ARGUMENT);
459+
#endif
460+
// Cast does not lose information, because we then check that we only parsed
461+
// 4 digits, so our number can't be bigger than 9999.
462+
year = static_cast<uint16_t>(strtoul(dateStr, &parseEnd, 10));
463+
VerifyOrExit(parseEnd == dateStr + 4, err = CHIP_ERROR_INVALID_ARGUMENT);
464+
465+
// Cast does not lose information, because we then check that we only parsed
466+
// 2 digits, so our number can't be bigger than 99.
467+
month = static_cast<uint8_t>(strtoul(dateStr + 5, &parseEnd, 10));
468+
VerifyOrExit(parseEnd == dateStr + 7, err = CHIP_ERROR_INVALID_ARGUMENT);
469+
470+
// Cast does not lose information, because we then check that we only parsed
471+
// 2 digits, so our number can't be bigger than 99.
472+
day = static_cast<uint8_t>(strtoul(dateStr + 8, &parseEnd, 10));
473+
VerifyOrExit(parseEnd == dateStr + 10, err = CHIP_ERROR_INVALID_ARGUMENT);
474+
475+
exit:
476+
if (err != CHIP_NO_ERROR && err != CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND)
433477
{
434-
ReturnErrorCodeIf(sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER) > bufSize, CHIP_ERROR_BUFFER_TOO_SMALL);
435-
memcpy(buf, CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER, sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER));
436-
serialNumLen = sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER) - 1;
437-
err = CHIP_NO_ERROR;
478+
ChipLogError(DeviceLayer, "Invalid manufacturing date: %s", dateStr);
438479
}
439-
#endif // CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER
440-
441-
ReturnErrorCodeIf(serialNumLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL);
442-
ReturnErrorCodeIf(buf[serialNumLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH);
443-
444480
return err;
445481
}
446482

447-
CHIP_ERROR ASRFactoryDataProvider::GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day)
448-
{
449-
return CHIP_ERROR_NOT_IMPLEMENTED;
450-
}
451-
452483
CHIP_ERROR ASRFactoryDataProvider::GetHardwareVersion(uint16_t & hardwareVersion)
453484
{
454-
return CHIP_ERROR_NOT_IMPLEMENTED;
485+
#if !CONFIG_ENABLE_ASR_FACTORY_DEVICE_INFO_PROVIDER
486+
hardwareVersion = static_cast<uint16_t>(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION);
487+
#else
488+
uint32_t hardwareVersion32;
489+
ReturnErrorOnFailure(ASRConfig::ReadFactoryConfigValue(ASR_HARDWARE_VERSION_PARTITION, hardwareVersion32));
490+
hardwareVersion = static_cast<uint16_t>(hardwareVersion32);
491+
#endif
492+
return CHIP_NO_ERROR;
455493
}
456494

457495
CHIP_ERROR ASRFactoryDataProvider::GetHardwareVersionString(char * buf, size_t bufSize)
458496
{
497+
#if !CONFIG_ENABLE_ASR_FACTORY_DEVICE_INFO_PROVIDER
459498
ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL);
460499
strcpy(buf, CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING);
500+
#else
501+
#define BUFFER_MAX_SIZE 32
502+
uint8_t buffer[BUFFER_MAX_SIZE + 1] = { 0 };
503+
size_t buffer_len = BUFFER_MAX_SIZE + 1;
504+
ReturnErrorOnFailure(ASRConfig::ReadFactoryConfigValue(ASR_HARDWARE_VERSION_STR_PARTITION, buffer, buffer_len, buffer_len));
505+
ReturnErrorCodeIf(bufSize < buffer_len, CHIP_ERROR_BUFFER_TOO_SMALL);
506+
memcpy(buf, buffer, buffer_len);
507+
buf[buffer_len] = 0;
508+
#endif
461509
return CHIP_NO_ERROR;
462510
}
463511

src/platform/ASR/CHIPDevicePlatformConfig.h

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 1024 * 8
3131
#define CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY 1
3232
#define CHIP_DEVICE_CONFIG_ENABLE_TEST_SETUP_PARAMS 1
33+
#define CHIP_DEVICE_CONFIG_TEST_MANUFACTURY_DATE "2023-07-07"
3334

3435
#if defined(CFG_PLF_RV32) || defined(CFG_PLF_DUET)
3536
// ASR582X/ASR595X support Wi-Fi and BLE

src/platform/ASR/NetworkCommissioningWiFiDriver.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ void ASRWiFiDriver::OnNetworkStatusChange()
297297
if (staConnected)
298298
{
299299
mpStatusChangeCallback->OnNetworkingStatusChange(
300-
Status::kSuccess, MakeOptional(ByteSpan(configuredNetwork.networkID, configuredNetwork.networkIDLen)),
301-
MakeOptional(GetLastDisconnectReason()));
300+
Status::kSuccess, MakeOptional(ByteSpan(configuredNetwork.networkID, configuredNetwork.networkIDLen)), NullOptional);
302301
return;
303302
}
304303
mpStatusChangeCallback->OnNetworkingStatusChange(

0 commit comments

Comments
 (0)