Skip to content
Merged

0.2.4 #103

Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 14 additions & 13 deletions .github/workflows/gen-test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ jobs:
# Avoid multiline: flatten JSON
- id: set-env
run: |
content='${{ toJson(env) }}'
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
echo "::set-output name=env::$content"
content='${{ toJson(env) }}' # convert env vars to json
content="${content//'%'/'%25'}" # escape percent entities
content="${content//$'\n'/''}" # remove lf
content="${content//$'\r'/''}" # remove cr
echo "env=${content}" >> $GITHUB_OUTPUT



gen_keys:
Expand Down Expand Up @@ -165,7 +166,7 @@ jobs:
cat $pub_key_h_path

- name: Upload RootCA/PubKey as artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: Certs
path: |
Expand Down Expand Up @@ -197,7 +198,7 @@ jobs:
steps:

- name: Checkout Current
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

Expand All @@ -223,14 +224,14 @@ jobs:
cp ${{env.cert_path}}/pub_key.h $pub_key_c_path

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

- name: Checkout ESP32-targz
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: tobozo/ESP32-targz
ref: master
Expand Down Expand Up @@ -297,7 +298,7 @@ jobs:
cat firmware.sign ${{env.littlefs_bin_path}} > ${{env.littlefs_signed_bin_path}}

- name: Update TestSuite artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: TestSuite
path: |
Expand All @@ -315,7 +316,7 @@ jobs:
steps:

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

Expand All @@ -334,14 +335,14 @@ jobs:
# rm ${{env.privkey_path}}

- name: Update TestSuite artifacts with new JSON Manifest
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: TestSuite
path: |
${{env.artifact_path}}/**

- name: Delete Cert/Signature/Privkey artifact
uses: geekyeggo/delete-artifact@v1
uses: geekyeggo/delete-artifact@v2
with:
name: Certs

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/platformio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
matrix:
python-version: [3.7]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -51,7 +51,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: arduino/arduino-lint-action@v1
with:
project-type: library
Expand Down
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ A simple library to add support for Over-The-Air (OTA) updates to your project.

## Features

- [x] Zlib or gzip compressed firmware support
- [x] SPIFFS/LittleFS partition Update [#25], [#47], [#60], [#92] (thanks to all participants)
- [x] Any fs::FS support (SPIFFS/LITTLEFS/SD) for cert/signature storage [#79], [#74], [#91], [#92] (thanks to all participants)
- [x] Seamless http/https
- [x] Web update (requires web server)
- [x] Batch firmware sync
- [x] Force firmware update [#8]
- [x] https support [#26] ( Thanks to @fbambusi )
- [x] Signature check of downloaded firmware-image [#65]
- [x] https or https
- [x] Signature verification
- [x] Semantic versioning support
- [x] Any fs::FS support (SPIFFS/LITTLEFS/SD) for cert/signature storage [#79], [#74], [#91], [#92] (thanks to all participants)
- [x] SPIFFS/LittleFS partition Update [#25], [#47], [#60], [#92] (thanks to all participants)
- [ ] Checking for update via bin headers [#15]

## How it works
Expand All @@ -34,7 +35,7 @@ There are a few things that need to be in place for an update to work.
- A webserver with the firmware information in a JSON file
- Firmware version
- Firmware type
- Firmware bin
- Firmware bin (can optionnally be compressed with zlib or gzip)
- For https or signature check: SPIFFS with root_ca.pem (https) and rsa_key.pem (signature check)

You can supply http or https URLs. If you are using https, you need the root_ca.pem in your SPIFFS partition. For the actual firmware it will use https when you define port 443 or 4433. Otherwise it will use plain http.
Expand Down Expand Up @@ -155,11 +156,13 @@ const char *password = "";

esp32FOTA esp32FOTA("esp32-fota-http", "1.0.0");

const char* manifest_url = "http://server/fota/fota.json";

void setup()
{
Serial.begin(115200);
setup_wifi();
esp32FOTA.setManifestURL( "http://server/fota/fota.json" );
esp32FOTA.setManifestURL( manifest_url );
// esp32FOTA.useDeviceId( true ); // optionally append the device ID to the HTTP query
}

Expand Down Expand Up @@ -190,11 +193,14 @@ void loop()
Late init is possible using `FOTAConfig_t`, allowing more complex configurations:

```cpp
#include <SPIFFS.h> // include filesystem *before* esp32FOTA librart
#include <esp32FOTA.hpp>
#include <SPIFFS.h>

esp32FOTA FOTA;

const char* manifest_url = "http://server/fota/fota.json";
const char* fota_name = "esp32-fota-http";

// CryptoFileAsset *MyRootCA = new CryptoFileAsset( "/root_ca.pem", &SPIFFS );
// CryptoFileAsset *MyRSAKey = new CryptoFileAsset( "/rsa_key.pub", &SD );

Expand All @@ -205,8 +211,8 @@ void setup()

{
auto cfg = FOTA.getConfig();
cfg.name = "esp32-fota-http";
cfg.manifest_url = "http://server/fota/fota.json";
cfg.name = fota_name;
cfg.manifest_url = manifest_url;
cfg.sem = SemverClass( 1, 0, 0 ); // major, minor, patch
cfg.check_sig = false; // verify signed firmware with rsa public key
cfg.unsafe = true; // disable certificate check when using TLS
Expand Down Expand Up @@ -335,10 +341,13 @@ CryptoFileAsset *MyPubKey = new CryptoFileAsset("RSA Key", "/rsa_key.pub", &SD);
Then later in the `setup()`:

```C++

const char* manifest_url = "http://server/fota/fota.json";

void setup()
{
// (...)
esp32FOTA.setManifestURL( "http://server/fota/fota.json" );
esp32FOTA.setManifestURL( manifest_url );
esp32FOTA.setRootCA( MyRootCA );
esp32FOTA.setPubKey( MyPubKey );
}
Expand Down
4 changes: 3 additions & 1 deletion examples/HTTP/HTTP.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const char *password = "";
// esp32fota esp32fota("<Type of Firme for this device>", <this version>, <validate signature>);
esp32FOTA esp32FOTA("esp32-fota-http", 1, false);

const char* manifest_url = "http://server/fota/fota.json";

void setup_wifi()
{
delay(10);
Expand All @@ -44,7 +46,7 @@ void setup_wifi()

void setup()
{
esp32FOTA.setManifestURL( "http://server/fota/fota.json" );
esp32FOTA.setManifestURL( manifest_url );
Serial.begin(115200);
setup_wifi();
}
Expand Down
3 changes: 2 additions & 1 deletion examples/HTTP/HTTPS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const char *password = "";

// esp32fota esp32fota("<Type of Firme for this device>", <this version>, <validate signature>);
esp32FOTA esp32FOTA("esp32-fota-http", 1, false);
const char* manifest_url = "http://server/fota/fota.json";

void setup_wifi()
{
Expand All @@ -54,7 +55,7 @@ void setup()
// Provide spiffs with root_ca.pem to validate server certificate
SPIFFS.begin(true);

esp32FOTA.setManifestURL( "http://server/fota/fota.json" );
esp32FOTA.setManifestURL( manifest_url );
Serial.begin(115200);
setup_wifi();
}
Expand Down
9 changes: 5 additions & 4 deletions examples/HTTP/HTTPS_without_root_cert.ino
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
esp32 firmware OTA

Purpose: Perform an OTA update from a bin located on a webserver (HTTPS) without having a root cert

Setup:
Step 1 : Set your WiFi (ssid & password)
Step 2 : set esp32fota()

Upload:
Step 1 : Menu > Sketch > Export Compiled Library. The bin file will be saved in the sketch folder (Menu > Sketch > Show Sketch folder)
Step 2 : Upload it to your webserver
Expand All @@ -29,6 +29,7 @@ const char *password = "";

// esp32fota esp32fota("<Type of Firmware for this device>", <this version>, <validate signature>, <allow insecure https>);
esp32FOTA esp32FOTA("esp32-fota-http", 1, false, true);
const char* manifest_url = "http://server/fota/fota.json";

void setup_wifi()
{
Expand All @@ -50,8 +51,8 @@ void setup_wifi()

void setup()
{
esp32FOTA.checkURL = "https://server/fota/fota.json";

esp32FOTA.checkURL = manifest_url;
Serial.begin(115200);
setup_wifi();
}
Expand Down
4 changes: 3 additions & 1 deletion examples/HTTP/HTTP_signature_check.ino
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const char *password = "";
// esp32fota esp32fota("<Type of Firme for this device>", <this version>, <validate signature>);
esp32FOTA esp32FOTA("esp32-fota-http", 1, true);

const char* manifest_url = "http://server/fota/fota.json";

void setup_wifi()
{
delay(10);
Expand All @@ -51,7 +53,7 @@ void setup_wifi()

void setup()
{
esp32FOTA.setManifestURL( "http://server/fota/fota.json" );
esp32FOTA.setManifestURL( manifest_url );
Serial.begin(115200);
setup_wifi();
}
Expand Down
39 changes: 6 additions & 33 deletions examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,22 @@

#include <ESP32-targz.h> // optional ESP32-targz for gzip compressed firmwares
#include <esp32FOTA.hpp>
#include <debug/test_fota_common.h>

// esp32fota settings
int firmware_version_major = 1;
int firmware_version_minor = 1;
int firmware_version_patch = 0;

#if !defined FOTA_URL
#define FOTA_URL "http://server/fota/fota.json"
#endif
// #define FOTA_URL "http://server/fota/fota.json"

const char* firmware_name = "esp32-fota-http";
const bool check_signature = false;
const bool disable_security = true;
// for debug only
const char* title = "1.1";
const char* description = "Basic example with no security and no filesystem";

const char* fota_debug_fmt = R"DBG_FMT(

***************** STAGE %s *****************

Description : %s
Firmware type : %s
Firmware version : %i.%i.%i
Signature check : %s
TLS Cert check : %s
Compression : %s

********************************************

)DBG_FMT";


// esp32fota esp32fota("<Type of Firmware for this device>", <this version>, <validate signature>, <allow insecure TLS>);
// esp32FOTA esp32FOTA( String(firmware_name), firmware_version, check_signature, disable_security );


esp32FOTA FOTA;

Expand Down Expand Up @@ -76,17 +58,7 @@ void setup()
{
Serial.begin(115200);

Serial.printf( fota_debug_fmt,
"1.1",
description,
firmware_name,
firmware_version_major,
firmware_version_minor,
firmware_version_patch,
check_signature ?"Enabled":"Disabled",
disable_security ?"Disabled":"Enabled",
FOTA.zlibSupported() ?"Enabled":"Disabled"
);
PrintFOTAInfo();

{
auto cfg = FOTA.getConfig();
Expand All @@ -103,6 +75,7 @@ void setup()
setup_wifi();
}


void loop()
{
FOTA.handle();
Expand Down
Loading