Skip to content

Commit 4ed3c95

Browse files
authored
Merge pull request #102 from chrisjoyce911/0.2.3
0.2.3
2 parents bcfd437 + b45fe64 commit 4ed3c95

File tree

17 files changed

+924
-286
lines changed

17 files changed

+924
-286
lines changed

.github/templates/firmware.test-suite.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
[{
22
"type": "FIRMWARE_TYPE",
3-
"version": 1,
3+
"version": "1.1",
44
"host": "FIRMWARE_HOST",
55
"port": FIRMWARE_PORT,
6-
"bin": "FIRMWARE_PATH/1.nosecurity.ino.bin?raw=true"
6+
"bin": "FIRMWARE_PATH/1.1.nosecurity.ino.bin?raw=true"
7+
},
8+
{
9+
"type": "FIRMWARE_TYPE",
10+
"version": "1.2",
11+
"host": "FIRMWARE_HOST",
12+
"port": FIRMWARE_PORT,
13+
"bin": "FIRMWARE_PATH/1.2.nosecurity.gz.ino.bin.gz?raw=true"
14+
},
15+
{
16+
"type": "FIRMWARE_TYPE",
17+
"version": "1.3",
18+
"host": "FIRMWARE_HOST",
19+
"port": FIRMWARE_PORT,
20+
"bin": "FIRMWARE_PATH/1.3.nosecurity.zz.ino.bin.zz?raw=true"
721
},
822
{
923
"type": "FIRMWARE_TYPE",

.github/workflows/gen-test-suite.yml

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ on:
7070
- large_spiffs
7171
default: 'default'
7272

73+
debug_level:
74+
description: 'Core Debug Level'
75+
required: true
76+
type: choice
77+
options:
78+
- none
79+
- error
80+
- warning
81+
- info
82+
- debug
83+
- verbose
84+
default: 'none'
7385

7486
jobs:
7587

@@ -172,7 +184,9 @@ jobs:
172184
matrix:
173185

174186
sketch:
175-
- 1.nosecurity.ino
187+
- 1.1.nosecurity.ino
188+
- 1.2.nosecurity.gz.ino
189+
- 1.3.nosecurity.zz.ino
176190
- 2.cert-in-spiffs.ino
177191
- 3.cert-in-progmem.ino
178192
- 4.cert-in-littlefs.ino
@@ -182,7 +196,7 @@ jobs:
182196

183197
steps:
184198

185-
- name: Checkout
199+
- name: Checkout Current
186200
uses: actions/checkout@v2
187201
with:
188202
ref: ${{ github.event.pull_request.head.sha }}
@@ -208,25 +222,42 @@ jobs:
208222
cp ${{env.cert_path}}/root_ca.h $root_ca_c_path
209223
cp ${{env.cert_path}}/pub_key.h $pub_key_c_path
210224
225+
- name: Checkout esp32-flashz
226+
uses: actions/checkout@v2
227+
with:
228+
repository: vortigont/esp32-flashz
229+
ref: main
230+
path: CustomflashZ # must contain string "Custom"
231+
232+
- name: Checkout ESP32-targz
233+
uses: actions/checkout@v2
234+
with:
235+
repository: tobozo/ESP32-targz
236+
ref: master
237+
path: CustomESP32-targz # must contain string "Custom"
238+
239+
211240
- name: Compile ${{ matrix.sketch }}
212241
uses: ArminJo/arduino-test-compile@v3
213242
with:
214243
platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
215-
arduino-board-fqbn: ${{inputs.board_fqbn}}:PartitionScheme=${{inputs.partition_scheme}}
244+
arduino-board-fqbn: ${{inputs.board_fqbn}}:PartitionScheme=${{inputs.partition_scheme}},DebugLevel=${{inputs.debug_level}}
216245
required-libraries: ArduinoJson
217246
extra-arduino-lib-install-args: --no-deps
218247
extra-arduino-cli-args: "--warnings default " # see https://github.com/ArminJo/arduino-test-compile/issues/28
219248
sketch-names: ${{ matrix.sketch }}
220249
set-build-path: true
221250

222-
- name: Sign and Save compiled binary
251+
- name: Sign and Save binaries
223252
run: |
224253
mkdir -p ${{env.artifact_path}}
225254
full_ino_bin_path=`find ${{env.work_path}}/ | grep "build/${{ matrix.sketch }}.bin"`
226255
openssl dgst -sign ${{env.privkey_path}} -keyform PEM -sha256 -out firmware.sign -binary $full_ino_bin_path
227256
cat firmware.sign $full_ino_bin_path > $full_ino_bin_path.img
228257
cp $full_ino_bin_path ${{env.artifact_path}}/${{ matrix.sketch }}.bin
229258
cp $full_ino_bin_path.img ${{env.artifact_path}}/${{ matrix.sketch }}.signed.bin
259+
gzip -c $full_ino_bin_path > ${{env.artifact_path}}/${{ matrix.sketch }}.bin.gz
260+
pigz -9kzc $full_ino_bin_path > ${{env.artifact_path}}/${{ matrix.sketch }}.bin.zz
230261
231262
232263
- name: Prepare data folder
@@ -252,6 +283,12 @@ jobs:
252283
# Create the partition binaries
253284
${{env.mkspiffs_esp32}} -c ${{env.data_path}} -p 256 -b 4096 -s $${{inputs.partition_scheme}}_size ${{env.spiffs_bin_path}}
254285
${{env.mklittlefs_esp32}} -c ${{env.data_path}} -p 256 -b 4096 -s $${{inputs.partition_scheme}}_size ${{env.littlefs_bin_path}}
286+
# Create gzipped versions
287+
gzip -c ${{env.littlefs_bin_path}} > ${{env.littlefs_bin_path}}.gz
288+
gzip -c ${{env.spiffs_bin_path}} > ${{env.spiffs_bin_path}}.gz
289+
# Create flashZ versions
290+
pigz -9kzc ${{env.littlefs_bin_path}} > ${{env.littlefs_bin_path}}.zz
291+
pigz -9kzc ${{env.spiffs_bin_path}} > ${{env.spiffs_bin_path}}.zz
255292
256293
# Sign partition binaries
257294
openssl dgst -sign ${{env.privkey_path}} -keyform PEM -sha256 -out firmware.sign -binary ${{env.spiffs_bin_path}}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
_Notes
33
.pio
44
test/stage1
5+
.directory

README.md

Lines changed: 76 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
[![PlatformIO](https://github.com/chrisjoyce911/esp32FOTA/workflows/PlatformIO/badge.svg)](https://github.com/chrisjoyce911/esp32FOTA/actions/)
22

3+
[![arduino-library-badge](https://www.ardu-badge.com/badge/esp32FOTA.svg?)](https://www.ardu-badge.com/esp32FOTA)
4+
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/chrisjoyce911/library/esp32FOTA.svg)](https://registry.platformio.org/libraries/chrisjoyce911/esp32FOTA)
5+
6+
7+
38
# esp32FOTA library for Arduino
49

510
## Purpose
@@ -90,12 +95,15 @@ A single JSON file can also contain several versions of a single firmware type:
9095
{
9196
"type":"esp32-fota-http",
9297
"version":"0.0.3",
93-
"url":"http://192.168.0.100/fota/esp32-fota-0.0.3.bin"
98+
"url":"http://192.168.0.100/fota/esp32-fota-0.0.3.bin",
99+
"spiffs":"http://192.168.0.100/fota/esp32-fota-0.0.3.spiffs.bin"
94100
}
95101
]
96102
```
97103

98104

105+
106+
99107
#### Filesystem image (spiffs/littlefs)
100108

101109
Adding `spiffs` key to the JSON entry will end up with the filesystem being updated first, then the firmware.
@@ -168,10 +176,12 @@ void setup_wifi()
168176

169177
void loop()
170178
{
171-
bool updatedNeeded = esp32FOTA.execHTTPcheck();
172-
if (updatedNeeded) {
173-
esp32FOTA.execOTA();
174-
}
179+
esp32FOTA.handle();
180+
// or ...
181+
// bool updatedNeeded = esp32FOTA.execHTTPcheck();
182+
// if (updatedNeeded) {
183+
// esp32FOTA.execOTA();
184+
// }
175185
delay(2000);
176186
}
177187
```
@@ -209,16 +219,67 @@ void setup()
209219
210220
void loop()
211221
{
212-
bool updatedNeeded = esp32FOTA.execHTTPcheck();
213-
if (updatedNeeded) {
214-
esp32FOTA.execOTA();
215-
}
222+
esp32FOTA.handle();
223+
// or ...
224+
// bool updatedNeeded = esp32FOTA.execHTTPcheck();
225+
// if (updatedNeeded) {
226+
// esp32FOTA.execOTA();
227+
// }
216228
delay(2000);
217229
}
218230
219231
```
220232

221233

234+
### Zlib/gzip support
235+
236+
⚠️ This feature cannot be used with signature check.
237+
238+
239+
For firmwares compressed with `pigz` utility (see , file extension must be `.zz`:
240+
241+
```cpp
242+
#include <flashz.hpp> // http://github.com/vortigont/esp32-flashz
243+
#include <esp32FOTA.hpp>
244+
```
245+
246+
```bash
247+
$ pigz -9kzc esp32-fota-http-2.bin > esp32-fota-http-2.bin.zz
248+
```
249+
250+
```json
251+
{
252+
"type": "esp32-fota-http",
253+
"version": "2.5.1",
254+
"url": "http://192.168.0.100/fota/esp32-fota-http-2.bin.zz"
255+
}
256+
```
257+
258+
259+
For firmwares compressed with `gzip` utility, file extension must be `.gz`
260+
261+
```cpp
262+
#include <ESP32-targz.h> // http://github.com/tobozo/ESP32-targz
263+
#include <esp32FOTA.hpp>
264+
```
265+
266+
```bash
267+
$ gzip -c esp32-fota-http-2.bin > esp32-fota-http-2.bin.gz
268+
```
269+
270+
```json
271+
{
272+
"type": "esp32-fota-http",
273+
"version": "2.5.1",
274+
"url": "http://192.168.0.100/fota/esp32-fota-http-2.bin.gz"
275+
}
276+
```
277+
278+
279+
280+
281+
282+
222283
### Root Certificates
223284

224285
Certificates and signatures can be stored in different places: any fs::FS filesystem or progmem as const char*.
@@ -428,11 +489,14 @@ On the next update-check the ESP32 will download the `firmware.img` extract the
428489
[#92]: https://github.com/chrisjoyce911/esp32FOTA/pull/92
429490

430491

492+
### Libraries
431493

494+
This library relies on [semver.c by h2non](https://github.com/h2non/semver.c) for semantic versioning support. semver.c is licensed under [MIT](https://github.com/h2non/semver.c/blob/master/LICENSE).
432495

433-
### Libraries
496+
Optional dependencies (zlib/gzip support):
497+
* [esp32-flashz](https://github.com/vortigont/esp32-flashz)
498+
* [esp32-targz](https://github.com/tobozo/ESP32-targz)
434499

435-
This relies on [semver.c by h2non](https://github.com/h2non/semver.c) for semantic versioning support. semver.c is licensed under [MIT](https://github.com/h2non/semver.c/blob/master/LICENSE).
436500

437501
### Thanks to
438502

@@ -441,4 +505,5 @@ This relies on [semver.c by h2non](https://github.com/h2non/semver.c) for semant
441505
* @tuan-karma
442506
* @hpsaturn
443507
* @tobozo
508+
* @vortigont
444509

examples/anyFS/anyFS.ino

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
#include <LittleFS.h>
1414
//#include <PSRamFS.h>
1515

16+
//#include <flashz.hpp> // optional esp32-flashz for zlib compressed firmwares
17+
//#include <ESP32-targz.h> // optional ESP32-targz for gzip compressed firmwares
1618
#include <esp32fota.h> // fota pulls WiFi library
1719

1820

21+
1922
// esp32fota settings
2023
const int firmware_version = 1;
2124
#if !defined FOTA_URL
@@ -36,11 +39,14 @@ CryptoFileAsset *MyRSAKey = new CryptoFileAsset( "/rsa_key.pub", &LittleFS );
3639
// CryptoMemAsset *MyRSAKey = new CryptoMemAsset("RSA Public Key", rsa_key_pub, strlen(rsa_key_pub)+1 );
3740

3841

39-
esp32FOTA FOTA;
40-
//esp32FOTA esp32FOTA( String(firmware_name), firmware_version, check_signature, disable_security );
42+
esp32FOTA FOTA; // empty constructor
43+
4144

45+
bool WiFiConnected()
46+
{
47+
return (WiFi.status() == WL_CONNECTED);
48+
}
4249

43-
//esp32FOTA esp32FOTA("esp32-fota-http", 1, false );
4450

4551
void setup_wifi()
4652
{
@@ -50,7 +56,7 @@ void setup_wifi()
5056

5157
WiFi.begin(); // no WiFi creds in this demo :-)
5258

53-
while (WiFi.status() != WL_CONNECTED)
59+
while ( !WiFiConnected() )
5460
{
5561
delay(500);
5662
Serial.print(".");
@@ -86,6 +92,10 @@ void setup()
8692
FOTA.setConfig( cfg );
8793
}
8894

95+
96+
// FOTA.setStatusChecker( WiFiConnected );
97+
98+
8999
// /!\ FOTA.checkURL is deprecated, use setManifestURL( String ) instead
90100
//FOTA.setManifestURL( FOTA_URL );
91101
//FOTA.setRootCA( MyRootCA );

0 commit comments

Comments
 (0)