Skip to content

Commit b3b95ee

Browse files
authored
Filesystems and data partitions (SD/SPIFFS/LittleFS/SD_MMC) (#92)
* @tuan-karma's compiler warning fix (#a0e9e5c) * LittleFS/SD/SD_MMC/SPIFFS (any FS) support for certs/signatures * Auto assign filesystem when applicable * Added SPIFFS/LittleFS partition support to execOTA() * Added Callback setter for Update progress handler * Implemented `esp32fota.setExtraHTTPHeader( name, value )` * C++11 compliance * Credits update * Updated examples * Created test suite (#6) * Added Dispatchable Workflow for library maintainers (manual triggering) * bump version
1 parent 601766f commit b3b95ee

File tree

20 files changed

+1500
-302
lines changed

20 files changed

+1500
-302
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[{
2+
"type": "FIRMWARE_TYPE",
3+
"version": 1,
4+
"host": "FIRMWARE_HOST",
5+
"port": FIRMWARE_PORT,
6+
"bin": "FIRMWARE_PATH/1.nosecurity.ino.bin?raw=true"
7+
},
8+
{
9+
"type": "FIRMWARE_TYPE",
10+
"version": 2,
11+
"host": "FIRMWARE_HOST",
12+
"port": FIRMWARE_PORT,
13+
"bin": "FIRMWARE_PATH/2.cert-in-spiffs.ino.bin?raw=true",
14+
"spiffs": "FIRMWARE_PATH/2.cert-in-spiffs.spiffs.bin?raw=true"
15+
},
16+
{
17+
"type": "FIRMWARE_TYPE",
18+
"version": 3,
19+
"host": "FIRMWARE_HOST",
20+
"port": FIRMWARE_PORT,
21+
"bin": "FIRMWARE_PATH/3.cert-in-progmem.ino.bin?raw=true"
22+
},
23+
{
24+
"type": "FIRMWARE_TYPE",
25+
"version": 4,
26+
"host": "FIRMWARE_HOST",
27+
"port": FIRMWARE_PORT,
28+
"bin": "FIRMWARE_PATH/4.cert-in-littlefs.ino.bin?raw=true",
29+
"littlefs": "FIRMWARE_PATH/4.cert-in-littlefs.littlefs.bin?raw=true"
30+
},
31+
{
32+
"type": "FIRMWARE_TYPE",
33+
"version": 5,
34+
"host": "FIRMWARE_HOST",
35+
"port": FIRMWARE_PORT,
36+
"bin": "FIRMWARE_PATH/5.final-stage.ino.bin?raw=true"
37+
}]
38+

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

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
name: Dispatchable build
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
firmware_type:
6+
description: 'Firmware Type'
7+
default: 'esp32-fota-http'
8+
required: true
9+
type: string
10+
manifest_url:
11+
description: 'Complete URL (where the JSON Manifest will be hosted)'
12+
required: true
13+
default: 'https://github.com/[user]/[repo]/raw/[branch]/[path to manifest]/firmware.json'
14+
type: string
15+
manifest_host:
16+
description: 'Hostname (where the binaries will be hosted)'
17+
required: true
18+
default: 'github.com'
19+
type: string
20+
manifest_port:
21+
description: 'Port (e.g 80 or 443)'
22+
required: true
23+
default: '443'
24+
type: string
25+
manifest_bin_path:
26+
description: 'Path (no trailing slash)'
27+
required: true
28+
default: '/[user]/[repo]/blob/[branch]/[path to binaries]'
29+
type: string
30+
board_fqbn:
31+
description: 'Board FQBN (for arduino-cli)'
32+
required: true
33+
default: 'esp32:esp32:esp32'
34+
type: string
35+
partition_scheme:
36+
description: 'Partition scheme'
37+
required: true
38+
type: choice
39+
options:
40+
- default
41+
- min_spiffs
42+
- large_spiffs
43+
default: 'default'
44+
45+
jobs:
46+
47+
matrix_build:
48+
49+
name: ${{ matrix.sketch }}
50+
runs-on: ubuntu-latest
51+
52+
strategy:
53+
matrix:
54+
55+
sketch:
56+
- 1.nosecurity.ino
57+
- 2.cert-in-spiffs.ino
58+
- 3.cert-in-progmem.ino
59+
- 4.cert-in-littlefs.ino
60+
- 5.final-stage.ino
61+
62+
steps:
63+
64+
- name: Checkout
65+
uses: actions/checkout@v2
66+
with:
67+
ref: ${{ github.event.pull_request.head.sha }}
68+
69+
- name: Inject Manifest URL
70+
run: |
71+
full_ino_path=`find /home/runner/work/ | grep "${{ matrix.sketch }}"`
72+
echo -e "#define FOTA_URL \"${{ inputs.manifest_url }}\"\n$(cat $full_ino_path)" > $full_ino_path
73+
74+
75+
- name: Inject TLS Cert if applicable
76+
if: (inputs.manifest_port == '443' || inputs.manifest_port == '4433')
77+
run: |
78+
full_rootca_path=`find /home/runner/work/ | grep "progmem/root_ca.h"`
79+
ssl_host="${{ inputs.manifest_host }}"
80+
prefix="const char* root_ca =\\"
81+
suffix="\"\";"
82+
echo $prefix > $full_rootca_path
83+
openssl s_client -showcerts -connect $ssl_host:${{ inputs.manifest_port }} </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | awk '{print "\"" $0 "\\n\"\\"}' >> $full_rootca_path
84+
echo $suffix >> $full_rootca_path
85+
cat $full_rootca_path
86+
87+
88+
- name: ${{ matrix.sketch }}
89+
uses: ArminJo/arduino-test-compile@v3
90+
with:
91+
platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
92+
arduino-board-fqbn: ${{ inputs.board_fqbn }}:PartitionScheme=${{inputs.partition_scheme}}
93+
required-libraries: ArduinoJson
94+
extra-arduino-lib-install-args: --no-deps
95+
extra-arduino-cli-args: "--warnings default " # see https://github.com/ArminJo/arduino-test-compile/issues/28
96+
sketch-names: ${{ matrix.sketch }}
97+
set-build-path: true
98+
# build-properties: ${{ toJson(matrix.build-properties) }}
99+
# arduino-platform: esp32:esp32@${{ matrix.sdk-version }}
100+
# extra-arduino-cli-args: ${{ matrix.extra-arduino-cli-args }}
101+
# debug-install: true
102+
103+
- name: Save compiled binaries
104+
run: |
105+
mkdir -p /home/runner/builds
106+
ls /home/runner/builds -la
107+
cd /home/runner/work/
108+
full_ino_bin_path=`find . | grep "build/${{ matrix.sketch }}.bin"`
109+
echo "Bin path: $full_ino_bin_path"
110+
cp "$full_ino_bin_path" /home/runner/builds/${{ matrix.sketch }}.bin
111+
112+
- name: Prepare data folder if applicable
113+
if: (inputs.manifest_port == '443' || inputs.manifest_port == '4433')
114+
run: |
115+
full_rootca_path=`find /home/runner/work/ | grep "anyFS/data/root_ca.pem"`
116+
ssl_host="${{ inputs.manifest_host }}"
117+
openssl s_client -showcerts -connect $ssl_host:${{ inputs.manifest_port }} </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > $full_rootca_path
118+
cat $full_rootca_path
119+
120+
- name: Create filesystem images
121+
run: |
122+
# ooh that's dirty :-)
123+
default_size=0x170000
124+
large_spiffs_size=0x6F0000
125+
min_spiffs_size=0x30000
126+
127+
mkspiffs_esp32=~/.arduino15/packages/esp32*/tools/mkspiffs/*/mkspiffs
128+
mklittlefs_esp32=~/.arduino15/packages/esp32*/tools/mklittlefs/*/mklittlefs
129+
echo "mkspiffs path: $mkspiffs_esp32"
130+
echo "mklittlefs path: $mklittlefs_esp32"
131+
$mkspiffs_esp32 -c examples/anyFS/data/ -p 256 -b 4096 -s $${{inputs.partition_scheme}}_size /home/runner/builds/2.cert-in-spiffs.spiffs.bin
132+
$mklittlefs_esp32 -c examples/anyFS/data/ -p 256 -b 4096 -s $${{inputs.partition_scheme}}_size /home/runner/builds/4.cert-in-littlefs.littlefs.bin
133+
ls /home/runner/builds -la
134+
135+
- name: Upload artifact for Stage ${{ matrix.test-stage }}
136+
uses: actions/upload-artifact@v2
137+
with:
138+
name: TestSuite
139+
path: |
140+
/home/runner/builds/**
141+
142+
143+
post_build:
144+
name: Gather Artefacts
145+
runs-on: ubuntu-latest
146+
# wait until matrix jobs are all finished
147+
needs: matrix_build
148+
steps:
149+
150+
- name: Checkout
151+
uses: actions/checkout@v2
152+
153+
- name: Create artifacts dir
154+
run: mkdir -p /home/runner/builds
155+
156+
#- name: Download artifacts
157+
#uses: actions/download-artifact@v2
158+
#with:
159+
#path: /home/runner/builds
160+
161+
- name: Polulate JSON Manifest
162+
run: |
163+
firmware_json_path=/home/runner/builds/firmware.json
164+
cp .github/templates/firmware.test-suite.json $firmware_json_path
165+
sed -i -e 's/FIRMWARE_TYPE/${{ inputs.firmware_type }}/g' $firmware_json_path
166+
sed -i -e 's/FIRMWARE_HOST/${{ inputs.manifest_host }}/g' $firmware_json_path
167+
sed -i -e 's/FIRMWARE_PORT/${{ inputs.manifest_port }}/g' $firmware_json_path
168+
sed -i -e 's~FIRMWARE_PATH~${{ inputs.manifest_bin_path }}~g' $firmware_json_path
169+
cat $firmware_json_path
170+
171+
- name: Update artifacts with new JSON Manifest
172+
uses: actions/upload-artifact@v2
173+
with:
174+
name: TestSuite
175+
path: |
176+
/home/runner/builds/**
177+
178+
179+
- name: Release check
180+
uses: softprops/action-gh-release@v1
181+
if: startsWith(github.ref, 'refs/tags/')
182+
with:
183+
files: |
184+
/home/runner/builds/**
185+
186+

.github/workflows/platformio.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
pull_request:
99
branches:
1010
- master
11+
workflow_dispatch:
1112

1213
jobs:
1314
build:
@@ -30,4 +31,4 @@ jobs:
3031
- name: Build test
3132
run: |
3233
pio run
33-
34+

.gitignore

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

0 commit comments

Comments
 (0)