fbiego / ESP32_BLE_OTA_Arduino

OTA update on ESP32 via BLE
MIT License
203 stars 41 forks source link

Firmware uploaded but performUpdate fails while partitionEraseRange... #33

Open om0wt opened 9 months ago

om0wt commented 9 months ago

Hello all, I have following problem on WeMoS D1 MINI ESP32 platform: firmware update is uploaded, but while executing

size_t written = Update.writeStream(updateSource);

image

it fails:

00:57:35.339 -> Notify callback for characteristic fb1e4003-54ae-4a28-9f74-dfccb248601d of data length 3
00:57:35.339 -> TX  F2 00 0F 
00:57:35.339 -> Status 1 on characteristic fb1e4003-54ae-4a28-9f74-dfccb248601d with code 0
00:57:35.373 -> Write binary file /update.bin
00:57:35.514 -> Complete
00:57:40.541 -> Trying to start update
00:57:40.541 -> 
00:57:40.541 -> abort() was called at PC 0x40081ece on core 1
00:57:40.541 -> 
00:57:40.541 -> 
00:57:40.541 -> Backtrace: 0x400836a5:0x3ffd1150 0x40093601:0x3ffd1170 0x40098855:0x3ffd1190 0x40081ece:0x3ffd1210 0x400e1973:0x3ffd1260 0x400db57d:0x3ffd1280 0x400d32ff:0x3ffd12a0 0x400d355f:0x3ffd12c0 0x400d2582:0x3ffd12e0 0x400d2b4b:0x3ffd1360 0x400d2e4b:0x3ffd13b0 0x400dc63d:0x3ffd13e0
00:57:40.541 -> 
00:57:40.541 -> 
00:57:40.541 -> 
00:57:40.541 -> 
00:57:40.541 -> ELF file SHA256: 0f188e5b9d82dfd5
00:57:40.574 -> 
00:57:40.681 -> Rebooting...
00:57:40.681 -> ets Jun  8 2016 00:22:57

Backtrace decoded shows:

Decoding stack results
0x400836a5: panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c line 408
0x40093601: esp_system_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/esp_system.c line 137
0x40098855: abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/abort.c line 46
0x40081ece: esp_flash_erase_region at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/spi_flash/esp_flash_api.c line 561
0x400e1973: esp_partition_erase_range at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/spi_flash/partition.c line 540
0x400db57d: EspClass::partitionEraseRange(esp_partition_t const*, unsigned int, unsigned int) at /Users/pavol/Library/Arduino15/packages/esp32/hardware/esp32/2.0.14/cores/esp32/Esp.cpp line 432
0x400d32ff: UpdateClass::_writeBuffer() at /Users/pavol/Library/Arduino15/packages/esp32/hardware/esp32/2.0.14/libraries/Update/src/Updater.cpp line 211
0x400d355f: UpdateClass::writeStream(Stream&) at /Users/pavol/Library/Arduino15/packages/esp32/hardware/esp32/2.0.14/libraries/Update/src/Updater.cpp line 386
0x400d2582: performUpdate(Stream&, unsigned int) at /Users/pavol/Documents/esp32_ble_ota/esp32_ble_ota.ino line 215
0x400d2b4b: updateFromFS(fs::FS&) at /Users/pavol/Documents/esp32_ble_ota/esp32_ble_ota.ino line 265
0x400d2e4b: loop() at /Users/pavol/Documents/esp32_ble_ota/esp32_ble_ota.ino line 410
0x400dc63d: loopTask(void*) at /Users/pavol/Library/Arduino15/packages/esp32/hardware/esp32/2.0.14/cores/esp32/main.cpp line 50

Another error:

02:20:25.530 -> Incomplete
02:20:25.530 -> Expected: 305472Received: 304000
02:20:27.531 -> Write binary file /update.bin
02:20:27.598 -> Complete
02:20:32.618 -> Trying to start update
02:20:32.618 -> Written only : 0/305472. Retry?
02:20:32.618 -> Error Occurred. Error #: 8
02:20:32.618 -> Notify callback for characteristic fb1e4003-54ae-4a28-9f74-dfccb248601d of data length 36
02:20:32.618 -> TX  0F 57 72 69 74 74 65 6E 20 3A 20 30 2F 33 30 35 34 37 32 20 5B 30 25 5D 20 0A 45 72 72 6F 72 20 23 3A 20 38 
02:20:32.652 -> Status 1 on characteristic fb1e4003-54ae-4a28-9f74-dfccb248601d with code 0
02:20:37.827 -> Removing update file

What I try to do

  1. I flash esp32_ble_ota firmware to WeMoS D1 MINI ESP32

  2. I upload an empty SPIFFS to ESP32:

        Leaving...
        Hard resetting via RTS pin...
        [SPIFFS] data   : /Users/pavol/Documents/esp32_ble_ota/data
        [SPIFFS] start  : 1966080
        [SPIFFS] size   : 1856
        [SPIFFS] page   : 256
        [SPIFFS] block  : 4096
        [SPIFFS] upload : /var/folders/0d/70vb7f0j1t114w9nkrmypn4r0000gn/T/arduino_build_904895/esp32_ble_ota.spiffs.bin
        [SPIFFS] address: 1966080
        [SPIFFS] port   : /dev/cu.usbserial-02T9S8H5
        [SPIFFS] speed  : 921600
        [SPIFFS] mode   : dio
        [SPIFFS] freq   : 40m
    
        esptool.py v4.5.1
        Serial port /dev/cu.usbserial-02T9S8H5
        Connecting....
        Chip is ESP32-D0WDQ6 (revision v1.0)
        Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
        Crystal is 40MHz
        MAC: 84:cc:a8:5f:57:ac
        Uploading stub...
        Running stub...
        Stub running...
        Changing baud rate to 921600
        Changed.
        Configuring flash size...
        Auto-detected Flash size: 4MB
        Flash will be erased from 0x001e0000 to 0x003affff...
        Compressed 1900544 bytes to 3420...
        Writing at 0x001e0000... (100 %)
        Wrote 1900544 bytes (3420 compressed) at 0x001e0000 in 8.1 seconds (effective 1888.1 kbit/s)...
        Hash of data verified.
  3. I compile Blink firmware and upload final bin image to Android application (blink_firmware.bin). Both firmwares were compiled with partition app_spiffs (check below)

  4. I try to upload blink firmware via Android updater application EPS32 BLE OTA to ESP32. The transfer is successfull, but problem occurres as described above.

What am I doing wrong???

My Partitions layout

Here is my partition layout:

app_sppifs.cvs:

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
app0,     app,  ota_0,   0x10000, 0x1D0000,
spiffs,     data,  spiffs, 0x1E0000,0x1D0000,
coredump, data, coredump,0x3E0000,0x10000,

I supposed that app0 and spiffs needs to have the same size, but the update fails anyway...

Board partition scheme

...
d1_mini32.menu.PartitionScheme.min_spiffs_nocoredump=APP_SPIFFS
d1_mini32.menu.PartitionScheme.min_spiffs_nocoredump.build.partitions=app_spiffs
d1_mini32.menu.PartitionScheme.min_spiffs_nocoredump.upload.maximum_size=1966080

Thanks a lot for any hint to move forward...

Pavol

hugo8873 commented 7 months ago

Having similar issues here. In my case the received date length is alway less then the expected length if I set the maximum MTU to 517. And the Checksum is always wrong if I set the MTU to minimum 23. I Tried SPIFFS and FFAT, on both ESP32 and ESP32-S3. I doubt somehow the transfer between phone and ESP32 is experiencing package loss.

BTW, this is a great project, and wish someone can help maintain this project further.