project-chip / connectedhomeip

Matter (formerly Project CHIP) creates more connections between more objects, simplifying development for manufacturers and increasing compatibility for consumers, guided by the Connectivity Standards Alliance.
https://buildwithmatter.com
Apache License 2.0
7.45k stars 1.99k forks source link

OTA provider software version #26346

Closed SYESHASWINI closed 2 days ago

SYESHASWINI commented 1 year ago

Reproduction steps

how to change the ota provider's software version. It is always 1.
Once the ota is completed with version 1, then the ota for second time is getting failed as the ota-requestor software version is equal or greater the ota-provider.

Bug prevalence

whenever I execute the command

GitHub hash of the SDK that was being used

none

Platform

esp32

Platform Version(s)

No response

Type

Core SDK Interopability Issue

Anything else?

No response

bzbarsky-apple commented 1 year ago

how to change the ota provider's software version. It is always 1.

You mean how to change the version reported by the image that the ota-requestor updates to? Where is that image coming from? How are you generating the image @SYESHASWINI ?

SYESHASWINI commented 1 year ago

@bzbarsky-apple I'm Generating the image by enabling Matter Ota Image and setting the version in Get the project version from kconfig. Even though project version is set to 3, when I read the basic information cluster the software version is seen has 1.

bzbarsky-apple commented 1 year ago

@SYESHASWINI I don't know what "enabling Matter Ota Image" means (e.g. where are you enabling it?), but it sounds like you should report the bug on whatever utility you are using to generate the image.

SYESHASWINI commented 1 year ago

@bzbarsky-apple I'm enabling those using menuconfig and the ota image will be generated as project_name-ota.bin image image

shubhamdp commented 1 year ago

@SYESHASWINI please update the below lines in your CMakeLists.txt. https://github.com/project-chip/connectedhomeip/blob/dbf24304ba8473808768aba0196b5dd6a7dee640/examples/all-clusters-app/esp32/CMakeLists.txt#L21-L22

SYESHASWINI commented 1 year ago

@shubhamdp it is already set in the cmake list. ota-provider-app version is not same as the ota image version. image

shubhamdp commented 1 year ago

Sorry, I may have misread the very first comment.

how to change the ota provider's software version. It is always 1.

As mentioned in https://github.com/project-chip/connectedhomeip/issues/26346#issuecomment-1534145720, you can change the firmware version like below in your project's CMakeLists.txt

 set(PROJECT_VER "v2.0") 
 set(PROJECT_VER_NUMBER 2)

Once the ota is completed with version 1, then the ota for second time is getting failed as the ota-requestor software version is equal or greater the ota-provider.

Here, OTA provider's version has nothing to do with this. The check is for ota-requestor's verison, it checks if the version of downloaded firmware is greater than the running firmware version.

To test OTA requestor and provider functionality, please see if you are trying the below things.

  1. Build, flash, commission the ota-requestor (eg: version is 1)
  2. In ota-requestor, change the version as suggested above to 2(or any higher value) and build the firmware. [FYI: Generate Matter OTA image flow is broken, can you please generate the matter ota image using ota_image_tool.py]
  3. Build ota-provider and embed the ota-requestor firmware image with v2 here (please see the docs here), flash, commission the ota-provider
  4. Install acl on ota-provider and try sending announce-ota-provider command to ota-requestor
shubhamdp commented 1 year ago

Filed an issue for broken ota image generation flow: https://github.com/project-chip/connectedhomeip/issues/26364

SYESHASWINI commented 1 year ago

@shubhamdp I tried generating the ota image using the ota_image_tool.py, then it shows the error:

/esp/esp-matter/connectedhomeip/connectedhomeip/src/app$ ./ota_image_tool.py show e sp/light2/build/light-ota.bin Traceback (most recent call last): File "/home/ubuntu/esp/esp-matter/connectedhomeip/connectedhomeip/src/app/./ota_image_tool.py", line 391, in main() File "/home/ubuntu/esp/esp-matter/connectedhomeip/connectedhomeip/src/app/./ota_image_tool.py", line 383, in main show_header(args) File "/home/ubuntu/esp/esp-matter/connectedhomeip/connectedhomeip/src/app/./ota_image_tool.py", line 260, in show_header magic, total_size, header_size, header_tlv = parse_header(args) File "/home/ubuntu/esp/esp-matter/connectedhomeip/connectedhomeip/src/app/./ota_image_tool.py", line 221, in parse_header with open(args.image_file, 'rb') as file: FileNotFoundError: [Errno 2] No such file or directory: 'esp/light2/build/light-ota.bin'

shubhamdp commented 1 year ago

Please find below the sample command...

./ota_image_tool.py create --vendor-id 0xFFF1 --product-id 0x8001 \
                           --version 2 --version-str "v2.0" \
                           --digest-algorithm sha256 \
                           light.bin light-matter-ota.bin

NOTE: please provide the valid path for build/light.bin and modify the vendor-id product-id, version, and version string as per your configurations.

To see the header details in generated image,

./ota_image_tool.py show light-matter-ota.bin
SYESHASWINI commented 1 year ago

@shubhamdp given the valid path and the error through like this:

./ota_image_tool.py create --vendor-id 0xFFF1 --product-id 0x8000 \ --version 1 --version-str "v1.0" \ --digest-algorithm sha256 /esp/light/build/light.bin /esp/light/build/light-ota.bin

usage: ota_image_tool.py create [-h] -v VENDOR_ID -p PRODUCT_ID -vn VERSION -vs VERSION_STR -da {sha3_512,sha3_224,sha3_256,sha256,sha3_384,sha512,sha384} [-mi MIN_VERSION] [-ma MAX_VERSION] [-rn RELEASE_NOTES] input_files [input_files ...] output_file ota_image_tool.py create: error: the following arguments are required: input_files, output_file -bash: /esp/light/build/light.bin: No such file or directory

shubhamdp commented 1 year ago

-bash: /esp/light/build/light.bin: No such file or directory

This is the error, are you sure that the file (/esp/light/build/light.bin) is present, because error says it not.

SYESHASWINI commented 1 year ago

Yes, the file is present in the path, but don't know why the error occurs.

shubhamdp commented 1 year ago

Ohh, I missed one escape character in command after specifying the digest algorithm :-(. Please try the following, I have pasted the whole command in the single line now.

./ota_image_tool.py create --vendor-id 0xFFF1 --product-id 0x8001 --version 2 --version-str "v2.0" --digest-algorithm sha256 /esp/light/build/light.bin /esp/light/build/light-ota.bin
SYESHASWINI commented 1 year ago

@shubhamdp Generated OTA image using ota_image_tool and performed ota. Once the device restarts it shows the confirm image failure.

E (2742) chip[SWU]: Failed to confirm image: 3

shubhamdp commented 1 year ago

Can you please attach the complete logs from ota-requestor when this happened?

SYESHASWINI commented 1 year ago

@shubhamdp attaching the requestor log matter_ota_requestor.txt

shubhamdp commented 1 year ago

Boot up logs before OTA

I (369) boot: Loaded app from partition at offset 0x20000
I (396) cpu_start: Application information:
I (399) cpu_start: Project name:     light
I (404) cpu_start: App version:      1
I (408) cpu_start: Compile time:     May  5 2023 17:15:08
I (414) cpu_start: ELF file SHA256:  752e579ea7c45437...

Boot up logs after OTA

I (374) boot: Loaded app from partition at offset 0x200000
I (401) cpu_start: Application information:
I (404) cpu_start: Project name:     light
I (408) cpu_start: App version:      1
I (413) cpu_start: Compile time:     May  5 2023 17:15:08
I (419) cpu_start: ELF file SHA256:  9a77918ecc6981cb...

Few observations based on above logs:

Please try following:

shubhamdp commented 1 year ago

Duplicate Comment, I am unable to delete it...

SYESHASWINI commented 1 year ago

@shubhamdp while performing ota it throws the error as Unsupported Cluster.Before it was working fine. attaching the error log. ota-unsupported cluster.txt

SYESHASWINI commented 1 year ago

Hi @shubhamdp, is there any issue with OTA process currently?. As I announce the OTA it shows general error :0xc3 (UNSUPPORTED CLUSTER)

shubhamdp commented 1 year ago

@SYESHASWINI Sorry for the delayed response for the above message. Have you enabled config option CONFIG_ENABLE_OTA_REQUESTOR https://github.com/project-chip/connectedhomeip/blob/bfa05804ac3c224c9e70921a857ffcac32ccc7f4/config/esp32/components/chip/Kconfig#L176-L180

SYESHASWINI commented 1 year ago

@shubhamdp Yes, forgot to enable it. Thank You.

SYESHASWINI commented 1 year ago

@shubhamdp followed the instructions as below and changed the versions in CMakelist but still the error E (2674) chip[SWU]: Failed to confirm image: 3 is appearing.

Build an application with Version: 1 and flash it on the device. To generate the OTA image, please please bump the firmware version as described in https://github.com/project-chip/connectedhomeip/issues/26346#issuecomment-1534145720 in your projects CMakeLists.txt. Build the firmware with updated version and generate the matter ota image using ota_image_too.py Then use that image with ota-provider-app

shubhamdp commented 1 year ago

@SYESHASWINI After OTA upgrade is complete, device boots from upgraded partition.

Below is the source of error log If you see [here](https://github.com/project-chip/connectedhomeip/blob/master/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp#L79) (place for error print), this is when it fails to confirm the image.

And below is the implementation for ConfirmCurrentImage() https://github.com/project-chip/connectedhomeip/blob/43cfe21dc1f852e7c1d2f2667f13b4db125d20d0/src/platform/ESP32/OTAImageProcessorImpl.cpp#L68-L84 It has an explicit check for version, if version is not exactly same as it was promised in then it prints an error.

Can you please read the version using chip-tool to confirm if that is that case?

// 1 is the node id, please replace with the node id of requestor
./chip-tool basicinformation read software-version 1 0

Also, one more identifier if OTA was success or not is I (369) boot: Loaded app from partition at offset 0x20000 line in ESP32 bootup logs. The address will change after OTA upgrade. (https://github.com/project-chip/connectedhomeip/issues/26346#issuecomment-1539997780)

SYESHASWINI commented 1 year ago

@shubhamdp the partition address is changing from ota1 to ota2, but the basic information cluster values are same before and after ota.

shubhamdp commented 1 year ago

@SYESHASWINI Can you please share the sdkconfig and below two lines from your project's top level CMakeLists.txt https://github.com/project-chip/connectedhomeip/blob/4f6923fe7c7df3dea22b3e9d5bc4944b888e5dbb/examples/lighting-app/esp32/CMakeLists.txt#L21-L22

SYESHASWINI commented 1 year ago

@shubhamdp Sharing the sdkconfig file. sdkconfig.txt This is for OTA-Requestor: set(PROJECT_VER "v1.0") set(PROJECT_VER_NUMBER 1) OTA-Image: set(PROJECT_VER "v2.0") set(PROJECT_VER_NUMBER )

shubhamdp commented 1 year ago

OTA-Image: set(PROJECT_VER "v2.0") set(PROJECT_VER_NUMBER )

If you see here, version number is missing right? It should be set(PROJECT_VER_NUMBER 2).

SYESHASWINI commented 1 year ago

@shubhamdp It is gone while commenting it is set(PROJECT_VER "v2.0") set(PROJECT_VER_NUMBER 2) performed OTA with this versions

shubhamdp commented 1 year ago

@SYESHASWINI Thanks for the sdkconfig, now I understood the problem, and I think it will be better to document it in docs/guides/esp32 other than code.

You have CONFIG_APP_PROJECT_VER_FROM_CONFIG=y option enabled which is not allowing to pick the version from CMakeLists.txt. Please see below https://github.com/project-chip/connectedhomeip/blob/530349abc047f3d911216eac94c733bd6de4604d/config/esp32/components/chip/CMakeLists.txt#L70-L80.

This was done in order to be in sync with IDF.

So, two options:

  1. If you have set CONFIG_APP_PROJECT_VER_FROM_CONFIG intentionally then please set the version using CONFIG_DEVICE_SOFTWARE_VERSION_NUMBER option. (Component config -> CHIP Device Layer -> Device Identification Options -> Device Software Version Number)
  2. If its not intentional then please disable the option and keep using versions as you just changed in CMakeLists.txt.
shubhamdp commented 1 year ago

@SYESHASWINI any updates?

SYESHASWINI commented 1 year ago

@shubhamdp sorry for the delay. I'm facing issues while commissioning devices through chip-tool, the ble is getting error so I was unable to test it. error: bluez.Errorsoftware caused connection abort(38). Is there any other way to test OTA functionality

shubhamdp commented 1 year ago

@SYESHASWINI If you are facing BLE commissioning issues then you can connect the device to wifi using below config options. Then carry out the onnetwork commissioning and rest stays the same.

CONFIG_DEFAULT_WIFI_SSID=example-ssid
CONFIG_DEFAULT_WIFI_PASSWORD=example-passphrase
SYESHASWINI commented 1 year ago

@shubhamdp Checking with this method, will update you soon

SYESHASWINI commented 1 year ago

@shubhamdp with idf version v4.4.4 I'm getting the error while ota is inprogress. error: Failed to Send CHIP MessageCounter:5072182 on exchange 34130i sendCount: 4 max retries: 4. How can I solve this error as it is interrupting the ota process

Shahmeera commented 9 months ago

I am having the same error: chip[SWU]: Failed to confirm image: 3. and I have project config CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set and my cmake_minimum_required(VERSION 3.5)

set(PROJECT_VER "v1.0") set(PROJECT_VER_NUMBER 1)

and device logs are as below I (681) cpu_start: Project name: chip-lighting-app I (687) cpu_start: App version: v1.0 but as soon as I update the firmware, version remains same and then this error appears.

dhrishi commented 2 days ago

@SYESHASWINI Closing this issue as the problem was solved