Skip to content

Commit

Permalink
Export factory binaries (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
jesserockz authored Mar 24, 2022
1 parent 4797897 commit 9b29196
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,55 +65,36 @@
data = json.loads(idedata.decode("utf-8"))

elf = Path(data["prog_path"])
bin = elf.with_suffix(".bin")
bin = elf.with_name("firmware-factory.bin")
print("::endgroup::")

print("::group::Copy firmware file(s) to folder")
file_base.mkdir(parents=True, exist_ok=True)
shutil.chown(file_base, GH_RUNNER_USER_UID, GH_RUNNER_USER_GID)

shutil.copyfile(bin, file_base / "firmware.bin")
shutil.copyfile(bin, file_base / f"{name}.bin")
shutil.chown(file_base / "firmware.bin", GH_RUNNER_USER_UID, GH_RUNNER_USER_GID)

extras = data["extra"]["flash_images"]

chip_family = None
esp32 = False
define: str
for define in data["defines"]:
if define == "USE_ESP8266":
chip_family = "ESP8266"
break
elif m := re.match(r"USE_ESP32_VARIANT_(\w+)", define):
chip_family = m.group(1)
esp32 = True
break

firmware_offset = 0x10000 if esp32 else 0x0

manifest = {
"chipFamily": chip_family,
"parts": [
{
"path": str(file_base / "firmware.bin"),
"offset": firmware_offset,
"path": str(file_base / f"{name}.bin"),
"offset": 0x00,
}
],
}

for extra in extras:
extra_bin = extra["path"]
new_path = file_base / Path(extra_bin).name
shutil.copyfile(extra_bin, new_path)
shutil.chown(new_path, GH_RUNNER_USER_UID, GH_RUNNER_USER_GID)

print(f"Copied {new_path}")
manifest["parts"].append(
{
"path": str(new_path),
"offset": int(extra["offset"], 16),
}
)
print("::endgroup::")

print("::group::Write manifest.json file")
Expand Down

0 comments on commit 9b29196

Please sign in to comment.