Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compress firmware bin with gzip for ota #467

Merged
merged 1 commit into from
Dec 1, 2022
Merged
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
10 changes: 10 additions & 0 deletions scripts/getVersion.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
import shutil
import gzip
from datetime import date

def genOtaBin(path):
Expand All @@ -24,6 +26,11 @@ def genOtaBin(path):
with open(path + "ota.bin", "wb") as f:
f.write(bytearray(arr))

# write gzip firmware file
def gzip_bin(bin_file, gzip_file):
with open(bin_file,"rb") as fp:
with gzip.open(gzip_file, "wb", compresslevel = 9) as f:
shutil.copyfileobj(fp, f)

def readVersion(path, infile):
f = open(path + infile, "r")
Expand All @@ -48,16 +55,19 @@ def readVersion(path, infile):
src = path + ".pio/build/esp8266-release/firmware.bin"
dst = path + "firmware/" + versionout
os.rename(src, dst)
gzip_bin(dst, dst + ".gz")

versionout = version[:-1] + "_esp8266_1m_" + sha + ".bin"
src = path + ".pio/build/esp8285-release/firmware.bin"
dst = path + "firmware/" + versionout
os.rename(src, dst)
gzip_bin(dst, dst + ".gz")

versionout = version[:-1] + "_esp32_" + sha + ".bin"
src = path + ".pio/build/esp32-wroom32-release/firmware.bin"
dst = path + "firmware/" + versionout
os.rename(src, dst)
gzip_bin(dst, dst + ".gz")

# other ESP32 bin files
src = path + ".pio/build/esp32-wroom32-release/"
Expand Down