generate versioned output files for initial and update
This commit is contained in:
parent
20187fcb1d
commit
de5bc17c77
|
@ -59,5 +59,5 @@ jobs:
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
tag: ${{ steps.version.outputs.version}}
|
tag: ${{ steps.version.outputs.version}}
|
||||||
file: ./.pio/build/*/*-all.bin
|
file: ./.pio/build/*/*-{all,update}.bin
|
||||||
file_glob: true
|
file_glob: true
|
||||||
|
|
42
post.py
42
post.py
|
@ -1,7 +1,35 @@
|
||||||
Import("env", "projenv")
|
Import("env", "projenv")
|
||||||
import os
|
import os
|
||||||
|
import glob
|
||||||
|
import shutil
|
||||||
|
|
||||||
print("##post script running")
|
print("##post script running")
|
||||||
|
HDROFFSET=288
|
||||||
|
VERSIONOFFSET=16
|
||||||
|
NAMEOFFSET=48
|
||||||
|
MINSIZE=HDROFFSET+NAMEOFFSET+32
|
||||||
|
CHECKBYTES={
|
||||||
|
0: 0xe9, #image magic
|
||||||
|
288: 0x32, #app header magic
|
||||||
|
289: 0x54,
|
||||||
|
290: 0xcd,
|
||||||
|
291: 0xab
|
||||||
|
}
|
||||||
|
def getString(buffer,offset,len):
|
||||||
|
return buffer[offset:offset+len].rstrip(b'\0').decode('utf-8')
|
||||||
|
|
||||||
|
def getFirmwareInfo(imageFile):
|
||||||
|
with open(imageFile,"rb") as ih:
|
||||||
|
buffer=ih.read(MINSIZE)
|
||||||
|
if len(buffer) != MINSIZE:
|
||||||
|
raise Exception("invalid image file %s, to short",imageFile)
|
||||||
|
for k,v in CHECKBYTES.items():
|
||||||
|
if buffer[k] != v:
|
||||||
|
raise Exception("invalid magic in %s at %d, expected %d got %d"
|
||||||
|
%(imageFile,k,v,buffer[k]))
|
||||||
|
name=getString(buffer,HDROFFSET+NAMEOFFSET,32)
|
||||||
|
version=getString(buffer,HDROFFSET+VERSIONOFFSET,32)
|
||||||
|
return (name,version)
|
||||||
|
|
||||||
def post(source,target,env):
|
def post(source,target,env):
|
||||||
#print(env.Dump())
|
#print(env.Dump())
|
||||||
|
@ -10,6 +38,8 @@ def post(source,target,env):
|
||||||
base=env.subst("$PIOENV")
|
base=env.subst("$PIOENV")
|
||||||
appoffset=env.subst("$ESP32_APP_OFFSET")
|
appoffset=env.subst("$ESP32_APP_OFFSET")
|
||||||
firmware=env.subst("$BUILD_DIR/${PROGNAME}.bin")
|
firmware=env.subst("$BUILD_DIR/${PROGNAME}.bin")
|
||||||
|
(fwname,version)=getFirmwareInfo(firmware)
|
||||||
|
print("found fwname=%s, fwversion=%s"%(fwname,version))
|
||||||
python=env.subst("$PYTHONEXE")
|
python=env.subst("$PYTHONEXE")
|
||||||
print("base=%s,esptool=%s,appoffset=%s,uploaderflags=%s"%(base,esptool,appoffset,uploaderflags))
|
print("base=%s,esptool=%s,appoffset=%s,uploaderflags=%s"%(base,esptool,appoffset,uploaderflags))
|
||||||
uploadparts=uploaderflags.split(" ")
|
uploadparts=uploaderflags.split(" ")
|
||||||
|
@ -23,7 +53,17 @@ def post(source,target,env):
|
||||||
print("file %s for combine not found"%uploadfiles[i])
|
print("file %s for combine not found"%uploadfiles[i])
|
||||||
return
|
return
|
||||||
offset=uploadfiles[0]
|
offset=uploadfiles[0]
|
||||||
outfile=os.path.join(env.subst("$BUILD_DIR"),base+"-all.bin")
|
#cleanup old versioned files
|
||||||
|
outdir=env.subst("$BUILD_DIR")
|
||||||
|
for f in glob.glob(os.path.join(outdir,base+"*.bin")):
|
||||||
|
print("removing old file %s"%f)
|
||||||
|
os.unlink(f)
|
||||||
|
ofversion=''
|
||||||
|
if not version.startswith('dev'):
|
||||||
|
ofversion="-"+version
|
||||||
|
versionedFile=os.path.join(outdir,"%s%s-update.bin"%(base,ofversion))
|
||||||
|
shutil.copyfile(firmware,versionedFile)
|
||||||
|
outfile=os.path.join(outdir,"%s%s-all.bin"%(base,ofversion))
|
||||||
cmd=[python,esptool,"--chip","esp32","merge_bin","--target-offset",offset,"-o",outfile]
|
cmd=[python,esptool,"--chip","esp32","merge_bin","--target-offset",offset,"-o",outfile]
|
||||||
cmd+=uploadfiles
|
cmd+=uploadfiles
|
||||||
cmd+=[appoffset,firmware]
|
cmd+=[appoffset,firmware]
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#ifdef GWRELEASEVERSION
|
#ifdef GWRELEASEVERSION
|
||||||
#define VERSION GWSTRINGIFY(GWRELEASEVERSION)
|
#define VERSION GWSTRINGIFY(GWRELEASEVERSION)
|
||||||
#define LOGLEVEL GwLog::ERROR
|
#define LOGLEVEL GwLog::ERROR
|
||||||
#endif
|
#else
|
||||||
#ifdef GWDEVVERSION
|
#ifdef GWDEVVERSION
|
||||||
#define VERSION GWSTRINGIFY(GWDEVVERSION)
|
#define VERSION GWSTRINGIFY(GWDEVVERSION)
|
||||||
#define LOGLEVEL GwLog::DEBUG
|
#define LOGLEVEL GwLog::DEBUG
|
||||||
|
@ -25,6 +25,7 @@
|
||||||
#define VERSION "0.7.0"
|
#define VERSION "0.7.0"
|
||||||
#define LOGLEVEL GwLog::DEBUG
|
#define LOGLEVEL GwLog::DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// #define GW_MESSAGE_DEBUG_ENABLED
|
// #define GW_MESSAGE_DEBUG_ENABLED
|
||||||
//#define FALLBACK_SERIAL
|
//#define FALLBACK_SERIAL
|
||||||
|
|
Loading…
Reference in New Issue