FwUpdate: over the mesh only deltas, a full image only over USB / BLE
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9080d8339d
commit
9165590d13
2 files changed
+24
-7
No files matched your search
@@ -548,6 +548,7 @@ int FwUpdate::handleBinary(const uint8_t *req, int len, uint8_t *reply, int repl
|
||||
return 0;
|
||||
}
|
||||
_w_bin++;
|
||||
_remote = true; // binary chunks are the mesh protocol (`fw bin` replays it on the bench)
|
||||
_mani_src = 'b';
|
||||
writeAt(off, &req[11], n); // errors show in the next 'm'
|
||||
return 0;
|
||||
@@ -635,6 +636,10 @@ bool FwUpdate::checkManifest() {
|
||||
strcpy(_err, "size mismatch");
|
||||
return false;
|
||||
}
|
||||
if (_remote && m->format != 2) {
|
||||
strcpy(_err, "full image not over the mesh (USB or BLE)");
|
||||
return false;
|
||||
}
|
||||
if (m->format == 2) {
|
||||
if (!deltaInRam()) {
|
||||
strcpy(_err, "no delta support in this build");
|
||||
@@ -690,10 +695,15 @@ void FwUpdate::cmdStatus(char *reply) {
|
||||
}
|
||||
}
|
||||
|
||||
void FwUpdate::cmdBegin(const char *arg, char *reply) {
|
||||
void FwUpdate::cmdBegin(uint32_t sender_timestamp, const char *arg, char *reply) {
|
||||
char *rest;
|
||||
uint32_t total = strtoul(arg, &rest, 10);
|
||||
uint32_t sid = strtoul(rest, NULL, 10); // optional transfer session (binary chunks)
|
||||
if (sender_timestamp != 0 && total > FW_OTA_PATCH_AREA) {
|
||||
sprintf(reply, "ERR: over the mesh only a delta (<= %u B); a full image goes over USB or BLE",
|
||||
(unsigned)FW_OTA_PATCH_AREA);
|
||||
return;
|
||||
}
|
||||
// small = delta: top of the free flash, out of reach of the in-place shift;
|
||||
// big = full image: right above the running one, as before
|
||||
uint32_t stage = total <= FW_OTA_PATCH_AREA ? PATCH_LO : (imageEnd() + PAGE - 1) & ~(PAGE - 1);
|
||||
@@ -708,6 +718,7 @@ void FwUpdate::cmdBegin(const char *arg, char *reply) {
|
||||
}
|
||||
_stage = stage;
|
||||
_total = total;
|
||||
_remote = sender_timestamp != 0;
|
||||
memset(_have, 0, sizeof(_have));
|
||||
_state = RECEIVING;
|
||||
_manifest_ok = false;
|
||||
@@ -724,7 +735,8 @@ void FwUpdate::cmdBegin(const char *arg, char *reply) {
|
||||
FW_OTA_CHUNK, (unsigned long)stage);
|
||||
}
|
||||
|
||||
void FwUpdate::cmdWrite(const char *arg, char *reply) {
|
||||
void FwUpdate::cmdWrite(uint32_t sender_timestamp, const char *arg, char *reply) {
|
||||
if (sender_timestamp != 0) _remote = true;
|
||||
if (_state == FAILED) {
|
||||
sprintf(reply, "ERR: %s", _err);
|
||||
return;
|
||||
@@ -1016,11 +1028,11 @@ bool FwUpdate::handleCommand(uint32_t sender_timestamp, const char *command, cha
|
||||
while (*arg == ' ')
|
||||
arg++;
|
||||
if (strncmp(arg, "w ", 2) == 0)
|
||||
cmdWrite(arg + 2, reply);
|
||||
cmdWrite(sender_timestamp, arg + 2, reply);
|
||||
else if (strcmp(arg, "status") == 0 || !*arg)
|
||||
cmdStatus(reply);
|
||||
else if (strncmp(arg, "begin ", 6) == 0)
|
||||
cmdBegin(arg + 6, reply);
|
||||
cmdBegin(sender_timestamp, arg + 6, reply);
|
||||
else if (strcmp(arg, "missing") == 0)
|
||||
cmdMissing(reply);
|
||||
else if (strcmp(arg, "verify") == 0)
|
||||
|
||||
Reference in new issue
Block a user