From f6f05525e30e11c7c1f323aeb7bed64201dbc9fc Mon Sep 17 00:00:00 2001 From: Sven Naumann <3747263+sVnsation@users.noreply.github.com> Date: Wed, 30 Nov 2022 21:03:54 +0100 Subject: [PATCH] compress firmware bin with gzip for ota allows smaller update files for ota update --- scripts/getVersion.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/getVersion.py b/scripts/getVersion.py index 2346966d7..214064182 100644 --- a/scripts/getVersion.py +++ b/scripts/getVersion.py @@ -1,4 +1,6 @@ import os +import shutil +import gzip from datetime import date def genOtaBin(path): @@ -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") @@ -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/"