diff --git a/docs/guides/infineon_p6_software_update.md b/docs/guides/infineon_p6_software_update.md index ae88abc5701260..136f577dfb6301 100644 --- a/docs/guides/infineon_p6_software_update.md +++ b/docs/guides/infineon_p6_software_update.md @@ -23,11 +23,18 @@ option to the build script. - Build the P6 OTA Requestor application from the chip root dir: - $ ./examples//p6/ota_base_build.sh + ``` + $ scripts/build/build_examples.py --enable-flashbundle --target infineon-p6-lock-ota build + $ third_party/p6/p6_sdk/ota/ota_base_build.sh out/infineon-p6-lock-ota chip-p6-lock-example + ``` -- Build the P6 OTA Update application from the chip root dir: +- Build the P6 OTA Update application from the chip root dir and create OTA + file - $ ./examples//p6/ota_update_build.sh + ``` + $ scripts/build/build_examples.py --enable-flashbundle --no-log-timestamps --target infineon-p6-lock-ota-updateimage build + $ third_party/p6/p6_sdk/ota/ota_update_build.sh out/infineon-p6-lock-ota-updateimage chip-p6-lock-example + ``` * Additionally a pre-compiled bootloader must be flashed to the board using [Cypress Programmer](https://softwaretools.infineon.com/tools/com.ifx.tb.tool.cypressprogrammer). @@ -40,7 +47,7 @@ option to the build script. ``` rm -r /tmp/chip_* - ./out/debug/chip-ota-provider-app -f chip-p6-lighting-example.ota + ./out/debug/chip-ota-provider-app -f chip-p6-lock-example.ota ``` * In a separate terminal run the chip-tool commands to provision the Provider: diff --git a/examples/all-clusters-app/p6/BUILD.gn b/examples/all-clusters-app/p6/BUILD.gn index 07dae88a3cf33d..1ad3458e14464b 100644 --- a/examples/all-clusters-app/p6/BUILD.gn +++ b/examples/all-clusters-app/p6/BUILD.gn @@ -75,8 +75,6 @@ config("p6_ota_config") { if (build_update_image) { defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION=2" ] - } else { - defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION=1" ] } } @@ -98,23 +96,6 @@ p6_sdk_sources("all_clusters_app_sdk_sources") { public_configs = [ "${chip_root}/third_party/p6:p6_sdk_config" ] if (chip_enable_ota_requestor) { - sources += [ - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/bootutil/src/bootutil_misc.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/cy_flash_map.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/cy_flash_psoc6.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/cy_smif_psoc6.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/mem_config/mem_config_sfdp.c", - ] - include_dirs += [ - "${p6_sdk_root}/ota/config", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/mem_config/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/include/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/include/flash_map_backend/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/sysflash/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/bootutil/include", - ] public_configs += [ ":p6_ota_config" ] } } diff --git a/examples/all-clusters-app/p6/README.md b/examples/all-clusters-app/p6/README.md index 1a859b7944dd79..d218c24c97dc46 100644 --- a/examples/all-clusters-app/p6/README.md +++ b/examples/all-clusters-app/p6/README.md @@ -53,16 +53,13 @@ will then join the network. * Build the example application: - ``` - $ ./scripts/examples/gn_p6_example.sh ./examples/all-clusters-app/p6 out/clusters_app_p6 - ``` + $ source scripts/activate.sh + $ scripts/build/build_examples.py --no-log-timestamps --target 'infineon-p6-all-clusters' build - To delete generated executable, libraries and object files use: - ``` $ cd ~/connectedhomeip $ rm -rf out/ - ``` @@ -74,10 +71,8 @@ will then join the network. - On the command line: - ``` $ cd ~/connectedhomeip - $ python3 out/clusters_app_p6/chip-p6-clusters-example.flash.py - ``` + $ python3 out/infineon-p6-all-clusters/chip-p6-clusters-example.flash.py @@ -94,16 +89,12 @@ perform commissioning and cluster control. - Set up python controller. - ``` $ cd {path-to-connectedhomeip} $ ./scripts/examples/gn_build_example.sh examples/chip-tool out/debug - ``` - Execute the controller. - ``` $ ./out/debug/chip-tool - ``` @@ -112,7 +103,6 @@ perform commissioning and cluster control. Run the built executable and pass it the discriminator and pairing code of the remote device, as well as the network credentials to use. - ``` $ ./out/debug/chip-tool pairing ble-wifi 1234 ${SSID} ${PASSWORD} 20202021 3840 Parameters: @@ -121,7 +111,6 @@ remote device, as well as the network credentials to use. 3. Node ID: 1234 (you can assign any node id) 4. SSID : Wi-Fi SSID 5. PASSWORD : Wi-Fi Password - ``` @@ -130,11 +119,9 @@ remote device, as well as the network credentials to use. Raspberry Pi 4 BLE connection issues can be avoided by running the following commands. These power cycle the BlueTooth hardware and disable BR/EDR mode. - ``` - sudo btmgmt -i hci0 power off - sudo btmgmt -i hci0 bredr off - sudo btmgmt -i hci0 power on - ``` + $ sudo btmgmt -i hci0 power off + $ sudo btmgmt -i hci0 bredr off + $ sudo btmgmt -i hci0 power on ## OTA Software Update diff --git a/examples/all-clusters-app/p6/include/CHIPProjectConfig.h b/examples/all-clusters-app/p6/include/CHIPProjectConfig.h index f582a28fce06b5..3f304a5f55728c 100644 --- a/examples/all-clusters-app/p6/include/CHIPProjectConfig.h +++ b/examples/all-clusters-app/p6/include/CHIPProjectConfig.h @@ -38,6 +38,21 @@ #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 #endif +/* The ProductID attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8003 + +/* The ProductName attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME "P6-CYW43012 All Clusters" + +/* The HardwareVersionString attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING "P6-43012" + +/* The HardwareVersion attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION 43012 + +/* The SoftwareVersion attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 1 + // For convenience, Chip Security Test Mode can be enabled and the // requirement for authentication in various protocols can be disabled. // @@ -54,7 +69,7 @@ * physical device, a change to its packaging, and/or a change to its marketing presentation. * This value is generally *not* incremented for device software versions. */ -#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1 +#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 43012 /** * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING @@ -64,7 +79,7 @@ * {MAJOR_VERSION}.0d{MINOR_VERSION} */ #ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING -#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA" +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.0" #endif /** * CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/examples/all-clusters-app/p6/ota_base_build.sh b/examples/all-clusters-app/p6/ota_base_build.sh deleted file mode 100755 index 61bb808e3c1412..00000000000000 --- a/examples/all-clusters-app/p6/ota_base_build.sh +++ /dev/null @@ -1,8 +0,0 @@ -OUT_DIR=out/all-clusters-app/ -ANYCLOUD_DIR=third_party/p6/p6_sdk/libs/anycloud-ota/ - -scripts/examples/gn_p6_example.sh examples/all-clusters-app/p6 "$OUT_DIR" chip_enable_ota_requestor=true - -mv "$OUT_DIR"/chip-p6-clusters-example.hex "$OUT_DIR"/chip-p6-clusters-example.unsigned.hex - -./"$ANYCLOUD_DIR"/scripts/sign_script.bash "$OUT_DIR"/ chip-p6-clusters-example python3 arm-none-eabi-objcopy "-O ihex" "" "$ANYCLOUD_DIR"/source/mcuboot/scripts/ imgtool_v1.7.0/imgtool.py create 0xFF 0x400 3584 1.0.0 0x00018000 0x001C0000 arm-none-eabi-objcopy "" diff --git a/examples/all-clusters-app/p6/ota_update_build.sh b/examples/all-clusters-app/p6/ota_update_build.sh deleted file mode 100755 index 58f870977fd97b..00000000000000 --- a/examples/all-clusters-app/p6/ota_update_build.sh +++ /dev/null @@ -1,14 +0,0 @@ -OUT_DIR=out/all-clusters-app-ota -ANYCLOUD_DIR=third_party/p6/p6_sdk/libs/anycloud-ota/ - -./scripts/examples/gn_p6_example.sh examples/all-clusters-app/p6 "$OUT_DIR" chip_enable_ota_requestor=true build_update_image=true - -mv "$OUT_DIR"/chip-p6-clusters-example.hex "$OUT_DIR"/chip-p6-clusters-example.unsigned.hex - -./"$ANYCLOUD_DIR"/scripts/sign_script.bash "$OUT_DIR"/ chip-p6-clusters-example python3 arm-none-eabi-objcopy "-O ihex" "" "$ANYCLOUD_DIR"/source/mcuboot/scripts/ imgtool_v1.7.0/imgtool.py sign 0xFF 0x400 3584 1.0.0 0x00018000 0x001C0000 arm-none-eabi-objcopy "-k $ANYCLOUD_DIR/source/mcuboot/keys/cypress-test-ec-p256.pem" - -if [ -f "$OUT_DIR"/chip-p6-clusters-example.ota ]; then - rm "$OUT_DIR"/chip-p6-clusters-example.ota -fi - -src/app/ota_image_tool.py create -v 0xFFF1 -p 0x8000 -vn 2 -vs "2.0" -da sha256 "$OUT_DIR"/chip-p6-clusters-example.bin "$OUT_DIR"/chip-p6-clusters-example.ota diff --git a/examples/all-clusters-app/p6/src/AppTask.cpp b/examples/all-clusters-app/p6/src/AppTask.cpp index 4b99db7e7f38d3..bdbc976c10b5ce 100644 --- a/examples/all-clusters-app/p6/src/AppTask.cpp +++ b/examples/all-clusters-app/p6/src/AppTask.cpp @@ -50,9 +50,7 @@ #include #include #include -extern "C" { -#include "cy_smif_psoc6.h" -} + using chip::BDXDownloader; using chip::CharSpan; using chip::DefaultOTARequestor; @@ -60,7 +58,7 @@ using chip::FabricIndex; using chip::GetRequestorInstance; using chip::NodeId; using chip::OTADownloader; -using chip::OTAImageProcessorImpl; +using chip::DeviceLayer::OTAImageProcessorImpl; using chip::System::Layer; using namespace ::chip; @@ -314,35 +312,16 @@ bool lowPowerClusterSleep() #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR void AppTask::InitOTARequestor() { - CHIP_ERROR err = CHIP_NO_ERROR; SetRequestorInstance(&gRequestorCore); + ConfigurationMgr().StoreSoftwareVersion(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); gRequestorStorage.Init(chip::Server::GetInstance().GetPersistentStorage()); gRequestorCore.Init(chip::Server::GetInstance(), gRequestorStorage, gRequestorUser, gDownloader); gImageProcessor.SetOTADownloader(&gDownloader); gDownloader.SetImageProcessorDelegate(&gImageProcessor); - gRequestorUser.Init(&gRequestorCore, &gImageProcessor); - uint32_t savedSoftwareVersion; - err = ConfigurationMgr().GetSoftwareVersion(savedSoftwareVersion); - if (err != CHIP_NO_ERROR) - { - P6_LOG("Can't get saved software version"); - appError(err); - } - - if (savedSoftwareVersion != CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION) - { - ConfigurationMgr().StoreSoftwareVersion(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); - - P6_LOG("Confirming update to version: %u", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); - chip::OTARequestorInterface * requestor = chip::GetRequestorInstance(); - if (requestor != nullptr) - { - requestor->NotifyUpdateApplied(); - } - } + gRequestorUser.Init(&gRequestorCore, &gImageProcessor); P6_LOG("Current Software Version: %u", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); - P6_LOG("Current Firmware Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); + P6_LOG("Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); } #endif diff --git a/examples/all-clusters-app/p6/src/main.cpp b/examples/all-clusters-app/p6/src/main.cpp index d365f9ff8220d4..7f38b516b93fe1 100644 --- a/examples/all-clusters-app/p6/src/main.cpp +++ b/examples/all-clusters-app/p6/src/main.cpp @@ -143,7 +143,7 @@ int main(void) #endif P6_LOG("==================================================\r\n"); - P6_LOG("chip-p6-all-clusters-example starting\r\n"); + P6_LOG("chip-p6-all-clusters-example starting Version %d\r\n", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); P6_LOG("==================================================\r\n"); /* Start the FreeRTOS scheduler */ diff --git a/examples/all-clusters-minimal-app/p6/BUILD.gn b/examples/all-clusters-minimal-app/p6/BUILD.gn index b7e60c58938cec..980085b0de4dab 100644 --- a/examples/all-clusters-minimal-app/p6/BUILD.gn +++ b/examples/all-clusters-minimal-app/p6/BUILD.gn @@ -75,8 +75,6 @@ config("p6_ota_config") { if (build_update_image) { defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION=2" ] - } else { - defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION=1" ] } } @@ -98,23 +96,6 @@ p6_sdk_sources("all_clusters_app_sdk_sources") { public_configs = [ "${chip_root}/third_party/p6:p6_sdk_config" ] if (chip_enable_ota_requestor) { - sources += [ - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/bootutil/src/bootutil_misc.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/cy_flash_map.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/cy_flash_psoc6.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/cy_smif_psoc6.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/mem_config/mem_config_sfdp.c", - ] - include_dirs += [ - "${p6_sdk_root}/ota/config", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/mem_config/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/include/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/include/flash_map_backend/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/sysflash/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/bootutil/include", - ] public_configs += [ ":p6_ota_config" ] } } diff --git a/examples/all-clusters-minimal-app/p6/README.md b/examples/all-clusters-minimal-app/p6/README.md index c6b752d209a6ca..730891ccef53a1 100644 --- a/examples/all-clusters-minimal-app/p6/README.md +++ b/examples/all-clusters-minimal-app/p6/README.md @@ -53,16 +53,13 @@ will then join the network. * Build the example application: - ``` - $ ./scripts/examples/gn_p6_example.sh ./examples/all-clusters-minimal-app/p6 out/minimal_clusters_app_p6 - ``` + $ source scripts/activate.sh + $ scripts/build/build_examples.py --no-log-timestamps --target 'infineon-p6-all-clusters-minimal' build - To delete generated executable, libraries and object files use: - ``` $ cd ~/connectedhomeip $ rm -rf out/ - ``` @@ -74,10 +71,8 @@ will then join the network. - On the command line: - ``` $ cd ~/connectedhomeip - $ python3 out/clusters_app_p6/chip-p6-clusters-minimal-example.flash.py - ``` + $ python3 out/infineon-p6-all-clusters-minimal/chip-p6-clusters-minimal-example.flash.py @@ -94,16 +89,12 @@ perform commissioning and cluster control. - Set up python controller. - ``` $ cd {path-to-connectedhomeip} $ ./scripts/examples/gn_build_example.sh examples/chip-tool out/debug - ``` - Execute the controller. - ``` $ ./out/debug/chip-tool - ``` @@ -112,7 +103,6 @@ perform commissioning and cluster control. Run the built executable and pass it the discriminator and pairing code of the remote device, as well as the network credentials to use. - ``` $ ./out/debug/chip-tool pairing ble-wifi 1234 ${SSID} ${PASSWORD} 20202021 3840 Parameters: @@ -121,7 +111,6 @@ remote device, as well as the network credentials to use. 3. Node ID: 1234 (you can assign any node id) 4. SSID : Wi-Fi SSID 5. PASSWORD : Wi-Fi Password - ``` @@ -130,11 +119,9 @@ remote device, as well as the network credentials to use. Raspberry Pi 4 BLE connection issues can be avoided by running the following commands. These power cycle the BlueTooth hardware and disable BR/EDR mode. - ``` - sudo btmgmt -i hci0 power off - sudo btmgmt -i hci0 bredr off - sudo btmgmt -i hci0 power on - ``` + $ sudo btmgmt -i hci0 power off + $ sudo btmgmt -i hci0 bredr off + $ sudo btmgmt -i hci0 power on ## OTA Software Update diff --git a/examples/all-clusters-minimal-app/p6/include/CHIPProjectConfig.h b/examples/all-clusters-minimal-app/p6/include/CHIPProjectConfig.h index f582a28fce06b5..69252cf8c260d1 100644 --- a/examples/all-clusters-minimal-app/p6/include/CHIPProjectConfig.h +++ b/examples/all-clusters-minimal-app/p6/include/CHIPProjectConfig.h @@ -38,6 +38,21 @@ #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 #endif +/* The ProductID attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8004 + +/* The ProductName attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME "P6-CYW43012 Clusters Minimal" + +/* The HardwareVersionString attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING "P6-43012" + +/* The HardwareVersion attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION 43012 + +/* The SoftwareVersion attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 1 + // For convenience, Chip Security Test Mode can be enabled and the // requirement for authentication in various protocols can be disabled. // @@ -54,7 +69,7 @@ * physical device, a change to its packaging, and/or a change to its marketing presentation. * This value is generally *not* incremented for device software versions. */ -#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1 +#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 43012 /** * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING @@ -64,7 +79,7 @@ * {MAJOR_VERSION}.0d{MINOR_VERSION} */ #ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING -#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA" +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.0" #endif /** * CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/examples/all-clusters-minimal-app/p6/ota_base_build.sh b/examples/all-clusters-minimal-app/p6/ota_base_build.sh deleted file mode 100755 index c49fad50303fdf..00000000000000 --- a/examples/all-clusters-minimal-app/p6/ota_base_build.sh +++ /dev/null @@ -1,8 +0,0 @@ -OUT_DIR=out/all-clusters-minimal-app/ -ANYCLOUD_DIR=third_party/p6/p6_sdk/libs/anycloud-ota/ - -scripts/examples/gn_p6_example.sh examples/all-clusters-minimal-app/p6 "$OUT_DIR" chip_enable_ota_requestor=true - -mv "$OUT_DIR"/chip-p6-clusters-minimal-example.hex "$OUT_DIR"/chip-p6-clusters-minimal-example.unsigned.hex - -./"$ANYCLOUD_DIR"/scripts/sign_script.bash "$OUT_DIR"/ chip-p6-clusters-minimal-example python3 arm-none-eabi-objcopy "-O ihex" "" "$ANYCLOUD_DIR"/source/mcuboot/scripts/ imgtool_v1.7.0/imgtool.py create 0xFF 0x400 3584 1.0.0 0x00018000 0x001C0000 arm-none-eabi-objcopy "" diff --git a/examples/all-clusters-minimal-app/p6/ota_update_build.sh b/examples/all-clusters-minimal-app/p6/ota_update_build.sh deleted file mode 100755 index 2aa7902556bd62..00000000000000 --- a/examples/all-clusters-minimal-app/p6/ota_update_build.sh +++ /dev/null @@ -1,13 +0,0 @@ -OUT_DIR=out/all-clusters-minimal-app-ota -ANYCLOUD_DIR=third_party/p6/p6_sdk/libs/anycloud-ota/ - -./scripts/examples/gn_p6_example.sh examples/all-clusters-minimal-app/p6 "$OUT_DIR" chip_enable_ota_requestor=true build_update_image=true - -mv "$OUT_DIR"/chip-p6-clusters-minimal-example.hex "$OUT_DIR"/chip-p6-clusters-minimal-example.unsigned.hex - -./"$ANYCLOUD_DIR"/scripts/sign_script.bash "$OUT_DIR"/ chip-p6-clusters-minimal-example python3 arm-none-eabi-objcopy "-O ihex" "" "$ANYCLOUD_DIR"/source/mcuboot/scripts/ imgtool_v1.7.0/imgtool.py sign 0xFF 0x400 3584 1.0.0 0x00018000 0x001C0000 arm-none-eabi-objcopy "-k $ANYCLOUD_DIR/source/mcuboot/keys/cypress-test-ec-p256.pem" - -if [ -f "$OUT_DIR"/chip-p6-clusters-minimal-example.ota ]; then - rm "$OUT_DIR"/chip-p6-clusters-minimal-example.ota -fi -src/app/ota_image_tool.py create -v 0xFFF1 -p 0x8000 -vn 2 -vs "2.0" -da sha256 "$OUT_DIR"/chip-p6-clusters-minimal-example.bin "$OUT_DIR"/chip-p6-clusters-minimal-example.ota diff --git a/examples/all-clusters-minimal-app/p6/src/AppTask.cpp b/examples/all-clusters-minimal-app/p6/src/AppTask.cpp index c8717c30740357..b8b51b9ed47e06 100644 --- a/examples/all-clusters-minimal-app/p6/src/AppTask.cpp +++ b/examples/all-clusters-minimal-app/p6/src/AppTask.cpp @@ -50,9 +50,7 @@ #include #include #include -extern "C" { -#include "cy_smif_psoc6.h" -} + using chip::BDXDownloader; using chip::CharSpan; using chip::DefaultOTARequestor; @@ -60,7 +58,7 @@ using chip::FabricIndex; using chip::GetRequestorInstance; using chip::NodeId; using chip::OTADownloader; -using chip::OTAImageProcessorImpl; +using chip::DeviceLayer::OTAImageProcessorImpl; using chip::System::Layer; using namespace ::chip; @@ -314,35 +312,16 @@ bool lowPowerClusterSleep() #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR void AppTask::InitOTARequestor() { - CHIP_ERROR err = CHIP_NO_ERROR; SetRequestorInstance(&gRequestorCore); + ConfigurationMgr().StoreSoftwareVersion(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); gRequestorStorage.Init(chip::Server::GetInstance().GetPersistentStorage()); gRequestorCore.Init(chip::Server::GetInstance(), gRequestorStorage, gRequestorUser, gDownloader); gImageProcessor.SetOTADownloader(&gDownloader); gDownloader.SetImageProcessorDelegate(&gImageProcessor); - gRequestorUser.Init(&gRequestorCore, &gImageProcessor); - uint32_t savedSoftwareVersion; - err = ConfigurationMgr().GetSoftwareVersion(savedSoftwareVersion); - if (err != CHIP_NO_ERROR) - { - P6_LOG("Can't get saved software version"); - appError(err); - } - - if (savedSoftwareVersion != CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION) - { - ConfigurationMgr().StoreSoftwareVersion(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); - - P6_LOG("Confirming update to version: %u", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); - chip::OTARequestorInterface * requestor = chip::GetRequestorInstance(); - if (requestor != nullptr) - { - requestor->NotifyUpdateApplied(); - } - } + gRequestorUser.Init(&gRequestorCore, &gImageProcessor); P6_LOG("Current Software Version: %u", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); - P6_LOG("Current Firmware Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); + P6_LOG("Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); } #endif diff --git a/examples/all-clusters-minimal-app/p6/src/main.cpp b/examples/all-clusters-minimal-app/p6/src/main.cpp index d365f9ff8220d4..7f38b516b93fe1 100644 --- a/examples/all-clusters-minimal-app/p6/src/main.cpp +++ b/examples/all-clusters-minimal-app/p6/src/main.cpp @@ -143,7 +143,7 @@ int main(void) #endif P6_LOG("==================================================\r\n"); - P6_LOG("chip-p6-all-clusters-example starting\r\n"); + P6_LOG("chip-p6-all-clusters-example starting Version %d\r\n", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); P6_LOG("==================================================\r\n"); /* Start the FreeRTOS scheduler */ diff --git a/examples/lighting-app/p6/BUILD.gn b/examples/lighting-app/p6/BUILD.gn index d109d59e10cf24..b0619c096dd7e5 100644 --- a/examples/lighting-app/p6/BUILD.gn +++ b/examples/lighting-app/p6/BUILD.gn @@ -75,8 +75,6 @@ config("p6_ota_config") { if (build_update_image) { defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION=2" ] - } else { - defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION=1" ] } } @@ -97,23 +95,6 @@ p6_sdk_sources("lighting_app_sdk_sources") { public_configs = [ "${chip_root}/third_party/p6:p6_sdk_config" ] if (chip_enable_ota_requestor) { - sources += [ - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/bootutil/src/bootutil_misc.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/cy_flash_map.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/cy_flash_psoc6.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/cy_smif_psoc6.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/mem_config/mem_config_sfdp.c", - ] - include_dirs += [ - "${p6_sdk_root}/ota/config", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/mem_config/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/include/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/include/flash_map_backend/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/sysflash/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/bootutil/include", - ] public_configs += [ ":p6_ota_config" ] } } diff --git a/examples/lighting-app/p6/README.md b/examples/lighting-app/p6/README.md index 45d536e0cc40a7..e37894efcafb2d 100644 --- a/examples/lighting-app/p6/README.md +++ b/examples/lighting-app/p6/README.md @@ -50,7 +50,8 @@ will then join the network. * Build the example application: - $ ./scripts/examples/gn_p6_example.sh ./examples/lighting-app/p6 out/lighting_app_p6 + $ source scripts/activate.sh + $ scripts/build/build_examples.py --no-log-timestamps --target 'infineon-p6-light' build - To delete generated executable, libraries and object files use: @@ -68,7 +69,7 @@ will then join the network. - On the command line: $ cd ~/connectedhomeip - $ python3 out/lighting_app_p6/chip-p6-lock-example.flash.py + $ python3 out/infineon-p6-light/chip-p6-lighting-example.flash.py diff --git a/examples/lighting-app/p6/include/CHIPProjectConfig.h b/examples/lighting-app/p6/include/CHIPProjectConfig.h index 2609a4278d28d2..60aa10e99b238d 100644 --- a/examples/lighting-app/p6/include/CHIPProjectConfig.h +++ b/examples/lighting-app/p6/include/CHIPProjectConfig.h @@ -47,7 +47,22 @@ #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 #endif -// define Device type based on the application +/* The ProductID attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8005 + +/* The ProductName attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME "P6-CYW43012 Light" + +/* The HardwareVersionString attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING "P6-43012" + +/* The HardwareVersion attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION 43012 + +/* The SoftwareVersion attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 1 + +/* define Device type based on the application */ #define CHIP_DEVICE_CONFIG_DEVICE_TYPE 257 // 0x0101 Dimmable Bulb // For convenience, Chip Security Test Mode can be enabled and the @@ -76,7 +91,7 @@ * {MAJOR_VERSION}.0d{MINOR_VERSION} */ #ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING -#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA" +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.0" #endif /** * CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/examples/lighting-app/p6/ota_base_build.sh b/examples/lighting-app/p6/ota_base_build.sh deleted file mode 100755 index 5cdaf4d274d11c..00000000000000 --- a/examples/lighting-app/p6/ota_base_build.sh +++ /dev/null @@ -1,8 +0,0 @@ -OUT_DIR=out/lighting-app/ -ANYCLOUD_DIR=third_party/p6/p6_sdk/libs/anycloud-ota/ - -scripts/examples/gn_p6_example.sh examples/lighting-app/p6 "$OUT_DIR" chip_enable_ota_requestor=true - -mv "$OUT_DIR"/chip-p6-lighting-example.hex "$OUT_DIR"/chip-p6-lighting-example.unsigned.hex - -./"$ANYCLOUD_DIR"/scripts/sign_script.bash "$OUT_DIR"/ chip-p6-lighting-example python3 arm-none-eabi-objcopy "-O ihex" "" "$ANYCLOUD_DIR"/source/mcuboot/scripts/ imgtool_v1.7.0/imgtool.py create 0xFF 0x400 3584 1.0.0 0x00018000 0x001C0000 arm-none-eabi-objcopy "" diff --git a/examples/lighting-app/p6/ota_update_build.sh b/examples/lighting-app/p6/ota_update_build.sh deleted file mode 100755 index 1c5c301429b5e0..00000000000000 --- a/examples/lighting-app/p6/ota_update_build.sh +++ /dev/null @@ -1,14 +0,0 @@ -OUT_DIR=out/lighting-app-ota -ANYCLOUD_DIR=third_party/p6/p6_sdk/libs/anycloud-ota/ - -./scripts/examples/gn_p6_example.sh examples/lighting-app/p6 "$OUT_DIR" chip_enable_ota_requestor=true build_update_image=true - -mv "$OUT_DIR"/chip-p6-lighting-example.hex "$OUT_DIR"/chip-p6-lighting-example.unsigned.hex - -./"$ANYCLOUD_DIR"/scripts/sign_script.bash "$OUT_DIR"/ chip-p6-lighting-example python3 arm-none-eabi-objcopy "-O ihex" "" "$ANYCLOUD_DIR"/source/mcuboot/scripts/ imgtool_v1.7.0/imgtool.py sign 0xFF 0x400 3584 1.0.0 0x00018000 0x001C0000 arm-none-eabi-objcopy "-k $ANYCLOUD_DIR/source/mcuboot/keys/cypress-test-ec-p256.pem" - -if [ -f "$OUT_DIR"/chip-p6-lighting-example.ota ]; then - rm "$OUT_DIR"/chip-p6-lighting-example.ota -fi - -src/app/ota_image_tool.py create -v 0xFFF1 -p 0x8000 -vn 2 -vs "2.0" -da sha256 "$OUT_DIR"/chip-p6-lighting-example.bin "$OUT_DIR"/chip-p6-lighting-example.ota diff --git a/examples/lighting-app/p6/src/AppTask.cpp b/examples/lighting-app/p6/src/AppTask.cpp index d6a92f2a8945ee..9e465ec2923eee 100644 --- a/examples/lighting-app/p6/src/AppTask.cpp +++ b/examples/lighting-app/p6/src/AppTask.cpp @@ -48,9 +48,7 @@ #include #include #include -extern "C" { -#include "cy_smif_psoc6.h" -} + using chip::BDXDownloader; using chip::CharSpan; using chip::DefaultOTARequestor; @@ -58,7 +56,7 @@ using chip::FabricIndex; using chip::GetRequestorInstance; using chip::NodeId; using chip::OTADownloader; -using chip::OTAImageProcessorImpl; +using chip::DeviceLayer::OTAImageProcessorImpl; using chip::System::Layer; using namespace ::chip; @@ -572,35 +570,16 @@ void AppTask::UpdateClusterState(intptr_t context) #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR void AppTask::InitOTARequestor() { - CHIP_ERROR err = CHIP_NO_ERROR; SetRequestorInstance(&gRequestorCore); + ConfigurationMgr().StoreSoftwareVersion(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); gRequestorStorage.Init(chip::Server::GetInstance().GetPersistentStorage()); gRequestorCore.Init(chip::Server::GetInstance(), gRequestorStorage, gRequestorUser, gDownloader); gImageProcessor.SetOTADownloader(&gDownloader); gDownloader.SetImageProcessorDelegate(&gImageProcessor); - gRequestorUser.Init(&gRequestorCore, &gImageProcessor); - uint32_t savedSoftwareVersion; - err = ConfigurationMgr().GetSoftwareVersion(savedSoftwareVersion); - if (err != CHIP_NO_ERROR) - { - P6_LOG("Can't get saved software version"); - appError(err); - } - - if (savedSoftwareVersion != CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION) - { - ConfigurationMgr().StoreSoftwareVersion(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); - - P6_LOG("Confirming update to version: %u", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); - chip::OTARequestorInterface * requestor = chip::GetRequestorInstance(); - if (requestor != nullptr) - { - requestor->NotifyUpdateApplied(); - } - } + gRequestorUser.Init(&gRequestorCore, &gImageProcessor); P6_LOG("Current Software Version: %u", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); - P6_LOG("Current Firmware Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); + P6_LOG("Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); } #endif diff --git a/examples/lighting-app/p6/src/main.cpp b/examples/lighting-app/p6/src/main.cpp index 8e4105b8f79356..9c5daa77856b60 100644 --- a/examples/lighting-app/p6/src/main.cpp +++ b/examples/lighting-app/p6/src/main.cpp @@ -142,7 +142,7 @@ int main(void) #endif P6_LOG("==================================================\r\n"); - P6_LOG("chip-p6-lighting-example starting\r\n"); + P6_LOG("chip-p6-lighting-example starting Version %d\r\n", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); P6_LOG("==================================================\r\n"); /* Start the FreeRTOS scheduler */ diff --git a/examples/lock-app/p6/BUILD.gn b/examples/lock-app/p6/BUILD.gn index 1468498c2e093b..d2c45b8c0adc2a 100644 --- a/examples/lock-app/p6/BUILD.gn +++ b/examples/lock-app/p6/BUILD.gn @@ -72,8 +72,6 @@ config("p6_ota_config") { if (build_update_image) { defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION=2" ] - } else { - defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION=1" ] } } p6_sdk_sources("lock_app_sdk_sources") { @@ -94,23 +92,6 @@ p6_sdk_sources("lock_app_sdk_sources") { public_configs = [ "${chip_root}/third_party/p6:p6_sdk_config" ] if (chip_enable_ota_requestor) { - sources += [ - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/bootutil/src/bootutil_misc.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/cy_flash_map.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/cy_flash_psoc6.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/cy_smif_psoc6.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/mem_config/mem_config_sfdp.c", - ] - include_dirs += [ - "${p6_sdk_root}/ota/config", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/mem_config/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/include/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/include/flash_map_backend/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/sysflash/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/bootutil/include", - ] public_configs += [ ":p6_ota_config" ] } } diff --git a/examples/lock-app/p6/README.md b/examples/lock-app/p6/README.md index 36b1ed1a158ed4..345782204802df 100644 --- a/examples/lock-app/p6/README.md +++ b/examples/lock-app/p6/README.md @@ -50,7 +50,8 @@ will then join the network. * Build the example application: - $ ./scripts/examples/gn_p6_example.sh examples/lock-app/p6 out/lock_app_p6 + $ source scripts/activate.sh + $ scripts/build/build_examples.py --no-log-timestamps --target 'infineon-p6-lock' build - To delete generated executable, libraries and object files use: @@ -68,7 +69,7 @@ will then join the network. - On the command line: $ cd ~/connectedhomeip - $ python3 out/lock_app_p6/chip-p6-lock-example.flash.py + $ python3 out/infineon-p6-lock/chip-p6-lock-example.flash.py diff --git a/examples/lock-app/p6/include/CHIPProjectConfig.h b/examples/lock-app/p6/include/CHIPProjectConfig.h index db1cfff67ed350..d6d5fe34815b0d 100644 --- a/examples/lock-app/p6/include/CHIPProjectConfig.h +++ b/examples/lock-app/p6/include/CHIPProjectConfig.h @@ -34,7 +34,22 @@ #endif #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 -// define Device type based on the application +/* The ProductID attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8006 + +/* The ProductName attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME "P6-CYW43012 Lock" + +/* The HardwareVersionString attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING "P6-43012" + +/* The HardwareVersion attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION 43012 + +/* The SoftwareVersion attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 1 + +/* define Device type based on the application */ #define CHIP_DEVICE_CONFIG_DEVICE_TYPE 10 // 0x00A Door lock // For convenience, Chip Security Test Mode can be enabled and the @@ -53,7 +68,7 @@ * physical device, a change to its packaging, and/or a change to its marketing presentation. * This value is generally *not* incremented for device software versions. */ -#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1 +#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 43012 /** * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING @@ -63,7 +78,7 @@ * {MAJOR_VERSION}.0d{MINOR_VERSION} */ #ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING -#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA" +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.0" #endif /** * CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/examples/lock-app/p6/ota_base_build.sh b/examples/lock-app/p6/ota_base_build.sh deleted file mode 100755 index 7ab6e27ec17fab..00000000000000 --- a/examples/lock-app/p6/ota_base_build.sh +++ /dev/null @@ -1,8 +0,0 @@ -OUT_DIR=out/lock-app/ -ANYCLOUD_DIR=third_party/p6/p6_sdk/libs/anycloud-ota/ - -scripts/examples/gn_p6_example.sh examples/lock-app/p6 "$OUT_DIR" chip_enable_ota_requestor=true - -mv "$OUT_DIR"/chip-p6-lock-example.hex "$OUT_DIR"/chip-p6-lock-example.unsigned.hex - -./"$ANYCLOUD_DIR"/scripts/sign_script.bash "$OUT_DIR"/ chip-p6-lock-example python3 arm-none-eabi-objcopy "-O ihex" "" "$ANYCLOUD_DIR"/source/mcuboot/scripts/ imgtool_v1.7.0/imgtool.py create 0xFF 0x400 3584 1.0.0 0x00018000 0x001C0000 arm-none-eabi-objcopy "" diff --git a/examples/lock-app/p6/ota_update_build.sh b/examples/lock-app/p6/ota_update_build.sh deleted file mode 100755 index ac5d674cd67115..00000000000000 --- a/examples/lock-app/p6/ota_update_build.sh +++ /dev/null @@ -1,14 +0,0 @@ -OUT_DIR=out/lock-app-ota -ANYCLOUD_DIR=third_party/p6/p6_sdk/libs/anycloud-ota/ - -./scripts/examples/gn_p6_example.sh examples/lock-app/p6 "$OUT_DIR" chip_enable_ota_requestor=true build_update_image=true - -mv "$OUT_DIR"/chip-p6-lock-example.hex "$OUT_DIR"/chip-p6-lock-example.unsigned.hex - -./"$ANYCLOUD_DIR"/scripts/sign_script.bash "$OUT_DIR"/ chip-p6-lock-example python3 arm-none-eabi-objcopy "-O ihex" "" "$ANYCLOUD_DIR"/source/mcuboot/scripts/ imgtool_v1.7.0/imgtool.py sign 0xFF 0x400 3584 1.0.0 0x00018000 0x001C0000 arm-none-eabi-objcopy "-k $ANYCLOUD_DIR/source/mcuboot/keys/cypress-test-ec-p256.pem" - -if [ -f "$OUT_DIR"/chip-p6-lock-example.ota ]; then - rm "$OUT_DIR"/chip-p6-lock-example.ota -fi - -src/app/ota_image_tool.py create -v 0xFFF1 -p 0x8000 -vn 2 -vs "2.0" -da sha256 "$OUT_DIR"/chip-p6-lock-example.bin "$OUT_DIR"/chip-p6-lock-example.ota diff --git a/examples/lock-app/p6/src/AppTask.cpp b/examples/lock-app/p6/src/AppTask.cpp index 7c4dd3d10385a8..f26dc79731f8a5 100644 --- a/examples/lock-app/p6/src/AppTask.cpp +++ b/examples/lock-app/p6/src/AppTask.cpp @@ -56,9 +56,7 @@ #include #include #include -extern "C" { -#include "cy_smif_psoc6.h" -} + using chip::BDXDownloader; using chip::CharSpan; using chip::DefaultOTARequestor; @@ -284,11 +282,11 @@ CHIP_ERROR AppTask::Init() sLockLED.Init(LOCK_STATE_LED); if (state.Value() == DlLockState::kUnlocked) { - sLockLED.Set(true); + sLockLED.Set(false); } else { - sLockLED.Set(false); + sLockLED.Set(true); } ConfigurationMgr().LogDeviceConfig(); @@ -663,11 +661,12 @@ void vApplicationStackOverflowHook(TaskHandle_t pxTask, char * pcTaskName) void AppTask::InitOTARequestor() { SetRequestorInstance(&gRequestorCore); + ConfigurationMgr().StoreSoftwareVersion(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); gRequestorStorage.Init(chip::Server::GetInstance().GetPersistentStorage()); gRequestorCore.Init(chip::Server::GetInstance(), gRequestorStorage, gRequestorUser, gDownloader); gImageProcessor.SetOTADownloader(&gDownloader); gDownloader.SetImageProcessorDelegate(&gImageProcessor); - ConfigurationMgr().StoreSoftwareVersion(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); + gRequestorUser.Init(&gRequestorCore, &gImageProcessor); P6_LOG("Current Software Version: %u", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); diff --git a/examples/lock-app/p6/src/main.cpp b/examples/lock-app/p6/src/main.cpp index 6b4e07c16b30c2..f998b3c4e54f54 100644 --- a/examples/lock-app/p6/src/main.cpp +++ b/examples/lock-app/p6/src/main.cpp @@ -136,7 +136,7 @@ int main(void) #endif P6_LOG("==================================================\r\n"); - P6_LOG("chip-p6-lock-example starting\r\n"); + P6_LOG("chip-p6-lock-example starting Version %d\r\n", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); P6_LOG("==================================================\r\n"); /* Start the FreeRTOS scheduler */ diff --git a/examples/ota-requestor-app/p6/.gn b/examples/ota-requestor-app/p6/.gn deleted file mode 100644 index 81cec9d11a421b..00000000000000 --- a/examples/ota-requestor-app/p6/.gn +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (c) 2021 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build_overrides/build.gni") - -# The location of the build configuration file. -buildconfig = "${build_root}/config/BUILDCONFIG.gn" - -# CHIP uses angle bracket includes. -check_system_includes = true - -default_args = { - target_cpu = "arm" - target_os = "freertos" - - import("//args.gni") -} diff --git a/examples/ota-requestor-app/p6/BUILD.gn b/examples/ota-requestor-app/p6/BUILD.gn deleted file mode 100644 index d370d7256db3ff..00000000000000 --- a/examples/ota-requestor-app/p6/BUILD.gn +++ /dev/null @@ -1,174 +0,0 @@ -# Copyright (c) 2021 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build_overrides/build.gni") -import("//build_overrides/chip.gni") -import("//build_overrides/p6.gni") - -import("${build_root}/config/defaults.gni") -import("${p6_sdk_build_root}/p6_executable.gni") -import("${p6_sdk_build_root}/p6_sdk.gni") - -assert(current_os == "freertos") - -p6_project_dir = "${chip_root}/examples/ota-requestor-app/p6" -examples_plat_dir = "${chip_root}/examples/platform/p6" - -declare_args() { - # Dump memory usage at link time. - chip_print_memory_usage = false - - # PIN code for PASE session establishment. - setup_pin_code = 20202021 - - # Monitor & log memory usage at runtime. - enable_heap_monitoring = false - - # Build update app - build_update_image = false -} - -config("p6_ota_config") { - linker_script = "${p6_sdk_root}/ota/cy8c6xxa_cm4_dual_ota_int.ld" - - ldflags = [ "-T" + rebase_path(linker_script, root_build_dir) ] - - ldflags += [ "-Wl,--defsym,MCUBOOT_HEADER_SIZE=0x400,--defsym,MCUBOOT_BOOTLOADER_SIZE=0x18000,--defsym,CY_BOOT_PRIMARY_1_SIZE=0x1C0000" ] - - defines = [ - "P6_OTA", - "OTA_SUPPORT ", - "OTA_USE_EXTERNAL_FLASH", - "CY_BOOT_USE_EXTERNAL_FLASH", - "MCUBOOT_HEADER_SIZE=0x400", - "MCUBOOT_MAX_IMG_SECTORS=3584", - "CY_BOOT_SCRATCH_SIZE=0x00004000", - "MCUBOOT_BOOTLOADER_SIZE=0x00018000", - "CY_BOOT_BOOTLOADER_SIZE=0x00018000", - "CY_BOOT_PRIMARY_1_START=0x00018000", - "CY_BOOT_PRIMARY_1_SIZE=0x1C0000", - "CY_BOOT_SECONDARY_1_START=0x00000000", - "CY_BOOT_SECONDARY_1_SIZE=0x001C0000", - "CY_FLASH_ERASE_VALUE=0xFF", - "MCUBOOT_IMAGE_NUMBER=1", - "MCUBOOT_SLOT_SIZE=0x1C0000", - "MCUBOOT_SCRATCH_SIZE=0x4000", - "MCUBOOT_SECTOR_SIZE = 512", - "APP_VERSION_MAJOR=1", - "APP_VERSION_MINOR=0", - "APP_VERSION_BUILD=0", - "MCUBOOT_OVERWRITE_ONLY", - "CY_ENABLE_XIP_PROGRAM", - ] - - if (build_update_image) { - defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION=2" ] - } else { - defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION=1" ] - } -} - -# Warning: Don't change the name of this target without also modifying -# third_party/p6/BUILD.gn and third_party/p6/p6_sdk.gn. There are conditionals -# relying on this name. -p6_sdk_sources("ota_requestor_app_sdk_sources") { - include_dirs = [ - "${chip_root}/src/platform/P6", - "${p6_project_dir}/include", - "${examples_plat_dir}", - "${p6_sdk_root}/ota/config", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/mem_config/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/include/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/include/flash_map_backend/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/sysflash/", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/bootutil/include", - ] - - defines = [ - "BOARD_ID=${p6_board}", - "P6_LOG_ENABLED=1", - "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setup_pin_code}", - ] - - sources = [ - "${p6_project_dir}/include/CHIPProjectConfig.h", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/bootutil/src/bootutil_misc.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/cy_flash_map.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/cy_flash_psoc6.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/cy_smif_psoc6.c", - "${p6_sdk_root}/libs/anycloud-ota/source/mcuboot/cy_flash_pal/mem_config/mem_config_sfdp.c", - ] - - public_configs = [ - "${chip_root}/third_party/p6:p6_sdk_config", - ":p6_ota_config", - ] -} - -p6_executable("ota_requestor_app") { - include_dirs = [] - defines = [] - output_name = "chip-p6-ota-requestor-example.out" - - sources = [ - "${examples_plat_dir}/LEDWidget.cpp", - "${examples_plat_dir}/init_p6Platform.cpp", - "src/AppTask.cpp", - "src/ButtonHandler.cpp", - "src/ZclCallbacks.cpp", - "src/main.cpp", - ] - - deps = [ - ":ota_requestor_app_sdk_sources", - "${chip_root}/examples/common/QRCode", - "${chip_root}/examples/ota-requestor-app/ota-requestor-common", - "${chip_root}/src/app/server", - "${chip_root}/src/lib", - "${chip_root}/src/setup_payload", - ] - - include_dirs += [ - "include", - "${examples_plat_dir}", - "${p6_project_dir}/include", - "${chip_root}/examples/ota-requestor-app/ota-requestor-common/include", - ] - - defines = [] - - if (enable_heap_monitoring) { - sources += [ "${examples_plat_dir}/MemMonitoring.cpp" ] - defines += [ "HEAP_MONITORING" ] - } - - if (chip_print_memory_usage) { - ldflags += [ - "-Wl,--print-memory-usage", - "-fstack-usage", - ] - } - - output_dir = root_out_dir -} - -group("p6") { - deps = [ ":ota_requestor_app" ] -} - -group("default") { - deps = [ ":p6" ] -} diff --git a/examples/ota-requestor-app/p6/README.md b/examples/ota-requestor-app/p6/README.md deleted file mode 100644 index dc58d3da7bc4b1..00000000000000 --- a/examples/ota-requestor-app/p6/README.md +++ /dev/null @@ -1,138 +0,0 @@ -#CHIP P6 OTA Requestor Example - -An example demonstrating the OTA Requestor cluster on a Infineon -CY8CKIT-062S2-43012 board. - -
- -- [Matter P6 OTA Requestor Example](#chip-p6-ota-requestor-example) - - [Introduction](#introduction) - - [Building](#building) - - [Flashing the Application](#flashing-the-application) - - [Running OTA Update Process](#running-ota-update-process) - - [Notes](#notes) - -
- - - -## Introduction - -The P6 OTA Requestor example provides a baseline demonstration of a OTA -requestor device, built using Matter and the Infineon Modustoolbox SDK. It can -be controlled by Matter controller over Wi-Fi network. - -The P6 device can be commissioned over Bluetooth Low Energy where the device and -the Matter controller will exchange security information with the Rendezvous -procedure. Wi-Fi Network credentials are then provided to the P6 device which -will then join the network. - - - -## Building - -- [Modustoolbox Software](https://www.cypress.com/products/modustoolbox) - - Refer to `integrations/docker/images/chip-build-infineon/Dockerfile` or - `scripts/examples/gn_p6_example.sh` for downloading the Software and related - tools. - -- Install some additional tools (likely already present for Matter - developers): \$ sudo apt install gcc g++ clang ninja-build python - python3-venv libssl-dev libavahi-client-dev libglib2.0-dev git cmake - python3-pip - -- Supported hardware: - [CY8CKIT-062S2-43012](https://www.cypress.com/CY8CKIT-062S2-43012) - -* The following applications must be built to demonstrate the OTA process: - - - The P6 OTA Requestor App - - The Updated P6 OTA Requestor App (or other app) - - An OTA Provider App (the Linux ota-provider app is used here) - - chip-tool - -* Build the P6 OTA Requestor application from the chip root dir: - - $ ./examples/ota-requestor-app/p6/ota_base_build.sh - -* Build the P6 OTA Update application from the chip root dir: - - $ ./examples/ota-requestor-app/p6/ota_update_build.sh - -* On a RPi4: Build the Linux OTA Provider application from the chip root dir: - - $ ./scripts/examples/gn_build_example.sh examples/ota-provider-app/linux/ out/ota_provider_debug/ chip_config_network_layer_ble=false - -* On a RPi4: Build chip-tool: - - $ ./scripts/examples/gn_build_example.sh examples/chip-tool/ out/chip-tool/ - -* Additionally a pre-compiled bootloader must be flashed to the board. This - can be found at: - - $ ./third_party/p6/p6_sdk/ota/matter-psoc6-mcuboot-bootloader.hex - - - -## Flashing the Application - -- Flash the bootloader by first putting the CY8CKIT-062S2-43012 board into - KitProg3 DAPLINK Mode by pressing the `MODE SELECT` button. - `KITPROG3 STATUS` LED will blink to indicate the the board is in the proper - mode. A drive named 'DAPLINK' should be automatically mounted. To flash - drag-and-drop matter-psoc6-mcuboot-bootloader.hex into that drive. - -- Put CY8CKIT-062S2-43012 board back into KitProg3 CMSIS-DAP Mode by pressing - the `MODE SELECT` button. `KITPROG3 STATUS` LED is ON confirms board is in - proper mode. - -- On the command line: - - $ cd ~/connectedhomeip - $ python3 out/ota_requestor_debug/chip-p6-ota-requestor-example.flash.py - - - -### Running OTA Update Process - -- Make sure the ota-requestor-app is flashed and booting on the - CY8CKIT-062S2-43012. - -- Transfer out/ota_requestor_update_debug/chip-p6-ota-requestor-example.bin to - a RPi4. - -- On the RPi: In terminal 1 run the Linux ota-provider-app as follows: - - $ ./out/ota_provider_debug/chip-ota-provider-app -f chip-p6-ota-requestor-example.bin - -- On the RPi: In terminal 2 run the following chip-tool commands - - $ ./out/chip-tool/chip-tool pairing ble-wifi 2 "" "" 20202021 3840 - - $ ./out/chip-tool/chip-tool pairing onnetwork 1 20202021 - - $ ./chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null}, {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": [1, 2], "targets": [{"cluster": null, "endpoint": 0, "deviceType": null}]}]' 1 0 - - $ ./chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null}, {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": [1, 2], "targets": [{"cluster": null, "endpoint": 0, "deviceType": null}]}]' 2 0 - - $ ./chip-tool otasoftwareupdaterequestor write default-ota-providers '[{"fabricIndex": 1, "providerNodeID": 1, "endpoint": 0}]' 2 0 - -- Press user button 1 on the CY8CKIT-062S2-43012. This will trigger a - query-image call from the board using the default ota provider list written - in the above commands. - -- Using a serial emulator reading from the CY8CKIT-062S2-43012, you should - observe the updated application being transferred to the board, written to - flash, and, when completed, booted into. - - - -#### Notes - -Raspberry Pi 4 BLE connection issues can be avoided by running the following -commands. These power cycle the BlueTooth hardware and disable BR/EDR mode. - - $ sudo btmgmt -i hci0 power off - $ sudo btmgmt -i hci0 bredr off - $ sudo btmgmt -i hci0 power on diff --git a/examples/ota-requestor-app/p6/args.gni b/examples/ota-requestor-app/p6/args.gni deleted file mode 100644 index 8505c08a26d719..00000000000000 --- a/examples/ota-requestor-app/p6/args.gni +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (c) 2021 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build_overrides/chip.gni") -import("//build_overrides/pigweed.gni") -import("${chip_root}/src/platform/P6/args.gni") - -chip_enable_ota_requestor = true - -p6_target_project = - get_label_info(":ota_requestor_app_sdk_sources", "label_no_toolchain") diff --git a/examples/ota-requestor-app/p6/build_overrides b/examples/ota-requestor-app/p6/build_overrides deleted file mode 120000 index 194ee0b812dc3d..00000000000000 --- a/examples/ota-requestor-app/p6/build_overrides +++ /dev/null @@ -1 +0,0 @@ -../../build_overrides/ \ No newline at end of file diff --git a/examples/ota-requestor-app/p6/include/AppConfig.h b/examples/ota-requestor-app/p6/include/AppConfig.h deleted file mode 100644 index a7b25027a031af..00000000000000 --- a/examples/ota-requestor-app/p6/include/AppConfig.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * Copyright 2021, Cypress Semiconductor Corporation (an Infineon company) - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "cybsp.h" -#include "cyhal.h" - -// ---- OTA Requestor Example App Config ---- - -#define APP_TASK_NAME "APP" - -#define APP_UPDATE_BUTTON_IDX 0 -#define APP_FUNCTION_BUTTON_IDX 1 - -#define APP_UPDATE_BUTTON CYBSP_USER_BTN1 -#define APP_FUNCTION_BUTTON CYBSP_USER_BTN2 -#define APP_BUTTON_DEBOUNCE_PERIOD_MS 50 - -#define APP_BUTTON_PRESSED 0 -#define APP_BUTTON_RELEASED 1 - -#define SYSTEM_STATE_LED CYBSP_USER_LED1 -#define UPDATE_LED CYBSP_USER_LED2 - -// Time it takes in ms for the simulated actuator to move from one -// state to another. -#define ACTUATOR_MOVEMENT_PERIOS_MS 2000 - -// ---- Thread Polling Config ---- -#define THREAD_ACTIVE_POLLING_INTERVAL_MS 100 -#define THREAD_INACTIVE_POLLING_INTERVAL_MS 1000 - -// P6 Logging -#ifdef __cplusplus -extern "C" { -#endif - -void appError(int err); -void P6Log(const char * aFormat, ...); -#define P6_LOG(...) P6Log(__VA_ARGS__) - -#ifdef __cplusplus -} - -#include -void appError(CHIP_ERROR error); -#endif diff --git a/examples/ota-requestor-app/p6/include/AppEvent.h b/examples/ota-requestor-app/p6/include/AppEvent.h deleted file mode 100644 index 671a1be6419724..00000000000000 --- a/examples/ota-requestor-app/p6/include/AppEvent.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * Copyright (c) 2018 Nest Labs, Inc. - * Copyright 2021, Cypress Semiconductor Corporation (an Infineon company) - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -struct AppEvent; -typedef void (*EventHandler)(AppEvent *); - -struct AppEvent -{ - enum AppEventTypes - { - kEventType_Button = 0, - kEventType_Timer, - kEventType_Light, - kEventType_Install, - }; - - uint16_t Type; - - union - { - struct - { - uint8_t ButtonIdx; - uint8_t Action; - } ButtonEvent; - struct - { - void * Context; - } TimerEvent; - }; - - EventHandler Handler; -}; diff --git a/examples/ota-requestor-app/p6/include/AppTask.h b/examples/ota-requestor-app/p6/include/AppTask.h deleted file mode 100644 index c460807f997c84..00000000000000 --- a/examples/ota-requestor-app/p6/include/AppTask.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * Copyright 2021, Cypress Semiconductor Corporation (an Infineon company) - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include - -#include "AppEvent.h" -#include "FreeRTOS.h" -#include "timers.h" // provides FreeRTOS timer support -#include -#include - -// Application-defined error codes in the CHIP_ERROR space. -#define APP_ERROR_EVENT_QUEUE_FAILED CHIP_APPLICATION_ERROR(0x01) -#define APP_ERROR_CREATE_TASK_FAILED CHIP_APPLICATION_ERROR(0x02) -#define APP_ERROR_UNHANDLED_EVENT CHIP_APPLICATION_ERROR(0x03) -#define APP_ERROR_CREATE_TIMER_FAILED CHIP_APPLICATION_ERROR(0x04) -#define APP_ERROR_START_TIMER_FAILED CHIP_APPLICATION_ERROR(0x05) -#define APP_ERROR_STOP_TIMER_FAILED CHIP_APPLICATION_ERROR(0x06) - -class AppTask -{ - -public: - CHIP_ERROR StartAppTask(); - static void AppTaskMain(void * pvParameter); - - void PostEvent(const AppEvent * event); - - void ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction); - void InitOTARequestor(); - -private: - friend AppTask & GetAppTask(void); - - CHIP_ERROR Init(); - - void CancelTimer(void); - - void DispatchEvent(AppEvent * event); - - static void FunctionTimerEventHandler(AppEvent * aEvent); - static void UpdateButtonHandler(AppEvent * aEvent); - static void FunctionHandler(AppEvent * aEvent); - static void TimerEventHandler(TimerHandle_t xTimer); - - static void UpdateClusterState(void); - - void StartTimer(uint32_t aTimeoutMs); - - enum class Function - { - kNoneSelected = 0, - kSoftwareUpdate = 0, - kStartBleAdv = 1, - kFactoryReset = 2, - - kInvalid - }; - - Function mFunction = Function::kNoneSelected; - bool mFunctionTimerActive = false; - bool mSyncClusterToButtonAction = false; - - static AppTask sAppTask; -}; - -inline AppTask & GetAppTask(void) -{ - return AppTask::sAppTask; -} diff --git a/examples/ota-requestor-app/p6/include/ButtonHandler.h b/examples/ota-requestor-app/p6/include/ButtonHandler.h deleted file mode 100644 index ea509caef40e8e..00000000000000 --- a/examples/ota-requestor-app/p6/include/ButtonHandler.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * Copyright 2021, Cypress Semiconductor Corporation (an Infineon company) - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -#include "FreeRTOS.h" -#include "cyhal.h" -#include "timers.h" // provides FreeRTOS timer support - -#define GPIO_INTERRUPT_PRIORITY (5) - -class ButtonHandler -{ -public: - static void Init(void); - -private: - static void GpioInit(void); - static void update_button_callback(void * handler_arg, cyhal_gpio_event_t event); - static void func_button_callback(void * handler_arg, cyhal_gpio_event_t event); - static void TimerCallback(TimerHandle_t xTimer); -}; diff --git a/examples/ota-requestor-app/p6/include/CHIPProjectConfig.h b/examples/ota-requestor-app/p6/include/CHIPProjectConfig.h deleted file mode 100644 index c3ef134be2a110..00000000000000 --- a/examples/ota-requestor-app/p6/include/CHIPProjectConfig.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * Example project configuration file for CHIP. - * - * This is a place to put application or project-specific overrides - * to the default configuration values for general CHIP features. - * - */ - -#pragma once - -/** - * CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY - * - * Enables the use of a hard-coded default Chip device id and credentials if no device id - * is found in Chip NV storage. - * - * This option is for testing only and should be disabled in production releases. - */ -#define CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY 34 - -// Use a default pairing code if one hasn't been provisioned in flash. -#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE -#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 -#endif - -#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR -#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 -#endif - -// For convenience, Chip Security Test Mode can be enabled and the -// requirement for authentication in various protocols can be disabled. -// -// WARNING: These options make it possible to circumvent basic Chip security functionality, -// including message encryption. Because of this they MUST NEVER BE ENABLED IN PRODUCTION BUILDS. -// -#define CHIP_CONFIG_SECURITY_TEST_MODE 0 - -/** - * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION - * - * The product revision number assigned to device or product by the device vendor. This - * number is scoped to the device product id, and typically corresponds to a revision of the - * physical device, a change to its packaging, and/or a change to its marketing presentation. - * This value is generally *not* incremented for device software revisions. - */ -#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION 1 - -/** - * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING - * - * A string identifying the software version running on the device. - * CHIP service currently expects the software version to be in the format - * {MAJOR_VERSION}.0d{MINOR_VERSION} - */ -#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING -#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA" -#endif -/** - * CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE - * - * Enable support for Chip-over-BLE (CHIPoBLE). - */ -#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 1 - -/** - * CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC - * - * Enables synchronizing the device's real time clock with a remote Chip Time service - * using the Chip Time Sync protocol. - */ -#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 0 - -/** - * CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER - * - * Enables the use of a hard-coded default serial number if none - * is found in Chip NV storage. - */ -#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN" - -/** - * CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS - * - * Enable recording UTC timestamps. - */ -#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1 - -/** - * CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE - * - * A size, in bytes, of the individual debug event logging buffer. - */ -#define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512) - -/** - * CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION - * - * The hardware version number assigned to device or product by the device vendor. This - * number is scoped to the device product id, and typically corresponds to a version of the - * physical device, a change to its packaging, and/or a change to its marketing presentation. - * This value is generally *not* incremented for device software versions. - */ -#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1 - -/** - * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING - * - * A string identifying the software version running on the device. - * CHIP service currently expects the software version to be in the format - * {MAJOR_VERSION}.0d{MINOR_VERSION} - */ -#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING -#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA" -#endif diff --git a/examples/ota-requestor-app/p6/ota_base_build.sh b/examples/ota-requestor-app/p6/ota_base_build.sh deleted file mode 100755 index 69ca770cc8a613..00000000000000 --- a/examples/ota-requestor-app/p6/ota_base_build.sh +++ /dev/null @@ -1,8 +0,0 @@ -OUT_DIR=out/ota_requestor_debug/ -ANYCLOUD_DIR=third_party/p6/p6_sdk/libs/anycloud-ota/ - -./scripts/examples/gn_p6_example.sh examples/ota-requestor-app/p6/ "$OUT_DIR" - -mv "$OUT_DIR"/chip-p6-ota-requestor-example.hex "$OUT_DIR"/chip-p6-ota-requestor-example.unsigned.hex - -./"$ANYCLOUD_DIR"/scripts/sign_script.bash "$OUT_DIR"/ chip-p6-ota-requestor-example python3 arm-none-eabi-objcopy "-O ihex" "" "$ANYCLOUD_DIR"/source/mcuboot/scripts/ imgtool_v1.7.0/imgtool.py create 0xFF 0x400 3584 1.0.0 0x00018000 0x001C0000 arm-none-eabi-objcopy "" diff --git a/examples/ota-requestor-app/p6/ota_update_build.sh b/examples/ota-requestor-app/p6/ota_update_build.sh deleted file mode 100755 index 825b1db6457318..00000000000000 --- a/examples/ota-requestor-app/p6/ota_update_build.sh +++ /dev/null @@ -1,14 +0,0 @@ -OUT_DIR=out/ota_requestor_update_debug/ -ANYCLOUD_DIR=third_party/p6/p6_sdk/libs/anycloud-ota/ - -./scripts/examples/gn_p6_example.sh examples/ota-requestor-app/p6/ "$OUT_DIR" build_update_image=true - -mv "$OUT_DIR"/chip-p6-ota-requestor-example.hex "$OUT_DIR"/chip-p6-ota-requestor-example.unsigned.hex - -./"$ANYCLOUD_DIR"/scripts/sign_script.bash "$OUT_DIR" chip-p6-ota-requestor-example python3 arm-none-eabi-objcopy "-O ihex" "" "$ANYCLOUD_DIR"/source/mcuboot/scripts/ imgtool_v1.7.0/imgtool.py sign 0xFF 0x400 3584 1.0.0 0x00018000 0x001C0000 arm-none-eabi-objcopy "-k $ANYCLOUD_DIR/source/mcuboot/keys/cypress-test-ec-p256.pem" - -if [ -f "$OUT_DIR"/chip-p6-ota-requestor-example.ota ]; then - rm "$OUT_DIR"/chip-p6-ota-requestor-example.ota -fi - -src/app/ota_image_tool.py create -v 0xFFF1 -p 0x8000 -vn 2 -vs "2.0" -da sha256 "$OUT_DIR"/chip-p6-ota-requestor-example.bin "$OUT_DIR"/chip-p6-ota-requestor-example.ota diff --git a/examples/ota-requestor-app/p6/src/AppTask.cpp b/examples/ota-requestor-app/p6/src/AppTask.cpp deleted file mode 100644 index 0fb347d11f30d1..00000000000000 --- a/examples/ota-requestor-app/p6/src/AppTask.cpp +++ /dev/null @@ -1,479 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * Copyright 2021, Cypress Semiconductor Corporation (an Infineon company) - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "AppTask.h" -#include "AppConfig.h" -#include "AppEvent.h" -#include "ButtonHandler.h" -#include "LEDWidget.h" -#include "qrcodegen.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -extern "C" { -#include "cy_smif_psoc6.h" -} - -#define FACTORY_RESET_TRIGGER_TIMEOUT 3000 -#define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000 -#define APP_TASK_STACK_SIZE (4096) -#define APP_TASK_PRIORITY 2 -#define APP_EVENT_QUEUE_SIZE 10 - -using chip::BDXDownloader; -using chip::CharSpan; -using chip::DefaultOTARequestor; -using chip::FabricIndex; -using chip::GetRequestorInstance; -using chip::NodeId; -using chip::OTADownloader; -using chip::OTAImageProcessorImpl; -using chip::System::Layer; - -using namespace ::chip; -using namespace chip::TLV; -using namespace ::chip::Credentials; -using namespace ::chip::DeviceLayer; -using namespace ::chip::System; - -namespace { -TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer. - -TaskHandle_t sAppTaskHandle; -QueueHandle_t sAppEventQueue; - -LEDWidget sStatusLED; - -bool sIsWiFiStationProvisioned = false; -bool sIsWiFiStationEnabled = false; -bool sIsWiFiStationConnected = false; -bool sHaveBLEConnections = false; - -uint8_t sAppEventQueueBuffer[APP_EVENT_QUEUE_SIZE * sizeof(AppEvent)]; -StaticQueue_t sAppEventQueueStruct; - -StackType_t appStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)]; -StaticTask_t appTaskStruct; - -DefaultOTARequestor gRequestorCore; -DefaultOTARequestorStorage gRequestorStorage; -DefaultOTARequestorDriver gRequestorUser; -BDXDownloader gDownloader; -OTAImageProcessorImpl gImageProcessor; - -app::Clusters::NetworkCommissioning::Instance - sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, &(NetworkCommissioning::P6WiFiDriver::GetInstance())); -} // namespace - -void OnTriggerUpdateTimerHandler(Layer * systemLayer, void * appState); - -AppTask AppTask::sAppTask; - -void NetWorkCommissioningInstInit() -{ - sWiFiNetworkCommissioningInstance.Init(); -} - -static void InitServer(intptr_t context) -{ - // Init ZCL Data Model - static chip::CommonCaseDeviceServerInitParams initParams; - (void) initParams.InitializeStaticResourcesBeforeServerInit(); - chip::Server::GetInstance().Init(initParams); - - // Initialize device attestation config - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); - GetAppTask().InitOTARequestor(); -} - -CHIP_ERROR AppTask::StartAppTask() -{ - sAppEventQueue = xQueueCreateStatic(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent), sAppEventQueueBuffer, &sAppEventQueueStruct); - if (sAppEventQueue == NULL) - { - P6_LOG("Failed to allocate app event queue"); - appError(APP_ERROR_EVENT_QUEUE_FAILED); - } - - // Start App task. - sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), NULL, 1, appStack, &appTaskStruct); - return (sAppTaskHandle == nullptr) ? APP_ERROR_CREATE_TASK_FAILED : CHIP_NO_ERROR; -} - -CHIP_ERROR AppTask::Init() -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - int rc = boot_set_confirmed(); - if (rc != 0) - { - P6_LOG("boot_set_confirmed failed"); - appError(CHIP_ERROR_WELL_UNINITIALIZED); - } - - // Register the callback to init the MDNS server when connectivity is available - PlatformMgr().AddEventHandler( - [](const ChipDeviceEvent * event, intptr_t arg) { - // Restart the server whenever an ip address is renewed - if (event->Type == DeviceEventType::kInternetConnectivityChange) - { - if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established || - event->InternetConnectivityChange.IPv6 == kConnectivity_Established) - { - chip::app::DnssdServer::Instance().StartServer(); - } - } - }, - 0); - - chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast(nullptr)); - - // Initialise WSTK buttons PB0 and PB1 (including debounce). - ButtonHandler::Init(); - - // Create FreeRTOS sw timer for Function Selection. - sFunctionTimer = xTimerCreate("FnTmr", // Just a text name, not used by the RTOS kernel - 1, // == default timer period (mS) - false, // no timer reload (==one-shot) - (void *) this, // init timer id = app task obj context - TimerEventHandler // timer callback handler - ); - if (sFunctionTimer == NULL) - { - P6_LOG("funct timer create failed"); - appError(APP_ERROR_CREATE_TIMER_FAILED); - } - - NetWorkCommissioningInstInit(); - - // Initialize LEDs - sStatusLED.Init(SYSTEM_STATE_LED); - - ConfigurationMgr().LogDeviceConfig(); - - // Print setup info - PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); - - return err; -} - -void AppTask::AppTaskMain(void * pvParameter) -{ - AppEvent event; - CHIP_ERROR err = sAppTask.Init(); - if (err != CHIP_NO_ERROR) - { - P6_LOG("AppTask.Init() failed"); - appError(err); - } - - P6_LOG("App Task started"); - - while (true) - { - BaseType_t eventReceived = xQueueReceive(sAppEventQueue, &event, pdMS_TO_TICKS(10)); - while (eventReceived == pdTRUE) - { - sAppTask.DispatchEvent(&event); - eventReceived = xQueueReceive(sAppEventQueue, &event, 0); - } - - // Update the status LED if factory reset has not been initiated. - // - // If system has "full connectivity", keep the LED On constantly. - // - // If thread and service provisioned, but not attached to the thread network - // yet OR no connectivity to the service OR subscriptions are not fully - // established THEN blink the LED Off for a short period of time. - // - // If the system has ble connection(s) uptill the stage above, THEN blink - // the LEDs at an even rate of 100ms. - // - // Otherwise, blink the LED ON for a very short time. - if (sAppTask.mFunction != Function::kFactoryReset) - { - if (sIsWiFiStationEnabled && sIsWiFiStationProvisioned && !sIsWiFiStationConnected) - { - sStatusLED.Blink(950, 50); - } - else if (sHaveBLEConnections) - { - sStatusLED.Blink(100, 100); - } - else - { - sStatusLED.Blink(50, 950); - } - } - - sStatusLED.Animate(); - } -} - -void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction) -{ - if (btnIdx != APP_FUNCTION_BUTTON_IDX && btnIdx != APP_UPDATE_BUTTON_IDX) - { - return; - } - - AppEvent button_event = {}; - button_event.Type = AppEvent::kEventType_Button; - button_event.ButtonEvent.ButtonIdx = btnIdx; - button_event.ButtonEvent.Action = btnAction; - - if (btnIdx == APP_FUNCTION_BUTTON_IDX) - { - button_event.Handler = FunctionHandler; - sAppTask.PostEvent(&button_event); - } - if (btnIdx == APP_UPDATE_BUTTON_IDX) - { - button_event.Handler = UpdateButtonHandler; - sAppTask.PostEvent(&button_event); - } -} - -void AppTask::TimerEventHandler(TimerHandle_t xTimer) -{ - AppEvent event; - event.Type = AppEvent::kEventType_Timer; - event.TimerEvent.Context = (void *) xTimer; - event.Handler = FunctionTimerEventHandler; - sAppTask.PostEvent(&event); -} - -void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) -{ - if (aEvent->Type != AppEvent::kEventType_Timer) - { - return; - } - - // If we reached here, the button was held past FACTORY_RESET_TRIGGER_TIMEOUT, - // initiate factory reset - if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == Function::kStartBleAdv) - { - P6_LOG("Factory Reset Triggered. Release button within %ums to cancel.", FACTORY_RESET_CANCEL_WINDOW_TIMEOUT); - - // Start timer for FACTORY_RESET_CANCEL_WINDOW_TIMEOUT to allow user to - // cancel, if required. - sAppTask.StartTimer(FACTORY_RESET_CANCEL_WINDOW_TIMEOUT); - - sAppTask.mFunction = Function::kFactoryReset; - - // Turn off all LEDs before starting blink to make sure blink is - // co-ordinated. - sStatusLED.Set(false); - - sStatusLED.Blink(500); - } - else if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == Function::kFactoryReset) - { - // Actually trigger Factory Reset - sAppTask.mFunction = Function::kNoneSelected; - ConfigurationMgr().InitiateFactoryReset(); - } -} - -void AppTask::FunctionHandler(AppEvent * aEvent) -{ - // To trigger software update: press the APP_FUNCTION_BUTTON button briefly (< - // FACTORY_RESET_TRIGGER_TIMEOUT) To initiate factory reset: press the - // APP_FUNCTION_BUTTON for FACTORY_RESET_TRIGGER_TIMEOUT + - // FACTORY_RESET_CANCEL_WINDOW_TIMEOUT All LEDs start blinking after - // FACTORY_RESET_TRIGGER_TIMEOUT to signal factory reset has been initiated. - // To cancel factory reset: release the APP_FUNCTION_BUTTON once all LEDs - // start blinking within the FACTORY_RESET_CANCEL_WINDOW_TIMEOUT - if (aEvent->ButtonEvent.Action == APP_BUTTON_RELEASED) - { - if (!sAppTask.mFunctionTimerActive && sAppTask.mFunction == Function::kNoneSelected) - { - sAppTask.StartTimer(FACTORY_RESET_TRIGGER_TIMEOUT); - sAppTask.mFunction = Function::kStartBleAdv; - } - } - else - { - // If the button was released before factory reset got initiated, start Thread Network - if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == Function::kStartBleAdv) - { - sAppTask.CancelTimer(); - sAppTask.mFunction = Function::kNoneSelected; - } - else if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == Function::kFactoryReset) - { - - sAppTask.CancelTimer(); - - // Change the function to none selected since factory reset has been - // canceled. - sAppTask.mFunction = Function::kNoneSelected; - - P6_LOG("Factory Reset has been Canceled"); - } - } -} - -void AppTask::UpdateButtonHandler(AppEvent * aEvent) -{ - if (aEvent->ButtonEvent.Action == APP_BUTTON_RELEASED) - { - chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Milliseconds32(2000), OnTriggerUpdateTimerHandler, - nullptr); - } -} - -void AppTask::CancelTimer() -{ - if (xTimerStop(sFunctionTimer, 0) == pdFAIL) - { - P6_LOG("app timer stop() failed"); - appError(APP_ERROR_STOP_TIMER_FAILED); - } - - mFunctionTimerActive = false; -} - -void AppTask::StartTimer(uint32_t aTimeoutInMs) -{ - if (xTimerIsTimerActive(sFunctionTimer)) - { - P6_LOG("app timer already started!"); - CancelTimer(); - } - - // timer is not active, change its period to required value (== restart). - // FreeRTOS- Block for a maximum of 100 ticks if the change period command - // cannot immediately be sent to the timer command queue. - if (xTimerChangePeriod(sFunctionTimer, aTimeoutInMs / portTICK_PERIOD_MS, 100) != pdPASS) - { - P6_LOG("app timer start() failed"); - appError(APP_ERROR_START_TIMER_FAILED); - } - - mFunctionTimerActive = true; -} - -void AppTask::PostEvent(const AppEvent * aEvent) -{ - if (sAppEventQueue != NULL) - { - BaseType_t status; - if (xPortIsInsideInterrupt()) - { - BaseType_t higherPrioTaskWoken = pdFALSE; - status = xQueueSendFromISR(sAppEventQueue, aEvent, &higherPrioTaskWoken); - -#ifdef portYIELD_FROM_ISR - portYIELD_FROM_ISR(higherPrioTaskWoken); -#elif portEND_SWITCHING_ISR // portYIELD_FROM_ISR or portEND_SWITCHING_ISR - portEND_SWITCHING_ISR(higherPrioTaskWoken); -#else // portYIELD_FROM_ISR or portEND_SWITCHING_ISR -#error "Must have portYIELD_FROM_ISR or portEND_SWITCHING_ISR" -#endif // portYIELD_FROM_ISR or portEND_SWITCHING_ISR - } - else - { - status = xQueueSend(sAppEventQueue, aEvent, 1); - } - - if (!status) - P6_LOG("Failed to post event to app task event queue"); - } - else - { - P6_LOG("Event Queue is NULL should never happen"); - } -} - -void AppTask::DispatchEvent(AppEvent * aEvent) -{ - if (aEvent->Handler) - { - aEvent->Handler(aEvent); - } - else - { - P6_LOG("Event received with no handler. Dropping event."); - } -} - -void OnTriggerUpdateTimerHandler(Layer * systemLayer, void * appState) -{ - P6_LOG("Triggering immediate OTA update query"); - - GetRequestorInstance()->TriggerImmediateQuery(); -} - -void AppTask::InitOTARequestor() -{ - CHIP_ERROR err = CHIP_NO_ERROR; - SetRequestorInstance(&gRequestorCore); - gRequestorStorage.Init(chip::Server::GetInstance().GetPersistentStorage()); - gRequestorCore.Init(chip::Server::GetInstance(), gRequestorStorage, gRequestorUser, gDownloader); - gImageProcessor.SetOTADownloader(&gDownloader); - gDownloader.SetImageProcessorDelegate(&gImageProcessor); - gRequestorUser.Init(&gRequestorCore, &gImageProcessor); - - uint32_t savedSoftwareVersion; - err = ConfigurationMgr().GetSoftwareVersion(savedSoftwareVersion); - if (err != CHIP_NO_ERROR) - { - P6_LOG("Can't get saved software version"); - appError(err); - } - - if (savedSoftwareVersion != CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION) - { - ConfigurationMgr().StoreSoftwareVersion(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); - - P6_LOG("Confirming update to version: %u", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); - chip::OTARequestorInterface * requestor = chip::GetRequestorInstance(); - if (requestor != nullptr) - { - requestor->NotifyUpdateApplied(); - } - } - - P6_LOG("Current Software Version: %u", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); - P6_LOG("Current Firmware Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); -} diff --git a/examples/ota-requestor-app/p6/src/ButtonHandler.cpp b/examples/ota-requestor-app/p6/src/ButtonHandler.cpp deleted file mode 100644 index e20f24ed5dc347..00000000000000 --- a/examples/ota-requestor-app/p6/src/ButtonHandler.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * Copyright 2021, Cypress Semiconductor Corporation (an Infineon company) - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ButtonHandler.h" -#include "AppConfig.h" -#include "AppTask.h" - -namespace { -constexpr int kButtonCount = 2; - -TimerHandle_t buttonTimers[kButtonCount]; // FreeRTOS timers used for debouncing -// buttons. Array to hold handles to -// the created timers. - -} // namespace - -void ButtonHandler::Init(void) -{ - GpioInit(); - // Create FreeRTOS sw timers for debouncing buttons. - for (uint8_t i = 0; i < kButtonCount; i++) - { - buttonTimers[i] = xTimerCreate("BtnTmr", // Just a text name, not used by the RTOS kernel - APP_BUTTON_DEBOUNCE_PERIOD_MS, // timer period - false, // no timer reload (==one-shot) - (void *) (int) i, // init timer id = button index - TimerCallback // timer callback handler (all buttons use - // the same timer cn function) - ); - } -} - -void ButtonHandler::GpioInit(void) -{ - cy_rslt_t result = CY_RSLT_SUCCESS; - // Set up button GPIOs to input with pullups. - result = cyhal_gpio_init(APP_UPDATE_BUTTON, CYHAL_GPIO_DIR_INPUT, CYHAL_GPIO_DRIVE_PULLUP, CYBSP_BTN_OFF); - if (result != CY_RSLT_SUCCESS) - { - printf(" cyhal_gpio_init failed for APP_LOCK_BUTTON\r\n"); - } - result = cyhal_gpio_init(APP_FUNCTION_BUTTON, CYHAL_GPIO_DIR_INPUT, CYHAL_GPIO_DRIVE_PULLUP, CYBSP_BTN_OFF); - if (result != CY_RSLT_SUCCESS) - { - printf(" cyhal_gpio_init failed for APP_FUNCTION_BUTTON\r\n"); - } - /* Configure GPIO interrupt. */ - static cyhal_gpio_callback_data_t update_button_cbdata; - static cyhal_gpio_callback_data_t func_button_cbdata; - - /* Register for Update Button */ - update_button_cbdata.callback = update_button_callback; - update_button_cbdata.callback_arg = NULL; - cyhal_gpio_register_callback(APP_UPDATE_BUTTON, &update_button_cbdata); - - /* Register for Function Button for factory reset */ - func_button_cbdata.callback = func_button_callback; - func_button_cbdata.callback_arg = NULL; - cyhal_gpio_register_callback(APP_FUNCTION_BUTTON, &func_button_cbdata); - - cyhal_gpio_enable_event(APP_UPDATE_BUTTON, CYHAL_GPIO_IRQ_FALL, GPIO_INTERRUPT_PRIORITY, true); - cyhal_gpio_enable_event(APP_FUNCTION_BUTTON, CYHAL_GPIO_IRQ_FALL, GPIO_INTERRUPT_PRIORITY, true); -} - -void ButtonHandler::update_button_callback(void * handler_arg, cyhal_gpio_event_t event) -{ - portBASE_TYPE taskWoken = pdFALSE; - xTimerStartFromISR(buttonTimers[APP_UPDATE_BUTTON_IDX], &taskWoken); -} - -void ButtonHandler::func_button_callback(void * handler_arg, cyhal_gpio_event_t event) -{ - portBASE_TYPE taskWoken = pdFALSE; - xTimerStartFromISR(buttonTimers[APP_FUNCTION_BUTTON_IDX], &taskWoken); -} - -void ButtonHandler::TimerCallback(TimerHandle_t xTimer) -{ - // Get the button index of the expired timer and call button event helper. - uint32_t timerId; - uint8_t buttonevent = 0; - timerId = (uint32_t) pvTimerGetTimerID(xTimer); - if (timerId) - { - buttonevent = cyhal_gpio_read(APP_FUNCTION_BUTTON); - } - else - { - buttonevent = cyhal_gpio_read(APP_UPDATE_BUTTON); - } - GetAppTask().ButtonEventHandler(timerId, (buttonevent) ? APP_BUTTON_PRESSED : APP_BUTTON_RELEASED); -} diff --git a/examples/ota-requestor-app/p6/src/ZclCallbacks.cpp b/examples/ota-requestor-app/p6/src/ZclCallbacks.cpp deleted file mode 100644 index eca4602def88e9..00000000000000 --- a/examples/ota-requestor-app/p6/src/ZclCallbacks.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * Copyright 2021, Cypress Semiconductor Corporation (an Infineon company) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * This file implements the handler for data model messages. - */ - -#include "AppConfig.h" -#include - -#include -#include -#include -#include -#include - -using namespace ::chip; -using namespace ::chip::app::Clusters; - -void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, - uint8_t * value) -{ - EndpointId endpoint = attributePath.mEndpointId; - ClusterId clusterId = attributePath.mClusterId; - AttributeId attributeId = attributePath.mAttributeId; - P6_LOG("MatterPostAttributeChangeCallback - Cluster ID: " ChipLogFormatMEI - ", EndPoint ID: '0x%02x', Attribute ID: " ChipLogFormatMEI, - ChipLogValueMEI(clusterId), endpoint, ChipLogValueMEI(attributeId)); - - switch (clusterId) - { - case Identify::Id: - ChipLogProgress(Zcl, "Identify attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", - ChipLogValueMEI(attributeId), type, *value, size); - break; - default: - P6_LOG("Unhandled cluster ID: " ChipLogFormatMEI, ChipLogValueMEI(clusterId)); - break; - } -} diff --git a/examples/ota-requestor-app/p6/src/main.cpp b/examples/ota-requestor-app/p6/src/main.cpp deleted file mode 100644 index f2bcc8b51fba57..00000000000000 --- a/examples/ota-requestor-app/p6/src/main.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * Copyright 2021, Cypress Semiconductor Corporation (an Infineon company) - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include - -#include "AppConfig.h" -#include "cyhal_wdt.h" -#include "init_p6Platform.h" -#include - -#ifdef HEAP_MONITORING -#include "MemMonitoring.h" -#endif -#define MAIN_TASK_STACK_SIZE (4096) -#define MAIN_TASK_PRIORITY 2 - -using namespace ::chip; -using namespace ::chip::Inet; -using namespace ::chip::DeviceLayer; - -volatile int apperror_cnt; -static void main_task(void * pvParameters); - -// ================================================================================ -// App Error -//================================================================================= -void appError(int err) -{ - P6_LOG("!! App Critical Error: %d !!", err); - portDISABLE_INTERRUPTS(); - while (1) - ; -} - -void appError(CHIP_ERROR error) -{ - appError(static_cast(error.AsInteger())); -} - -// ================================================================================ -// FreeRTOS Callbacks -// ================================================================================ -extern "C" void vApplicationIdleHook(void) -{ - // FreeRTOS Idle callback -} - -extern "C" void vApplicationDaemonTaskStartupHook() -{ - // Init Chip memory management before the stack - chip::Platform::MemoryInit(); - - /* Create the Main task. */ - xTaskCreate(main_task, "Main task", MAIN_TASK_STACK_SIZE, NULL, MAIN_TASK_PRIORITY, NULL); -} - -static void main_task(void * pvParameters) -{ - CHIP_ERROR ret = chip::DeviceLayer::PersistedStorage::KeyValueStoreMgrImpl().Init(); - if (ret != CHIP_NO_ERROR) - { - P6_LOG("PersistedStorage::KeyValueStoreMgrImpl().Init() failed"); - appError(ret); - } - - ret = PlatformMgr().InitChipStack(); - if (ret != CHIP_NO_ERROR) - { - P6_LOG("PlatformMgr().InitChipStack() failed"); - appError(ret); - } - - ret = chip::DeviceLayer::ConnectivityMgr().SetBLEDeviceName("P6_OTA_REQ"); - if (ret != CHIP_NO_ERROR) - { - P6_LOG("ConnectivityMgr().SetBLEDeviceName() failed"); - appError(ret); - } - - P6_LOG("Starting Platform Manager Event Loop"); - ret = PlatformMgr().StartEventLoopTask(); - if (ret != CHIP_NO_ERROR) - { - P6_LOG("PlatformMgr().StartEventLoopTask() failed"); - appError(ret); - } - ret = GetAppTask().StartAppTask(); - if (ret != CHIP_NO_ERROR) - { - P6_LOG("GetAppTask().Init() failed"); - appError(ret); - } - - /* Delete task */ - vTaskDelete(NULL); -} - -// ================================================================================ -// Main Code -// ================================================================================ -int main(void) -{ - init_p6Platform(); - - // Clear watchdog timer (started by bootloader) so that it doesn't trigger a reset - cyhal_wdt_t wdt_obj; - cyhal_wdt_init(&wdt_obj, cyhal_wdt_get_max_timeout_ms()); - cyhal_wdt_free(&wdt_obj); - -#ifdef HEAP_MONITORING - MemMonitoring::startHeapMonitoring(); -#endif - - P6_LOG("==================================================\r\n"); - P6_LOG("chip-p6-ota-requestor-example starting\r\n"); - P6_LOG("==================================================\r\n"); - - /* Start the FreeRTOS scheduler */ - vTaskStartScheduler(); - - chip::Platform::MemoryShutdown(); - PlatformMgr().StopEventLoopTask(); - PlatformMgr().Shutdown(); - - // Should never get here. - P6_LOG("vTaskStartScheduler() failed"); -} diff --git a/examples/ota-requestor-app/p6/third_party/connectedhomeip b/examples/ota-requestor-app/p6/third_party/connectedhomeip deleted file mode 120000 index 11a54ed360106c..00000000000000 --- a/examples/ota-requestor-app/p6/third_party/connectedhomeip +++ /dev/null @@ -1 +0,0 @@ -../../../../ \ No newline at end of file diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 09836d01db1b9b..cb457e61a4b6a6 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -516,12 +516,19 @@ def MbedTargets(): def InfineonTargets(): - target = Target('infineon', InfineonBuilder) + builder = VariantBuilder() + builder.AppendVariant(name="ota", enable_ota_requestor=True) + builder.AppendVariant(name="updateimage", update_image=True) + + target = Target('infineon-p6', InfineonBuilder, board=InfineonBoard.P6BOARD) + + builder.targets.append(target.Extend('lock', app=InfineonApp.LOCK)) + builder.targets.append(target.Extend('light', app=InfineonApp.LIGHT)) + builder.targets.append(target.Extend('all-clusters', app=InfineonApp.ALL_CLUSTERS)) + builder.targets.append(target.Extend('all-clusters-minimal', app=InfineonApp.ALL_CLUSTERS_MINIMAL)) - yield target.Extend('p6-lock', board=InfineonBoard.P6BOARD, app=InfineonApp.LOCK) - yield target.Extend('p6-all-clusters', board=InfineonBoard.P6BOARD, app=InfineonApp.ALL_CLUSTERS) - yield target.Extend('p6-all-clusters-minimal', board=InfineonBoard.P6BOARD, app=InfineonApp.ALL_CLUSTERS_MINIMAL) - yield target.Extend('p6-light', board=InfineonBoard.P6BOARD, app=InfineonApp.LIGHT) + for target in builder.AllVariants(): + yield target def AmebaTargets(): diff --git a/scripts/build/builders/infineon.py b/scripts/build/builders/infineon.py index a46cec1a0fa44a..d0b73611a318cc 100644 --- a/scripts/build/builders/infineon.py +++ b/scripts/build/builders/infineon.py @@ -60,6 +60,9 @@ def FlashBundleName(self): else: raise Exception('Unknown app type: %r' % self) + def BuildRoot(self, root): + return os.path.join(root, 'examples', self.ExampleName(), 'p6') + class InfineonBoard(Enum): P6BOARD = 1 @@ -75,16 +78,23 @@ def __init__(self, root, runner, app: InfineonApp = InfineonApp.LOCK, - board: InfineonBoard = InfineonBoard.P6BOARD): + board: InfineonBoard = InfineonBoard.P6BOARD, + enable_ota_requestor: bool = False, + update_image: bool = False): super(InfineonBuilder, self).__init__( - root=os.path.join(root, 'examples', app.ExampleName(), 'p6'), + root=app.BuildRoot(root), runner=runner) self.app = app - self.board = board + self.extra_gn_options = ['p6_board="%s"' % board.GnArgName()] + + if enable_ota_requestor: + self.extra_gn_options.append('chip_enable_ota_requestor=true') + if update_image: + self.extra_gn_options.append('build_update_image=true') def GnBuildArgs(self): - return ['p6_board="%s"' % self.board.GnArgName()] + return self.extra_gn_options def build_outputs(self): items = { diff --git a/scripts/build/testdata/all_targets_except_host.txt b/scripts/build/testdata/all_targets_except_host.txt index 74eb20b4af658e..fe98801f8ee5ac 100644 --- a/scripts/build/testdata/all_targets_except_host.txt +++ b/scripts/build/testdata/all_targets_except_host.txt @@ -180,8 +180,20 @@ imx-thermostat imx-thermostat-release infineon-p6-all-clusters infineon-p6-all-clusters-minimal +infineon-p6-all-clusters-minimal-ota (NOGLOB: Reduce default build variants) +infineon-p6-all-clusters-minimal-ota-updateimage (NOGLOB: Reduce default build variants) +infineon-p6-all-clusters-minimal-updateimage (NOGLOB: Reduce default build variants) +infineon-p6-all-clusters-ota (NOGLOB: Reduce default build variants) +infineon-p6-all-clusters-ota-updateimage (NOGLOB: Reduce default build variants) +infineon-p6-all-clusters-updateimage (NOGLOB: Reduce default build variants) infineon-p6-light +infineon-p6-light-ota (NOGLOB: Reduce default build variants) +infineon-p6-light-ota-updateimage (NOGLOB: Reduce default build variants) +infineon-p6-light-updateimage (NOGLOB: Reduce default build variants) infineon-p6-lock +infineon-p6-lock-ota (NOGLOB: Reduce default build variants) +infineon-p6-lock-ota-updateimage (NOGLOB: Reduce default build variants) +infineon-p6-lock-updateimage (NOGLOB: Reduce default build variants) k32w-light-ota-se (NOGLOB: Only on demand build) k32w-light-release-no-ota k32w-lock-low-power-release (NOGLOB: Only on demand build) diff --git a/scripts/build/testdata/build_all_except_host.txt b/scripts/build/testdata/build_all_except_host.txt index e365f295f08c20..6cb3d25fcf67a2 100644 --- a/scripts/build/testdata/build_all_except_host.txt +++ b/scripts/build/testdata/build_all_except_host.txt @@ -849,12 +849,48 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa # Generating infineon-p6-all-clusters-minimal gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/all-clusters-minimal-app/p6 '--args=p6_board="CY8CKIT-062S2-43012"' {out}/infineon-p6-all-clusters-minimal +# Generating infineon-p6-all-clusters-minimal-ota +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/all-clusters-minimal-app/p6 '--args=p6_board="CY8CKIT-062S2-43012" chip_enable_ota_requestor=true' {out}/infineon-p6-all-clusters-minimal-ota + +# Generating infineon-p6-all-clusters-minimal-ota-updateimage +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/all-clusters-minimal-app/p6 '--args=p6_board="CY8CKIT-062S2-43012" chip_enable_ota_requestor=true build_update_image=true' {out}/infineon-p6-all-clusters-minimal-ota-updateimage + +# Generating infineon-p6-all-clusters-minimal-updateimage +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/all-clusters-minimal-app/p6 '--args=p6_board="CY8CKIT-062S2-43012" build_update_image=true' {out}/infineon-p6-all-clusters-minimal-updateimage + +# Generating infineon-p6-all-clusters-ota +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/all-clusters-app/p6 '--args=p6_board="CY8CKIT-062S2-43012" chip_enable_ota_requestor=true' {out}/infineon-p6-all-clusters-ota + +# Generating infineon-p6-all-clusters-ota-updateimage +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/all-clusters-app/p6 '--args=p6_board="CY8CKIT-062S2-43012" chip_enable_ota_requestor=true build_update_image=true' {out}/infineon-p6-all-clusters-ota-updateimage + +# Generating infineon-p6-all-clusters-updateimage +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/all-clusters-app/p6 '--args=p6_board="CY8CKIT-062S2-43012" build_update_image=true' {out}/infineon-p6-all-clusters-updateimage + # Generating infineon-p6-light gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/p6 '--args=p6_board="CY8CKIT-062S2-43012"' {out}/infineon-p6-light +# Generating infineon-p6-light-ota +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/p6 '--args=p6_board="CY8CKIT-062S2-43012" chip_enable_ota_requestor=true' {out}/infineon-p6-light-ota + +# Generating infineon-p6-light-ota-updateimage +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/p6 '--args=p6_board="CY8CKIT-062S2-43012" chip_enable_ota_requestor=true build_update_image=true' {out}/infineon-p6-light-ota-updateimage + +# Generating infineon-p6-light-updateimage +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/p6 '--args=p6_board="CY8CKIT-062S2-43012" build_update_image=true' {out}/infineon-p6-light-updateimage + # Generating infineon-p6-lock gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/p6 '--args=p6_board="CY8CKIT-062S2-43012"' {out}/infineon-p6-lock +# Generating infineon-p6-lock-ota +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/p6 '--args=p6_board="CY8CKIT-062S2-43012" chip_enable_ota_requestor=true' {out}/infineon-p6-lock-ota + +# Generating infineon-p6-lock-ota-updateimage +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/p6 '--args=p6_board="CY8CKIT-062S2-43012" chip_enable_ota_requestor=true build_update_image=true' {out}/infineon-p6-lock-ota-updateimage + +# Generating infineon-p6-lock-updateimage +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/p6 '--args=p6_board="CY8CKIT-062S2-43012" build_update_image=true' {out}/infineon-p6-lock-updateimage + {root}/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh # Generating k32w-light-ota-se @@ -2073,12 +2109,48 @@ ninja -C {out}/infineon-p6-all-clusters # Building infineon-p6-all-clusters-minimal ninja -C {out}/infineon-p6-all-clusters-minimal +# Building infineon-p6-all-clusters-minimal-ota +ninja -C {out}/infineon-p6-all-clusters-minimal-ota + +# Building infineon-p6-all-clusters-minimal-ota-updateimage +ninja -C {out}/infineon-p6-all-clusters-minimal-ota-updateimage + +# Building infineon-p6-all-clusters-minimal-updateimage +ninja -C {out}/infineon-p6-all-clusters-minimal-updateimage + +# Building infineon-p6-all-clusters-ota +ninja -C {out}/infineon-p6-all-clusters-ota + +# Building infineon-p6-all-clusters-ota-updateimage +ninja -C {out}/infineon-p6-all-clusters-ota-updateimage + +# Building infineon-p6-all-clusters-updateimage +ninja -C {out}/infineon-p6-all-clusters-updateimage + # Building infineon-p6-light ninja -C {out}/infineon-p6-light +# Building infineon-p6-light-ota +ninja -C {out}/infineon-p6-light-ota + +# Building infineon-p6-light-ota-updateimage +ninja -C {out}/infineon-p6-light-ota-updateimage + +# Building infineon-p6-light-updateimage +ninja -C {out}/infineon-p6-light-updateimage + # Building infineon-p6-lock ninja -C {out}/infineon-p6-lock +# Building infineon-p6-lock-ota +ninja -C {out}/infineon-p6-lock-ota + +# Building infineon-p6-lock-ota-updateimage +ninja -C {out}/infineon-p6-lock-ota-updateimage + +# Building infineon-p6-lock-updateimage +ninja -C {out}/infineon-p6-lock-updateimage + # Building k32w-light-ota-se ninja -C {out}/k32w-light-ota-se diff --git a/src/platform/P6/CHIPDevicePlatformConfig.h b/src/platform/P6/CHIPDevicePlatformConfig.h index c1b7c1af383eb5..51aae4d025170d 100644 --- a/src/platform/P6/CHIPDevicePlatformConfig.h +++ b/src/platform/P6/CHIPDevicePlatformConfig.h @@ -30,8 +30,13 @@ #define CHIP_DEVICE_CONFIG_LWIP_WIFI_STATION_IF_NAME "infineon" #define CHIP_DEVICE_CONFIG_LOG_PROVISIONING_HASH 0 + +/* The VendorName attribute of the Basic cluster. */ +#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_PRODUCT_ID 0x8000 + #define CHIP_DEVICE_CONFIG_WIFI_AP_SSID_PREFIX "INF" #define CHIP_DEVICE_CONFIG_WIFI_AP_PASSWORD "AP_PASSWORD" #define CHIP_DEVICE_CONFIG_WIFI_AP_CHANNEL 11 diff --git a/src/platform/P6/DiagnosticDataProviderImpl.cpp b/src/platform/P6/DiagnosticDataProviderImpl.cpp index 9b8fd37a23172b..ae3efbcf091e80 100644 --- a/src/platform/P6/DiagnosticDataProviderImpl.cpp +++ b/src/platform/P6/DiagnosticDataProviderImpl.cpp @@ -254,7 +254,8 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(uint8_t & wiFiVersion) ChipLogError(DeviceLayer, "whd_wifi_get_ap_info failed: %d", (int) result); SuccessOrExit(CHIP_ERROR_INTERNAL); } - /* VHT Capable bit variable is not defined in whd and has to use the reserved bit */ + + /* VHT Capable */ if (bss_info.vht_cap) { wiFiVersion = EMBER_ZCL_WI_FI_VERSION_TYPE_802__11AC; diff --git a/src/platform/P6/OTAImageProcessorImpl.cpp b/src/platform/P6/OTAImageProcessorImpl.cpp index 5ca1fa089e98ea..5fb0d1505314c2 100644 --- a/src/platform/P6/OTAImageProcessorImpl.cpp +++ b/src/platform/P6/OTAImageProcessorImpl.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include using namespace ::chip::DeviceLayer::Internal; @@ -151,6 +152,9 @@ void OTAImageProcessorImpl::HandlePrepareDownload(intptr_t context) return; } + /* Initialize SMIF subsystem for OTA Image download */ + ota_smif_initialize(); + // Open and erase secondary flash area to prepare if (flash_area_open(FLASH_AREA_IMAGE_SECONDARY(0), &(imageProcessor->mFlashArea)) != 0) { diff --git a/src/platform/P6/OTAImageProcessorImpl.h b/src/platform/P6/OTAImageProcessorImpl.h index 4150565f8867ec..e1ec3d50e9806c 100644 --- a/src/platform/P6/OTAImageProcessorImpl.h +++ b/src/platform/P6/OTAImageProcessorImpl.h @@ -28,7 +28,8 @@ extern "C" { #include "bootutil/bootutil.h" #include "cy_flash_psoc6.h" -#include "cy_smif_psoc6.h" +#include "flash_map_backend.h" +#include "flash_qspi.h" #include "sysflash/sysflash.h" } diff --git a/third_party/p6/p6_sdk/Makefile b/third_party/p6/p6_sdk/Makefile index 19acb28dbbe4f5..45318c6686baa7 100755 --- a/third_party/p6/p6_sdk/Makefile +++ b/third_party/p6/p6_sdk/Makefile @@ -81,7 +81,7 @@ ENABLE_SECURE_MOSQUITTO_BROKER_SUPPORT=0 # ... then code in directories named COMPONENT_foo and COMPONENT_bar will be # added to the build # -COMPONENTS=FREERTOS LWIP MBEDTLS RTOS_AWARE WICED_BLE +COMPONENTS=FREERTOS LWIP MBEDTLS RTOS_AWARE WICED_BLE OTA_MCUBOOT_PSOC # CHIP: ModusToolbox 2.2 & 2.3 do not have a way to disable indirect library # dependencies. This causes trouble for CHIP because we need to use its @@ -114,7 +114,7 @@ INCLUDES=./configs MBEDTLSFLAGS = MBEDTLS_USER_CONFIG_FILE= # Add additional defines to the build process (without a leading -D). -DEFINES=$(MBEDTLSFLAGS) CYBSP_WIFI_CAPABLE CY_RETARGET_IO_CONVERT_LF_TO_CRLF CY_RTOS_AWARE +DEFINES=$(MBEDTLSFLAGS) CYBSP_WIFI_CAPABLE CY_RETARGET_IO_CONVERT_LF_TO_CRLF CY_RTOS_AWARE PSOC_062_2M # Enable support for Mosquitto Broker based on 'ENABLE_SECURE_MOSQUITTO_BROKER_ # SUPPORT' variable. See the MQTT Client library's README for more information. diff --git a/third_party/p6/p6_sdk/build/CY8CKIT-062S2-43012/Debug/GCC_ARM.json b/third_party/p6/p6_sdk/build/CY8CKIT-062S2-43012/Debug/GCC_ARM.json index f1f27129365cbd..e96bb45ea363fe 100644 --- a/third_party/p6/p6_sdk/build/CY8CKIT-062S2-43012/Debug/GCC_ARM.json +++ b/third_party/p6/p6_sdk/build/CY8CKIT-062S2-43012/Debug/GCC_ARM.json @@ -84,6 +84,26 @@ "-I./libs/abstraction-rtos/include", "-I./libs/abstraction-rtos/include/COMPONENT_FREERTOS", "-I./libs/abstraction-rtos/include/Template", + "-I./libs/anycloud-ota", + "-I./libs/anycloud-ota/include", + "-I./libs/anycloud-ota/source", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/bootutil", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/bootutil/include", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/bootutil/include/bootutil", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/bootutil/src", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/flash_qspi", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/include", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/include/flash_map_backend", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/mem_config", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/mcuboot_header", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/mcuboot_header/mcuboot_config", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/sysflash", + "-I./libs/anycloud-ota/source/port_support", + "-I./libs/anycloud-ota/source/port_support/serial_flash", + "-I./libs/anycloud-ota/source/port_support/untar", "-I./libs/bluetooth-freertos", "-I./libs/bluetooth-freertos/platform", "-I./libs/bluetooth-freertos/platform/common", @@ -120,6 +140,8 @@ "-I./libs/mbedtls", "-I./libs/mbedtls/include", "-I./libs/mbedtls/include/mbedtls", + "-I./libs/mbedtls/include/psa", + "-I./libs/mbedtls/library", "-I./libs/mtb-hal-cat1", "-I./libs/mtb-hal-cat1/COMPONENT_CAT1A", "-I./libs/mtb-hal-cat1/COMPONENT_CAT1A/include", @@ -165,13 +187,15 @@ "-I./libs/wifi-host-driver/WiFi_Host_Driver/src/bus_protocols", "-I./libs/wifi-host-driver/WiFi_Host_Driver/src/include", "-I./libs/wifi-mw-core", - "-I./libs/wifi-mw-core/lwip-whd-port" + "-I./libs/wifi-mw-core/lwip-whd-port", + "-I./ota/config" ], "defines": [ "-DMBEDTLS_USER_CONFIG_FILE=", "-DCYBSP_WIFI_CAPABLE", "-DCY_RETARGET_IO_CONVERT_LF_TO_CRLF", "-DCY_RTOS_AWARE", + "-DPSOC_062_2M", "-DCY_USING_HAL", "-DCY_APPNAME_mtb_chip_sdk", "-DCY8C624ABZI_S2D44", @@ -190,6 +214,7 @@ "-DCOMPONENT_LWIP", "-DCOMPONENT_MBEDTLS", "-DCOMPONENT_MURATA_1LV", + "-DCOMPONENT_OTA_MCUBOOT_PSOC", "-DCOMPONENT_PSOC6HAL", "-DCOMPONENT_RTOS_AWARE", "-DCOMPONENT_SOFTFP", @@ -199,6 +224,7 @@ ], "c_source": [ "./libs/abstraction-rtos/source/cy_worker_thread.c", + "./libs/anycloud-ota/source/port_support/serial_flash/ota_serial_flash.c", "./libs/bluetooth-freertos/platform/common/cybt_hci_rx_task.c", "./libs/bluetooth-freertos/platform/common/cybt_hci_tx_task.c", "./libs/bluetooth-freertos/platform/common/cybt_host_stack_platform_interface.c", @@ -547,6 +573,13 @@ "./libs/TARGET_CY8CKIT-062S2-43012/COMPONENT_CM4/system_psoc6_cm4.c", "./libs/abstraction-rtos/source/COMPONENT_FREERTOS/cyabs_freertos_helpers.c", "./libs/abstraction-rtos/source/COMPONENT_FREERTOS/cyabs_rtos_freertos.c", + "./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/bootutil/src/bootutil_misc.c", + "./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/cy_flash_map.c", + "./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/cy_flash_psoc6.c", + "./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/flash_qspi/flash_qspi.c", + "./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/mem_config/mem_config_sfdp.c", + "./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/ota_flash_map.c", + "./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/ota_flash_xip_map.c", "./libs/bluetooth-freertos/firmware/COMPONENT_43012/COMPONENT_MURATA-1LV/COMPONENT_HCI-UART/w_bt_firmware_controller.c", "./libs/clib-support/COMPONENT_FREERTOS/cy_mutex_pool.c", "./libs/connectivity-utilities/network/COMPONENT_LWIP/cy_nw_helper.c", diff --git a/third_party/p6/p6_sdk/build/CY8CKIT-062S2-43012/Release/GCC_ARM.json b/third_party/p6/p6_sdk/build/CY8CKIT-062S2-43012/Release/GCC_ARM.json index d7d5c1b35f24a7..f31178e379e213 100644 --- a/third_party/p6/p6_sdk/build/CY8CKIT-062S2-43012/Release/GCC_ARM.json +++ b/third_party/p6/p6_sdk/build/CY8CKIT-062S2-43012/Release/GCC_ARM.json @@ -84,6 +84,26 @@ "-I./libs/abstraction-rtos/include", "-I./libs/abstraction-rtos/include/COMPONENT_FREERTOS", "-I./libs/abstraction-rtos/include/Template", + "-I./libs/anycloud-ota", + "-I./libs/anycloud-ota/include", + "-I./libs/anycloud-ota/source", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/bootutil", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/bootutil/include", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/bootutil/include/bootutil", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/bootutil/src", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/flash_qspi", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/include", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/include/flash_map_backend", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/mem_config", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/mcuboot_header", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/mcuboot_header/mcuboot_config", + "-I./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/sysflash", + "-I./libs/anycloud-ota/source/port_support", + "-I./libs/anycloud-ota/source/port_support/serial_flash", + "-I./libs/anycloud-ota/source/port_support/untar", "-I./libs/bluetooth-freertos", "-I./libs/bluetooth-freertos/platform", "-I./libs/bluetooth-freertos/platform/common", @@ -120,6 +140,8 @@ "-I./libs/mbedtls", "-I./libs/mbedtls/include", "-I./libs/mbedtls/include/mbedtls", + "-I./libs/mbedtls/include/psa", + "-I./libs/mbedtls/library", "-I./libs/mtb-hal-cat1", "-I./libs/mtb-hal-cat1/COMPONENT_CAT1A", "-I./libs/mtb-hal-cat1/COMPONENT_CAT1A/include", @@ -165,13 +187,15 @@ "-I./libs/wifi-host-driver/WiFi_Host_Driver/src/bus_protocols", "-I./libs/wifi-host-driver/WiFi_Host_Driver/src/include", "-I./libs/wifi-mw-core", - "-I./libs/wifi-mw-core/lwip-whd-port" + "-I./libs/wifi-mw-core/lwip-whd-port", + "-I./ota/config" ], "defines": [ "-DMBEDTLS_USER_CONFIG_FILE=", "-DCYBSP_WIFI_CAPABLE", "-DCY_RETARGET_IO_CONVERT_LF_TO_CRLF", "-DCY_RTOS_AWARE", + "-DPSOC_062_2M", "-DCY_USING_HAL", "-DCY_APPNAME_mtb_chip_sdk", "-DCY8C624ABZI_S2D44", @@ -190,6 +214,7 @@ "-DCOMPONENT_LWIP", "-DCOMPONENT_MBEDTLS", "-DCOMPONENT_MURATA_1LV", + "-DCOMPONENT_OTA_MCUBOOT_PSOC", "-DCOMPONENT_PSOC6HAL", "-DCOMPONENT_RTOS_AWARE", "-DCOMPONENT_SOFTFP", @@ -199,6 +224,7 @@ ], "c_source": [ "./libs/abstraction-rtos/source/cy_worker_thread.c", + "./libs/anycloud-ota/source/port_support/serial_flash/ota_serial_flash.c", "./libs/bluetooth-freertos/platform/common/cybt_hci_rx_task.c", "./libs/bluetooth-freertos/platform/common/cybt_hci_tx_task.c", "./libs/bluetooth-freertos/platform/common/cybt_host_stack_platform_interface.c", @@ -547,6 +573,13 @@ "./libs/TARGET_CY8CKIT-062S2-43012/COMPONENT_CM4/system_psoc6_cm4.c", "./libs/abstraction-rtos/source/COMPONENT_FREERTOS/cyabs_freertos_helpers.c", "./libs/abstraction-rtos/source/COMPONENT_FREERTOS/cyabs_rtos_freertos.c", + "./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/bootutil/src/bootutil_misc.c", + "./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/cy_flash_map.c", + "./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/cy_flash_psoc6.c", + "./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/flash_qspi/flash_qspi.c", + "./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/mem_config/mem_config_sfdp.c", + "./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/ota_flash_map.c", + "./libs/anycloud-ota/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/cy_flash_pal/ota_flash_xip_map.c", "./libs/bluetooth-freertos/firmware/COMPONENT_43012/COMPONENT_MURATA-1LV/COMPONENT_HCI-UART/w_bt_firmware_controller.c", "./libs/clib-support/COMPONENT_FREERTOS/cy_mutex_pool.c", "./libs/connectivity-utilities/network/COMPONENT_LWIP/cy_nw_helper.c", diff --git a/third_party/p6/p6_sdk/libs/anycloud-ota b/third_party/p6/p6_sdk/libs/anycloud-ota index 040f563c5fa34b..adc942bb85aa6e 160000 --- a/third_party/p6/p6_sdk/libs/anycloud-ota +++ b/third_party/p6/p6_sdk/libs/anycloud-ota @@ -1 +1 @@ -Subproject commit 040f563c5fa34bf64a4ab487b7af35c6e6e9d7c5 +Subproject commit adc942bb85aa6e43021cbf31454314dbe6038e25 diff --git a/third_party/p6/p6_sdk/ota/ota_base_build.sh b/third_party/p6/p6_sdk/ota/ota_base_build.sh new file mode 100755 index 00000000000000..ca072f8a88cc9a --- /dev/null +++ b/third_party/p6/p6_sdk/ota/ota_base_build.sh @@ -0,0 +1,7 @@ +OUT_DIR=$1 +HEX_NAME=$2 +ANYCLOUD_DIR=third_party/p6/p6_sdk/libs/anycloud-ota/ + +mv "$OUT_DIR"/"$HEX_NAME".hex "$OUT_DIR"/"$HEX_NAME".unsigned.hex + +./"$ANYCLOUD_DIR"/scripts/sign_script.bash "$OUT_DIR"/ "$HEX_NAME" python3 arm-none-eabi-objcopy "-O ihex" "" "$ANYCLOUD_DIR"/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/scripts/ imgtool_v1.7.0/imgtool.py create 0xFF 0x400 3584 1.0.0 0x00018000 0x001C0000 arm-none-eabi-objcopy "" diff --git a/third_party/p6/p6_sdk/ota/ota_update_build.sh b/third_party/p6/p6_sdk/ota/ota_update_build.sh new file mode 100755 index 00000000000000..4a02cc89be9153 --- /dev/null +++ b/third_party/p6/p6_sdk/ota/ota_update_build.sh @@ -0,0 +1,13 @@ +OUT_DIR=$1 +HEX_NAME=$2 +ANYCLOUD_DIR=third_party/p6/p6_sdk/libs/anycloud-ota/ + +mv "$OUT_DIR"/"$HEX_NAME".hex "$OUT_DIR"/"$HEX_NAME".unsigned.hex + +./"$ANYCLOUD_DIR"/scripts/sign_script.bash "$OUT_DIR"/ "$HEX_NAME" python3 arm-none-eabi-objcopy "-O ihex" "" "$ANYCLOUD_DIR"/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/scripts/ imgtool_v1.7.0/imgtool.py sign 0xFF 0x400 3584 1.0.0 0x00018000 0x001C0000 arm-none-eabi-objcopy "-k $ANYCLOUD_DIR/source/COMPONENT_OTA_MCUBOOT_PSOC/mcuboot/keys/cypress-test-ec-p256.pem" + +if [ -f "$OUT_DIR"/"$HEX_NAME".ota ]; then + rm "$OUT_DIR"/"$HEX_NAME".ota +fi + +src/app/ota_image_tool.py create -v 0xFFF1 -p 0x8000 -vn 2 -vs "2.0" -da sha256 "$OUT_DIR"/"$HEX_NAME".bin "$OUT_DIR"/"$HEX_NAME".ota