Skip to content

Commit

Permalink
Merge pull request #67 from tobozo/1.1.9
Browse files Browse the repository at this point in the history
1.1.9
  • Loading branch information
tobozo authored May 1, 2023
2 parents 69ebece + 4f62a68 commit b171e5d
Show file tree
Hide file tree
Showing 23 changed files with 347 additions and 384 deletions.
43 changes: 37 additions & 6 deletions .github/workflows/LibraryBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,24 @@ jobs:

arduino-boards-fqbn:
- esp8266:esp8266:generic:eesz=4M3M,xtal=80
- esp32:esp32:esp32:FlashFreq=80
- esp32:esp32:esp32:FlashMode=dio,FlashFreq=80,FlashSize=4M
- rp2040:rp2040:rpipico

include:
- arduino-boards-fqbn: esp32:esp32:esp32:FlashFreq=80
- arduino-boards-fqbn: esp32:esp32:esp32:FlashMode=dio,FlashFreq=80,FlashSize=4M
platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
sketch-names: Test_tar_gz_tgz.ino,Update_from_gz_stream.ino,Unpack_tar_gz_stream.ino # Comma separated list of sketch names (no path required) or patterns to use in build
board-name: esp32

- arduino-boards-fqbn: esp8266:esp8266:generic:eesz=4M3M,xtal=80
sketch-names: Test_tar_gz_tgz.ino,Update_spiffs_from_http_gz_stream.ino
platform-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json
required-libraries: ESP32-Chimera-Core,LovyanGFX
board-name: esp8266

- arduino-boards-fqbn: rp2040:rp2040:rpipico
sketch-names: Test_tar_gz_tgz.ino
platform-url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
board-name: rp2040

fail-fast: false

Expand All @@ -46,9 +49,37 @@ jobs:
uses: ArminJo/arduino-test-compile@v3
with:
arduino-board-fqbn: ${{ matrix.arduino-boards-fqbn }}
#platform-default-url: ${{ env.PLATFORM_DEFAULT_URL }}
platform-url: ${{ matrix.platform-url }}
required-libraries: ${{ matrix.required-libraries }}
sketch-names: ${{ matrix.sketch-names }}
#sketches-exclude: ${{ matrix.sketches-exclude }}
build-properties: ${{ toJson(matrix.build-properties) }}
set-build-path: true # build in the sketch folder
#build-properties: ${{ toJson(matrix.build-properties) }}


- name: Create littlefs image (ESP32)
if: matrix.board-name == 'esp32'
run: |
sketch_folder=examples/Test_tar_gz_tgz
MKLITTLEFS_BIN=`find /home/runner -type f -name 'mklittlefs'`
if [[ -d "$sketch_folder/data" ]]; then
echo "MKLITTLEFS_BIN = $MKLITTLEFS_BIN"
echo "Data folder = $sketch_folder/data"
[[ ! -f "$MKLITTLEFS_BIN" ]] && { echo "[ERROR] mklittlefs not found"; exit 1; }
$MKLITTLEFS_BIN -s 1441792 -b 4096 -p 256 -c $sketch_folder/data $sketch_folder/build/Test_tar_gz_tgz.ino.spiffs.bin
ls $sketch_folder/build/Test_tar_gz_tgz.ino.spiffs.bin -la
fi
- name: Run ESP32 project in QEmu
if: matrix.board-name == 'esp32'
uses: tobozo/esp32-qemu-sim@main
with:
# Set the build folder and file names for esp32-qemu-sim
debug: true
qemu-timeout: 999
build-folder: examples/Test_tar_gz_tgz/build
partitions-csv: partitions.csv
firmware-bin: Test_tar_gz_tgz.ino.bin
bootloader-bin: Test_tar_gz_tgz.ino.bootloader.bin
partitions-bin: Test_tar_gz_tgz.ino.partitions.bin
spiffs-bin: Test_tar_gz_tgz.ino.spiffs.bin

1 change: 1 addition & 0 deletions examples/Test_platformio/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.pio
39 changes: 39 additions & 0 deletions examples/Test_platformio/include/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

This directory is intended for project header files.

A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.

```src/main.c

#include "header.h"

int main (void)
{
...
}
```

Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.

In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.

Read more about using header files in official GCC documentation:

* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes

https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
46 changes: 46 additions & 0 deletions examples/Test_platformio/lib/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.

The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").

For example, see a structure of the following two libraries `Foo` and `Bar`:

|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c

and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>

int main (void)
{
...
}

```

PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.

More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
20 changes: 20 additions & 0 deletions examples/Test_platformio/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
default_envs = nodemcu


[env:nodemcu]
platform = espressif8266
board = nodemcu
framework = arduino
lib_deps =
https://github.com/tobozo/ESP32-targz#1.1.8
12 changes: 12 additions & 0 deletions examples/Test_platformio/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <ESP32-targz.h>

void setup()
{

}


void loop()
{

}
11 changes: 11 additions & 0 deletions examples/Test_platformio/test/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

This directory is intended for PlatformIO Test Runner and project tests.

Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.

More information about PlatformIO Unit Testing:
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
57 changes: 46 additions & 11 deletions examples/Test_tar_gz_tgz/Test_tar_gz_tgz.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
\*/
// Set **destination** filesystem by uncommenting one of these:
//#define DEST_FS_USES_SPIFFS // WARN: SPIFFS is full of bugs
//#define DEST_FS_USES_LITTLEFS
#define DEST_FS_USES_SD
#define DEST_FS_USES_LITTLEFS
//#define DEST_FS_USES_SD
//#define DEST_FS_USES_FFAT // ESP32 only
//#define DEST_FS_USES_SD_MMC // ESP32 only
//#define DEST_FS_USES_PSRAMFS // ESP32 only
Expand Down Expand Up @@ -103,6 +103,9 @@ bool test_tarExpander()
} else {
ret = true;
}

delete TARUnpacker;

return ret;
}

Expand Down Expand Up @@ -143,6 +146,10 @@ bool test_tarStreamExpander()
} else {
ret = true;
}

tarFile.close();
delete TARUnpacker;

return ret;
}

Expand Down Expand Up @@ -178,6 +185,9 @@ bool test_gzExpander()
} else {
ret = true;
}

delete GZUnpacker;

return ret;
}

Expand Down Expand Up @@ -221,6 +231,10 @@ bool test_gzStreamExpander()
} else {
ret = true;
}

file.close();
delete GZUnpacker;

return ret;
}

Expand Down Expand Up @@ -252,12 +266,15 @@ bool test_tarGzExpander()
TARGZUnpacker->setTarMessageCallback( myTarMessageCallback/*BaseUnpacker::targzPrintLoggerCallback*/ ); // tar log verbosity

// include/exclude filters, can be set/omitted both or separately
TARGZUnpacker->setTarExcludeFilter( myTarExcludeFilter ); // will ignore files/folders
TARGZUnpacker->setTarIncludeFilter( myTarIncludeFilter ); // will allow files/folders
//TARGZUnpacker->setTarExcludeFilter( myTarExcludeFilter ); // will ignore files/folders
//TARGZUnpacker->setTarIncludeFilter( myTarIncludeFilter ); // will allow files/folders

#ifdef ESP32
TARGZUnpacker->setPsram( true );
#endif
#ifdef ESP8266
TARGZUnpacker->noDict(); // use crc-based instead of dictionary-based decompression, saves ~30Kb but is much slower
#endif

if( !TARGZUnpacker->tarGzExpander(sourceFS, tarGzFile, tarGzFS, myPackage.folder ) ) {
Serial.println( OpenLine );
Expand All @@ -266,6 +283,7 @@ bool test_tarGzExpander()
} else {
ret = true;
}
delete TARGZUnpacker;
return ret;
}

Expand Down Expand Up @@ -314,6 +332,7 @@ bool test_tarGzExpander_no_intermediate()
//TARGZUnpacker->tarGzListDir( tarGzFS, myPackage.folder, 3 );
#endif
}
delete TARGZUnpacker;
return ret;
}

Expand All @@ -336,7 +355,7 @@ bool test_tarGzExpander_no_intermediate()

GzUnpacker *GZUnpacker = new GzUnpacker();

GZUnpacker->haltOnError( true ); // stop on fail (manual restart/reset required)
GZUnpacker->haltOnError( false ); // stop on fail (manual restart/reset required)
GZUnpacker->setupFSCallbacks( targzTotalBytesFn, targzFreeBytesFn ); // prevent the partition from exploding, recommended
GZUnpacker->setGzProgressCallback( BaseUnpacker::defaultProgressCallback ); // targzNullProgressCallback or defaultProgressCallback
GZUnpacker->setLoggerCallback( BaseUnpacker::targzPrintLoggerCallback ); // gz log verbosity
Expand All @@ -347,11 +366,13 @@ bool test_tarGzExpander_no_intermediate()

if( ! GZUnpacker->gzUpdater( sourceFS, firmwareFile, U_FLASH, /*restart on update*/false ) ) {
Serial.println( OpenLine );
SerialPrintfCentered("gzUpdater failed with return code #%d", GZUnpacker->tarGzGetError() );
SerialPrintfCentered("gzUpdater failed updating from %s with return code #%d", firmwareFile, GZUnpacker->tarGzGetError() );
Serial.println( CloseLine );
} else {
ret = true;
ESP.restart();
}
delete GZUnpacker;
return ret;
}

Expand Down Expand Up @@ -414,11 +435,15 @@ bool test_tarGzStreamExpander()

if( !TARGZUnpacker->tarGzStreamExpander( streamptr, tarGzFS ) ) {
Serial.println( OpenLine );
SerialPrintfCentered("tarGzStreamExpander failed with return code #%d", TARGZUnpacker->tarGzGetError() );
SerialPrintfCentered("tarGzStreamExpander failed updating from %s with return code #%d", tarGzFile, TARGZUnpacker->tarGzGetError() );
Serial.println( CloseLine );
} else {
ret = true;
}
#if ! __has_include(<PSRamFS.h>)
file.close();
#endif
delete TARGZUnpacker;
return ret;
}

Expand All @@ -432,6 +457,11 @@ bool test_tarGzStreamExpander()

bool test_tarGzStreamUpdater()
{
#if defined DEST_FS_USES_LITTLEFS && sourceFS==LittleFS
SerialPrintCentered("Source and destination FS collide, skipping test", false, true );
return true;
#endif

bool ret = false;
#if defined ESP32
const char* bundleGzFile = "/partitions_bundle_esp32.tar.gz"; // archive containing both partitions for app and spiffs
Expand All @@ -444,7 +474,7 @@ bool test_tarGzStreamUpdater()
SerialPrintCentered("Testing tarGzStreamUpdater", false, true );

TarGzUnpacker *TARGZUnpacker = new TarGzUnpacker();
TARGZUnpacker->haltOnError( true ); // stop on fail (manual restart/reset required)
TARGZUnpacker->haltOnError( false ); // stop on fail (manual restart/reset required)
TARGZUnpacker->setTarVerify( false ); // nothing to verify as we're writing a partition
// TARGZUnpacker->setupFSCallbacks( nullptr, nullptr ); // Update.h already takes care of that
TARGZUnpacker->setGzProgressCallback( BaseUnpacker::targzNullProgressCallback ); // don't care about gz progress
Expand Down Expand Up @@ -477,6 +507,8 @@ bool test_tarGzStreamUpdater()
} else {
ret = true;
}
file.close();
delete TARGZUnpacker;
return ret;
}

Expand Down Expand Up @@ -616,9 +648,12 @@ void setup()
Serial.println( CloseLine );

testNum++;
goto _test_begin;
// go on with next test
// DEVICE_RESTART();
#if defined ESP32
goto _test_begin;
#else
// go on with next test
DEVICE_RESTART();
#endif
}

}
Expand Down
5 changes: 3 additions & 2 deletions examples/Test_tar_gz_tgz/test_files.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fileMeta myFiles[15] =
fileMeta myFiles[15] =
{
{ 279200 , "2297aacd9380d9b438490d6002bc83be", "firmware_example_esp32" },
{ 120188 , "42ad7a973640e95f1cbfbd7b45a94ef1", "firmware_example_esp32.gz" },
Expand All @@ -15,8 +15,9 @@ fileMeta myFiles[15] =
{ 7172 , "cf1f1f596ab7a726334ffcee1100a912", "zombo.com/img/spinner.png" },
{ 2040 , "808a446d1885a65202fc8f7dc5fb7341", "zombo.com/index.html" },
{ 7925 , "22ed447b5be77f1bd7a8c3f08f9b702a", "zombo.com/snd/inrozxa.swf" },

};
packageMeta myPackage =
packageMeta myPackage =
{
nullptr, 15, myFiles
};
Loading

0 comments on commit b171e5d

Please sign in to comment.