Open giedriuslt opened 1 month ago
Works with fine with 637 This seems not correct, it tries to receive everything???
while (1) {
int remaining = request.receivedLenmax - request.receivedLen;
int received = recv(fd, request.received + request.receivedLen, remaining, 0);
if (received <= 0) {
break;
}
request.receivedLen += received;
if (received < remaining) {
break;
}
// grow by 1024
request.receivedLenmax += 1024;
request.received = (char*)realloc(request.received, request.receivedLenmax+2);
if (request.received == NULL) {
// no memory
return;
}
}
Luckily recovery IS possible. I set up network throttling to 8kb/s like this and it worked, old firmware was uploaded, took 7 minutes.
That's strange, I reverted for BL602: https://github.com/openshwprojects/OpenBK7231T_App/commit/c00f1a968de368ecf64f22114d1b152e96165685 Maybe realloc is not working on BL602?
Why do you think that the code is incorrect? recv will return 0 or -1 if there is no more data.
The folowing change (realloc) was added so we can receive HTTP packets longer than 1024 bytes.
Yes, so that is the issue, ota data size is 400KB, it tries to allocate all of that, and then there is no memory left to do anything else. This code should have some limit. Not exactly sure why this even works for Beken.
I didn't expect that, it passed all tests on Beken. So, shall we introduce a limit? I don't know, 8kB?
I don't know what is required, but I would say having limit would be good here, like 8kb or 16kb or 32kb...
1.17.647 OTA again works good for BL602
Describe the bug OTA is broken
Firmware:
To Reproduce Steps to reproduce the behavior: Update fails, device crashes, log shows this:
Maybe realloc causing trouble?