Skip to content

Commit 183cc45

Browse files
committed
fix(upgrade): correct appendData params to {"length": N} (hardware-validated)
Reversed from the hunter CUpgradeService::appendData handler and confirmed by a live UART-free flash on a GK7205V510: appendData expects params {"length": N} with an N-byte binary payload (the handler checks params.length == actual binary length), NOT {"Offset","Length"} — which returned 400 "param error". prepare ({"Type":"System"}) and execute params are ignored. State machine: prepare(0->2) -> appendData(2/4, repeatable) -> execute(4->0), with a ~60s idle timeout. With this, DahuaClient.upgrade_firmware() successfully flashed an OpenIPC package over DHIP end-to-end (device rebooted into the new firmware). const comment updated to record the byte-proven param shape.
1 parent 2d25671 commit 183cc45

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎dahua/client.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ def upgrade_firmware(self, path: str, *, confirm: bool = False,
494494
if not chunk:
495495
break
496496
resp, _ = self.request(const.UPGRADER_APPEND,
497-
{"Offset": sent, "Length": len(chunk)},
497+
{"length": len(chunk)},
498498
data=chunk)
499499
self._check(resp, const.UPGRADER_APPEND)
500500
sent += len(chunk)

‎dahua/const.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@
6969
# -- firmware upgrade -------------------------------------------------------
7070
# The `hunter` daemon's RPC upgrade handlers (reversed on a Zenointel GK7205
7171
# camera): prepare -> appendData(chunk) -> execute; getState is read-only. These
72-
# are the same handlers the web /cgi-bin/upgrader.cgi bridges to. The JSON param
73-
# names below (Type / Offset+Length) match the reversed "append upgrade data"
74-
# stream but are not byte-proven — verify against upgrader.getState / a web
75-
# capture before trusting a real flash.
72+
# are the same handlers the web /cgi-bin/upgrader.cgi bridges to. Validated on a
73+
# GK7205V510 (hunter decompile + live flash): appendData takes params {"length": N}
74+
# with an N-byte binary payload; prepare/execute params are ignored. State machine:
75+
# prepare(0->2) -> appendData(2/4, chunks) -> execute(4->0); ~60s idle timeout.
7676
UPGRADER_STATE = "upgrader.getState"
7777
UPGRADER_PREPARE = "upgrader.prepare"
7878
UPGRADER_APPEND = "upgrader.appendData"

0 commit comments

Comments
 (0)