Closed infrafast closed 1 year ago
hi, thanks for your feedback :+1:
Here's how I generate tar.gz files from the command line:
tar -cvzf data.tar.gz src/data
But it also pulls the src/data
folder path in the archive, and it's probably not what you want.
If doing tar and gz separately, only use tar in the first step, and gzip in the second step:
tar -C src\data -cvf archive.tar .
gzip archive.tar
If this does not solve the issue, I'll need you to provide extra info such as device (ESP32/ESP8266/RP2040), available heap, platform and core version , and a faulty .tar.gz file so I can reproduce the problem locally.
BTW the current development version of ESP32-Targz is ahead of the release version: https://github.com/tobozo/ESP32-targz/tree/1.1.8 so if you feel like experimenting you may also try this one.
tar -cvzf data.tar.gz src/data But it also pulls the
src/data
folder path in the archive, and it's probably not what you want.
yep, that's why I use the -C option first
If doing tar and gz separately, only use tar in the first step, and gzip in the second step:
Ok, I've tried as you suggested but it doesnt work... the file I generate in two tsep is http://infrafast.com/archive-2steps.tar.gz
If this does not solve the issue, I'll need you to provide extra info such as device (ESP32/ESP8266/RP2040), available heap, platform and core version, and a faulty .tar.gz file so I can reproduce the problem locally.
_Here are the info:
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini.html PLATFORM: Espressif 8266 (4.1.0) > WeMos D1 R2 and mini HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash PACKAGES:
runtime debug info: free heap size before calling unpacker: 6112 (I know it's not much, when I disabled all debug trace, etc, I get ~10K of heap and still have the issue)
BTW the current development version of ESP32-Targz is ahead of the release version: https://github.com/tobozo/ESP32-targz/tree/1.1.8 so if you feel like experimenting you may also try this one.
well, in my platformIO.ini file I have tobozo/ESP32-targz which uses the latest (1.1.7), I tried to add tobozo/ESP32-targz@1.1.8 but doesnt find it, by chance could you let me know which line I should use to go with 1.1.8 ?
I'm not sure how to tweak platformio to pull a git branch, but I still don't know what device to test with, is that an esp32, esp8266 or rp2040 ?
I managed to decompress your archive.tar.gz on an ESP32 in verify mode, so the file format/contents is not the cause.
I misread your initial post, at first I thought you were pasting a positive result, but you're using the same code block both for .tar and .tar.gz files, right? If so, then this is the cause.
Although using tarExpander()
is fine for .tar
files, it should be tarGzExpander()
when using .tar.gz
files.
I'm not sure how to tweak platformio to pull a git branch, but I still don't know what device to test with, is that an esp32, esp8266 or rp2040 ?
sorry if it was not clear, the device to test was indicated into my previous post: PLATFORM: Espressif 8266 (4.1.0) > WeMos D1 R2 and mini HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
I misread your initial post, at first I thought you were pasting a positive result, but you're using the same code block both for .tar and .tar.gz files, right? If so, then this is the cause.
Although using
tarExpander()
is fine for.tar
files, it should betarGzExpander()
when using.tar.gz
files.
Oh my god, how could I miss that.... I've used tarGzExpander. I've tested with it, When sGzexpander is calledl looks like the esp freezem then watchdog is triggered
starting expansion of: archive.fsaz ets Jan 8 2013,rst cause:4, boot mode:(3,7)
wdt reset load 0x4010f000, len 3424, room 16 tail 0 chksum 0x2e load 0x3fff20b8, len 40, room 8 tail 0 chksum 0x2b csum 0x2b v000940f0 ~ld
I will check if this is due to memeory or FS fill or whatever and reports here if I can not find why... unless you have an obvious idea.
tar.gz expanding can be memory hungry indeed, the latest branch has some tweaks for that and also for the wdt reset: ther is a missing yield() in the tar decompression loop, SPIFFS and SD don't care if it's missing but LittleFS needs it.
Here's how you can use the current development/unstable branch in your platformio.ini
lib_deps =
https://github.com/tobozo/ESP32-targz#1.1.8
thanks for the hint. I have now switched to 1.1.8.
Interestingly, when I do not use the log callback function TARGZUnpacker.setLoggerCallback(BaseUnpacker::targzPrintLoggerCallback); => system watchdog is triggered
when I activate log, the code works but I get the following debug message
starting tgz expansion of: test.fsaz[TGZ] Will expand using an intermediate file: /tmp/data.tar [GZ] Expanding test.fsaz to /tmp/data.tar [E][ESP32-targz-lib.cpp:1278] gzUncompress(): [ERROR] can't alloc 1024 bytes for output buffer [E][ESP32-targz-lib.cpp:1465] gzExpander(): gzUncompress returned error code -106
I managed to free the required memory (without debug) and it works successuflly.
The only problem I thought this would already be usefull to know that wtch raise if you have no debug log output activated, this should probably be fixed for productive use.
I could make the gz dictionary disabled by default on esp8266. It would prevent the allocation of 32Kb of heap, and disable dictionary based decompression. An intermediary file would become mandatory for .tar.gz files though
Plus crc based decompression is much slower and the spiffs partition may explode in the process, if the size becomes an issue, using gzStreamUpdater() on U_SPIFFS with an incoming HTTP stream may be a safer solution.
Reminder: ESP8266 has built-in uzlib so you may transparently use firmware.gz or spiffs.gz directly with the Update class
if you delete your .pio folder and re-pull the 1.1.8 branch, there's a new GzUnpacker->noDict()
method you can now call before decompression, this sould solve the memory problem, and even let you enable debug.
TARGZUnpacker.noDict();
TARGZUnpacker.tarGzExpander(/*...*/);
or if you want to try dictionary-based first and use crc-based on failure:
if ( ! TARGZUnpacker.tarGzExpander(/*...*/) ) {
if ( TARGZUnpacker.getError() == ESP32_TARGZ_HEAP_TOO_LOW ) {
TARGZUnpacker.noDict();
TARGZUnpacker.tarGzExpander(/*...*/);
}
}
Thanks a lot for all information, I've tested 1.1.8 with the code update and this works well :-) you can close the issue
Hello Tobozo, first of all thanks again for your lib. this is really working great! I face one issue , when using a tar it's working good, but when using a tar.gz, I got a -33 error (Error TAR_ERR_HEADERCB_FAIL). here is the code (quite standard)
My assumption is that my tar.gz file has a format issue ?
Here are the command I use to generate my file:
the files link if it may help: (copy paste in another windows as this is not https and github will reject the link) http://infrafast.com/archive.tar.gz http://infrafast.com/archive.tar thanks a lot!
ps: I am using lib version 1.1.4