Skip to content
Merged

0.2.3 #102

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/templates/firmware.test-suite.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
[{
"type": "FIRMWARE_TYPE",
"version": 1,
"version": "1.1",
"host": "FIRMWARE_HOST",
"port": FIRMWARE_PORT,
"bin": "FIRMWARE_PATH/1.nosecurity.ino.bin?raw=true"
"bin": "FIRMWARE_PATH/1.1.nosecurity.ino.bin?raw=true"
},
{
"type": "FIRMWARE_TYPE",
"version": "1.2",
"host": "FIRMWARE_HOST",
"port": FIRMWARE_PORT,
"bin": "FIRMWARE_PATH/1.2.nosecurity.gz.ino.bin.gz?raw=true"
},
{
"type": "FIRMWARE_TYPE",
"version": "1.3",
"host": "FIRMWARE_HOST",
"port": FIRMWARE_PORT,
"bin": "FIRMWARE_PATH/1.3.nosecurity.zz.ino.bin.zz?raw=true"
},
{
"type": "FIRMWARE_TYPE",
Expand Down
45 changes: 41 additions & 4 deletions .github/workflows/gen-test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ on:
- large_spiffs
default: 'default'

debug_level:
description: 'Core Debug Level'
required: true
type: choice
options:
- none
- error
- warning
- info
- debug
- verbose
default: 'none'

jobs:

Expand Down Expand Up @@ -172,7 +184,9 @@ jobs:
matrix:

sketch:
- 1.nosecurity.ino
- 1.1.nosecurity.ino
- 1.2.nosecurity.gz.ino
- 1.3.nosecurity.zz.ino
- 2.cert-in-spiffs.ino
- 3.cert-in-progmem.ino
- 4.cert-in-littlefs.ino
Expand All @@ -182,7 +196,7 @@ jobs:

steps:

- name: Checkout
- name: Checkout Current
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
Expand All @@ -208,25 +222,42 @@ jobs:
cp ${{env.cert_path}}/root_ca.h $root_ca_c_path
cp ${{env.cert_path}}/pub_key.h $pub_key_c_path

- name: Checkout esp32-flashz
uses: actions/checkout@v2
with:
repository: vortigont/esp32-flashz
ref: main
path: CustomflashZ # must contain string "Custom"

- name: Checkout ESP32-targz
uses: actions/checkout@v2
with:
repository: tobozo/ESP32-targz
ref: master
path: CustomESP32-targz # must contain string "Custom"


- name: Compile ${{ matrix.sketch }}
uses: ArminJo/arduino-test-compile@v3
with:
platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
arduino-board-fqbn: ${{inputs.board_fqbn}}:PartitionScheme=${{inputs.partition_scheme}}
arduino-board-fqbn: ${{inputs.board_fqbn}}:PartitionScheme=${{inputs.partition_scheme}},DebugLevel=${{inputs.debug_level}}
required-libraries: ArduinoJson
extra-arduino-lib-install-args: --no-deps
extra-arduino-cli-args: "--warnings default " # see https://github.com/ArminJo/arduino-test-compile/issues/28
sketch-names: ${{ matrix.sketch }}
set-build-path: true

- name: Sign and Save compiled binary
- name: Sign and Save binaries
run: |
mkdir -p ${{env.artifact_path}}
full_ino_bin_path=`find ${{env.work_path}}/ | grep "build/${{ matrix.sketch }}.bin"`
openssl dgst -sign ${{env.privkey_path}} -keyform PEM -sha256 -out firmware.sign -binary $full_ino_bin_path
cat firmware.sign $full_ino_bin_path > $full_ino_bin_path.img
cp $full_ino_bin_path ${{env.artifact_path}}/${{ matrix.sketch }}.bin
cp $full_ino_bin_path.img ${{env.artifact_path}}/${{ matrix.sketch }}.signed.bin
gzip -c $full_ino_bin_path > ${{env.artifact_path}}/${{ matrix.sketch }}.bin.gz
pigz -9kzc $full_ino_bin_path > ${{env.artifact_path}}/${{ matrix.sketch }}.bin.zz


- name: Prepare data folder
Expand All @@ -252,6 +283,12 @@ jobs:
# Create the partition binaries
${{env.mkspiffs_esp32}} -c ${{env.data_path}} -p 256 -b 4096 -s $${{inputs.partition_scheme}}_size ${{env.spiffs_bin_path}}
${{env.mklittlefs_esp32}} -c ${{env.data_path}} -p 256 -b 4096 -s $${{inputs.partition_scheme}}_size ${{env.littlefs_bin_path}}
# Create gzipped versions
gzip -c ${{env.littlefs_bin_path}} > ${{env.littlefs_bin_path}}.gz
gzip -c ${{env.spiffs_bin_path}} > ${{env.spiffs_bin_path}}.gz
# Create flashZ versions
pigz -9kzc ${{env.littlefs_bin_path}} > ${{env.littlefs_bin_path}}.zz
pigz -9kzc ${{env.spiffs_bin_path}} > ${{env.spiffs_bin_path}}.zz

# Sign partition binaries
openssl dgst -sign ${{env.privkey_path}} -keyform PEM -sha256 -out firmware.sign -binary ${{env.spiffs_bin_path}}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
_Notes
.pio
test/stage1
.directory
87 changes: 76 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[![PlatformIO](https://github.com/chrisjoyce911/esp32FOTA/workflows/PlatformIO/badge.svg)](https://github.com/chrisjoyce911/esp32FOTA/actions/)

[![arduino-library-badge](https://www.ardu-badge.com/badge/esp32FOTA.svg?)](https://www.ardu-badge.com/esp32FOTA)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/chrisjoyce911/library/esp32FOTA.svg)](https://registry.platformio.org/libraries/chrisjoyce911/esp32FOTA)



# esp32FOTA library for Arduino

## Purpose
Expand Down Expand Up @@ -90,12 +95,15 @@ A single JSON file can also contain several versions of a single firmware type:
{
"type":"esp32-fota-http",
"version":"0.0.3",
"url":"http://192.168.0.100/fota/esp32-fota-0.0.3.bin"
"url":"http://192.168.0.100/fota/esp32-fota-0.0.3.bin",
"spiffs":"http://192.168.0.100/fota/esp32-fota-0.0.3.spiffs.bin"
}
]
```




#### Filesystem image (spiffs/littlefs)

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

void loop()
{
bool updatedNeeded = esp32FOTA.execHTTPcheck();
if (updatedNeeded) {
esp32FOTA.execOTA();
}
esp32FOTA.handle();
// or ...
// bool updatedNeeded = esp32FOTA.execHTTPcheck();
// if (updatedNeeded) {
// esp32FOTA.execOTA();
// }
delay(2000);
}
```
Expand Down Expand Up @@ -209,16 +219,67 @@ void setup()

void loop()
{
bool updatedNeeded = esp32FOTA.execHTTPcheck();
if (updatedNeeded) {
esp32FOTA.execOTA();
}
esp32FOTA.handle();
// or ...
// bool updatedNeeded = esp32FOTA.execHTTPcheck();
// if (updatedNeeded) {
// esp32FOTA.execOTA();
// }
delay(2000);
}

```


### Zlib/gzip support

⚠️ This feature cannot be used with signature check.


For firmwares compressed with `pigz` utility (see , file extension must be `.zz`:

```cpp
#include <flashz.hpp> // http://github.com/vortigont/esp32-flashz
#include <esp32FOTA.hpp>
```

```bash
$ pigz -9kzc esp32-fota-http-2.bin > esp32-fota-http-2.bin.zz
```

```json
{
"type": "esp32-fota-http",
"version": "2.5.1",
"url": "http://192.168.0.100/fota/esp32-fota-http-2.bin.zz"
}
```


For firmwares compressed with `gzip` utility, file extension must be `.gz`

```cpp
#include <ESP32-targz.h> // http://github.com/tobozo/ESP32-targz
#include <esp32FOTA.hpp>
```

```bash
$ gzip -c esp32-fota-http-2.bin > esp32-fota-http-2.bin.gz
```

```json
{
"type": "esp32-fota-http",
"version": "2.5.1",
"url": "http://192.168.0.100/fota/esp32-fota-http-2.bin.gz"
}
```






### Root Certificates

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


### Libraries

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).

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

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).

### Thanks to

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

18 changes: 14 additions & 4 deletions examples/anyFS/anyFS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
#include <LittleFS.h>
//#include <PSRamFS.h>

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



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


esp32FOTA FOTA;
//esp32FOTA esp32FOTA( String(firmware_name), firmware_version, check_signature, disable_security );
esp32FOTA FOTA; // empty constructor


bool WiFiConnected()
{
return (WiFi.status() == WL_CONNECTED);
}

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

void setup_wifi()
{
Expand All @@ -50,7 +56,7 @@ void setup_wifi()

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

while (WiFi.status() != WL_CONNECTED)
while ( !WiFiConnected() )
{
delay(500);
Serial.print(".");
Expand Down Expand Up @@ -86,6 +92,10 @@ void setup()
FOTA.setConfig( cfg );
}


// FOTA.setStatusChecker( WiFiConnected );


// /!\ FOTA.checkURL is deprecated, use setManifestURL( String ) instead
//FOTA.setManifestURL( FOTA_URL );
//FOTA.setRootCA( MyRootCA );
Expand Down
Loading