Closed jortega11 closed 1 year ago
Can you try if the update works if you do not enter deepSleep
on the ESP8266
. I'm not sure if flashing the firmware onto the device is supported while the device is in deep sleep mode.
It also would be good to know, which version of the library you are using. I am assuming you are still using v0.10.2
. I would recommend an upgrade to v0.11.1
and implement the fix in #149. At least for both of them in the issue the OTA update worked.
Yes, I forgot to mention I was using v0.10.2
.
After upgrading the version of the library I was getting the error as expected:
[TB] No keys that we subscribed too were changed, skipping callback
[TB] Unable to de-serialize received json data with error (InvalidInput)
After implementing the fix in #149 I get:
[TB] Failed to initalize flash updater
[TB] Receive chunk (0), with size (4096) bytes
Regarding the deepSleep
:
The goal of this project is to have a remote device that will be sleeping most of the time and only wake up to take a few measurements and go back to sleep right after. The user should have the ability to update the code remotely using OTA updates.
Since the device is subscribed to the firmware update topic it will not update the firmware while it is sleeping because it will not be connected to the Internet so the device is not able to get the data needed for it. So, we were thinking about updating the code on ThingsBoard and start the update once the device wakes up. (We would have some flags to prevent the ESP8266
go to sleep before we make sure the device has correctly updates but we have not implemented it yet.)
We have only tried to update the code of the device while it is not sleeping to check if it is able to download and update correctly and then is when we get this error. (After this we would work on updating the code while it is sleeping so it can update after waking up but, as I said, it is not implemented yet because we are currently working on getting a simpler version working).
Okay bad news, this is relatively surely not a problem with this library, because it is the underlying component that should flash the memory that fails to initalize.
Good news however it is probably not an implementation problem but a problem with how you are using the update.
The initial flash begin can fail because of multiple errors, but one of them and the one I find currently most likely is that the binary size you receive from the server is too big for your OTA data partition
or that you have not created a 2nd OTA data partition
altogether.
What kind of partitions.csv
file are you using, because I am assuming you are using the default one and did not change the configuration for it. Because if you did not that might be the cause for the update initialisation failing, because to do an OTA update the partitions.csv
needs two app partitions and the new firmware is then flashed onto the non-active one. Once that has been completed we reboot onto the new flashed firmware.
Therefore the OTA update will of course not work if there is no 2nd app partition. An example of how the partition should look like for an OTA update can be found below.
# Name, Type, SubType, Offset, Size, Flags
otadata, data, ota, 0xE000, 0x2000,
app0, app, ota_0, , 0x300000,
app1, app, ota_1, , 0x300000,
spiffs, data, spiffs, , 0x3F6000,
nvs, data, nvs, , 0x25000,
nvs_key, data, nvs_keys, , 0x25000,
test, app, test, , 0x300000,
Okay good news, that was the problem. I did not fix it exactly as you said because apparently for the ESP8266
module the way that changing the flash size is this. So I changed the board_build.ldscript
flag in my platformio.ini
and now the OTA update works.
Nice to know that the partitions file fixed your issue. Would be nice if you could close this issue as resolved.
Yes, thank you!
I am trying to perform an OTA update using my ESP8266. When I try to do the update, it starts downloading it and it fails at the end, saying that the firmware update failed.
Most of the chunks fail to download, but after retrying it can manage to download them and continue the download of the firmware. However, when it reaches the end of the download the Serial Monitor output is not successful.
I have seen that at the beginning of the update the serial monitor says that there was an error during Update.begin so I think that the problem is because of that.
The code I am using right now is the following: (I have removed credentials like the WiFi SSID, Password, Server IP and Token)