Added console image flashing to rnodeconf

This commit is contained in:
Mark Qvist 2023-01-11 13:56:41 +01:00
parent 32922868b9
commit 63d54dbecb

View File

@ -898,7 +898,7 @@ def ensure_firmware_file(fw_filename):
RNS.log("No release hash found for "+fw_filename+". The firmware integrity could not be verified.") RNS.log("No release hash found for "+fw_filename+". The firmware integrity could not be verified.")
exit(97) exit(97)
RNS.log("Veryfying firmware integrity...") RNS.log("Verifying firmware integrity...")
fw_file = open(UPD_DIR+"/"+selected_version+"/"+fw_filename, "rb") fw_file = open(UPD_DIR+"/"+selected_version+"/"+fw_filename, "rb")
expected_hash = bytes.fromhex(selected_hash) expected_hash = bytes.fromhex(selected_hash)
file_hash = hashlib.sha256(fw_file.read()).hexdigest() file_hash = hashlib.sha256(fw_file.read()).hexdigest()
@ -1670,9 +1670,29 @@ def main():
RNS.log("Please install \""+flasher+"\" and try again.") RNS.log("Please install \""+flasher+"\" and try again.")
exit() exit()
elif platform == ROM.PLATFORM_ESP32: elif platform == ROM.PLATFORM_ESP32:
numeric_version = float(selected_version)
flasher = UPD_DIR+"/"+selected_version+"/esptool.py" flasher = UPD_DIR+"/"+selected_version+"/esptool.py"
if which(flasher) is not None: if which(flasher) is not None:
if fw_filename == "rnode_firmware_tbeam.zip": if fw_filename == "rnode_firmware_tbeam.zip":
if numeric_version >= 1.55:
return [
flasher,
"--chip", "esp32",
"--port", args.port,
"--baud", "921600",
"--before", "default_reset",
"--after", "hard_reset",
"write_flash", "-z",
"--flash_mode", "dio",
"--flash_freq", "80m",
"--flash_size", "4MB",
"0xe000", UPD_DIR+"/"+selected_version+"/rnode_firmware_tbeam.boot_app0",
"0x1000", UPD_DIR+"/"+selected_version+"/rnode_firmware_tbeam.bootloader",
"0x10000", UPD_DIR+"/"+selected_version+"/rnode_firmware_tbeam.bin",
"0x210000",UPD_DIR+"/"+selected_version+"/spiffs.bin",
"0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_tbeam.partitions",
]
else:
return [ return [
flasher, flasher,
"--chip", "esp32", "--chip", "esp32",
@ -1690,6 +1710,25 @@ def main():
"0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_tbeam.partitions", "0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_tbeam.partitions",
] ]
elif fw_filename == "rnode_firmware_lora32v20.zip": elif fw_filename == "rnode_firmware_lora32v20.zip":
if numeric_version >= 1.55:
return [
flasher,
"--chip", "esp32",
"--port", args.port,
"--baud", "921600",
"--before", "default_reset",
"--after", "hard_reset",
"write_flash", "-z",
"--flash_mode", "dio",
"--flash_freq", "80m",
"--flash_size", "4MB",
"0xe000", UPD_DIR+"/"+selected_version+"/rnode_firmware_lora32v20.boot_app0",
"0x1000", UPD_DIR+"/"+selected_version+"/rnode_firmware_lora32v20.bootloader",
"0x10000", UPD_DIR+"/"+selected_version+"/rnode_firmware_lora32v20.bin",
"0x210000",UPD_DIR+"/"+selected_version+"/spiffs.bin",
"0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_lora32v20.partitions",
]
else:
return [ return [
flasher, flasher,
"--chip", "esp32", "--chip", "esp32",
@ -1707,6 +1746,25 @@ def main():
"0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_lora32v20.partitions", "0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_lora32v20.partitions",
] ]
elif fw_filename == "rnode_firmware_lora32v21.zip": elif fw_filename == "rnode_firmware_lora32v21.zip":
if numeric_version >= 1.55:
return [
flasher,
"--chip", "esp32",
"--port", args.port,
"--baud", "921600",
"--before", "default_reset",
"--after", "hard_reset",
"write_flash", "-z",
"--flash_mode", "dio",
"--flash_freq", "80m",
"--flash_size", "4MB",
"0xe000", UPD_DIR+"/"+selected_version+"/rnode_firmware_lora32v21.boot_app0",
"0x1000", UPD_DIR+"/"+selected_version+"/rnode_firmware_lora32v21.bootloader",
"0x10000", UPD_DIR+"/"+selected_version+"/rnode_firmware_lora32v21.bin",
"0x210000",UPD_DIR+"/"+selected_version+"/spiffs.bin",
"0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_lora32v21.partitions",
]
else:
return [ return [
flasher, flasher,
"--chip", "esp32", "--chip", "esp32",
@ -1724,6 +1782,25 @@ def main():
"0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_lora32v21.partitions", "0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_lora32v21.partitions",
] ]
elif fw_filename == "rnode_firmware_heltec32v2.zip": elif fw_filename == "rnode_firmware_heltec32v2.zip":
if numeric_version >= 1.55:
return [
flasher,
"--chip", "esp32",
"--port", args.port,
"--baud", "921600",
"--before", "default_reset",
"--after", "hard_reset",
"write_flash", "-z",
"--flash_mode", "dio",
"--flash_freq", "80m",
"--flash_size", "8MB",
"0xe000", UPD_DIR+"/"+selected_version+"/rnode_firmware_heltec32v2.boot_app0",
"0x1000", UPD_DIR+"/"+selected_version+"/rnode_firmware_heltec32v2.bootloader",
"0x10000", UPD_DIR+"/"+selected_version+"/rnode_firmware_heltec32v2.bin",
"0x210000",UPD_DIR+"/"+selected_version+"/spiffs.bin",
"0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_heltec32v2.partitions",
]
else:
return [ return [
flasher, flasher,
"--chip", "esp32", "--chip", "esp32",
@ -1741,6 +1818,25 @@ def main():
"0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_heltec32v2.partitions", "0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_heltec32v2.partitions",
] ]
elif fw_filename == "rnode_firmware_featheresp32.zip": elif fw_filename == "rnode_firmware_featheresp32.zip":
if numeric_version >= 1.55:
return [
flasher,
"--chip", "esp32",
"--port", args.port,
"--baud", "921600",
"--before", "default_reset",
"--after", "hard_reset",
"write_flash", "-z",
"--flash_mode", "dio",
"--flash_freq", "80m",
"--flash_size", "4MB",
"0xe000", UPD_DIR+"/"+selected_version+"/rnode_firmware_featheresp32.boot_app0",
"0x1000", UPD_DIR+"/"+selected_version+"/rnode_firmware_featheresp32.bootloader",
"0x10000", UPD_DIR+"/"+selected_version+"/rnode_firmware_featheresp32.bin",
"0x210000",UPD_DIR+"/"+selected_version+"/spiffs.bin",
"0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_featheresp32.partitions",
]
else:
return [ return [
flasher, flasher,
"--chip", "esp32", "--chip", "esp32",
@ -1758,6 +1854,25 @@ def main():
"0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_featheresp32.partitions", "0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_featheresp32.partitions",
] ]
elif fw_filename == "rnode_firmware_esp32_generic.zip": elif fw_filename == "rnode_firmware_esp32_generic.zip":
if numeric_version >= 1.55:
return [
flasher,
"--chip", "esp32",
"--port", args.port,
"--baud", "921600",
"--before", "default_reset",
"--after", "hard_reset",
"write_flash", "-z",
"--flash_mode", "dio",
"--flash_freq", "80m",
"--flash_size", "4MB",
"0xe000", UPD_DIR+"/"+selected_version+"/rnode_firmware_esp32_generic.boot_app0",
"0x1000", UPD_DIR+"/"+selected_version+"/rnode_firmware_esp32_generic.bootloader",
"0x10000", UPD_DIR+"/"+selected_version+"/rnode_firmware_esp32_generic.bin",
"0x210000",UPD_DIR+"/"+selected_version+"/spiffs.bin",
"0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_esp32_generic.partitions",
]
else:
return [ return [
flasher, flasher,
"--chip", "esp32", "--chip", "esp32",
@ -1775,6 +1890,25 @@ def main():
"0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_esp32_generic.partitions", "0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_esp32_generic.partitions",
] ]
elif fw_filename == "rnode_firmware_ng20.zip": elif fw_filename == "rnode_firmware_ng20.zip":
if numeric_version >= 1.55:
return [
flasher,
"--chip", "esp32",
"--port", args.port,
"--baud", "921600",
"--before", "default_reset",
"--after", "hard_reset",
"write_flash", "-z",
"--flash_mode", "dio",
"--flash_freq", "80m",
"--flash_size", "4MB",
"0xe000", UPD_DIR+"/"+selected_version+"/rnode_firmware_ng20.boot_app0",
"0x1000", UPD_DIR+"/"+selected_version+"/rnode_firmware_ng20.bootloader",
"0x10000", UPD_DIR+"/"+selected_version+"/rnode_firmware_ng20.bin",
"0x210000",UPD_DIR+"/"+selected_version+"/spiffs.bin",
"0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_ng20.partitions",
]
else:
return [ return [
flasher, flasher,
"--chip", "esp32", "--chip", "esp32",
@ -1792,6 +1926,25 @@ def main():
"0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_ng20.partitions", "0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_ng20.partitions",
] ]
elif fw_filename == "rnode_firmware_ng21.zip": elif fw_filename == "rnode_firmware_ng21.zip":
if numeric_version >= 1.55:
return [
flasher,
"--chip", "esp32",
"--port", args.port,
"--baud", "921600",
"--before", "default_reset",
"--after", "hard_reset",
"write_flash", "-z",
"--flash_mode", "dio",
"--flash_freq", "80m",
"--flash_size", "4MB",
"0xe000", UPD_DIR+"/"+selected_version+"/rnode_firmware_ng21.boot_app0",
"0x1000", UPD_DIR+"/"+selected_version+"/rnode_firmware_ng21.bootloader",
"0x10000", UPD_DIR+"/"+selected_version+"/rnode_firmware_ng21.bin",
"0x210000",UPD_DIR+"/"+selected_version+"/spiffs.bin",
"0x8000", UPD_DIR+"/"+selected_version+"/rnode_firmware_ng21.partitions",
]
else:
return [ return [
flasher, flasher,
"--chip", "esp32", "--chip", "esp32",
@ -1932,8 +2085,10 @@ def main():
try: try:
RNS.log("Checking firmware file availability...") RNS.log("Checking firmware file availability...")
fw_file_ensured = False
if selected_version == None: if selected_version == None:
ensure_firmware_file(fw_filename) ensure_firmware_file(fw_filename)
fw_file_ensured = True
if not force_update: if not force_update:
if rnode.version == selected_version: if rnode.version == selected_version:
@ -1956,7 +2111,7 @@ def main():
RNS.log("Override with -U option to install anyway") RNS.log("Override with -U option to install anyway")
exit(0) exit(0)
if selected_version != None: if not fw_file_ensured and selected_version != None:
ensure_firmware_file(fw_filename) ensure_firmware_file(fw_filename)
if fw_filename.endswith(".zip"): if fw_filename.endswith(".zip"):