pvvx / ZigbeeTLc

Custom firmware for Zigbee 3.0 IoT devices on the TLSR825x chip
Other
365 stars 20 forks source link

Z2M: OTA update failed with reason: 'invalid image' (fw below v0.1.0.3) #11

Closed ikoz closed 10 months ago

ikoz commented 10 months ago

Some days ago I flashed a couple of LYWSD03MMC sensors from custom BTHome to the ZigbeeTLc firmware using TelinkMiFlasher.

I added the 2 devices in Z2M and they work fine so far - showing up as version 3001-0102

I am now trying to do OTA update via Z2M - either to latest 106 firmware or even back to BLE.

I've tried both firmware 1141-020a-01103001-Z03MMC.zigbee and 1141-020a-99993001-ATC_v46.zigbee

However in both cases Z2M shows update starting ..0% - and then immediatelly after it fails with "Update failed with reason: 'invalid image'"

2023-11-20 14:31:56 Got upgrade end request for '0xa4c138fda3d5689c': {"status":150,"manufacturerCode":4417,"imageType":522,"fileVersion":2576953345}
2023-11-20 14:31:56 Update failed with reason: 'invalid image'

Not sure where to go from there - any way to update via OTA or do I need to use USB cable?

nonflammable commented 10 months ago

what size are the update files on your disk? did you try to download this file: https://github.com/pvvx/ZigbeeTLc/raw/master/bin/1141-020a-01103001-Z03MMC.zigbee size: 126274

ikoz commented 10 months ago

what size are the update files on your disk? did you try to download this file: https://github.com/pvvx/ZigbeeTLc/raw/master/bin/1141-020a-01103001-Z03MMC.zigbee size: 126274

yes that's the file, and the file size is correct on disk.

$ cat configuration.yaml 
...
ota:
  ikea_ota_use_test_url: false
  zigbee_ota_override_index_location: override_update_index.json

$ cat override_update_index.json 
[
  {
    "url": "1141-020a-01103001-Z03MMC.zigbee",
    "force": true
  }
]

$ ls -l 1141-020a-01103001-Z03MMC.zigbee
-rwxrwxrwx+ 1 ikoz users 126274 Nov 20 13:56 1141-020a-01103001-Z03MMC.zigbee

$ sha1sum 1141-020a-01103001-Z03MMC.zigbee
ce1096a0f2a349b91649617fb8269bc4ca709d88  1141-020a-01103001-Z03MMC.zigbee
pvvx commented 10 months ago

Before flashing the firmware, check the compliance of the “Manufacturer Code” and “Image Type” between the OTA file and those issued by the Zigbee device.

Sample: "1141-020a-01103001-Z03MMC.zigbee"

Manufacturer Code Image Type File Version Stack Version Name Ext OTA
1141 020a 0110 3001 Z03MMC zigbee
0x1141 - Telink 0x02 - TLSR825x, 0x0a - Xiaomi LYWSD03MMC App release 0.1, App build 1.0 Zigbee v3.0, Release 0.1 Z03MMC OTA
Image Type Device, note
0x0201 MHO-C401 (old version)
0x0202 CGG1 (old version)
0x0203 LYWSD03MMC ver https://github.com/devbis/z03mmc
0x0204 WATERMETER ver https://github.com/slacky1965/watermeter_zed
0x0206 CGDK2
0x0207 CGG1 (new version)
0x0208 MHO-C401 (new version)
0x0209 MJWSD05MMC
0x020A LYWSD03MMC ver https://github.com/pvvx/ZigbeeTLc
0x020B MHO-C122
0x0210 Water Tank sensors
0x0211 TS0201-TZ3000
0x0212 TS0202-TZ3000
ikoz commented 10 months ago

Hmm not sure how to check these parameters. My device is 4417 (0x1141) and 522 image type (0x20A) as far as I can tell.

If I try to flash a firmware that is not for 0x20A I get a different message saying "No image available for imageType '522'".

So Z2M will not even attempt to flash a firmware that is not for 0x20A. But those that are for 0x20A fail with "invalid image". Is the format of the files correct for Z2M - has anyone successfully used them via Z2M instead of ZHA?

pvvx commented 10 months ago

I added the 2 devices in Z2M and they work fine so far - showing up as version 3001-0102

Beta version below 0.1.0.3 may have a bug related to the not very common TLSR825x, which has an integrated flash memory die from Zbit Semiconductor.

ikoz commented 10 months ago

I added the 2 devices in Z2M and they work fine so far - showing up as version 3001-0102

Beta version below 0.1.0.3 may have a bug related to the not very common TLSR825x, which has an integrated flash memory die from Zbit Semiconductor.

Interesting. How do I check if I have TLSR825x?

Both devices work fine and report temperatures fine, so I wouldn't consider them bricked though. Only the OTA doesn't work! I guess my only choice is to try to update using a cable.

pvvx commented 10 months ago

TLSR825x chips with Flash from ZB (Zbit Semiconductor) with fw version lower than 0.1.0.3 cannot write Flash. For this reason, OTA does not work. And any saving of the Zigbee configuration does not work. Rewriting flash memory is only possible using any version of the hardware programmer.