GyverLibs / FastBot2

Очень быстрая и лёгкая библиотека Telegram бота для Arduino, ESP8266, ESP32
MIT License
42 stars 3 forks source link

OTA error #12

Closed OleksandrGora closed 2 months ago

OleksandrGora commented 2 months ago

Sometimes I get OTA error message on ESP32 devkit. The complicated code is the more often the message appears. The file size is not changed. Partition map is not changed. It has been uploaded over a cable at the very beginning.

Where to dig?

GyverLibs commented 2 months ago

bot ticks on default loop task or custom rtos task? Your update handler is a big single function or splitted to little ones as shown in example/docs?

OleksandrGora commented 2 months ago

Loops and update funks look like that:

void loop()
{
  loop_firebase();
  loop_fastbot();
  loop_timers();
  loop_touch_check();
}

void loop_fastbot()
{
    bot.tick();
}

void update_bot(fb::Update &u)
{
    if (u.isMessage() &&
        u.message().hasDocument() &&
        u.message().document().name().endsWith(".bin") &&
        u.message().from().id() == CHAT_ID &&
        u.message().document().name().indexOf(BOARD) > -1)
    {
        fb::Fetcher fetch = mounting_bot.downloadFile(u.message().document().id());
        // OTA
        bool ok = fetch.updateFlash();
        bot.sendMessage(fb::Message(ok ? "OTA done" : "OTA error", u.message().chat().id()));
    }
}

List of libs used in the project: gyverlibs/FastBot2@^1.0.2 gyverlibs/UnixTime@^1.1 gyverlibs/GyverNTP@^1.3.1 beegee-tokyo/DHT sensor library for ESPx@^1.19 mobizt/FirebaseClient@^1.3.10 sstaub/TickTwo@^4.4.0

GyverLibs commented 2 months ago

thats all? and crashes?

OleksandrGora commented 2 months ago

There is a part of code under each loop_... There are about 10 timer, firebase works in async mode in case data is exchanged between the board and the base (is launched from timers).

I tried debugging the code from the simple example (concerning tg bot). Simple firebase examples had been included at that moment. There was not any issue in OTA at that moment.

In process of adding additional functionality, the error started to appear (lots of errors because I tried to change the message and examine if the board traces them): image

GyverLibs commented 2 months ago

seems like the board is rebooting, you should check serial monitor for exceptions

GyverLibs commented 2 months ago

i will make new way to OTA today, it will update from main loop to decrease memory using etc

OleksandrGora commented 2 months ago

The board is not rebooting. It does not freeze as well. It works as usual. At the moment there is no messages in serial that could help to trace the error. Sometimes rebooting happens, but it is not in this case.

Partition - if it can help: Name, Type, SubType, Offset, Size, Flags nvs, data, nvs, 0x9000, 0x5000, otadata, data, ota, , 0x2000, app0, app, ota_0, , 0x1E0000, app1, app, ota_1, , 0x1E0000, spiffs, data, spiffs, , 0x20000, coredump, data, coredump,, 0x10000,

GyverLibs commented 2 months ago

uncomment this and try ota

GyverLibs commented 2 months ago

in new update you can use

bot.updateFlash(u.message().document(), u.message().chat().id());

it's more stable

OleksandrGora commented 2 months ago

After uncommenting got this:

getFile in downloadFile() [.pio/libdeps/esp32/FastBot2/src/FastBot2Client.h : 76] send + wait in sendPacket() [.pio/libdeps/esp32/FastBot2/src/core/core.h : 267] bad response in _parseResponse() [.pio/libdeps/esp32/FastBot2/src/core/core.h : 325] send + wait in sendPacket() [.pio/libdeps/esp32/FastBot2/src/core/core.h : 267] got json in _parseResponse() [.pio/libdeps/esp32/FastBot2/src/core/core.h : 307] got result in _parseResult() [.pio/libdeps/esp32/FastBot2/src/core/core.h : 331] getUpdates in getUpdates() [.pio/libdeps/esp32/FastBot2/src/core/core.h : 208] send async in sendPacket() [.pio/libdeps/esp32/FastBot2/src/core/core.h : 270]

OleksandrGora commented 2 months ago

After update to 1.0.3 OTA done! Thanks!

Closing the issue.

GyverLibs commented 2 months ago

1.0.3? Nice

OleksandrGora commented 2 months ago

Unfortunately OTA does not seem to work. Yesterday once it was successful. But now there is no reaction at all. Not error, not success. Serial says:

getFile in downloadFile() [.pio/libdeps/esp32/FastBot2/src/FastBot2Client.h : 76] send + wait in sendPacket() [.pio/libdeps/esp32/FastBot2/src/core/core.h : 268] got json in _parseResponse() [.pio/libdeps/esp32/FastBot2/src/core/core.h : 308] got result in _parseResult() [.pio/libdeps/esp32/FastBot2/src/core/core.h : 336] download file in downloadFile() [.pio/libdeps/esp32/FastBot2/src/FastBot2Client.h : 88] send + wait in sendPacket() [.pio/libdeps/esp32/FastBot2/src/core/core.h : 268] got file in _parseResponse() [.pio/libdeps/esp32/FastBot2/src/core/core.h : 323] ota write error in _ota() [.pio/libdeps/esp32/FastBot2/src/core/Fetcher.h : 76] send + wait in sendPacket() [.pio/libdeps/esp32/FastBot2/src/core/core.h : 268] bad response in _parseResponse() [.pio/libdeps/esp32/FastBot2/src/core/core.h : 330] getUpdates in getUpdates() [.pio/libdeps/esp32/FastBot2/src/core/core.h : 209] send async in sendPacket() [.pio/libdeps/esp32/FastBot2/src/core/core.h : 271]

in new update you can use

bot.updateFlash(u.message().document(), u.message().chat().id());

it's more stable

image

In case it has not been realised - will wait.

GyverLibs commented 2 months ago

you need up to date version, 1.0.5

GyverLibs commented 2 months ago

just tested on esp32 and C3 - works like charm

OleksandrGora commented 2 months ago

Another issue while installation 1.0.5: PIO Core Call Error: "Resolving esp32 dependencies...\nLibrary Manager: Installing gyverlibs/FastBot2 @ ^1.0.5\n\n\nUnknownPackageError: Could not find the package with 'gyverlibs/FastBot2 @ ^1.0.5' requirements for your system 'darwin_x86_64'"

Can't help? There is no issue with 1.0.3...

GyverLibs commented 2 months ago

Just install from git. PIO doesn't update it's registry yet

OleksandrGora commented 2 months ago

Tested for a few days. It seems it works. Thank you. Closing the issue.

GyverLibs commented 2 months ago

nice

OleksandrGora commented 2 months ago

Hello. Something the same: image

GyverLibs commented 2 months ago

Maybe firmware file is too big for partition? Try change partition or use atomic update with .gz compression