Skip to content

Commit

Permalink
[Infineon][1.0] Add args for CYW30739 to provision DAC/PAI/CD. (#23068)
Browse files Browse the repository at this point in the history
* [Infineon][1.0] Add args for CYW30739 to provision DAC/PAI/CD.

* Implement DeviceAttestationCredentialsProvider APIs by
  FactoryDataProvider for CYW30739.
* Add GN args to provision DAC/PAI/CD from specified der files into
  CYW30739 flash.
* Obsolete CYW30739 static_config.txt by GN args.
* CYW30739Config loads factory data only from SS flash section.

* Address review comments.
  • Loading branch information
hsusid authored and pull[bot] committed Nov 22, 2022
1 parent 75b76de commit d662734
Show file tree
Hide file tree
Showing 24 changed files with 631 additions and 163 deletions.
18 changes: 18 additions & 0 deletions examples/lighting-app/infineon/cyw30739/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ dataset and CASE credentials are then provided.
$ rm -rf out/
```

## Building Options

### DAC / DAC Key / PAI Certificate / Certificate Declaration

Infineon CYW30739 examples use test certifications, keys, and CD by default. For
a production build, manufacturers can provision certifications, keys, and CD by
the following arguments:

- `matter_dac`, `matter_dac_key`, `matter_pai`, `matter_cd`

```bash
$ ./scripts/examples/gn_build_example.sh examples/lighting-app/infineon/cyw30739 out/lighting-app \
'matter_dac="/path/to/dac.der"' \
'matter_dac_key="/path/to/dac_key.der"' \
'matter_pai="/path/to/pai.der"' \
'matter_cd="/path/to/cd.der"'
```

## Flashing the Application

### Enter Recovery Mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME "Infineon"

/* The VendorID attribute of the Basic cluster. */
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF2

/* The ProductName attribute of the Basic cluster. */
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME "CYW30739 Lighting App"

/* The ProductID attribute of the Basic cluster. */
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8005
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8002

/* The HardwareVersionString attribute of the Basic cluster. */
#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING "30739"
Expand Down
5 changes: 4 additions & 1 deletion examples/lighting-app/infineon/cyw30739/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <lib/shell/Engine.h>
#include <lib/support/CHIPPlatformMemory.h>
#include <mbedtls/platform.h>
#include <platform/Infineon/CYW30739/FactoryDataProvider.h>
#include <protocols/secure_channel/PASESession.h>
#include <sparcommon.h>
#include <stdio.h>
Expand All @@ -47,6 +48,8 @@ using namespace ::chip::DeviceLayer;
using namespace ::chip::Shell;

static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
static FactoryDataProvider sFactoryDataProvider;

static void InitApp(intptr_t args);
static void LightManagerCallback(LightingManager::Actor_t actor, LightingManager::Action_t action, uint8_t value);

Expand Down Expand Up @@ -196,7 +199,7 @@ void InitApp(intptr_t args)
initParams.endpointNativeParams = static_cast<void *>(&nativeParams);
chip::Server::GetInstance().Init(initParams);

SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
SetDeviceAttestationCredentialsProvider(&sFactoryDataProvider);

LightMgr().Init();
LightMgr().SetCallbacks(LightManagerCallback, nullptr);
Expand Down
21 changes: 0 additions & 21 deletions examples/lighting-app/infineon/cyw30739/static_config.txt

This file was deleted.

18 changes: 18 additions & 0 deletions examples/lock-app/infineon/cyw30739/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ dataset and CASE credentials are then provided.
$ rm -rf out/
```

## Building Options

### DAC / DAC Key / PAI Certificate / Certificate Declaration

Infineon CYW30739 examples use test certifications, keys, and CD by default. For
a production build, manufacturers can provision certifications, keys, and CD by
the following arguments:

- `matter_dac`, `matter_dac_key`, `matter_pai`, `matter_cd`

```bash
$ ./scripts/examples/gn_build_example.sh examples/lighting-app/infineon/cyw30739 out/lighting-app \
'matter_dac="/path/to/dac.der"' \
'matter_dac_key="/path/to/dac_key.der"' \
'matter_pai="/path/to/pai.der"' \
'matter_cd="/path/to/cd.der"'
```

## Flashing the Application

### Enter Recovery Mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME "Infineon"

/* The VendorID attribute of the Basic cluster. */
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF2

/* The ProductName attribute of the Basic cluster. */
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME "CYW30739 Lock App"

/* The ProductID attribute of the Basic cluster. */
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8006
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8002

/* The HardwareVersionString attribute of the Basic cluster. */
#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING "30739"
Expand Down
5 changes: 4 additions & 1 deletion examples/lock-app/infineon/cyw30739/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <lib/shell/Engine.h>
#include <lib/support/CHIPPlatformMemory.h>
#include <mbedtls/platform.h>
#include <platform/Infineon/CYW30739/FactoryDataProvider.h>
#include <protocols/secure_channel/PASESession.h>
#include <sparcommon.h>
#include <stdio.h>
Expand All @@ -60,6 +61,8 @@ using namespace CYW30739DoorLock::LockInitParams;
wiced_bool_t syncClusterToButtonAction = false;

static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
static FactoryDataProvider sFactoryDataProvider;

static void InitApp(intptr_t args);
static void ActionInitiated(LockManager::Action_t aAction, int32_t aActor);
static void ActionCompleted(LockManager::Action_t aAction);
Expand Down Expand Up @@ -193,7 +196,7 @@ void InitApp(intptr_t args)
initParams.endpointNativeParams = static_cast<void *>(&nativeParams);
chip::Server::GetInstance().Init(initParams);

SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
SetDeviceAttestationCredentialsProvider(&sFactoryDataProvider);

// Initial lock state
chip::app::DataModel::Nullable<chip::app::Clusters::DoorLock::DlLockState> state;
Expand Down
21 changes: 0 additions & 21 deletions examples/lock-app/infineon/cyw30739/static_config.txt

This file was deleted.

18 changes: 18 additions & 0 deletions examples/ota-requestor-app/infineon/cyw30739/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ dataset and CASE credentials are then provided.
$ rm -rf out/
```

## Building Options

### DAC / DAC Key / PAI Certificate / Certificate Declaration

Infineon CYW30739 examples use test certifications, keys, and CD by default. For
a production build, manufacturers can provision certifications, keys, and CD by
the following arguments:

- `matter_dac`, `matter_dac_key`, `matter_pai`, `matter_cd`

```bash
$ ./scripts/examples/gn_build_example.sh examples/lighting-app/infineon/cyw30739 out/lighting-app \
'matter_dac="/path/to/dac.der"' \
'matter_dac_key="/path/to/dac_key.der"' \
'matter_pai="/path/to/pai.der"' \
'matter_cd="/path/to/cd.der"'
```

## Flashing the Application

### Enter Recovery Mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME "Infineon"

/* The VendorID attribute of the Basic cluster. */
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF2

/* The ProductName attribute of the Basic cluster. */
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME "CYW30739 OTA Requestor App"

/* The ProductID attribute of the Basic cluster. */
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8008
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8002

/* The HardwareVersionString attribute of the Basic cluster. */
#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING "30739"
Expand Down
5 changes: 4 additions & 1 deletion examples/ota-requestor-app/infineon/cyw30739/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <lib/shell/Engine.h>
#include <lib/support/CHIPPlatformMemory.h>
#include <mbedtls/platform.h>
#include <platform/Infineon/CYW30739/FactoryDataProvider.h>
#include <protocols/secure_channel/PASESession.h>
#include <sparcommon.h>
#include <stdio.h>
Expand All @@ -37,6 +38,8 @@ using namespace chip::Credentials;
using namespace chip::DeviceLayer;
using namespace chip::Shell;

static FactoryDataProvider sFactoryDataProvider;

static void InitApp(intptr_t args);

APPLICATION_START()
Expand Down Expand Up @@ -123,7 +126,7 @@ void InitApp(intptr_t args)
initParams.endpointNativeParams = static_cast<void *>(&nativeParams);
chip::Server::GetInstance().Init(initParams);

SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
SetDeviceAttestationCredentialsProvider(&sFactoryDataProvider);

OTAConfig::Init();
}
21 changes: 0 additions & 21 deletions examples/ota-requestor-app/infineon/cyw30739/static_config.txt

This file was deleted.

1 change: 1 addition & 0 deletions scripts/requirements.infineon.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
leb128
3 changes: 3 additions & 0 deletions scripts/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ virtualenv
# openiotsdk
-r requirements.openiotsdk.txt

# Infineon
-r requirements.infineon.txt

# cirque tests
requests>=2.24.0

Expand Down
8 changes: 8 additions & 0 deletions src/platform/Infineon/CYW30739/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ static_library("CYW30739") {
"ConnectivityManagerImpl.h",
"DiagnosticDataProviderImpl.cpp",
"DiagnosticDataProviderImpl.h",
"FactoryDataProvider.cpp",
"FactoryDataProvider.h",
"InetPlatformConfig.h",
"KeyValueStoreManagerImpl.cpp",
"KeyValueStoreManagerImpl.h",
Expand All @@ -61,6 +63,12 @@ static_library("CYW30739") {

deps = [ "${chip_root}/src/crypto" ]

public = [
"${chip_root}/src/credentials/DeviceAttestationCredsProvider.h",
"FactoryDataProvider.h",
"OTAImageProcessorImpl.h",
]

public_deps = [ "${chip_root}/src/platform:platform_base" ]

if (chip_enable_openthread) {
Expand Down
16 changes: 9 additions & 7 deletions src/platform/Infineon/CYW30739/CYW30739Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include <platform/internal/CHIPDeviceLayerInternal.h>

#include <hal/wiced_hal_eflash.h>
#include <platform/Infineon/CYW30739/CYW30739Config.h>
#include <platform_nvram.h>

namespace chip {
namespace DeviceLayer {
Expand Down Expand Up @@ -58,10 +56,14 @@ CHIP_ERROR CYW30739Config::ReadConfigValueBin(Key key, uint8_t * buf, size_t buf
CHIP_ERROR CYW30739Config::ReadConfigValueBin(Key key, void * buf, size_t bufSize, size_t & outLen)
{
wiced_result_t result;
uint16_t read_count = wiced_hal_read_nvram(PLATFORM_NVRAM_VSID_MATTER_BASE + key, bufSize, (uint8_t *) buf, &result);
if (kMinConfigKey_ChipFactory <= key && key <= kMaxConfigKey_ChipFactory && result != WICED_SUCCESS)
uint16_t read_count;
if (kMinConfigKey_ChipFactory <= key && key <= kMaxConfigKey_ChipFactory)
{
read_count = wiced_hal_read_nvram_static(PLATFORM_NVRAM_SSID_MATTER_BASE + key, bufSize, buf, &result);
read_count = wiced_hal_read_nvram_static(key, bufSize, buf, &result);
}
else
{
read_count = wiced_hal_read_nvram(key, bufSize, (uint8_t *) buf, &result);
}
if (result == WICED_SUCCESS)
{
Expand Down Expand Up @@ -124,7 +126,7 @@ CHIP_ERROR CYW30739Config::WriteConfigValueBin(Key key, const void * data, size_
}

wiced_result_t result;
const uint16_t write_count = wiced_hal_write_nvram(PLATFORM_NVRAM_VSID_MATTER_BASE + key, dataLen, (uint8_t *) data, &result);
const uint16_t write_count = wiced_hal_write_nvram(key, dataLen, (uint8_t *) data, &result);
if (result == WICED_SUCCESS && write_count == dataLen)
return CHIP_NO_ERROR;

Expand All @@ -135,7 +137,7 @@ CHIP_ERROR CYW30739Config::WriteConfigValueBin(Key key, const void * data, size_
CHIP_ERROR CYW30739Config::ClearConfigValue(Key key)
{
wiced_result_t result;
wiced_hal_delete_nvram(PLATFORM_NVRAM_VSID_MATTER_BASE + key, &result);
wiced_hal_delete_nvram(key, &result);
if (result == WICED_SUCCESS)
{
return CHIP_NO_ERROR;
Expand Down
Loading

0 comments on commit d662734

Please sign in to comment.