mirror of
https://github.com/EyeTrackVR/OpenIris.git
synced 2025-11-04 15:39:42 +08:00
feat: merge binaries
This commit is contained in:
parent
275a6d82c4
commit
d8980ae0d4
1
ESP/.gitignore
vendored
1
ESP/.gitignore
vendored
@ -4,3 +4,4 @@ build/
|
|||||||
*.log
|
*.log
|
||||||
/tools/firmware_name.txt
|
/tools/firmware_name.txt
|
||||||
/tools/version.txt
|
/tools/version.txt
|
||||||
|
/tools/_pycache_/
|
||||||
|
|||||||
@ -37,10 +37,44 @@ def createZip(source, target, env):
|
|||||||
file_name = "./build/{0}/{1}.zip".format(
|
file_name = "./build/{0}/{1}.zip".format(
|
||||||
str(env["PIOENV"]), env["PROGNAME"]
|
str(env["PIOENV"]), env["PROGNAME"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
my_flags = env.ParseFlags(env["BUILD_FLAGS"])
|
||||||
|
defines = dict()
|
||||||
|
for x in my_flags.get("CPPDEFINES"):
|
||||||
|
if type(x) is tuple:
|
||||||
|
(k, v) = x
|
||||||
|
defines[k] = v
|
||||||
|
elif type(x) is list:
|
||||||
|
k = x[0]
|
||||||
|
v = x[1]
|
||||||
|
defines[k] = v
|
||||||
|
else:
|
||||||
|
defines[x] = "" # empty value
|
||||||
|
|
||||||
|
# print("Project: %s" % defines)
|
||||||
|
# strip quotes needed for shell escaping
|
||||||
|
s = lambda x: x.replace('"', "")
|
||||||
|
s = lambda x: x.replace("'", "")
|
||||||
|
|
||||||
with ZipFile(file_name, "w") as archive:
|
with ZipFile(file_name, "w") as archive:
|
||||||
print('\nCreating "' + archive.filename + '"', end="\n")
|
print('\nCreating "' + archive.filename + '"', end="\n")
|
||||||
parts = []
|
parts = []
|
||||||
|
|
||||||
|
name = "OpenIris"
|
||||||
|
version = s(defines.get("PIO_SRC_TAG"))
|
||||||
|
new_install_prompt_erase = "true"
|
||||||
|
|
||||||
|
"""
|
||||||
|
python esptool.py --chip ESP32 merge_bin -o merged-firmware.bin --flash_mode dio --flash_freq 40m --flash_size 4MB
|
||||||
|
0x1000 bootloader.bin 0x8000 partitions.bin 0xe000 boot.bin 0x10000 OpenIris-v1.3.0-esp32AIThinker-8229a3a-master.bin
|
||||||
|
"""
|
||||||
|
env.Execute(
|
||||||
|
"$PYTHONEXE $PROJECT_PACKAGES_DIR/tool-esptoolpy/esptool.py --chip ESP32 merge_bin -o merged-firmware.bin --flash_mode dio --flash_freq 40m --flash_size 4MB %s"
|
||||||
|
% (partition.join(" "))
|
||||||
|
)
|
||||||
|
|
||||||
for [offset, path] in partitions:
|
for [offset, path] in partitions:
|
||||||
|
|
||||||
filename = basename(path)
|
filename = basename(path)
|
||||||
archive.write(path, filename)
|
archive.write(path, filename)
|
||||||
partition = {
|
partition = {
|
||||||
@ -48,9 +82,17 @@ def createZip(source, target, env):
|
|||||||
"offset": int(offset, 16),
|
"offset": int(offset, 16),
|
||||||
}
|
}
|
||||||
parts.append(partition)
|
parts.append(partition)
|
||||||
|
|
||||||
manifest = {
|
manifest = {
|
||||||
"chipFamily": "ESP32",
|
"builds": [
|
||||||
"parts": parts,
|
{
|
||||||
|
"name": name,
|
||||||
|
"version": version,
|
||||||
|
"new_install_prompt_erase": new_install_prompt_erase,
|
||||||
|
"chipFamily": "ESP32",
|
||||||
|
"parts": parts,
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
archive.writestr("manifest.json", json.dumps(manifest))
|
archive.writestr("manifest.json", json.dumps(manifest))
|
||||||
sys.stdout.write(RESET)
|
sys.stdout.write(RESET)
|
||||||
@ -63,4 +105,5 @@ def createZip(source, target, env):
|
|||||||
print("CI build not detected, skipping zip creation")
|
print("CI build not detected, skipping zip creation")
|
||||||
sys.stdout.write(RESET)
|
sys.stdout.write(RESET)
|
||||||
|
|
||||||
|
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", createZip)
|
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", createZip)
|
||||||
|
|||||||
@ -78,8 +78,6 @@ def handleGit():
|
|||||||
|
|
||||||
|
|
||||||
def customName(project, version, commit, branch):
|
def customName(project, version, commit, branch):
|
||||||
# Dump global construction environment (for debug purpose)
|
|
||||||
# print(env.Dump())
|
|
||||||
|
|
||||||
my_flags = env.ParseFlags(env["BUILD_FLAGS"])
|
my_flags = env.ParseFlags(env["BUILD_FLAGS"])
|
||||||
defines = dict()
|
defines = dict()
|
||||||
@ -133,6 +131,12 @@ def customName(project, version, commit, branch):
|
|||||||
try:
|
try:
|
||||||
flags = env["BUILD_FLAGS"]
|
flags = env["BUILD_FLAGS"]
|
||||||
my_flags = env.ParseFlags(flags)
|
my_flags = env.ParseFlags(flags)
|
||||||
|
|
||||||
|
# Dump global construction environment (for debug purpose)
|
||||||
|
# write env.Dump() to a file
|
||||||
|
#with open("env_dump.txt", "w") as f:
|
||||||
|
# f.write(env.Dump())
|
||||||
|
|
||||||
handleGit()
|
handleGit()
|
||||||
except ValueError as ex:
|
except ValueError as ex:
|
||||||
# look for apostrophes and warn the user
|
# look for apostrophes and warn the user
|
||||||
@ -140,4 +144,7 @@ except ValueError as ex:
|
|||||||
print(
|
print(
|
||||||
"[Warning]: Apostrophes are not allowed in the build flags. Please remove them from the \033[;1m\033[1;36m`user-config.ini` \033[1;31mfile and try again."
|
"[Warning]: Apostrophes are not allowed in the build flags. Please remove them from the \033[;1m\033[1;36m`user-config.ini` \033[1;31mfile and try again."
|
||||||
)
|
)
|
||||||
raise Exception("Could not parse BUILD_FLAGS - Possible apostrophy used in user configuration", ex)
|
raise Exception(
|
||||||
|
"Could not parse BUILD_FLAGS - Possible apostrophy used in user configuration",
|
||||||
|
ex,
|
||||||
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user