ElegantOTA icon indicating copy to clipboard operation
ElegantOTA copied to clipboard

Hook up esp32-flashz lib to support compressed updates

Open vortigont opened this issue 2 years ago • 0 comments

@ayushsharma82 was a bit busy lately So here is a test prototype with esp32-flashz lib back-end for anyone dare to try. Both uncompressed and zlib-compressed images uploading supported for all esp32 platforms. It works pretty fine on controller's side. But there are some 'but'`s with UI :)

  • for now it's just for WebServer's version, not for Async
  • I was unable to launch the UI at all from v3-alpha branch. It opens a pic and spins the spinner indefinitely. In network mon I can see a 404 for '/update/identity', whatever it means, that's all. Never mind, uploading works pretty fine with CLI curl tool
  • need to figure out what to do with MD5's for compressed images. It can't be applied to update's check. Not much of a use also, if file is broken on the way, than it will probably fail decompression anyway. For now md5 check is disabled for esp32. I think I can turn it back for uncompressed images, but need to decide what to do with front-end. Another option is to check md5 for compressed input and fail on end in case of a mismatch. But again, it will probably fail decompression before that
  • code style looks ugly an unreadable with all of those `#ifdef's, suppose would be better to split different arch types into separate cpp's

Testing:

> pigz -9kzc firmware.bin | curl -v http://$ESPHOST/update -F file=@-
>   Trying 192.168.176.207:80...
> Connected to 192.168.176.207 (192.168.176.207) port 80 (#0)
> POST /update HTTP/1.1
> Host: 192.168.176.207
> User-Agent: curl/7.81.0
> Accept: */*
> Content-Length: 516519
> Content-Type: multipart/form-data; boundary=------------------------b019f13fd0aba242
> 
> We are completely uploaded and fine

ESP output:

IP address: 192.168.176.207
HTTP server started
[ElegantOTA] OTA update received: -
[ElegantOTA] OTA update Started: -; mode_z: yes
[ 60138][I][flashz.cpp:296] flash_cb(): [FLASHZ] flashed 32768 bytes
[ 60322][I][flashz.cpp:296] flash_cb(): [FLASHZ] flashed 32768 bytes
[ 60630][I][flashz.cpp:296] flash_cb(): [FLASHZ] flashed 32768 bytes
[ 60767][I][flashz.cpp:296] flash_cb(): [FLASHZ] flashed 32768 bytes
...
[ 64595][I][flashz.cpp:296] flash_cb(): [FLASHZ] flashed 32768 bytes
[ 64771][I][flashz.cpp:296] flash_cb(): [FLASHZ] flashed 32768 bytes
[ 65163][I][flashz.cpp:296] flash_cb(): [FLASHZ] flashed 32768 bytes
[ 65304][I][flashz.cpp:296] flash_cb(): [FLASHZ] flashed 32768 bytes
[ 65657][I][flashz.cpp:296] flash_cb(): [FLASHZ] flashed 32768 bytes
[ 65829][I][flashz.cpp:296] flash_cb(): [FLASHZ] flashed 32768 bytes
[ 66193][I][flashz.cpp:296] flash_cb(): [FLASHZ] flashed 32768 bytes
[ 66285][I][flashz.cpp:296] flash_cb(): [FLASHZ] flashed 18176 bytes
[ElegantOTA] OTA update Success: 516366
ets Jun  8 2016 00:22:57

vortigont avatar Jul 21 '22 10:07 vortigont