Koenkk / zigbee-OTA

A collection of Zigbee OTA files
411 stars 189 forks source link

Legrand 067775/741811 update invalid image failure #328

Closed yashijoe closed 11 months ago

yashijoe commented 1 year ago

What happened?

Interface tells me there is an update I try to upgrade and get the message “invalid image”

What did you expect to happen?

Upgrade successfully

How to reproduce it (minimal and precise)

Press upgrade firmware Get the message: “ Error 2023-05-17 09:18:40Update of 'refrigerator_plug' failed (Update failed with reason: 'invalid image')”

Zigbee2MQTT version

1.30.4-1

Adapter firmware version

004a

Adapter

Legrand 067775/741811

I’ve also tried with dev version and updated index.json. Same result

thank you

SilentT-FR commented 1 year ago

For the moment the Gateway Legrand abort the OTA request... OTA ABORT.zip 29:06:2A:5F:ED:79:DD:E5:F4:28:93:0B:CD:22:06:03

Do I understand correctly that it also fails with the Legrand gateway?

No its because legrand provide ota update on the legrand gateway after 1 week of the available on the legrand developer website

zbee_nwk.addr == 0x4ce9

OTA begin.zip

Key : 29:06:2A:5F:ED:79:DD:E5:F4:28:93:0B:CD:22:06:03 i upload the begenning of the OTA i have cut off to keep the socket not up to date

SilentT-FR commented 1 year ago

as you can see the update begin and the socket ask more than two block

Koenkk commented 1 year ago

as you can see the update begin and the socket ask more than two block

I don't see any ZCL OTA: Image Block Request/ZCL OTA: Image Block Response in OTA begin.zip , can you sniff for a bit longer?

SilentT-FR commented 1 year ago

Yes i see, after 1600sec you can see the real begin OTA begin no response and real begin.zip

SilentT-FR commented 1 year ago

I see this difference :

by Z2M

    File Version: 0x00514203
        0000 0000 .... .... .... .... .... .... = Application Release: 0
        .... .... 0101 0001 .... .... .... .... = Application Build: 81
        .... .... .... .... 0100 0010 .... .... = Stack Release: 66
        .... .... .... .... .... .... 0000 0011 = Stack Build: 3

By Legrand Gateway

    File Version: 0x00510000
        0000 0000 .... .... .... .... .... .... = Application Release: 0
        .... .... 0101 0001 .... .... .... .... = Application Build: 81
        .... .... .... .... 0000 0000 .... .... = Stack Release: 0
        .... .... .... .... .... .... 0000 0000 = Stack Build: 0

Legrand dev / Legrand from Gateway not use same image ?

SilentT-FR commented 1 year ago

i double check the downloaded file from legrand have same sha512 from my git folder and from a downloaded link from github

Koenkk commented 1 year ago

Could it be that Legrand published the wrong OTA files on their site? The file version is parsed from the OTA file.

sekot commented 1 year ago

the ota files work for new device.

SilentT-FR commented 12 months ago

Legrand forum say

We see that the product downloads the firmware starting the offstet 78 and not offstet 0. This case is hard to understand as it’s not reproduced on our side with our gateways and zigbee gateways tested

Legrand say 78 but i see 50 in the https://github.com/Koenkk/zigbee-OTA/files/12579307/Update_imageinvalid.zip packet 81

and for the good one : https://github.com/Koenkk/zigbee-OTA/files/12642704/OTA.begin.no.response.and.real.begin.zip packet number 6346 offset 0

So is it not the Z2M or the file but the powersocket who asking not the beginning of the file offset

SilentT-FR commented 12 months ago

So only method is it to poweroff for a long time period Legrand say

Can you try the following :

perform an electrical reboot of the device (and wait at least 30 seconds)

or

make a factory reset, reinstall the device, then re-try to perform the update
SilentT-FR commented 12 months ago

I have the chance where i can poweroff with the circuit breaker room by room but for those have circuit breaker for multiple room its hard !

SilentT-FR commented 12 months ago

im going to test tonight

chpego commented 12 months ago

im going to test tonight

I will try too

chpego commented 12 months ago

im going to test tonight

I will try too

Failed for me

FabianMangold commented 12 months ago

Hi, sorry to jump in so late. Same issue for me, have a bunch of 067776 exposing the very same issue. Neither a long reset (power off) nor a factory reset helped. The device keeps requesting data starting with offset 50.

Attempted to offset the data by 50 bytes, no luck either.

FabianMangold commented 12 months ago

I've been poking around with the devices, and eventualy managed to have my 067776s updated to the latest NLV firmware (0038)! Attached is a non-production hack for the OTA. Can anyone test if that works on other devices as well ? After having applied the patch, simply run the OTA. The first attempt will fail and end-up in a timeout. A subsequent update should work just fine.

Cheers

common.ts.zip

yashijoe commented 12 months ago

I've been poking around with the devices, and eventualy managed to have my 067776s updated to the latest NLV firmware (0038)! Attached in a non-production hack for the OTA. Can anyone test if that works on other devices as well ? After having applied the patch, simply run the OTA. The first attempt will fail and end-up in a timeout. A subsequent update should work just fine.

Cheers

common.ts.zip

How to use the file? Thanks

SilentT-FR commented 12 months ago

we can use this pull https://github.com/Koenkk/zigbee-herdsman-converters/pull/6193 ? @Koenkk you agree ?

FabianMangold commented 12 months ago

The PR is ready (sorry for the intial issues with the Lint). Alternatively, you may want to patch this locally (OTA of zigbee-herdsman-converters), as i am not sure this should really make it into the dev branch.

Koenkk commented 11 months ago

Issue should be fixed now!

Changes will be available in the dev branch in a few hours from now. (https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html)

yashijoe commented 11 months ago

Issue should be fixed now!

Changes will be available in the dev branch in a few hours from now. (https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html)

Sounds great! Thanks

yashijoe commented 11 months ago

It works!

SilentT-FR commented 11 months ago

@benjR @trollix @tkintscher @essegi65 @titou4307 @rossowl @lamerjack @pierrepinon @Xavinooo @sekot @chpego @novisys @vezyr @Loic691 @marcbernis @denisjankovic @marcbernis

you can thank @FabianMangold, the problem is solved and the solution is available on the edge version of Z2M, otherwise you have to wait a little for production.

You have to launch an upgrade which will fail (its normal) then launch a second which will work

SilentT-FR commented 11 months ago

NLV(Shutter switch with neutral) and NLP(Connected outlet) product was tested, if you have other type of product and its work (or not) you can send it back to us

SilentT-FR commented 11 months ago

For the bug i cant say if its the Firmware of legrand is bugged or too careful or not respect the zigbee stack, or if Z2M not respect the ZigbeeStack @Koenkk you know ?

i want to use this meme "Legrand, Pas mal non c'est Français" => "Legrand, Not bad no it's French" Orson Welles

titou4307 commented 11 months ago

For me I will wait the time to pass the Edge to the production I am afraid to bug my Home Assistant installation by change the Zigbee2mqtt container- (I am not a perfect informatic !!)

And Many thanks to @FabianMangold and the other who have boss into this problem

If anyone could explain the solution easy (I am frenchee so it very difficult to traduce all the echanges

Titou4307

Xavinooo commented 11 months ago

Is the docker latest-dev tag already updated ? If so, I still have the issue with a connected outlet I know is not up to date :

Info 2023-09-24 23:32:48Checking if update available for '0x00047400000c565b'
Warning 2023-09-24 23:32:48Firmware on '0x00047400000c565b' is newer than latest firmware online.
Info 2023-09-24 23:32:48No update available for '0x00047400000c565b'
Info 2023-09-24 23:32:48MQTT publish: topic 'zigbee2mqtt/0x00047400000c565b', payload '{"action":null,"led_if_on":"OFF","led_in_dark":"OFF","linkquality":134,"power":0,"power_apparent":null,"power_on_behavior":"previous","state":null,"update":{"installed_version":54531584,"latest_version":5325315,"state":"idle"},"update_available":null}'
Info 2023-09-24 23:32:48MQTT publish: topic 'zigbee2mqtt/bridge/response/device/ota_update/check', payload '{"data":{"id":"0x00047400000c565b","updateAvailable":false},"status":"ok","transaction":"1xudq-1"}'
SilentT-FR commented 11 months ago

If anyone could explain the solution easy

When OTA the devices indicate the offset ( where the devices wants the ota files)

For legrand and all Devices its need the begin so the Zero

with this offset, its indicate the size ( dont know if its bytes ou KBytes) Legrand say 62

and its the beginning of problem

Z2M limmit/capping at 50 so z2m respond with offset 0 and size 50

after that the Devices ask the offset 50 and size 12 ( 62 original ) normal because its receive 0 to 50

but the Legrand Firmware wasent happy i thinks its analize the file or whatever it respond invalid image

and when we retry the device ask the offset 50 to 62 ( size 12 ) and looping so bricked :(

So for this looping problem is it to reset the task or stack

electrical reset not work each time so @FabianMangold tested to BufferOverflow the devices by sending more than expected

its result to reset the ota task of devices

and when new notify OTA to the devices its aksing offset 0 size 62

But we looping because Z2m continue to send only 50

so we have update the limit to 64 ( because legrand ask 62 at begin and 64 after ) only for legrand devices

So i cant say if Legrand fimware was not coded to receive less size because dont know if its allowed in zigbee stack or not

After reading the zigbee documentation https://csa-iot.org/wp-content/uploads/2022/01/07-5123-08-Zigbee-Cluster-Library-1.pdf#page1051

Article

11.13.6.2.6 Maximum Data Size The value indicates the largest possible length of data (in bytes) that the client can receive at once. The server SHALL respect the value and not send the data that is larger than the maximum data size. The server MAY send the data that is smaller than the maximum data size value, for example, to account for source routing payload overhead if the client is multiple hops away. By having the client send both file offset and maximum data size in every command, it eliminates the burden on the server for having to remember the information for each client.

and articles

11.13.8.2.6 Data Size The value indicates the length of the image data (in bytes) that is being included in the command. The value MAY be equal or smaller than the maximum data size value requested by the client. See section 11.11.2 for more description.

So my conclusion its was the Legrand firmware cannot accept a smaller size wich devices aksing so it dident respect the ZigbeeStack

titou4307 commented 11 months ago

@SilentT-FR

I have understand the big line of the problem and of the solution

Thanks

sekot commented 11 months ago

It's working. Great job guys. Many thanks !

Koenkk commented 11 months ago

@SilentT-FR Legrand doesn't respect the max data size which z2m sends so it's a bug from their side.

Since this issue is solved now, I will close it.

SilentT-FR commented 11 months ago

@SilentT-FR Legrand doesn't respect the max data size which z2m sends so it's a bug from their side.

Since this issue is solved now, I will close it.

Yes i have write this explanation before i read the Zigbee Protocol Documentation from Zigbee_Alliance

stefanuytterhoeven commented 11 months ago

still getting this error for Legrand 067776

FabianMangold commented 11 months ago

Hi @stefanuytterhoeven, Just wanna make sure, are you using the DEV branch when performing your tests ?

benjR commented 11 months ago

Worked for me, many thanks !

FabianMangold commented 11 months ago

Hi @stefanuytterhoeven, Has it worked out for you in the end ? Cheers

stefanuytterhoeven commented 11 months ago

Hi @stefanuytterhoeven, Just wanna make sure, are you using the DEV branch when performing your tests ?

No,

stefanuytterhoeven commented 11 months ago

Hi @stefanuytterhoeven, Has it worked out for you in the end ? Cheers

No, still the same error..

FabianMangold commented 11 months ago

Hi Stefan,

The fix is only available in the DEV for now, which explains why it fails. Can you either switch to the DEV branch or wait for the fix the new release to be available ?

On 28 Sep 2023, at 19:56, Stefan Uytterhoeven <notifications

SilentT-FR commented 11 months ago

@FabianMangold @Koenkk Response of Legrand 👍

Hello Clément,

The problem is now clear for the devs and they understand why it wasn’t reproduced on their side

They will fix the max lenght of frame sent by the gateway (but it’s not still prioritized so I don’t know when it will be done)

But the update of your devices will be impossible without a fix on your gateway’s side. We see that the code on gateway was patched last week (GitHub). It seems that you manage to update products. Do you still have problems since this patch was done ?

Have a good day,

Leslie – Community Manager

FabianMangold commented 11 months ago

HI @SilentT-FR , To be honnest, i don't get all those discussions about that topic. The issue is solved, there is nothing to be done anymore. Great that Legrand found an issue on their end, but from what we can tell, the latest firmware issue doesn't seem to expose the issue anymore. Regardless, our fix makes it possible to deal with the "bogus" firmware, and in addition enables flexible packet size, so all good from our end. Can you please tell Legrand, that "our" fix works, and that we have not experienced any issues since ? IMHO, this particular issue is fixed and closed. Thanks for your understanding.

SilentT-FR commented 11 months ago

i dont test to use old method ( cap 50 ) with the new firmware.

I no longer post discussions with Legrand on this thread

Thanks

SilentT-FR commented 11 months ago

I have tested old method (capping with size 50) with new firmware NLPv81 to same firmware with "forced: true" on the json

the devices OTA Invalid image, so the bug continue with the last firmware, so i continue to update legrand about the situation, for Z2M yes the issue is solved

rossowl commented 11 months ago

Yes, it works. Really great work. Thank you.

stefanuytterhoeven commented 11 months ago

Image updated, so .. it works! Thx!

trollix commented 11 months ago

Thanks for the great work.

titou4307 commented 11 months ago

Hi Z2M Updated today ... Legrand devices are updating (2/3 successv, awaiting the last one....)

All the update passed

Many thanks at all for the Energy to resolve this problem

v-vadim commented 11 months ago

Almost all devices have been updated. Cannot update Legrand 067774. The process reaches 99% and an error appears Update of 'Kitchen switch lighting' failed (Timeout: device did not request any image blocks)

FabianMangold commented 11 months ago

Hi @vvn123421345, Just try it again once more straightaway after the failure. That weird behaviour might actually be "normal". Also, if that doesn't work, try to power cycle the device, and give it another try. That worked just fine for me.

v-vadim commented 11 months ago

Thank you. Removing the battery for a few minutes and then updating it helped. Before this I ran the update 6 times and got an error