-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathupdate_fw.py
50 lines (32 loc) · 1.07 KB
/
update_fw.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Copyright (c) 2021 Alethea Katherine Flowers.
# Published under the standard MIT License.
# Full text available at: https://opensource.org/licenses/MIT
"""Update firmware on programmed C&P boards"""
import pathlib
import sys
import time
from wintertools import fs, git, tui
from libgemini import gemini
def _check_firmware_version(gem):
latest_release = git.latest_tag()
build_id = gem.get_firmware_version()
print(f"Firmware build ID: {build_id}")
if latest_release in build_id:
return True
else:
return False
def _update_firmware(gem):
print("Updating firmware..")
gem.reset_into_bootloader()
path = pathlib.Path(fs.wait_for_drive("GEMINIBOOT", timeout=60 * 5))
fs.copyfile("../firmware/build/gemini-firmware.uf2", path / "firmware.uf2")
fs.flush(path)
time.sleep(3)
print("[green]Firmware updated![/]")
build_id = gem.get_firmware_version()
print(f"Firmware build ID: {build_id}")
def main(stats=False):
gem = gemini.Gemini.get()
_update_firmware(gem)
if __name__ == "__main__":
main()