From 3299408b0083e69446422c9e411a0bcca872e190 Mon Sep 17 00:00:00 2001 From: Marius Tache <102153746+marius-alex-tache@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:15:05 +0300 Subject: [PATCH] [NXP] Move some components in common (#35594) * [nxp][platform][common] Rename S200 crypto PAL and move it to common Signed-off-by: marius-alex-tache * [nxp][examples][common] Make S200 Operational Keystore common Signed-off-by: marius-alex-tache * [nxp][platform][common] Make k32w1 BLEManager implementation common This can be reused by other platforms as long as they are using the same SDK. Signed-off-by: marius-alex-tache * [nxp][platform][common] Move OTA related files to a common folder OTAFirmwareProcessor and OTAHooks could be reused by other platforms as long as the SDK is the same, so moving them from k32w1 folder. Signed-off-by: marius-alex-tache * [nxp][platform][common] Move Factory Data provider into a common folder Some components were implemented for k32w1, but can be reused as long as the used SDK is the same. Moving them to factory_data/legacy until synchronizing with the other factory data implementation. Signed-off-by: marius-alex-tache * [nxp][platform][k32w0] Update files after moving some components Signed-off-by: marius-alex-tache * [nxp][mcxw71_k32w1] Update build system after moving some components Signed-off-by: marius-alex-tache * [nxp][examples][k32w0] Update build system after moving some components Signed-off-by: marius-alex-tache * [nxp][scripts][common] Update list of supported devices for multi-image OTA Signed-off-by: marius-alex-tache * [nxp] Bump nxp_matter_support Signed-off-by: marius-alex-tache * [nxp][mcxw71_k32w1][lock-app] Update build system after moving some components Signed-off-by: marius-alex-tache * [nxp][mcxw71_k32w1] Fix factory data compilation issue Signed-off-by: Doru Gucea * Restyled by gn * [nxp][ota] Fix spelling of platforms Signed-off-by: marius-alex-tache * Restyled by gn * [nxp][platform][k32w0] Move setting of k32w0_sdk_root k32w0_sdk_root set was moved to nxp_matter_support submodule Signed-off-by: Marius Tache --------- Signed-off-by: marius-alex-tache Signed-off-by: Doru Gucea Signed-off-by: Marius Tache Co-authored-by: Doru Gucea Co-authored-by: Restyled.io --- .../nxp/k32w0/main/AppTask.cpp | 2 +- .../contact-sensor-app/nxp/k32w1/BUILD.gn | 20 +++- .../contact-sensor-app/nxp/mcxw71/BUILD.gn | 20 +++- .../lighting-app/nxp/k32w0/main/AppTask.cpp | 2 +- examples/lighting-app/nxp/k32w1/BUILD.gn | 15 ++- examples/lighting-app/nxp/mcxw71/BUILD.gn | 20 +++- examples/lock-app/nxp/k32w1/BUILD.gn | 15 ++- examples/lock-app/nxp/mcxw71/BUILD.gn | 15 ++- .../source/OperationalKeystoreS200.cpp} | 4 +- scripts/tools/nxp/ota/README.md | 48 +++++----- .../{legacy => ble}/BLEManagerCommon.cpp | 2 +- .../common/{legacy => ble}/BLEManagerCommon.h | 2 +- .../ble}/BLEManagerImpl.cpp | 7 +- .../crypto/CHIPCryptoPalS200.cpp} | 2 +- .../PersistentStorageOpKeystoreS200.cpp} | 26 ++--- .../crypto/PersistentStorageOpKeystoreS200.h} | 10 +- .../legacy/FactoryDataDriver.cpp | 4 +- .../legacy/FactoryDataDriver.h | 0 .../legacy}/FactoryDataDriverImpl.cpp | 4 +- .../legacy}/FactoryDataDriverImpl.h | 4 +- .../legacy/FactoryDataProvider.cpp | 2 +- .../legacy/FactoryDataProvider.h | 2 +- .../legacy}/FactoryDataProviderImpl.cpp | 2 +- .../legacy}/FactoryDataProviderImpl.h | 2 +- src/platform/nxp/common/legacy/gatt_db.h | 30 ------ src/platform/nxp/common/legacy/gatt_uuid128.h | 26 ----- .../OTAFactoryDataProcessor.cpp | 2 +- .../{legacy => ota}/OTAFactoryDataProcessor.h | 6 +- .../ota}/OTAFirmwareProcessor.cpp | 4 +- .../ota}/OTAFirmwareProcessor.h | 2 +- .../{mcxw71_k32w1 => common/ota}/OTAHooks.cpp | 26 ++--- .../{legacy => ota}/OTAImageProcessorImpl.cpp | 2 +- .../{legacy => ota}/OTAImageProcessorImpl.h | 2 +- .../{legacy => ota}/OTATlvProcessor.cpp | 4 +- .../common/{legacy => ota}/OTATlvProcessor.h | 0 .../{legacy/OTA_README.md => ota/README.md} | 2 +- src/platform/nxp/k32w0/BLEManagerImpl.h | 2 +- src/platform/nxp/k32w0/BUILD.gn | 14 +-- .../nxp/k32w0/OTAFactoryDataProcessor.cpp | 2 +- .../nxp/k32w0/OTAFactoryDataProcessor.h | 2 +- .../nxp/k32w0/OTAFirmwareProcessor.cpp | 2 +- src/platform/nxp/k32w0/OTAFirmwareProcessor.h | 2 +- src/platform/nxp/k32w0/OTAHooks.cpp | 2 +- src/platform/nxp/k32w0/args.gni | 6 -- .../nxp/mcxw71_k32w1/BLEManagerImpl.h | 2 +- src/platform/nxp/mcxw71_k32w1/BUILD.gn | 56 ++++++----- .../nxp/mcxw71_k32w1/ble_function_mux.c | 94 ------------------- .../nxp/mcxw71_k32w1/ble_function_mux.h | 34 ------- src/platform/nxp/mcxw71_k32w1/gatt_db.h | 30 ------ src/platform/nxp/mcxw71_k32w1/gatt_uuid128.h | 26 ----- third_party/nxp/nxp_matter_support | 2 +- 51 files changed, 215 insertions(+), 397 deletions(-) rename examples/platform/nxp/{mcxw71_k32w1/operational_keystore/OperationalKeystore.cpp => common/operational_keystore/source/OperationalKeystoreS200.cpp} (88%) rename src/platform/nxp/common/{legacy => ble}/BLEManagerCommon.cpp (99%) rename src/platform/nxp/common/{legacy => ble}/BLEManagerCommon.h (99%) rename src/platform/nxp/{mcxw71_k32w1 => common/ble}/BLEManagerImpl.cpp (92%) rename src/platform/nxp/{mcxw71_k32w1/CHIPCryptoPalK32W1.cpp => common/crypto/CHIPCryptoPalS200.cpp} (99%) rename src/platform/nxp/{mcxw71_k32w1/K32W1PersistentStorageOpKeystore.cpp => common/crypto/PersistentStorageOpKeystoreS200.cpp} (89%) rename src/platform/nxp/{mcxw71_k32w1/K32W1PersistentStorageOpKeystore.h => common/crypto/PersistentStorageOpKeystoreS200.h} (93%) rename src/platform/nxp/common/{ => factory_data}/legacy/FactoryDataDriver.cpp (94%) rename src/platform/nxp/common/{ => factory_data}/legacy/FactoryDataDriver.h (100%) rename src/platform/nxp/{mcxw71_k32w1 => common/factory_data/legacy}/FactoryDataDriverImpl.cpp (96%) rename src/platform/nxp/{mcxw71_k32w1 => common/factory_data/legacy}/FactoryDataDriverImpl.h (92%) rename src/platform/nxp/common/{ => factory_data}/legacy/FactoryDataProvider.cpp (99%) rename src/platform/nxp/common/{ => factory_data}/legacy/FactoryDataProvider.h (98%) rename src/platform/nxp/{mcxw71_k32w1 => common/factory_data/legacy}/FactoryDataProviderImpl.cpp (99%) rename src/platform/nxp/{mcxw71_k32w1 => common/factory_data/legacy}/FactoryDataProviderImpl.h (98%) delete mode 100644 src/platform/nxp/common/legacy/gatt_db.h delete mode 100644 src/platform/nxp/common/legacy/gatt_uuid128.h rename src/platform/nxp/common/{legacy => ota}/OTAFactoryDataProcessor.cpp (98%) rename src/platform/nxp/common/{legacy => ota}/OTAFactoryDataProcessor.h (92%) rename src/platform/nxp/{mcxw71_k32w1 => common/ota}/OTAFirmwareProcessor.cpp (96%) rename src/platform/nxp/{mcxw71_k32w1 => common/ota}/OTAFirmwareProcessor.h (96%) rename src/platform/nxp/{mcxw71_k32w1 => common/ota}/OTAHooks.cpp (85%) rename src/platform/nxp/common/{legacy => ota}/OTAImageProcessorImpl.cpp (99%) rename src/platform/nxp/common/{legacy => ota}/OTAImageProcessorImpl.h (98%) rename src/platform/nxp/common/{legacy => ota}/OTATlvProcessor.cpp (97%) rename src/platform/nxp/common/{legacy => ota}/OTATlvProcessor.h (100%) rename src/platform/nxp/common/{legacy/OTA_README.md => ota/README.md} (99%) delete mode 100644 src/platform/nxp/mcxw71_k32w1/ble_function_mux.c delete mode 100644 src/platform/nxp/mcxw71_k32w1/ble_function_mux.h delete mode 100644 src/platform/nxp/mcxw71_k32w1/gatt_db.h delete mode 100644 src/platform/nxp/mcxw71_k32w1/gatt_uuid128.h diff --git a/examples/contact-sensor-app/nxp/k32w0/main/AppTask.cpp b/examples/contact-sensor-app/nxp/k32w0/main/AppTask.cpp index d350a4527d281c..36cf190adf0b54 100644 --- a/examples/contact-sensor-app/nxp/k32w0/main/AppTask.cpp +++ b/examples/contact-sensor-app/nxp/k32w0/main/AppTask.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #endif #include diff --git a/examples/contact-sensor-app/nxp/k32w1/BUILD.gn b/examples/contact-sensor-app/nxp/k32w1/BUILD.gn index 0e24893bd06737..e887b2c5cc4f7f 100644 --- a/examples/contact-sensor-app/nxp/k32w1/BUILD.gn +++ b/examples/contact-sensor-app/nxp/k32w1/BUILD.gn @@ -39,6 +39,8 @@ assert(target_os == "freertos") example_platform_dir = "${chip_root}/examples/platform/nxp/${nxp_platform}" common_example_dir = "${chip_root}/examples/platform/nxp/common" +support_common_platform_dir = + "${nxp_sdk_matter_support_root}/examples/platform/common" mcxw71_k32w1_sdk("sdk") { defines = [] @@ -54,6 +56,9 @@ mcxw71_k32w1_sdk("sdk") { # Indicate the default path to OpenThreadConfig.h include_dirs += [ "${example_platform_dir}/app/project_include/openthread" ] + # Indicate the default path to GATT database + include_dirs += [ "${support_common_platform_dir}/ble" ] + include_dirs += [ "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/K32W1480", @@ -69,6 +74,7 @@ mcxw71_k32w1_sdk("sdk") { "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/board_extflash.c", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/board_lp.c", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/hardware_init.c", + "${support_common_platform_dir}/ble/ble_function_mux.c", ] if (is_debug) { @@ -104,7 +110,7 @@ mcxw71_k32w1_executable("contact_sensor_app") { "CONFIG_NETWORK_LAYER_BLE=1", "CONFIG_THREAD_DEVICE_TYPE=kThreadDeviceType_SleepyEndDevice", "CONFIG_OPERATIONAL_KEYSTORE=1", - "EXTERNAL_FACTORY_DATA_PROVIDER_HEADER=\"platform/nxp/common/legacy/FactoryDataProvider.h\"", + "EXTERNAL_FACTORY_DATA_PROVIDER_HEADER=\"platform/nxp/common/factory_data/legacy/FactoryDataProvider.h\"", ] if (chip_with_diag_logs_demo) { @@ -141,6 +147,7 @@ mcxw71_k32w1_executable("contact_sensor_app") { "${common_example_dir}/clusters/source/ZclCallbacks.cpp", "${common_example_dir}/device_callbacks/source/CommonDeviceCallbacks.cpp", "${common_example_dir}/device_manager/source/CHIPDeviceManager.cpp", + "${common_example_dir}/operational_keystore/source/OperationalKeystoreS200.cpp", "${example_platform_dir}/factory_data/source/AppFactoryDataExample.cpp", ] @@ -149,19 +156,23 @@ mcxw71_k32w1_executable("contact_sensor_app") { } if (chip_with_factory_data == 1) { - include_dirs += [ "${chip_root}/src/platform/nxp/common/legacy" ] + include_dirs += + [ "${chip_root}/src/platform/nxp/common/factory_data/legacy" ] deps += [ "${chip_root}/src/platform/nxp:nxp_factory_data" ] } if (chip_enable_ota_requestor) { defines += [ - "CONFIG_CHIP_OTA_IMAGE_PROCESSOR_HEADER=\"platform/nxp/common/legacy/OTAImageProcessorImpl.h\"", + "CONFIG_CHIP_OTA_IMAGE_PROCESSOR_HEADER=\"platform/nxp/common/ota/OTAImageProcessorImpl.h\"", # The status LED and the external flash CS pin are wired together. The OTA image writing may fail if used together. "LED_MANAGER_ENABLE_STATUS_LED=0", ] - include_dirs += [ "${common_example_dir}/ota_requestor/include" ] + include_dirs += [ + "${common_example_dir}/ota_requestor/include", + "${chip_root}/src/platform/nxp/common/ota", + ] sources += [ "${common_example_dir}/ota_requestor/source/OTARequestorInitiatorMultiImage.cpp" ] deps += [ "${chip_root}/src/platform/nxp:nxp_ota" ] } @@ -183,7 +194,6 @@ mcxw71_k32w1_executable("contact_sensor_app") { sources += [ "${example_platform_dir}/button/ButtonManager.cpp", "${example_platform_dir}/clusters/Identify.cpp", - "${example_platform_dir}/operational_keystore/OperationalKeystore.cpp", ] if (chip_enable_ota_requestor) { diff --git a/examples/contact-sensor-app/nxp/mcxw71/BUILD.gn b/examples/contact-sensor-app/nxp/mcxw71/BUILD.gn index 02a0d7a78768dc..87b25125d1c47c 100644 --- a/examples/contact-sensor-app/nxp/mcxw71/BUILD.gn +++ b/examples/contact-sensor-app/nxp/mcxw71/BUILD.gn @@ -38,6 +38,8 @@ assert(target_os == "freertos") example_platform_dir = "${chip_root}/examples/platform/nxp/${nxp_platform}" common_example_dir = "${chip_root}/examples/platform/nxp/common" +support_common_platform_dir = + "${nxp_sdk_matter_support_root}/examples/platform/common" mcxw71_k32w1_sdk("sdk") { defines = [] @@ -53,6 +55,9 @@ mcxw71_k32w1_sdk("sdk") { # Indicate the default path to OpenThreadConfig.h include_dirs += [ "${example_platform_dir}/app/project_include/openthread" ] + # Indicate the default path to GATT database + include_dirs += [ "${support_common_platform_dir}/ble" ] + include_dirs += [ "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/MCXW716C", @@ -68,6 +73,7 @@ mcxw71_k32w1_sdk("sdk") { "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/board_extflash.c", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/board_lp.c", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/hardware_init.c", + "${support_common_platform_dir}/ble/ble_function_mux.c", ] if (is_debug) { @@ -103,7 +109,7 @@ mcxw71_k32w1_executable("contact_sensor_app") { "CONFIG_NETWORK_LAYER_BLE=1", "CONFIG_THREAD_DEVICE_TYPE=kThreadDeviceType_SleepyEndDevice", "CONFIG_OPERATIONAL_KEYSTORE=1", - "EXTERNAL_FACTORY_DATA_PROVIDER_HEADER=\"platform/nxp/common/legacy/FactoryDataProvider.h\"", + "EXTERNAL_FACTORY_DATA_PROVIDER_HEADER=\"platform/nxp/common/factory_data/legacy/FactoryDataProvider.h\"", ] if (chip_with_diag_logs_demo) { @@ -140,6 +146,7 @@ mcxw71_k32w1_executable("contact_sensor_app") { "${common_example_dir}/clusters/source/ZclCallbacks.cpp", "${common_example_dir}/device_callbacks/source/CommonDeviceCallbacks.cpp", "${common_example_dir}/device_manager/source/CHIPDeviceManager.cpp", + "${common_example_dir}/operational_keystore/source/OperationalKeystoreS200.cpp", "${example_platform_dir}/factory_data/source/AppFactoryDataExample.cpp", ] @@ -148,19 +155,23 @@ mcxw71_k32w1_executable("contact_sensor_app") { } if (chip_with_factory_data == 1) { - include_dirs += [ "${chip_root}/src/platform/nxp/common/legacy" ] + include_dirs += + [ "${chip_root}/src/platform/nxp/common/factory_data/legacy" ] deps += [ "${chip_root}/src/platform/nxp:nxp_factory_data" ] } if (chip_enable_ota_requestor) { defines += [ - "CONFIG_CHIP_OTA_IMAGE_PROCESSOR_HEADER=\"platform/nxp/common/legacy/OTAImageProcessorImpl.h\"", + "CONFIG_CHIP_OTA_IMAGE_PROCESSOR_HEADER=\"platform/nxp/common/ota/OTAImageProcessorImpl.h\"", # The status LED and the external flash CS pin are wired together. The OTA image writing may fail if used together. "LED_MANAGER_ENABLE_STATUS_LED=0", ] - include_dirs += [ "${common_example_dir}/ota_requestor/include" ] + include_dirs += [ + "${common_example_dir}/ota_requestor/include", + "${chip_root}/src/platform/nxp/common/ota", + ] sources += [ "${common_example_dir}/ota_requestor/source/OTARequestorInitiatorMultiImage.cpp" ] deps += [ "${chip_root}/src/platform/nxp:nxp_ota" ] } @@ -182,7 +193,6 @@ mcxw71_k32w1_executable("contact_sensor_app") { sources += [ "${example_platform_dir}/button/ButtonManager.cpp", "${example_platform_dir}/clusters/Identify.cpp", - "${example_platform_dir}/operational_keystore/OperationalKeystore.cpp", ] if (chip_enable_ota_requestor) { diff --git a/examples/lighting-app/nxp/k32w0/main/AppTask.cpp b/examples/lighting-app/nxp/k32w0/main/AppTask.cpp index 7db25b0a7c0451..2418ab85978eb2 100644 --- a/examples/lighting-app/nxp/k32w0/main/AppTask.cpp +++ b/examples/lighting-app/nxp/k32w0/main/AppTask.cpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include #endif #include "DefaultTestEventTriggerDelegate.h" diff --git a/examples/lighting-app/nxp/k32w1/BUILD.gn b/examples/lighting-app/nxp/k32w1/BUILD.gn index 541c288dd1eb5c..8b5bd6b2cd77f2 100644 --- a/examples/lighting-app/nxp/k32w1/BUILD.gn +++ b/examples/lighting-app/nxp/k32w1/BUILD.gn @@ -44,6 +44,8 @@ assert(target_os == "freertos") example_platform_dir = "${chip_root}/examples/platform/nxp/${nxp_platform}" common_example_dir = "${chip_root}/examples/platform/nxp/common" +support_common_platform_dir = + "${nxp_sdk_matter_support_root}/examples/platform/common" mcxw71_k32w1_sdk("sdk") { defines = [] @@ -59,6 +61,9 @@ mcxw71_k32w1_sdk("sdk") { # Indicate the default path to OpenThreadConfig.h include_dirs += [ "${example_platform_dir}/app/project_include/openthread" ] + # Indicate the default path to GATT database + include_dirs += [ "${support_common_platform_dir}/ble" ] + include_dirs += [ "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/K32W1480", @@ -74,6 +79,7 @@ mcxw71_k32w1_sdk("sdk") { "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/board_extflash.c", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/board_lp.c", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/hardware_init.c", + "${support_common_platform_dir}/ble/ble_function_mux.c", ] if (is_debug) { @@ -125,7 +131,7 @@ mcxw71_k32w1_executable("light_app") { "CONFIG_OPERATIONAL_KEYSTORE=1", "CONFIG_ENABLE_FEEDBACK=1", "APP_QUEUE_TICKS_TO_WAIT=pdMS_TO_TICKS(10)", - "EXTERNAL_FACTORY_DATA_PROVIDER_HEADER=\"platform/nxp/common/legacy/FactoryDataProvider.h\"", + "EXTERNAL_FACTORY_DATA_PROVIDER_HEADER=\"platform/nxp/common/factory_data/legacy/FactoryDataProvider.h\"", ] # App common files @@ -148,12 +154,13 @@ mcxw71_k32w1_executable("light_app") { "${common_example_dir}/clusters/source/ZclCallbacks.cpp", "${common_example_dir}/device_callbacks/source/CommonDeviceCallbacks.cpp", "${common_example_dir}/device_manager/source/CHIPDeviceManager.cpp", + "${common_example_dir}/operational_keystore/source/OperationalKeystoreS200.cpp", "${example_platform_dir}/factory_data/source/AppFactoryDataExample.cpp", ] if (chip_enable_ota_requestor) { defines += [ - "CONFIG_CHIP_OTA_IMAGE_PROCESSOR_HEADER=\"platform/nxp/common/legacy/OTAImageProcessorImpl.h\"", + "CONFIG_CHIP_OTA_IMAGE_PROCESSOR_HEADER=\"platform/nxp/common/ota/OTAImageProcessorImpl.h\"", # The status LED and the external flash CS pin are wired together. The OTA image writing may fail if used together. "LED_MANAGER_ENABLE_STATUS_LED=0", @@ -174,7 +181,6 @@ mcxw71_k32w1_executable("light_app") { sources += [ "${example_platform_dir}/button/ButtonManager.cpp", "${example_platform_dir}/clusters/Identify.cpp", - "${example_platform_dir}/operational_keystore/OperationalKeystore.cpp", ] if (chip_enable_ota_requestor) { @@ -186,7 +192,8 @@ mcxw71_k32w1_executable("light_app") { } if (chip_with_factory_data == 1) { - include_dirs += [ "${chip_root}/src/platform/nxp/common/legacy" ] + include_dirs += + [ "${chip_root}/src/platform/nxp/common/factory_data/legacy" ] deps += [ "${chip_root}/src/platform/nxp:nxp_factory_data" ] } diff --git a/examples/lighting-app/nxp/mcxw71/BUILD.gn b/examples/lighting-app/nxp/mcxw71/BUILD.gn index 34733584a80cd9..b5d393dc6b9afc 100644 --- a/examples/lighting-app/nxp/mcxw71/BUILD.gn +++ b/examples/lighting-app/nxp/mcxw71/BUILD.gn @@ -44,6 +44,8 @@ assert(target_os == "freertos") example_platform_dir = "${chip_root}/examples/platform/nxp/${nxp_platform}" common_example_dir = "${chip_root}/examples/platform/nxp/common" +support_common_platform_dir = + "${nxp_sdk_matter_support_root}/examples/platform/common" mcxw71_k32w1_sdk("sdk") { defines = [] @@ -59,6 +61,9 @@ mcxw71_k32w1_sdk("sdk") { # Indicate the default path to OpenThreadConfig.h include_dirs += [ "${example_platform_dir}/app/project_include/openthread" ] + # Indicate the default path to GATT database + include_dirs += [ "${support_common_platform_dir}/ble" ] + include_dirs += [ "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/MCXW716C", @@ -74,6 +79,7 @@ mcxw71_k32w1_sdk("sdk") { "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/board_extflash.c", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/board_lp.c", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/hardware_init.c", + "${support_common_platform_dir}/ble/ble_function_mux.c", ] if (is_debug) { @@ -125,7 +131,7 @@ mcxw71_k32w1_executable("light_app") { "CONFIG_OPERATIONAL_KEYSTORE=1", "CONFIG_ENABLE_FEEDBACK=1", "APP_QUEUE_TICKS_TO_WAIT=pdMS_TO_TICKS(10)", - "EXTERNAL_FACTORY_DATA_PROVIDER_HEADER=\"platform/nxp/common/legacy/FactoryDataProvider.h\"", + "EXTERNAL_FACTORY_DATA_PROVIDER_HEADER=\"platform/nxp/common/factory_data/legacy/FactoryDataProvider.h\"", ] # App common files @@ -148,18 +154,22 @@ mcxw71_k32w1_executable("light_app") { "${common_example_dir}/clusters/source/ZclCallbacks.cpp", "${common_example_dir}/device_callbacks/source/CommonDeviceCallbacks.cpp", "${common_example_dir}/device_manager/source/CHIPDeviceManager.cpp", + "${common_example_dir}/operational_keystore/source/OperationalKeystoreS200.cpp", "${example_platform_dir}/factory_data/source/AppFactoryDataExample.cpp", ] if (chip_enable_ota_requestor) { defines += [ - "CONFIG_CHIP_OTA_IMAGE_PROCESSOR_HEADER=\"platform/nxp/common/legacy/OTAImageProcessorImpl.h\"", + "CONFIG_CHIP_OTA_IMAGE_PROCESSOR_HEADER=\"platform/nxp/common/ota/OTAImageProcessorImpl.h\"", # The status LED and the external flash CS pin are wired together. The OTA image writing may fail if used together. "LED_MANAGER_ENABLE_STATUS_LED=0", ] - include_dirs += [ "${common_example_dir}/ota_requestor/include" ] + include_dirs += [ + "${common_example_dir}/ota_requestor/include", + "${chip_root}/src/platform/nxp/common/ota", + ] sources += [ "${common_example_dir}/ota_requestor/source/OTARequestorInitiatorMultiImage.cpp" ] deps += [ "${chip_root}/src/platform/nxp:nxp_ota" ] } @@ -174,7 +184,6 @@ mcxw71_k32w1_executable("light_app") { sources += [ "${example_platform_dir}/button/ButtonManager.cpp", "${example_platform_dir}/clusters/Identify.cpp", - "${example_platform_dir}/operational_keystore/OperationalKeystore.cpp", ] if (chip_enable_ota_requestor) { @@ -186,7 +195,8 @@ mcxw71_k32w1_executable("light_app") { } if (chip_with_factory_data == 1) { - include_dirs += [ "${chip_root}/src/platform/nxp/common/legacy" ] + include_dirs += + [ "${chip_root}/src/platform/nxp/common/factory_data/legacy" ] deps += [ "${chip_root}/src/platform/nxp:nxp_factory_data" ] } diff --git a/examples/lock-app/nxp/k32w1/BUILD.gn b/examples/lock-app/nxp/k32w1/BUILD.gn index b8b6b7f67fa34c..42cff8a8b42c45 100644 --- a/examples/lock-app/nxp/k32w1/BUILD.gn +++ b/examples/lock-app/nxp/k32w1/BUILD.gn @@ -37,6 +37,8 @@ assert(target_os == "freertos") example_platform_dir = "${chip_root}/examples/platform/nxp/${nxp_platform}" common_example_dir = "${chip_root}/examples/platform/nxp/common" +support_common_platform_dir = + "${nxp_sdk_matter_support_root}/examples/platform/common" mcxw71_k32w1_sdk("sdk") { defines = [] @@ -52,6 +54,9 @@ mcxw71_k32w1_sdk("sdk") { # Indicate the default path to OpenThreadConfig.h include_dirs += [ "${example_platform_dir}/app/project_include/openthread" ] + # Indicate the default path to GATT database + include_dirs += [ "${support_common_platform_dir}/ble" ] + include_dirs += [ "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/K32W1480", @@ -67,6 +72,7 @@ mcxw71_k32w1_sdk("sdk") { "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/board_extflash.c", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/board_lp.c", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/hardware_init.c", + "${support_common_platform_dir}/ble/ble_function_mux.c", ] if (is_debug) { @@ -102,7 +108,7 @@ mcxw71_k32w1_executable("lock_app") { "CONFIG_NETWORK_LAYER_BLE=1", "CONFIG_THREAD_DEVICE_TYPE=kThreadDeviceType_SleepyEndDevice", "CONFIG_OPERATIONAL_KEYSTORE=1", - "EXTERNAL_FACTORY_DATA_PROVIDER_HEADER=\"platform/nxp/common/legacy/FactoryDataProvider.h\"", + "EXTERNAL_FACTORY_DATA_PROVIDER_HEADER=\"platform/nxp/common/factory_data/legacy/FactoryDataProvider.h\"", "CONFIG_APP_FREERTOS_OS=1", ] @@ -144,6 +150,7 @@ mcxw71_k32w1_executable("lock_app") { "${common_example_dir}/device_callbacks/source/CommonDeviceCallbacks.cpp", "${common_example_dir}/device_manager/source/CHIPDeviceManager.cpp", "${common_example_dir}/icd/source/ICDUtil.cpp", + "${common_example_dir}/operational_keystore/source/OperationalKeystoreS200.cpp", "${example_platform_dir}/factory_data/source/AppFactoryDataExample.cpp", ] @@ -152,7 +159,8 @@ mcxw71_k32w1_executable("lock_app") { } if (chip_with_factory_data == 1) { - include_dirs += [ "${chip_root}/src/platform/nxp/common/legacy" ] + include_dirs += + [ "${chip_root}/src/platform/nxp/common/factory_data/legacy" ] deps += [ "${chip_root}/src/platform/nxp:nxp_factory_data" ] } @@ -170,7 +178,7 @@ mcxw71_k32w1_executable("lock_app") { if (chip_enable_ota_requestor) { defines += [ - "CONFIG_CHIP_OTA_IMAGE_PROCESSOR_HEADER=\"platform/nxp/common/legacy/OTAImageProcessorImpl.h\"", + "CONFIG_CHIP_OTA_IMAGE_PROCESSOR_HEADER=\"platform/nxp/common/ota/OTAImageProcessorImpl.h\"", # The status LED and the external flash CS pin are wired together. The OTA image writing may fail if used together. "LED_MANAGER_ENABLE_STATUS_LED=0", @@ -198,7 +206,6 @@ mcxw71_k32w1_executable("lock_app") { sources += [ "${example_platform_dir}/button/ButtonManager.cpp", "${example_platform_dir}/clusters/Identify.cpp", - "${example_platform_dir}/operational_keystore/OperationalKeystore.cpp", ] if (chip_enable_ota_requestor) { diff --git a/examples/lock-app/nxp/mcxw71/BUILD.gn b/examples/lock-app/nxp/mcxw71/BUILD.gn index effa43f226640b..febab870a524ca 100644 --- a/examples/lock-app/nxp/mcxw71/BUILD.gn +++ b/examples/lock-app/nxp/mcxw71/BUILD.gn @@ -37,6 +37,8 @@ assert(target_os == "freertos") example_platform_dir = "${chip_root}/examples/platform/nxp/${nxp_platform}" common_example_dir = "${chip_root}/examples/platform/nxp/common" +support_common_platform_dir = + "${nxp_sdk_matter_support_root}/examples/platform/common" mcxw71_k32w1_sdk("sdk") { defines = [] @@ -52,6 +54,9 @@ mcxw71_k32w1_sdk("sdk") { # Indicate the default path to OpenThreadConfig.h include_dirs += [ "${example_platform_dir}/app/project_include/openthread" ] + # Indicate the default path to GATT database + include_dirs += [ "${support_common_platform_dir}/ble" ] + include_dirs += [ "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/K32W1480", @@ -67,6 +72,7 @@ mcxw71_k32w1_sdk("sdk") { "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/board_extflash.c", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/board_lp.c", "${nxp_sdk_root}/middleware/wireless/framework/boards/kw45_k32w1/hardware_init.c", + "${support_common_platform_dir}/ble/ble_function_mux.c", ] if (is_debug) { @@ -102,7 +108,7 @@ mcxw71_k32w1_executable("lock_app") { "CONFIG_NETWORK_LAYER_BLE=1", "CONFIG_THREAD_DEVICE_TYPE=kThreadDeviceType_SleepyEndDevice", "CONFIG_OPERATIONAL_KEYSTORE=1", - "EXTERNAL_FACTORY_DATA_PROVIDER_HEADER=\"platform/nxp/common/legacy/FactoryDataProvider.h\"", + "EXTERNAL_FACTORY_DATA_PROVIDER_HEADER=\"platform/nxp/common/factory_data/legacy/FactoryDataProvider.h\"", "CONFIG_APP_FREERTOS_OS=1", ] @@ -144,6 +150,7 @@ mcxw71_k32w1_executable("lock_app") { "${common_example_dir}/device_callbacks/source/CommonDeviceCallbacks.cpp", "${common_example_dir}/device_manager/source/CHIPDeviceManager.cpp", "${common_example_dir}/icd/source/ICDUtil.cpp", + "${common_example_dir}/operational_keystore/source/OperationalKeystoreS200.cpp", "${example_platform_dir}/factory_data/source/AppFactoryDataExample.cpp", ] @@ -152,7 +159,8 @@ mcxw71_k32w1_executable("lock_app") { } if (chip_with_factory_data == 1) { - include_dirs += [ "${chip_root}/src/platform/nxp/common/legacy" ] + include_dirs += + [ "${chip_root}/src/platform/nxp/common/factory_data/legacy" ] deps += [ "${chip_root}/src/platform/nxp:nxp_factory_data" ] } @@ -170,7 +178,7 @@ mcxw71_k32w1_executable("lock_app") { if (chip_enable_ota_requestor) { defines += [ - "CONFIG_CHIP_OTA_IMAGE_PROCESSOR_HEADER=\"platform/nxp/common/legacy/OTAImageProcessorImpl.h\"", + "CONFIG_CHIP_OTA_IMAGE_PROCESSOR_HEADER=\"platform/nxp/common/ota/OTAImageProcessorImpl.h\"", # The status LED and the external flash CS pin are wired together. The OTA image writing may fail if used together. "LED_MANAGER_ENABLE_STATUS_LED=0", @@ -198,7 +206,6 @@ mcxw71_k32w1_executable("lock_app") { sources += [ "${example_platform_dir}/button/ButtonManager.cpp", "${example_platform_dir}/clusters/Identify.cpp", - "${example_platform_dir}/operational_keystore/OperationalKeystore.cpp", ] if (chip_enable_ota_requestor) { diff --git a/examples/platform/nxp/mcxw71_k32w1/operational_keystore/OperationalKeystore.cpp b/examples/platform/nxp/common/operational_keystore/source/OperationalKeystoreS200.cpp similarity index 88% rename from examples/platform/nxp/mcxw71_k32w1/operational_keystore/OperationalKeystore.cpp rename to examples/platform/nxp/common/operational_keystore/source/OperationalKeystoreS200.cpp index ecd72266178984..04f89e4c814f43 100644 --- a/examples/platform/nxp/mcxw71_k32w1/operational_keystore/OperationalKeystore.cpp +++ b/examples/platform/nxp/common/operational_keystore/source/OperationalKeystoreS200.cpp @@ -16,9 +16,9 @@ */ #include "OperationalKeystore.h" -#include "K32W1PersistentStorageOpKeystore.h" +#include -static chip::K32W1PersistentStorageOpKeystore sInstance; +static chip::PersistentStorageOpKeystoreS200 sInstance; chip::Crypto::OperationalKeystore * chip::NXP::App::OperationalKeystore::GetInstance() { diff --git a/scripts/tools/nxp/ota/README.md b/scripts/tools/nxp/ota/README.md index 5c3a12adba7cf9..d2f8fd17a5d028 100644 --- a/scripts/tools/nxp/ota/README.md +++ b/scripts/tools/nxp/ota/README.md @@ -11,10 +11,14 @@ format. The payload contains data in standard TLV format (not Matter TLV format). During OTA transfer, these TLV can span across multiple BDX blocks, thus the `OTAImageProcessorImpl` instance should take this into account. +For details related to the OTA implementation, please see +[OTA README](../../../../src/platform/nxp/common/ota/README.md). + ## Supported platforms -- K32W0 - - [K32W OTA README](../../../../src/platform/nxp/common/legacy/OTA_README.md) +- `k32w0` +- `k32w1` +- `mcxw71` ## Usage @@ -31,30 +35,22 @@ reference commands. The list of **custom options**: -``` -# Application options ---app-input-file --> Path to the application binary. ---app-version --> Application version. It's part of the descriptor and - can be different than the OTA image header version: -vn. ---app-version-str --> Application version string. Same as above. ---app-build-date --> Application build date. Same as above. - -# SSBL options ---bl-input-file --> Path to the SSBL binary. ---bl-version --> SSBL version. ---bl-version-str --> SSBL version string. ---bl-build-date --> SSBL build date. - -# Factory data options ---factory-data --> If set, enables the generation of factory data. ---cert_declaration --> Certification Declaration. ---dac_cert --> DAC certificate. ---dac_key --> DAC private key. ---pai_cert --> PAI certificate. - -# Custom TLV options ---json --> Path to a JSON file following ota_payload.schema -``` +| option | description | +| -------------------- | -------------------------------------------------- | +| `--app-input-file` | Path to the application binary | +| `--app-version` | Application version. Can differ from `-vn` | +| `--app-version-str` | Application version string. Same as above | +| `--app-build-date` | Application build date. Same as above | +| `--bl-input-file` | Path to the SSBL binary | +| `--bl-version` | SSBL version | +| `--bl-version-str` | SSBL version string | +| `--bl-build-date` | SSBL build date | +| `--factory-data` | Enable the generation of factory data | +| `--cert_declaration` | Matter Certification Declaration | +| `--dac_cert` | Matter DAC certificate | +| `--dac_key` | Matter DAC private key | +| `--pai_cert` | Matter PAI certificate | +| `--json` | Path to a JSON file following `ota_payload.schema` | Please note that the options above are separated into four categories: application, bootloader, factory data and custom TLV (`--json` option). If no diff --git a/src/platform/nxp/common/legacy/BLEManagerCommon.cpp b/src/platform/nxp/common/ble/BLEManagerCommon.cpp similarity index 99% rename from src/platform/nxp/common/legacy/BLEManagerCommon.cpp rename to src/platform/nxp/common/ble/BLEManagerCommon.cpp index d9dbde88f3a614..02871e31f71058 100644 --- a/src/platform/nxp/common/legacy/BLEManagerCommon.cpp +++ b/src/platform/nxp/common/ble/BLEManagerCommon.cpp @@ -20,7 +20,7 @@ /** * @file * Provides an implementation of the BLEManager singleton object - * for the K32W platforms. + * for NXP platforms. */ /* this file behaves like a config.h, comes first */ diff --git a/src/platform/nxp/common/legacy/BLEManagerCommon.h b/src/platform/nxp/common/ble/BLEManagerCommon.h similarity index 99% rename from src/platform/nxp/common/legacy/BLEManagerCommon.h rename to src/platform/nxp/common/ble/BLEManagerCommon.h index b7fc1275d2501f..780ee194b8b28f 100644 --- a/src/platform/nxp/common/legacy/BLEManagerCommon.h +++ b/src/platform/nxp/common/ble/BLEManagerCommon.h @@ -20,7 +20,7 @@ /** * @file * Provides an implementation of the BLEManager singleton object - * for the K32W platforms. + * for NXP platforms. */ #pragma once diff --git a/src/platform/nxp/mcxw71_k32w1/BLEManagerImpl.cpp b/src/platform/nxp/common/ble/BLEManagerImpl.cpp similarity index 92% rename from src/platform/nxp/mcxw71_k32w1/BLEManagerImpl.cpp rename to src/platform/nxp/common/ble/BLEManagerImpl.cpp index 1eefdf5ef16ffc..e8ac5e96a7da13 100644 --- a/src/platform/nxp/mcxw71_k32w1/BLEManagerImpl.cpp +++ b/src/platform/nxp/common/ble/BLEManagerImpl.cpp @@ -28,7 +28,12 @@ messaging_t gHci2Host_TaskQueue; /*! Event for the Host Task Queue */ OSA_EVENT_HANDLE_DEFINE(gHost_TaskEvent); -#include +#ifdef EXTERNAL_BLEMANAGERIMPL_HEADER +#include EXTERNAL_BLEMANAGERIMPL_HEADER +#elif defined(CHIP_DEVICE_LAYER_TARGET) +#define BLEMANAGERIMPL_HEADER +#include BLEMANAGERIMPL_HEADER +#endif // defined(CHIP_DEVICE_LAYER_TARGET) extern "C" bleResult_t Hci_Reset(void); diff --git a/src/platform/nxp/mcxw71_k32w1/CHIPCryptoPalK32W1.cpp b/src/platform/nxp/common/crypto/CHIPCryptoPalS200.cpp similarity index 99% rename from src/platform/nxp/mcxw71_k32w1/CHIPCryptoPalK32W1.cpp rename to src/platform/nxp/common/crypto/CHIPCryptoPalS200.cpp index 9506d1bdfe1cc3..6e9342658c7ddd 100644 --- a/src/platform/nxp/mcxw71_k32w1/CHIPCryptoPalK32W1.cpp +++ b/src/platform/nxp/common/crypto/CHIPCryptoPalS200.cpp @@ -17,7 +17,7 @@ /** * @file - * mbedTLS based implementation of CHIP crypto primitives + * mbedTLS and S200 based implementation of CHIP crypto primitives */ #include diff --git a/src/platform/nxp/mcxw71_k32w1/K32W1PersistentStorageOpKeystore.cpp b/src/platform/nxp/common/crypto/PersistentStorageOpKeystoreS200.cpp similarity index 89% rename from src/platform/nxp/mcxw71_k32w1/K32W1PersistentStorageOpKeystore.cpp rename to src/platform/nxp/common/crypto/PersistentStorageOpKeystoreS200.cpp index a3a4a480430979..09744d2ce51d15 100644 --- a/src/platform/nxp/mcxw71_k32w1/K32W1PersistentStorageOpKeystore.cpp +++ b/src/platform/nxp/common/crypto/PersistentStorageOpKeystoreS200.cpp @@ -29,7 +29,7 @@ #include #include -#include "K32W1PersistentStorageOpKeystore.h" +#include "PersistentStorageOpKeystoreS200.h" #include "sss_crypto.h" @@ -82,7 +82,7 @@ CHIP_ERROR P256KeypairSSS::ImportBlob(P256SerializedKeypairSSS & input) return CHIP_NO_ERROR; } -bool K32W1PersistentStorageOpKeystore::HasOpKeypairForFabric(FabricIndex fabricIndex) const +bool PersistentStorageOpKeystoreS200::HasOpKeypairForFabric(FabricIndex fabricIndex) const { VerifyOrReturnError(mStorage != nullptr, false); VerifyOrReturnError(IsValidFabricIndex(fabricIndex), false); @@ -102,8 +102,8 @@ bool K32W1PersistentStorageOpKeystore::HasOpKeypairForFabric(FabricIndex fabricI return (err == CHIP_NO_ERROR && (keySize == SSS_KEY_PAIR_BLOB_SIZE)); } -CHIP_ERROR K32W1PersistentStorageOpKeystore::NewOpKeypairForFabric(FabricIndex fabricIndex, - MutableByteSpan & outCertificateSigningRequest) +CHIP_ERROR PersistentStorageOpKeystoreS200::NewOpKeypairForFabric(FabricIndex fabricIndex, + MutableByteSpan & outCertificateSigningRequest) { VerifyOrReturnError(mStorage != nullptr, CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnError(IsValidFabricIndex(fabricIndex), CHIP_ERROR_INVALID_FABRIC_INDEX); @@ -135,8 +135,8 @@ CHIP_ERROR K32W1PersistentStorageOpKeystore::NewOpKeypairForFabric(FabricIndex f return CHIP_NO_ERROR; } -CHIP_ERROR K32W1PersistentStorageOpKeystore::ActivateOpKeypairForFabric(FabricIndex fabricIndex, - const Crypto::P256PublicKey & nocPublicKey) +CHIP_ERROR PersistentStorageOpKeystoreS200::ActivateOpKeypairForFabric(FabricIndex fabricIndex, + const Crypto::P256PublicKey & nocPublicKey) { VerifyOrReturnError(mStorage != nullptr, CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnError(mPendingKeypair != nullptr, CHIP_ERROR_INVALID_FABRIC_INDEX); @@ -149,7 +149,7 @@ CHIP_ERROR K32W1PersistentStorageOpKeystore::ActivateOpKeypairForFabric(FabricIn return CHIP_NO_ERROR; } -CHIP_ERROR K32W1PersistentStorageOpKeystore::CommitOpKeypairForFabric(FabricIndex fabricIndex) +CHIP_ERROR PersistentStorageOpKeystoreS200::CommitOpKeypairForFabric(FabricIndex fabricIndex) { VerifyOrReturnError(mStorage != nullptr, CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnError(mPendingKeypair != nullptr, CHIP_ERROR_INVALID_FABRIC_INDEX); @@ -168,7 +168,7 @@ CHIP_ERROR K32W1PersistentStorageOpKeystore::CommitOpKeypairForFabric(FabricInde return CHIP_NO_ERROR; } -CHIP_ERROR K32W1PersistentStorageOpKeystore::RemoveOpKeypairForFabric(FabricIndex fabricIndex) +CHIP_ERROR PersistentStorageOpKeystoreS200::RemoveOpKeypairForFabric(FabricIndex fabricIndex) { VerifyOrReturnError(mStorage != nullptr, CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnError(IsValidFabricIndex(fabricIndex), CHIP_ERROR_INVALID_FABRIC_INDEX); @@ -188,7 +188,7 @@ CHIP_ERROR K32W1PersistentStorageOpKeystore::RemoveOpKeypairForFabric(FabricInde return err; } -void K32W1PersistentStorageOpKeystore::RevertPendingKeypair() +void PersistentStorageOpKeystoreS200::RevertPendingKeypair() { VerifyOrReturn(mStorage != nullptr); @@ -196,8 +196,8 @@ void K32W1PersistentStorageOpKeystore::RevertPendingKeypair() ResetPendingKey(); } -CHIP_ERROR K32W1PersistentStorageOpKeystore::SignWithOpKeypair(FabricIndex fabricIndex, const ByteSpan & message, - Crypto::P256ECDSASignature & outSignature) const +CHIP_ERROR PersistentStorageOpKeystoreS200::SignWithOpKeypair(FabricIndex fabricIndex, const ByteSpan & message, + Crypto::P256ECDSASignature & outSignature) const { CHIP_ERROR error = CHIP_NO_ERROR; @@ -239,7 +239,7 @@ CHIP_ERROR K32W1PersistentStorageOpKeystore::SignWithOpKeypair(FabricIndex fabri return mCachedKeypair->ECDSA_sign_msg(message.data(), message.size(), outSignature); } -Crypto::P256Keypair * K32W1PersistentStorageOpKeystore::AllocateEphemeralKeypairForCASE() +Crypto::P256Keypair * PersistentStorageOpKeystoreS200::AllocateEphemeralKeypairForCASE() { // DO NOT CUT AND PASTE without considering the ReleaseEphemeralKeypair(). // If allocating a derived class, then `ReleaseEphemeralKeypair` MUST @@ -247,7 +247,7 @@ Crypto::P256Keypair * K32W1PersistentStorageOpKeystore::AllocateEphemeralKeypair return Platform::New(); } -void K32W1PersistentStorageOpKeystore::ReleaseEphemeralKeypair(Crypto::P256Keypair * keypair) +void PersistentStorageOpKeystoreS200::ReleaseEphemeralKeypair(Crypto::P256Keypair * keypair) { // DO NOT CUT AND PASTE without considering the AllocateEphemeralKeypairForCASE(). // This must delete the same concrete class as allocated in `AllocateEphemeralKeypairForCASE` diff --git a/src/platform/nxp/mcxw71_k32w1/K32W1PersistentStorageOpKeystore.h b/src/platform/nxp/common/crypto/PersistentStorageOpKeystoreS200.h similarity index 93% rename from src/platform/nxp/mcxw71_k32w1/K32W1PersistentStorageOpKeystore.h rename to src/platform/nxp/common/crypto/PersistentStorageOpKeystoreS200.h index c0aeabccd2e724..12edb9d8412cc0 100644 --- a/src/platform/nxp/mcxw71_k32w1/K32W1PersistentStorageOpKeystore.h +++ b/src/platform/nxp/common/crypto/PersistentStorageOpKeystoreS200.h @@ -61,15 +61,15 @@ class P256KeypairSSS : public Crypto::P256Keypair * of how to use the interface. * */ -class K32W1PersistentStorageOpKeystore : public Crypto::OperationalKeystore +class PersistentStorageOpKeystoreS200 : public Crypto::OperationalKeystore { public: - K32W1PersistentStorageOpKeystore() = default; - virtual ~K32W1PersistentStorageOpKeystore() { Finish(); } + PersistentStorageOpKeystoreS200() = default; + virtual ~PersistentStorageOpKeystoreS200() { Finish(); } // Non-copyable - K32W1PersistentStorageOpKeystore(K32W1PersistentStorageOpKeystore const &) = delete; - void operator=(K32W1PersistentStorageOpKeystore const &) = delete; + PersistentStorageOpKeystoreS200(PersistentStorageOpKeystoreS200 const &) = delete; + void operator=(PersistentStorageOpKeystoreS200 const &) = delete; /** * @brief Initialize the Operational Keystore to map to a given storage delegate. diff --git a/src/platform/nxp/common/legacy/FactoryDataDriver.cpp b/src/platform/nxp/common/factory_data/legacy/FactoryDataDriver.cpp similarity index 94% rename from src/platform/nxp/common/legacy/FactoryDataDriver.cpp rename to src/platform/nxp/common/factory_data/legacy/FactoryDataDriver.cpp index 6ddbedc3ca35c8..f54406cfa1cc58 100644 --- a/src/platform/nxp/common/legacy/FactoryDataDriver.cpp +++ b/src/platform/nxp/common/factory_data/legacy/FactoryDataDriver.cpp @@ -17,8 +17,8 @@ #include #include -#include -#include +#include +#include namespace chip { namespace DeviceLayer { diff --git a/src/platform/nxp/common/legacy/FactoryDataDriver.h b/src/platform/nxp/common/factory_data/legacy/FactoryDataDriver.h similarity index 100% rename from src/platform/nxp/common/legacy/FactoryDataDriver.h rename to src/platform/nxp/common/factory_data/legacy/FactoryDataDriver.h diff --git a/src/platform/nxp/mcxw71_k32w1/FactoryDataDriverImpl.cpp b/src/platform/nxp/common/factory_data/legacy/FactoryDataDriverImpl.cpp similarity index 96% rename from src/platform/nxp/mcxw71_k32w1/FactoryDataDriverImpl.cpp rename to src/platform/nxp/common/factory_data/legacy/FactoryDataDriverImpl.cpp index 473c4932ee1ba1..18ea65cdf18e26 100644 --- a/src/platform/nxp/mcxw71_k32w1/FactoryDataDriverImpl.cpp +++ b/src/platform/nxp/common/factory_data/legacy/FactoryDataDriverImpl.cpp @@ -16,8 +16,8 @@ */ #include -#include -#include +#include +#include using namespace chip::DeviceLayer::PersistedStorage; diff --git a/src/platform/nxp/mcxw71_k32w1/FactoryDataDriverImpl.h b/src/platform/nxp/common/factory_data/legacy/FactoryDataDriverImpl.h similarity index 92% rename from src/platform/nxp/mcxw71_k32w1/FactoryDataDriverImpl.h rename to src/platform/nxp/common/factory_data/legacy/FactoryDataDriverImpl.h index 8b3e77358c6d47..43e91793767f69 100644 --- a/src/platform/nxp/mcxw71_k32w1/FactoryDataDriverImpl.h +++ b/src/platform/nxp/common/factory_data/legacy/FactoryDataDriverImpl.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include extern "C" { #include "HWParameter.h" @@ -29,7 +29,7 @@ namespace chip { namespace DeviceLayer { /** - * This class implements the FactoryDataDriver with K32W1 specific functions + * This class implements the FactoryDataDriver */ class FactoryDataDriverImpl : public FactoryDataDriver diff --git a/src/platform/nxp/common/legacy/FactoryDataProvider.cpp b/src/platform/nxp/common/factory_data/legacy/FactoryDataProvider.cpp similarity index 99% rename from src/platform/nxp/common/legacy/FactoryDataProvider.cpp rename to src/platform/nxp/common/factory_data/legacy/FactoryDataProvider.cpp index 7ecc29a54cf077..38998ed3c5bde6 100644 --- a/src/platform/nxp/common/legacy/FactoryDataProvider.cpp +++ b/src/platform/nxp/common/factory_data/legacy/FactoryDataProvider.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include diff --git a/src/platform/nxp/common/legacy/FactoryDataProvider.h b/src/platform/nxp/common/factory_data/legacy/FactoryDataProvider.h similarity index 98% rename from src/platform/nxp/common/legacy/FactoryDataProvider.h rename to src/platform/nxp/common/factory_data/legacy/FactoryDataProvider.h index f7d05c3f1da1f4..f84336457f0ba9 100644 --- a/src/platform/nxp/common/legacy/FactoryDataProvider.h +++ b/src/platform/nxp/common/factory_data/legacy/FactoryDataProvider.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include diff --git a/src/platform/nxp/mcxw71_k32w1/FactoryDataProviderImpl.cpp b/src/platform/nxp/common/factory_data/legacy/FactoryDataProviderImpl.cpp similarity index 99% rename from src/platform/nxp/mcxw71_k32w1/FactoryDataProviderImpl.cpp rename to src/platform/nxp/common/factory_data/legacy/FactoryDataProviderImpl.cpp index c55940e8838395..abb189685bdc7f 100644 --- a/src/platform/nxp/mcxw71_k32w1/FactoryDataProviderImpl.cpp +++ b/src/platform/nxp/common/factory_data/legacy/FactoryDataProviderImpl.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ #include -#include +#include #include #include "fsl_adapter_flash.h" diff --git a/src/platform/nxp/mcxw71_k32w1/FactoryDataProviderImpl.h b/src/platform/nxp/common/factory_data/legacy/FactoryDataProviderImpl.h similarity index 98% rename from src/platform/nxp/mcxw71_k32w1/FactoryDataProviderImpl.h rename to src/platform/nxp/common/factory_data/legacy/FactoryDataProviderImpl.h index d7f15bba4ed422..ef23e59a6d05e6 100644 --- a/src/platform/nxp/mcxw71_k32w1/FactoryDataProviderImpl.h +++ b/src/platform/nxp/common/factory_data/legacy/FactoryDataProviderImpl.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include #if !CHIP_USE_PLAIN_DAC_KEY #include "sss_crypto.h" diff --git a/src/platform/nxp/common/legacy/gatt_db.h b/src/platform/nxp/common/legacy/gatt_db.h deleted file mode 100644 index 604fcfb61a7ba1..00000000000000 --- a/src/platform/nxp/common/legacy/gatt_db.h +++ /dev/null @@ -1,30 +0,0 @@ -PRIMARY_SERVICE(service_gatt, gBleSig_GenericAttributeProfile_d) -CHARACTERISTIC(char_service_changed, gBleSig_GattServiceChanged_d, (gGattCharPropRead_c | gGattCharPropNotify_c)) -VALUE(value_service_changed, gBleSig_GattServiceChanged_d, (gPermissionNone_c), 4, 0x00, 0x00, 0x00, 0x00) -CCCD(cccd_service_changed) - -PRIMARY_SERVICE(service_gap, gBleSig_GenericAccessProfile_d) -CHARACTERISTIC(char_device_name, gBleSig_GapDeviceName_d, (gGattCharPropRead_c)) -VALUE(value_device_name, gBleSig_GapDeviceName_d, (gPermissionFlagReadable_c), 16, "NXP_ELOCK_DEMO") -CHARACTERISTIC(char_appearance, gBleSig_GapAppearance_d, (gGattCharPropRead_c)) -VALUE(value_appearance, gBleSig_GapAppearance_d, (gPermissionFlagReadable_c), 2, 0x00, 0x00) - -PRIMARY_SERVICE(service_chipoble, gChipoBleService_d) -CHARACTERISTIC_UUID128(chipoble_rx, uuid_chipoble_rx, (gGattCharPropWrite_c)) -VALUE_UUID128_VARLEN(value_chipoble_rx, uuid_chipoble_rx, (gPermissionFlagWritable_c), gAttMaxMtu_c - 3, gAttMaxMtu_c - 3, 0x00) -CHARACTERISTIC_UUID128(chipoble_tx, uuid_chipoble_tx, (gGattCharPropIndicate_c | gGattCharPropRead_c)) -VALUE_UUID128_VARLEN(value_chipoble_tx, uuid_chipoble_tx, (gPermissionFlagReadable_c), gAttMaxMtu_c - 3, gAttMaxMtu_c - 3, 0x00) -CCCD(cccd_chipoble_tx) -CHARACTERISTIC_UUID128(chipoble_c3, uuid_chipoble_c3, (gGattCharPropRead_c)) -VALUE_UUID128_VARLEN(value_chipoble_c3, uuid_chipoble_c3, (gPermissionFlagReadable_c), gAttMaxReadDataSize_d(gAttMaxValueLength_c), - gAttMaxReadDataSize_d(gAttMaxValueLength_c), 0x00) - -PRIMARY_SERVICE(service_device_info, gBleSig_DeviceInformationService_d) -CHARACTERISTIC(char_model_no, gBleSig_ModelNumberString_d, (gGattCharPropRead_c)) -VALUE(value_model_no, gBleSig_ModelNumberString_d, (gPermissionFlagReadable_c), 15, "Chip ELock Demo") -CHARACTERISTIC(char_serial_no, gBleSig_SerialNumberString_d, (gGattCharPropRead_c)) -VALUE(value_serial_no, gBleSig_SerialNumberString_d, (gPermissionFlagReadable_c), 7, "BLESN01") -CHARACTERISTIC(char_fw_rev, gBleSig_FirmwareRevisionString_d, (gGattCharPropRead_c)) -VALUE(value_fw_rev, gBleSig_FirmwareRevisionString_d, (gPermissionFlagReadable_c), 5, "1.1.1") -CHARACTERISTIC(char_sw_rev, gBleSig_SoftwareRevisionString_d, (gGattCharPropRead_c)) -VALUE(value_sw_rev, gBleSig_SoftwareRevisionString_d, (gPermissionFlagReadable_c), 5, "1.1.4") diff --git a/src/platform/nxp/common/legacy/gatt_uuid128.h b/src/platform/nxp/common/legacy/gatt_uuid128.h deleted file mode 100644 index 938968b1943ce2..00000000000000 --- a/src/platform/nxp/common/legacy/gatt_uuid128.h +++ /dev/null @@ -1,26 +0,0 @@ -/* -* Declare all custom 128-bit UUIDs here using the format: -* -* UUID128(name, bytes) -* -* where: -* -name : an unique tag for the newly defined UUID; - will be used to reference this UUID when defining - services and characteristics in <> -* -bytes: 16 bytes representing the 128-bit value -* -* One definition per line. No semicolon required after each definition. -* -* example: -* UUID128(uuid_service_robot_characteristics, 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF, 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, -0xCD, 0xEF) -* UUID128(uuid_char_robot_direction, 0x12, 0x34, 0x50, 0x00, 0x90, 0xAB, 0xCD, 0xEF, 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, -0xEF) -*/ -/* Services */ - -#define gChipoBleService_d 0xFFF6 - -UUID128(uuid_chipoble_tx, 0x12, 0x9D, 0x9F, 0x42, 0x9C, 0x4F, 0x9F, 0x95, 0x59, 0x45, 0x3D, 0x26, 0xF5, 0x2E, 0xEE, 0x18) -UUID128(uuid_chipoble_rx, 0x11, 0x9D, 0x9F, 0x42, 0x9C, 0x4F, 0x9F, 0x95, 0x59, 0x45, 0x3D, 0x26, 0xF5, 0x2E, 0xEE, 0x18) -UUID128(uuid_chipoble_c3, 0x04, 0x8f, 0x21, 0x83, 0x8a, 0x74, 0x7d, 0xb8, 0xf2, 0x45, 0x72, 0x87, 0x38, 0x02, 0x63, 0x64) diff --git a/src/platform/nxp/common/legacy/OTAFactoryDataProcessor.cpp b/src/platform/nxp/common/ota/OTAFactoryDataProcessor.cpp similarity index 98% rename from src/platform/nxp/common/legacy/OTAFactoryDataProcessor.cpp rename to src/platform/nxp/common/ota/OTAFactoryDataProcessor.cpp index 4960ca2c4e0669..421f0203621add 100644 --- a/src/platform/nxp/common/legacy/OTAFactoryDataProcessor.cpp +++ b/src/platform/nxp/common/ota/OTAFactoryDataProcessor.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include namespace chip { diff --git a/src/platform/nxp/common/legacy/OTAFactoryDataProcessor.h b/src/platform/nxp/common/ota/OTAFactoryDataProcessor.h similarity index 92% rename from src/platform/nxp/common/legacy/OTAFactoryDataProcessor.h rename to src/platform/nxp/common/ota/OTAFactoryDataProcessor.h index 862aad2d9a6341..570a33ceed5924 100644 --- a/src/platform/nxp/common/legacy/OTAFactoryDataProcessor.h +++ b/src/platform/nxp/common/ota/OTAFactoryDataProcessor.h @@ -21,9 +21,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include PLATFORM_FACTORY_DATA_PROVIDER_IMPL_HEADER namespace chip { diff --git a/src/platform/nxp/mcxw71_k32w1/OTAFirmwareProcessor.cpp b/src/platform/nxp/common/ota/OTAFirmwareProcessor.cpp similarity index 96% rename from src/platform/nxp/mcxw71_k32w1/OTAFirmwareProcessor.cpp rename to src/platform/nxp/common/ota/OTAFirmwareProcessor.cpp index 2ea4d47cc655a1..15aa5f271c3ccc 100644 --- a/src/platform/nxp/mcxw71_k32w1/OTAFirmwareProcessor.cpp +++ b/src/platform/nxp/common/ota/OTAFirmwareProcessor.cpp @@ -17,8 +17,8 @@ */ #include -#include -#include +#include +#include #include "OtaSupport.h" diff --git a/src/platform/nxp/mcxw71_k32w1/OTAFirmwareProcessor.h b/src/platform/nxp/common/ota/OTAFirmwareProcessor.h similarity index 96% rename from src/platform/nxp/mcxw71_k32w1/OTAFirmwareProcessor.h rename to src/platform/nxp/common/ota/OTAFirmwareProcessor.h index b8bb3abd008e7a..1d17e352a4bbf5 100644 --- a/src/platform/nxp/mcxw71_k32w1/OTAFirmwareProcessor.h +++ b/src/platform/nxp/common/ota/OTAFirmwareProcessor.h @@ -20,7 +20,7 @@ #include "OtaPrivate.h" #include -#include +#include /* Posted Operations Size Info */ #define NB_PENDING_TRANSACTIONS 12 diff --git a/src/platform/nxp/mcxw71_k32w1/OTAHooks.cpp b/src/platform/nxp/common/ota/OTAHooks.cpp similarity index 85% rename from src/platform/nxp/mcxw71_k32w1/OTAHooks.cpp rename to src/platform/nxp/common/ota/OTAHooks.cpp index c476e705fd67be..032fe3d2ff9c4b 100644 --- a/src/platform/nxp/mcxw71_k32w1/OTAHooks.cpp +++ b/src/platform/nxp/common/ota/OTAHooks.cpp @@ -16,25 +16,25 @@ * limitations under the License. */ -#include +#include #include #include -#include +#include #if CONFIG_CHIP_OTA_FACTORY_DATA_PROCESSOR -#include -#include +#include +#include #endif // CONFIG_CHIP_OTA_FACTORY_DATA_PROCESSOR #include "OtaSupport.h" -#ifndef CONFIG_CHIP_K32W1_MAX_ENTRIES_TEST -#define CONFIG_CHIP_K32W1_MAX_ENTRIES_TEST 0 +#ifndef CONFIG_CHIP_MAX_ENTRIES_TEST +#define CONFIG_CHIP_MAX_ENTRIES_TEST 0 #endif -#ifndef CONFIG_CHIP_K32W1_OTA_ABORT_HOOK -#define CONFIG_CHIP_K32W1_OTA_ABORT_HOOK 0 +#ifndef CONFIG_CHIP_OTA_ABORT_HOOK +#define CONFIG_CHIP_OTA_ABORT_HOOK 0 #endif #define APPLICATION_PROCESSOR_TAG 1 @@ -61,7 +61,7 @@ CHIP_ERROR ProcessDescriptor(void * descriptor) extern "C" WEAK CHIP_ERROR OtaHookInit() { -#if CONFIG_CHIP_K32W1_MAX_ENTRIES_TEST +#if CONFIG_CHIP_MAX_ENTRIES_TEST static chip::OTAFirmwareProcessor processors[8]; #endif @@ -77,13 +77,13 @@ extern "C" WEAK CHIP_ERROR OtaHookInit() ReturnErrorOnFailure(imageProcessor.RegisterProcessor(FACTORY_DATA_PROCESSOR_TAG, &sFactoryDataProcessor)); #endif // CONFIG_CHIP_OTA_FACTORY_DATA_PROCESSOR -#if CONFIG_CHIP_K32W1_MAX_ENTRIES_TEST +#if CONFIG_CHIP_MAX_ENTRIES_TEST for (auto i = 0; i < 8; i++) { processors[i].RegisterDescriptorCallback(ProcessDescriptor); ReturnErrorOnFailure(imageProcessor.RegisterProcessor(i + 4, &processors[i])); } -#endif // CONFIG_CHIP_K32W1_MAX_ENTRIES_TEST +#endif // CONFIG_CHIP_MAX_ENTRIES_TEST return CHIP_NO_ERROR; } @@ -106,10 +106,10 @@ extern "C" WEAK void OtaHookAbort() Disclaimer: This is not default behavior and it was not checked against Matter specification compliance. You should use this at your own discretion. - Use CONFIG_CHIP_K32W1_OTA_ABORT_HOOK to enable/disable this feature (disabled by default). + Use CONFIG_CHIP_OTA_ABORT_HOOK to enable/disable this feature (disabled by default). This hook is called inside OTAImageProcessorImpl::HandleAbort to schedule a retry (when enabled). */ -#if CONFIG_CHIP_K32W1_OTA_ABORT_HOOK +#if CONFIG_CHIP_OTA_ABORT_HOOK auto & imageProcessor = chip::OTAImageProcessorImpl::GetDefaultInstance(); auto & providerLocation = imageProcessor.GetBackupProvider(); diff --git a/src/platform/nxp/common/legacy/OTAImageProcessorImpl.cpp b/src/platform/nxp/common/ota/OTAImageProcessorImpl.cpp similarity index 99% rename from src/platform/nxp/common/legacy/OTAImageProcessorImpl.cpp rename to src/platform/nxp/common/ota/OTAImageProcessorImpl.cpp index c26a7da59b9483..f6f42367329e54 100644 --- a/src/platform/nxp/common/legacy/OTAImageProcessorImpl.cpp +++ b/src/platform/nxp/common/ota/OTAImageProcessorImpl.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include using namespace chip::DeviceLayer; using namespace ::chip::DeviceLayer::Internal; diff --git a/src/platform/nxp/common/legacy/OTAImageProcessorImpl.h b/src/platform/nxp/common/ota/OTAImageProcessorImpl.h similarity index 98% rename from src/platform/nxp/common/legacy/OTAImageProcessorImpl.h rename to src/platform/nxp/common/ota/OTAImageProcessorImpl.h index 9a862a716b957f..3419cbd6e2a9f1 100644 --- a/src/platform/nxp/common/legacy/OTAImageProcessorImpl.h +++ b/src/platform/nxp/common/ota/OTAImageProcessorImpl.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/platform/nxp/common/legacy/OTATlvProcessor.cpp b/src/platform/nxp/common/ota/OTATlvProcessor.cpp similarity index 97% rename from src/platform/nxp/common/legacy/OTATlvProcessor.cpp rename to src/platform/nxp/common/ota/OTATlvProcessor.cpp index e50da13cecdd31..66a080135b42db 100644 --- a/src/platform/nxp/common/legacy/OTATlvProcessor.cpp +++ b/src/platform/nxp/common/ota/OTATlvProcessor.cpp @@ -20,8 +20,8 @@ #include #include -#include -#include +#include +#include #if OTA_ENCRYPTION_ENABLE #include "OtaUtils.h" #include "rom_aes.h" diff --git a/src/platform/nxp/common/legacy/OTATlvProcessor.h b/src/platform/nxp/common/ota/OTATlvProcessor.h similarity index 100% rename from src/platform/nxp/common/legacy/OTATlvProcessor.h rename to src/platform/nxp/common/ota/OTATlvProcessor.h diff --git a/src/platform/nxp/common/legacy/OTA_README.md b/src/platform/nxp/common/ota/README.md similarity index 99% rename from src/platform/nxp/common/legacy/OTA_README.md rename to src/platform/nxp/common/ota/README.md index 0c9715b4610ff8..e288e6ab412c18 100644 --- a/src/platform/nxp/common/legacy/OTA_README.md +++ b/src/platform/nxp/common/ota/README.md @@ -1,4 +1,4 @@ -# K32W OTA +# Multi-image OTA The OTA processing is now delegated to instances of `OTATlvProcessor` derived classes. These instances are registered with the `OTAImageProcessorImpl` diff --git a/src/platform/nxp/k32w0/BLEManagerImpl.h b/src/platform/nxp/k32w0/BLEManagerImpl.h index 686eb1e3f703ee..b1aaa524af57d5 100644 --- a/src/platform/nxp/k32w0/BLEManagerImpl.h +++ b/src/platform/nxp/k32w0/BLEManagerImpl.h @@ -25,7 +25,7 @@ #include "ble_host_task_config.h" #include "controller_interface.h" -#include +#include /* host task configuration */ #define HOST_TASK_PRIORITY (4U) diff --git a/src/platform/nxp/k32w0/BUILD.gn b/src/platform/nxp/k32w0/BUILD.gn index a1b40506d6cd6a..6693acc213e4a1 100644 --- a/src/platform/nxp/k32w0/BUILD.gn +++ b/src/platform/nxp/k32w0/BUILD.gn @@ -34,8 +34,8 @@ static_library("nxp_platform") { defines = [] sources = [ "../../SingletonConfigurationManager.cpp", - "../common/legacy/BLEManagerCommon.cpp", - "../common/legacy/BLEManagerCommon.h", + "../common/ble/BLEManagerCommon.cpp", + "../common/ble/BLEManagerCommon.h", "BLEManagerImpl.cpp", "BLEManagerImpl.h", "CHIPDevicePlatformConfig.h", @@ -83,13 +83,13 @@ static_library("nxp_platform") { } if (chip_enable_ota_requestor) { - public += [ "../common/legacy/OTAImageProcessorImpl.h" ] + public += [ "../common/ota/OTAImageProcessorImpl.h" ] sources += [ - "../common/legacy/OTAImageProcessorImpl.cpp", - "../common/legacy/OTAImageProcessorImpl.h", - "../common/legacy/OTATlvProcessor.cpp", - "../common/legacy/OTATlvProcessor.h", + "../common/ota/OTAImageProcessorImpl.cpp", + "../common/ota/OTAImageProcessorImpl.h", + "../common/ota/OTATlvProcessor.cpp", + "../common/ota/OTATlvProcessor.h", ] if (chip_enable_ota_firmware_processor == 1) { diff --git a/src/platform/nxp/k32w0/OTAFactoryDataProcessor.cpp b/src/platform/nxp/k32w0/OTAFactoryDataProcessor.cpp index b6777c7dc32820..9114906787a7b6 100644 --- a/src/platform/nxp/k32w0/OTAFactoryDataProcessor.cpp +++ b/src/platform/nxp/k32w0/OTAFactoryDataProcessor.cpp @@ -18,8 +18,8 @@ #include #include -#include #include +#include #include #include diff --git a/src/platform/nxp/k32w0/OTAFactoryDataProcessor.h b/src/platform/nxp/k32w0/OTAFactoryDataProcessor.h index 3109e64a8d0ae3..57b973d73f0750 100644 --- a/src/platform/nxp/k32w0/OTAFactoryDataProcessor.h +++ b/src/platform/nxp/k32w0/OTAFactoryDataProcessor.h @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/platform/nxp/k32w0/OTAFirmwareProcessor.cpp b/src/platform/nxp/k32w0/OTAFirmwareProcessor.cpp index c7a1a2bbf435dd..3fcb2fd43bf1d9 100644 --- a/src/platform/nxp/k32w0/OTAFirmwareProcessor.cpp +++ b/src/platform/nxp/k32w0/OTAFirmwareProcessor.cpp @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include diff --git a/src/platform/nxp/k32w0/OTAFirmwareProcessor.h b/src/platform/nxp/k32w0/OTAFirmwareProcessor.h index 444243f0c885d0..933a61538e068b 100644 --- a/src/platform/nxp/k32w0/OTAFirmwareProcessor.h +++ b/src/platform/nxp/k32w0/OTAFirmwareProcessor.h @@ -19,7 +19,7 @@ #pragma once #include -#include +#include namespace chip { diff --git a/src/platform/nxp/k32w0/OTAHooks.cpp b/src/platform/nxp/k32w0/OTAHooks.cpp index 30df88177ffdc6..659422de02a362 100644 --- a/src/platform/nxp/k32w0/OTAHooks.cpp +++ b/src/platform/nxp/k32w0/OTAHooks.cpp @@ -16,7 +16,7 @@ * limitations under the License. */ -#include +#include #include #include diff --git a/src/platform/nxp/k32w0/args.gni b/src/platform/nxp/k32w0/args.gni index 1076eea4f4cf7f..fda52672cf50e0 100644 --- a/src/platform/nxp/k32w0/args.gni +++ b/src/platform/nxp/k32w0/args.gni @@ -22,12 +22,6 @@ nxp_device_layer = "nxp/${nxp_platform}" nxp_use_lwip = false nxp_use_mbedtls_port = false -if (getenv("NXP_K32W0_SDK_ROOT") == "") { - k32w0_sdk_root = "${nxp_sdk_matter_support_root}/github_sdk/k32w0/repo" -} else { - k32w0_sdk_root = getenv("NXP_K32W0_SDK_ROOT") -} - # ARM architecture flags will be set based on NXP board. arm_platform_config = "${nxp_sdk_build_root}/${nxp_sdk_name}/nxp_arm.gni" diff --git a/src/platform/nxp/mcxw71_k32w1/BLEManagerImpl.h b/src/platform/nxp/mcxw71_k32w1/BLEManagerImpl.h index d2b38cdeda1619..1c51cd70b4e161 100644 --- a/src/platform/nxp/mcxw71_k32w1/BLEManagerImpl.h +++ b/src/platform/nxp/mcxw71_k32w1/BLEManagerImpl.h @@ -31,7 +31,7 @@ #include "controller_api.h" #include "controller_interface.h" -#include +#include /* host task configuration */ #define HOST_TASK_PRIORITY (4U) diff --git a/src/platform/nxp/mcxw71_k32w1/BUILD.gn b/src/platform/nxp/mcxw71_k32w1/BUILD.gn index 9e190474031296..253e21e4ef6a97 100644 --- a/src/platform/nxp/mcxw71_k32w1/BUILD.gn +++ b/src/platform/nxp/mcxw71_k32w1/BUILD.gn @@ -32,10 +32,10 @@ assert(chip_with_low_power == 0 || source_set("nxp_factory_data") { sources = [ - "../common/legacy/FactoryDataDriver.cpp", - "../common/legacy/FactoryDataProvider.cpp", - "FactoryDataDriverImpl.cpp", - "FactoryDataProviderImpl.cpp", + "../common/factory_data/legacy/FactoryDataDriver.cpp", + "../common/factory_data/legacy/FactoryDataDriverImpl.cpp", + "../common/factory_data/legacy/FactoryDataProvider.cpp", + "../common/factory_data/legacy/FactoryDataProviderImpl.cpp", ] public = [ @@ -43,7 +43,7 @@ source_set("nxp_factory_data") { "${chip_root}/src/credentials/CertificationDeclaration.h", ] - defines = [ "PLATFORM_FACTORY_DATA_PROVIDER_IMPL_HEADER=\"platform/nxp/mcxw71_k32w1/FactoryDataProviderImpl.h\"" ] + defines = [ "PLATFORM_FACTORY_DATA_PROVIDER_IMPL_HEADER=\"platform/nxp/common/factory_data/legacy/FactoryDataProviderImpl.h\"" ] deps = [ ":nxp_platform", @@ -52,23 +52,23 @@ source_set("nxp_factory_data") { } source_set("nxp_ota") { - public = [ "../common/legacy/OTAImageProcessorImpl.h" ] + public = [ "../common/ota/OTAImageProcessorImpl.h" ] sources = [ - "../common/legacy/OTAImageProcessorImpl.cpp", - "../common/legacy/OTAImageProcessorImpl.h", - "../common/legacy/OTATlvProcessor.cpp", - "../common/legacy/OTATlvProcessor.h", - "OTAFirmwareProcessor.cpp", - "OTAFirmwareProcessor.h", - "OTAHooks.cpp", + "../common/ota/OTAFirmwareProcessor.cpp", + "../common/ota/OTAFirmwareProcessor.h", + "../common/ota/OTAHooks.cpp", + "../common/ota/OTAImageProcessorImpl.cpp", + "../common/ota/OTAImageProcessorImpl.h", + "../common/ota/OTATlvProcessor.cpp", + "../common/ota/OTATlvProcessor.h", ] if (chip_with_factory_data == 1 && chip_enable_ota_factory_data_processor == 1) { sources += [ - "../common/legacy/OTAFactoryDataProcessor.cpp", - "../common/legacy/OTAFactoryDataProcessor.h", + "../common/ota/OTAFactoryDataProcessor.cpp", + "../common/ota/OTAFactoryDataProcessor.h", ] } @@ -78,15 +78,25 @@ source_set("nxp_ota") { ] } +config("nxp_platform_config") { + include_dirs = [ + ".", + "../common/ble", + "../common/crypto", + "../common/factory_data/legacy", + "../common/ota", + ] +} + static_library("nxp_platform") { deps = [] defines = [ "CHIP_DEVICE_K32W1=1" ] sources = [ "../../SingletonConfigurationManager.cpp", - "../common/legacy/BLEManagerCommon.cpp", - "../common/legacy/BLEManagerCommon.h", - "BLEManagerImpl.cpp", + "../common/ble/BLEManagerCommon.cpp", + "../common/ble/BLEManagerCommon.h", + "../common/ble/BLEManagerImpl.cpp", "BLEManagerImpl.h", "CHIPDevicePlatformConfig.h", "CHIPDevicePlatformEvent.h", @@ -99,7 +109,6 @@ static_library("nxp_platform") { "PlatformManagerImpl.cpp", "PlatformManagerImpl.h", "SystemTimeSupport.cpp", - "ble_function_mux.c", ] if (chip_key_storage == "fwk_nvm") { @@ -151,6 +160,7 @@ static_library("nxp_platform") { "${chip_root}/src/credentials/examples/DeviceAttestationCredsExample.h", "${chip_root}/src/credentials/examples/ExampleDACs.h", "${chip_root}/src/credentials/examples/ExamplePAI.h", + "${chip_root}/src/platform/nxp/common/crypto/PersistentStorageOpKeystoreS200.h", "${chip_root}/src/platform/nxp/mcxw71_k32w1/BLEManagerImpl.h", "${chip_root}/src/platform/nxp/mcxw71_k32w1/SMU2Manager.h", ] @@ -163,9 +173,9 @@ static_library("nxp_platform") { if (chip_crypto == "platform") { sources += [ - "CHIPCryptoPalK32W1.cpp", - "K32W1PersistentStorageOpKeystore.cpp", - "K32W1PersistentStorageOpKeystore.h", + "../common/crypto/CHIPCryptoPalS200.cpp", + "../common/crypto/PersistentStorageOpKeystoreS200.cpp", + "../common/crypto/PersistentStorageOpKeystoreS200.h", ] if (chip_with_ot_cli == 1) { @@ -208,4 +218,6 @@ static_library("nxp_platform") { "${chip_root}/src/platform:syscalls_stub", "${chip_root}/src/platform/logging:headers", ] + + public_configs = [ ":nxp_platform_config" ] } diff --git a/src/platform/nxp/mcxw71_k32w1/ble_function_mux.c b/src/platform/nxp/mcxw71_k32w1/ble_function_mux.c deleted file mode 100644 index ed3a643b8bdb9b..00000000000000 --- a/src/platform/nxp/mcxw71_k32w1/ble_function_mux.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * Copyright (c) 2020 Nest Labs, Inc. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * Provides an implementation for BLE Host NVM functions - */ -#include "assert.h" -#include "ble_constants.h" -#include "fsl_os_abstraction.h" -#include "gap_interface.h" -#include "gatt_database.h" - -#include "ble_constants.h" -#include "gatt_db_dynamic.h" - -#include "ble_function_mux.h" - -/* Security Manager */ -#define smpEdiv 0x1F99 -#define mcEncryptionKeySize_c 16 - -/* LTK */ -static uint8_t smpLtk[gcSmpMaxLtkSize_c] = { 0xD6, 0x93, 0xE8, 0xA4, 0x23, 0x55, 0x48, 0x99, - 0x1D, 0x77, 0x61, 0xE6, 0x63, 0x2B, 0x10, 0x8E }; - -/* RAND*/ -static uint8_t smpRand[gcSmpMaxRandSize_c] = { 0x26, 0x1E, 0xF6, 0x09, 0x97, 0x2E, 0xAD, 0x7E }; - -/* IRK */ -static uint8_t smpIrk[gcSmpIrkSize_c] = { 0x0A, 0x2D, 0xF4, 0x65, 0xE3, 0xBD, 0x7B, 0x49, - 0x1E, 0xB4, 0xC0, 0x95, 0x95, 0x13, 0x46, 0x73 }; - -/* CSRK */ -static uint8_t smpCsrk[gcSmpCsrkSize_c] = { 0x90, 0xD5, 0x06, 0x95, 0x92, 0xED, 0x91, 0xD7, - 0xA8, 0x9E, 0x2C, 0xDC, 0x4A, 0x93, 0x5B, 0xF9 }; - -gapSmpKeys_t gSmpKeys = { - .cLtkSize = mcEncryptionKeySize_c, - .aLtk = (void *) smpLtk, - .aIrk = (void *) smpIrk, - .aCsrk = (void *) smpCsrk, - .aRand = (void *) smpRand, - .cRandSize = gcSmpMaxRandSize_c, - .ediv = smpEdiv, -}; - -/******************************************************************************* - * Functions needed by the BLE stack - ******************************************************************************/ -void App_NvmRead(uint8_t mEntryIdx, void * pBondHeader, void * pBondDataDynamic, void * pBondDataStatic, void * pBondDataDeviceInfo, - void * pBondDataDescriptor, uint8_t mDescriptorIndex) -{ - NOT_USED(mEntryIdx); - NOT_USED(pBondHeader); - NOT_USED(pBondDataDynamic); - NOT_USED(pBondDataStatic); - NOT_USED(pBondDataDeviceInfo); - NOT_USED(pBondDataDescriptor); - NOT_USED(mDescriptorIndex); -} - -void App_NvmWrite(uint8_t mEntryIdx, void * pBondHeader, void * pBondDataDynamic, void * pBondDataStatic, - void * pBondDataDeviceInfo, void * pBondDataDescriptor, uint8_t mDescriptorIndex) -{ - NOT_USED(mEntryIdx); - NOT_USED(pBondHeader); - NOT_USED(pBondDataDynamic); - NOT_USED(pBondDataStatic); - NOT_USED(pBondDataDeviceInfo); - NOT_USED(pBondDataDescriptor); - NOT_USED(mDescriptorIndex); -} - -void App_NvmErase(uint8_t mEntryIdx) -{ - NOT_USED(mEntryIdx); -} diff --git a/src/platform/nxp/mcxw71_k32w1/ble_function_mux.h b/src/platform/nxp/mcxw71_k32w1/ble_function_mux.h deleted file mode 100644 index 8b9417d8b54e13..00000000000000 --- a/src/platform/nxp/mcxw71_k32w1/ble_function_mux.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Nest Labs, Inc. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * Provides an implementation for BLE Host NVM functions - */ - -#ifndef BLE_FUNCTION_MUX_H -#define BLE_FUNCTION_MUX_H - -typedef enum -{ - kBleFuncMux_AppMode_None, - kBleFuncMux_AppMode_Ota -} ble_func_mux_app_mode_t; - -#endif diff --git a/src/platform/nxp/mcxw71_k32w1/gatt_db.h b/src/platform/nxp/mcxw71_k32w1/gatt_db.h deleted file mode 100644 index 604fcfb61a7ba1..00000000000000 --- a/src/platform/nxp/mcxw71_k32w1/gatt_db.h +++ /dev/null @@ -1,30 +0,0 @@ -PRIMARY_SERVICE(service_gatt, gBleSig_GenericAttributeProfile_d) -CHARACTERISTIC(char_service_changed, gBleSig_GattServiceChanged_d, (gGattCharPropRead_c | gGattCharPropNotify_c)) -VALUE(value_service_changed, gBleSig_GattServiceChanged_d, (gPermissionNone_c), 4, 0x00, 0x00, 0x00, 0x00) -CCCD(cccd_service_changed) - -PRIMARY_SERVICE(service_gap, gBleSig_GenericAccessProfile_d) -CHARACTERISTIC(char_device_name, gBleSig_GapDeviceName_d, (gGattCharPropRead_c)) -VALUE(value_device_name, gBleSig_GapDeviceName_d, (gPermissionFlagReadable_c), 16, "NXP_ELOCK_DEMO") -CHARACTERISTIC(char_appearance, gBleSig_GapAppearance_d, (gGattCharPropRead_c)) -VALUE(value_appearance, gBleSig_GapAppearance_d, (gPermissionFlagReadable_c), 2, 0x00, 0x00) - -PRIMARY_SERVICE(service_chipoble, gChipoBleService_d) -CHARACTERISTIC_UUID128(chipoble_rx, uuid_chipoble_rx, (gGattCharPropWrite_c)) -VALUE_UUID128_VARLEN(value_chipoble_rx, uuid_chipoble_rx, (gPermissionFlagWritable_c), gAttMaxMtu_c - 3, gAttMaxMtu_c - 3, 0x00) -CHARACTERISTIC_UUID128(chipoble_tx, uuid_chipoble_tx, (gGattCharPropIndicate_c | gGattCharPropRead_c)) -VALUE_UUID128_VARLEN(value_chipoble_tx, uuid_chipoble_tx, (gPermissionFlagReadable_c), gAttMaxMtu_c - 3, gAttMaxMtu_c - 3, 0x00) -CCCD(cccd_chipoble_tx) -CHARACTERISTIC_UUID128(chipoble_c3, uuid_chipoble_c3, (gGattCharPropRead_c)) -VALUE_UUID128_VARLEN(value_chipoble_c3, uuid_chipoble_c3, (gPermissionFlagReadable_c), gAttMaxReadDataSize_d(gAttMaxValueLength_c), - gAttMaxReadDataSize_d(gAttMaxValueLength_c), 0x00) - -PRIMARY_SERVICE(service_device_info, gBleSig_DeviceInformationService_d) -CHARACTERISTIC(char_model_no, gBleSig_ModelNumberString_d, (gGattCharPropRead_c)) -VALUE(value_model_no, gBleSig_ModelNumberString_d, (gPermissionFlagReadable_c), 15, "Chip ELock Demo") -CHARACTERISTIC(char_serial_no, gBleSig_SerialNumberString_d, (gGattCharPropRead_c)) -VALUE(value_serial_no, gBleSig_SerialNumberString_d, (gPermissionFlagReadable_c), 7, "BLESN01") -CHARACTERISTIC(char_fw_rev, gBleSig_FirmwareRevisionString_d, (gGattCharPropRead_c)) -VALUE(value_fw_rev, gBleSig_FirmwareRevisionString_d, (gPermissionFlagReadable_c), 5, "1.1.1") -CHARACTERISTIC(char_sw_rev, gBleSig_SoftwareRevisionString_d, (gGattCharPropRead_c)) -VALUE(value_sw_rev, gBleSig_SoftwareRevisionString_d, (gPermissionFlagReadable_c), 5, "1.1.4") diff --git a/src/platform/nxp/mcxw71_k32w1/gatt_uuid128.h b/src/platform/nxp/mcxw71_k32w1/gatt_uuid128.h deleted file mode 100644 index 938968b1943ce2..00000000000000 --- a/src/platform/nxp/mcxw71_k32w1/gatt_uuid128.h +++ /dev/null @@ -1,26 +0,0 @@ -/* -* Declare all custom 128-bit UUIDs here using the format: -* -* UUID128(name, bytes) -* -* where: -* -name : an unique tag for the newly defined UUID; - will be used to reference this UUID when defining - services and characteristics in <> -* -bytes: 16 bytes representing the 128-bit value -* -* One definition per line. No semicolon required after each definition. -* -* example: -* UUID128(uuid_service_robot_characteristics, 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF, 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, -0xCD, 0xEF) -* UUID128(uuid_char_robot_direction, 0x12, 0x34, 0x50, 0x00, 0x90, 0xAB, 0xCD, 0xEF, 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, -0xEF) -*/ -/* Services */ - -#define gChipoBleService_d 0xFFF6 - -UUID128(uuid_chipoble_tx, 0x12, 0x9D, 0x9F, 0x42, 0x9C, 0x4F, 0x9F, 0x95, 0x59, 0x45, 0x3D, 0x26, 0xF5, 0x2E, 0xEE, 0x18) -UUID128(uuid_chipoble_rx, 0x11, 0x9D, 0x9F, 0x42, 0x9C, 0x4F, 0x9F, 0x95, 0x59, 0x45, 0x3D, 0x26, 0xF5, 0x2E, 0xEE, 0x18) -UUID128(uuid_chipoble_c3, 0x04, 0x8f, 0x21, 0x83, 0x8a, 0x74, 0x7d, 0xb8, 0xf2, 0x45, 0x72, 0x87, 0x38, 0x02, 0x63, 0x64) diff --git a/third_party/nxp/nxp_matter_support b/third_party/nxp/nxp_matter_support index f6329bb2280c8b..21d18627ad4671 160000 --- a/third_party/nxp/nxp_matter_support +++ b/third_party/nxp/nxp_matter_support @@ -1 +1 @@ -Subproject commit f6329bb2280c8bc3f50f6d39e79191499e67cffa +Subproject commit 21d18627ad46710dfb863080c1047cdbaf556d25