Skip to content

Commit

Permalink
1.2.2 (#72)
Browse files Browse the repository at this point in the history
* added platformio CI tests
* fix for platformio lib_ldf_mode deep+ and chain+
  • Loading branch information
tobozo committed Jan 10, 2024
1 parent a99c36e commit ff8f226
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 187 deletions.
11 changes: 11 additions & 0 deletions examples/Test_platformio/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ board = esp32dev
[env:esp32s3]
platform = espressif32
board = esp32-s3-devkitc-1
; Reminder: if using lib_ldf_mode deep+ or chain+, either include the undetected libraries
; from your cpp file, or add them to the lib_deps
lib_ldf_mode = chain+
lib_deps =
SD
FS
SPI
Update
LittleFS
ESP32-targz


[env:pico]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
Expand Down
5 changes: 5 additions & 0 deletions examples/Test_platformio/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ void setup()
Serial.println("Could not start filesystem");
while(1) yield();
}

TarUnpacker *TARUnpacker = new TarUnpacker();
GzUnpacker *GZUnpacker = new GzUnpacker();
TarGzUnpacker *TARGZUnpacker = new TarGzUnpacker();

}


Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ESP32-targz
version=1.2.1
version=1.2.2
author=tobozo <tobozo@noreply.github.com>
maintainer=tobozo <tobozo@noreply.github.com>
sentence=A library to unpack/uncompress tar, gz, and tar.gz files on ESP32 and ESP8266
Expand Down
4 changes: 2 additions & 2 deletions src/ESP32-targz-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ bool GzUnpacker::gzStreamExpander( Stream *stream, size_t gz_size )



#if defined HAS_OTA_SUPPORT
#if defined ESP32 || defined ESP8266

// uncompress gz file to flash (expected to be a valid gzipped firmware)
bool GzUnpacker::gzUpdater( fs::FS &fs, const char* gz_filename, int partition, bool restart_on_update )
Expand Down Expand Up @@ -2193,7 +2193,7 @@ bool TarGzUnpacker::tarGzStreamExpander( Stream *stream, fs::FS &destFS, const c



#if defined ESP32
#if defined ESP32 && defined HAS_OTA_SUPPORT

/** GzUpdateClass Class implementation **/

Expand Down
180 changes: 168 additions & 12 deletions src/ESP32-targz-lib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,183 @@
\*/

#ifndef _ESP_TGZ_H
#define _ESP_TGZ_H
#pragma once

#include <FS.h>
#include "ESP32-targz-log.hpp"


#if defined ESP32

#if defined( ESP32 )
#include <Update.h>
#define HAS_OTA_SUPPORT
#elif defined( ESP8266 )
//#ifdef USE_LittleFS
// #define SPIFFS LittleFS
// #include <LittleFS.h>
//#endif

// Figure out the chosen fs::FS library to load for the **destination** filesystem
#if defined DEST_FS_USES_SPIFFS
#include <SPIFFS.h>
#define tarGzFS SPIFFS
#define FS_NAME "SPIFFS"
#elif defined DEST_FS_USES_FFAT
#include <FFat.h>
#define tarGzFS FFat
#define FS_NAME "FFAT"
#elif defined DEST_FS_USES_SD
#include <SD.h>
#define tarGzFS SD
#define FS_NAME "SD"
#elif defined DEST_FS_USES_SD_MMC
#include <SD_MMC.h>
#define tarGzFS SD_MMC
#define FS_NAME "SD_MMC"
#elif defined DEST_FS_USES_LITTLEFS
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(2, 0, 0)
// littlefs is built-in since sdk 2.0.0
#include <LittleFS.h>
#define tarGzFS LittleFS
#define FS_NAME "LittleFS (builtin)"
#else
// get "littlefs_esp32" from library manager
#include <LITTLEFS.h>
#define tarGzFS LITTLEFS
#define FS_NAME "LITTLEFS (extlib)"
#endif
#elif defined DEST_FS_USES_PSRAMFS
#include <PSRamFS.h> // https://github.com/tobozo/ESP32-PsRamFS
#define tarGzFS PSRamFS
#define FS_NAME "PSRamFS"
#else
// no filesystem, no helpers available, power user ?
#endif

#elif defined ESP8266

#include <Updater.h>
#define HAS_OTA_SUPPORT

// ESP8266 has no SD_MMC or FFat.h library, so these are implicitely invalidated
#undef DEST_FS_USES_SD_MMC // unsupported
#undef DEST_FS_USES_FFAT // unsupported
// the fuck with spamming the console
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

// Figure out the chosen fs::FS library to load for the **destination** filesystem

#if defined DEST_FS_USES_SD
#include <SD.h>
#define tarGzFS SDFS
#define FS_NAME "SDFS"
#else
#if defined DEST_FS_USES_LITTLEFS
#include <LittleFS.h>
#define tarGzFS LittleFS
#define FS_NAME "LITTLEFS (extlib)"
#elif defined DEST_FS_USES_SPIFFS
#if defined USE_LittleFS // emulate SPIFFS using LittleFS
#include <LittleFS.h>
#define tarGzFS SPIFFS
#define FS_NAME "LITTLEFS (subst)"
#else // use core SPIFFS
#define tarGzFS SPIFFS
#define FS_NAME "SPIFFS"
#endif
#else // no destination filesystem defined in sketch
#warning "Unspecified or invalid destination filesystem, please #define one of these before including the library: DEST_FS_USES_SPIFFS, DEST_FS_USES_LITTLEFS, DEST_FS_USES_SD, DEST_FS_USES_PSRAMFS"
// however, check for USE_LittleFS as it is commonly defined since SPIFFS deprecation
#if defined USE_LittleFS
#include <LittleFS.h>
#define tarGzFS LittleFS
#warning "Defaulting to LittleFS"
#define DEST_FS_USES_LITTLEFS
#define FS_NAME "LITTLEFS (defaulted)"
#else
#define tarGzFS SPIFFS
#warning "Defaulting to SPIFFS (soon deprecated)"
#define DEST_FS_USES_SPIFFS
#define FS_NAME "SPIFFS"
#endif
#endif
#endif

static FSInfo fsinfo;

#elif defined ARDUINO_ARCH_RP2040
// TODO: RP2040 OTA implementation?

#pragma message "Experimental RP2040 support"

#undef DEST_FS_USES_SD_MMC // unsupported
#undef DEST_FS_USES_FFAT // unsupported
#undef DEST_FS_USES_SPIFFS // unsupported

// Figure out the chosen fs::FS library to load for the **destination** filesystem
#if defined DEST_FS_USES_SD
#include <SD.h>
#define tarGzFS SDFS
#define FS_NAME "SD"
#else
#include <LittleFS.h>
#define tarGzFS LittleFS
#define FS_NAME "LITTLEFS (picolib)"
#endif

static FSInfo fsinfo;

#else
#error Unsupported architecture

#error "Only ESP32, ESP8266 and RP2040/Pico architectures are supported"

#endif

#if defined DEST_FS_USES_SPIFFS || defined DEST_FS_USES_LITTLEFS || defined DEST_FS_USES_FFAT
#define WARN_LIMITED_FS
#endif

#include <stddef.h> // platformio whines about missing definition for 'size_t' 🤦

// required filesystem helpers are declared outside the main library
// because ESP32/ESP8266 <FS.h> use different abstraction flavours :)
__attribute__((unused)) static size_t targzFreeBytesFn() {
#if defined DEST_FS_USES_SPIFFS || defined DEST_FS_USES_SD || defined DEST_FS_USES_SD_MMC || defined DEST_FS_USES_LITTLEFS || defined DEST_FS_USES_PSRAMFS
#if defined ESP32
return tarGzFS.totalBytes() - tarGzFS.usedBytes();
#elif defined ESP8266 || defined ARDUINO_ARCH_RP2040
if( tarGzFS.info( fsinfo ) ) {
return fsinfo.totalBytes - fsinfo.usedBytes;
} else {
// fail
return 0;
}
#else
#error "Only ESP32, ESP8266 and RP2040/Pico are supported"
#endif
#elif defined DEST_FS_USES_FFAT
return tarGzFS.freeBytes();
#else
// no filesystem, no helpers available, power user ?
return 0;
#endif
}

__attribute__((unused)) static size_t targzTotalBytesFn() {
#if defined DEST_FS_USES_SPIFFS || defined DEST_FS_USES_SD || defined DEST_FS_USES_SD_MMC || defined DEST_FS_USES_LITTLEFS || defined DEST_FS_USES_FFAT || defined DEST_FS_USES_PSRAMFS
#if defined ESP32
return tarGzFS.totalBytes();
#elif defined ESP8266 || defined ARDUINO_ARCH_RP2040
if( tarGzFS.info( fsinfo ) ) {
return fsinfo.totalBytes;
} else {
// fail
return 0;
}
#else
#error "Only ESP32, ESP8266 and RP2040/Pico are supported"
#endif
#else
// no filesystem, no helpers available, power user ?
return 0;
#endif
}

#define GZIP_DICT_SIZE 32768

#if defined ESP8266
Expand Down Expand Up @@ -304,7 +460,7 @@ struct TarGzUnpacker : public TarUnpacker, public GzUnpacker



#if defined ESP32
#if defined ESP32 && defined HAS_OTA_SUPPORT

// this class was inspired by https://github.com/vortigont/esp32-flashz

Expand Down Expand Up @@ -390,4 +546,4 @@ struct TarGzUnpacker : public TarUnpacker, public GzUnpacker
#include "helpers/path_tools.h"


#endif // #ifdef _ESP_TGZ_H
//#endif // #ifdef _ESP_TGZ_H
Loading

0 comments on commit ff8f226

Please sign in to comment.