mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-26 23:40:18 +00:00
Compare commits
4 Commits
1cbf32aac1
...
9685726644
Author | SHA1 | Date | |
---|---|---|---|
|
9685726644 | ||
|
b81b1de4eb | ||
|
3551662187 | ||
|
f7f34e0ea3 |
@ -283,7 +283,7 @@ except Exception as e:
|
|||||||
print("No access to directory "+str(CNF_DIR)+". This utility needs file system access to store firmware and data files. Cannot continue.")
|
print("No access to directory "+str(CNF_DIR)+". This utility needs file system access to store firmware and data files. Cannot continue.")
|
||||||
print("The contained exception was:")
|
print("The contained exception was:")
|
||||||
print(str(e))
|
print(str(e))
|
||||||
exit(99)
|
graceful_exit(99)
|
||||||
|
|
||||||
squashvw = False
|
squashvw = False
|
||||||
|
|
||||||
@ -575,7 +575,7 @@ class RNode():
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise e
|
raise e
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
def updateBitrate(self):
|
def updateBitrate(self):
|
||||||
try:
|
try:
|
||||||
@ -601,6 +601,7 @@ class RNode():
|
|||||||
written = self.serial.write(kiss_command)
|
written = self.serial.write(kiss_command)
|
||||||
if written != len(kiss_command):
|
if written != len(kiss_command):
|
||||||
raise IOError("An IO error occurred while sending host left command to device")
|
raise IOError("An IO error occurred while sending host left command to device")
|
||||||
|
sleep(1)
|
||||||
|
|
||||||
def set_display_intensity(self, intensity):
|
def set_display_intensity(self, intensity):
|
||||||
data = bytes([intensity & 0xFF])
|
data = bytes([intensity & 0xFF])
|
||||||
@ -764,7 +765,7 @@ class RNode():
|
|||||||
sleep(0.6)
|
sleep(0.6)
|
||||||
if self.eeprom == None:
|
if self.eeprom == None:
|
||||||
RNS.log("Could not download EEPROM from device. Is a valid firmware installed?")
|
RNS.log("Could not download EEPROM from device. Is a valid firmware installed?")
|
||||||
exit()
|
graceful_exit()
|
||||||
else:
|
else:
|
||||||
self.parse_eeprom()
|
self.parse_eeprom()
|
||||||
|
|
||||||
@ -810,7 +811,7 @@ class RNode():
|
|||||||
if self.checksum != checksum:
|
if self.checksum != checksum:
|
||||||
self.provisioned = False
|
self.provisioned = False
|
||||||
RNS.log("EEPROM checksum mismatch")
|
RNS.log("EEPROM checksum mismatch")
|
||||||
exit()
|
graceful_exit()
|
||||||
else:
|
else:
|
||||||
RNS.log("EEPROM checksum correct")
|
RNS.log("EEPROM checksum correct")
|
||||||
|
|
||||||
@ -991,7 +992,7 @@ def ensure_firmware_file(fw_filename):
|
|||||||
RNS.log("One or more required firmware files are missing from the extracted RNode")
|
RNS.log("One or more required firmware files are missing from the extracted RNode")
|
||||||
RNS.log("Firmware archive. Installation cannot continue. Please try extracting the")
|
RNS.log("Firmware archive. Installation cannot continue. Please try extracting the")
|
||||||
RNS.log("firmware again with the --extract-firmware option.")
|
RNS.log("firmware again with the --extract-firmware option.")
|
||||||
exit(184)
|
graceful_exit(184)
|
||||||
|
|
||||||
vf = open(vfpath, "rb")
|
vf = open(vfpath, "rb")
|
||||||
release_info = vf.read().decode("utf-8").strip()
|
release_info = vf.read().decode("utf-8").strip()
|
||||||
@ -1001,7 +1002,7 @@ def ensure_firmware_file(fw_filename):
|
|||||||
else:
|
else:
|
||||||
RNS.log("No extracted firmware is available, cannot continue.")
|
RNS.log("No extracted firmware is available, cannot continue.")
|
||||||
RNS.log("Extract a firmware from an existing RNode first, using the --extract-firmware option.")
|
RNS.log("Extract a firmware from an existing RNode first, using the --extract-firmware option.")
|
||||||
exit(183)
|
graceful_exit(183)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
@ -1035,7 +1036,7 @@ def ensure_firmware_file(fw_filename):
|
|||||||
RNS.log("Check your internet connection and try again.")
|
RNS.log("Check your internet connection and try again.")
|
||||||
RNS.log("If you don't have Internet access currently, use the --fw-version option to manually specify a version.")
|
RNS.log("If you don't have Internet access currently, use the --fw-version option to manually specify a version.")
|
||||||
RNS.log("You can also use --extract to copy the firmware from a known-good RNode of the same model.")
|
RNS.log("You can also use --extract to copy the firmware from a known-good RNode of the same model.")
|
||||||
exit()
|
graceful_exit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# if custom firmware url, don't fallback
|
# if custom firmware url, don't fallback
|
||||||
if fw_url != None:
|
if fw_url != None:
|
||||||
@ -1043,7 +1044,7 @@ def ensure_firmware_file(fw_filename):
|
|||||||
RNS.log("Check your internet connection and try again.")
|
RNS.log("Check your internet connection and try again.")
|
||||||
RNS.log("If you don't have Internet access currently, use the --fw-version option to manually specify a version.")
|
RNS.log("If you don't have Internet access currently, use the --fw-version option to manually specify a version.")
|
||||||
RNS.log("You can also use --extract to copy the firmware from a known-good RNode of the same model.")
|
RNS.log("You can also use --extract to copy the firmware from a known-good RNode of the same model.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
RNS.log("")
|
RNS.log("")
|
||||||
RNS.log("WARNING!")
|
RNS.log("WARNING!")
|
||||||
@ -1072,7 +1073,7 @@ def ensure_firmware_file(fw_filename):
|
|||||||
selected_version = release_info.split()[0]
|
selected_version = release_info.split()[0]
|
||||||
if selected_version == "not":
|
if selected_version == "not":
|
||||||
RNS.log("No valid version found for this board, exiting.")
|
RNS.log("No valid version found for this board, exiting.")
|
||||||
exit(199)
|
graceful_exit(199)
|
||||||
|
|
||||||
selected_hash = release_info.split()[1]
|
selected_hash = release_info.split()[1]
|
||||||
if not os.path.isdir(UPD_DIR+"/"+selected_version):
|
if not os.path.isdir(UPD_DIR+"/"+selected_version):
|
||||||
@ -1083,7 +1084,7 @@ def ensure_firmware_file(fw_filename):
|
|||||||
else:
|
else:
|
||||||
RNS.log("Online firmware version check was disabled, but no firmware version specified for install.")
|
RNS.log("Online firmware version check was disabled, but no firmware version specified for install.")
|
||||||
RNS.log("use the --fw-version option to manually specify a version.")
|
RNS.log("use the --fw-version option to manually specify a version.")
|
||||||
exit(98)
|
graceful_exit(98)
|
||||||
|
|
||||||
# if custom firmware url, use it
|
# if custom firmware url, use it
|
||||||
if fw_url != None:
|
if fw_url != None:
|
||||||
@ -1117,7 +1118,7 @@ def ensure_firmware_file(fw_filename):
|
|||||||
|
|
||||||
if selected_hash == None:
|
if selected_hash == None:
|
||||||
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)
|
graceful_exit(97)
|
||||||
|
|
||||||
RNS.log("Verifying 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")
|
||||||
@ -1128,24 +1129,24 @@ def ensure_firmware_file(fw_filename):
|
|||||||
else:
|
else:
|
||||||
RNS.log("")
|
RNS.log("")
|
||||||
RNS.log("Firmware corrupt. Try clearing the local firmware cache with: rnodeconf --clear-cache")
|
RNS.log("Firmware corrupt. Try clearing the local firmware cache with: rnodeconf --clear-cache")
|
||||||
exit(96)
|
graceful_exit(96)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("An error occurred while checking firmware file integrity. The contained exception was:")
|
RNS.log("An error occurred while checking firmware file integrity. The contained exception was:")
|
||||||
RNS.log(str(e))
|
RNS.log(str(e))
|
||||||
exit(95)
|
graceful_exit(95)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Could not download required firmware file: ")
|
RNS.log("Could not download required firmware file: ")
|
||||||
RNS.log(str(update_target_url))
|
RNS.log(str(update_target_url))
|
||||||
RNS.log("The contained exception was:")
|
RNS.log("The contained exception was:")
|
||||||
RNS.log(str(e))
|
RNS.log(str(e))
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("An error occurred while reading version information for "+str(fw_filename)+". The contained exception was:")
|
RNS.log("An error occurred while reading version information for "+str(fw_filename)+". The contained exception was:")
|
||||||
RNS.log(str(e))
|
RNS.log(str(e))
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
def rnode_open_serial(port):
|
def rnode_open_serial(port):
|
||||||
import serial
|
import serial
|
||||||
@ -1163,6 +1164,21 @@ def rnode_open_serial(port):
|
|||||||
dsrdtr = False
|
dsrdtr = False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def graceful_exit(C=0):
|
||||||
|
if RNS.vendor.platformutils.is_windows():
|
||||||
|
RNS.log("Windows detected; delaying DTR",RNS.LOG_VERBOSE)
|
||||||
|
if rnode:
|
||||||
|
RNS.log("Sending \"Leave\" to Rnode",RNS.LOG_VERBOSE)
|
||||||
|
rnode.leave() # Leave has wait built in
|
||||||
|
elif rnode_serial:
|
||||||
|
RNS.log("Closing raw serial",RNS.LOG_VERBOSE)
|
||||||
|
sleep(1) # Wait for MCU to complete operation before DTR goes false
|
||||||
|
rnode_serial.close()
|
||||||
|
RNS.log("Exiting: Code "+str(C),RNS.LOG_INFO)
|
||||||
|
exit(C)
|
||||||
|
|
||||||
|
|
||||||
device_signer = None
|
device_signer = None
|
||||||
force_update = False
|
force_update = False
|
||||||
upd_nocheck = False
|
upd_nocheck = False
|
||||||
@ -1177,7 +1193,7 @@ def main():
|
|||||||
print("RNode Config Utility needs pyserial to work.")
|
print("RNode Config Utility needs pyserial to work.")
|
||||||
print("You can install it with: pip3 install pyserial")
|
print("You can install it with: pip3 install pyserial")
|
||||||
print("")
|
print("")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not util.find_spec("cryptography"):
|
if not util.find_spec("cryptography"):
|
||||||
@ -1187,7 +1203,7 @@ def main():
|
|||||||
print("RNode Config Utility needs the cryptography module to work.")
|
print("RNode Config Utility needs the cryptography module to work.")
|
||||||
print("You can install it with: pip3 install cryptography")
|
print("You can install it with: pip3 install cryptography")
|
||||||
print("")
|
print("")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
import serial
|
import serial
|
||||||
from serial.tools import list_ports
|
from serial.tools import list_ports
|
||||||
@ -1257,14 +1273,14 @@ def main():
|
|||||||
|
|
||||||
if args.version:
|
if args.version:
|
||||||
print("rnodeconf "+program_version)
|
print("rnodeconf "+program_version)
|
||||||
exit(0)
|
graceful_exit(0)
|
||||||
|
|
||||||
if args.clear_cache:
|
if args.clear_cache:
|
||||||
RNS.log("Clearing local firmware cache...")
|
RNS.log("Clearing local firmware cache...")
|
||||||
import shutil
|
import shutil
|
||||||
shutil.rmtree(UPD_DIR)
|
shutil.rmtree(UPD_DIR)
|
||||||
RNS.log("Done")
|
RNS.log("Done")
|
||||||
exit(0)
|
graceful_exit(0)
|
||||||
|
|
||||||
if args.fw_version != None:
|
if args.fw_version != None:
|
||||||
selected_version = args.fw_version
|
selected_version = args.fw_version
|
||||||
@ -1272,7 +1288,7 @@ def main():
|
|||||||
check_float = float(selected_version)
|
check_float = float(selected_version)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
RNS.log("Selected version \""+selected_version+"\" does not appear to be a number.")
|
RNS.log("Selected version \""+selected_version+"\" does not appear to be a number.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
if args.fw_url != None:
|
if args.fw_url != None:
|
||||||
fw_url = args.fw_url
|
fw_url = args.fw_url
|
||||||
@ -1311,7 +1327,7 @@ def main():
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Invalid key data supplied")
|
RNS.log("Invalid key data supplied")
|
||||||
exit(0)
|
graceful_exit(0)
|
||||||
|
|
||||||
if args.use_extracted and ((args.update and args.port != None) or args.autoinstall):
|
if args.use_extracted and ((args.update and args.port != None) or args.autoinstall):
|
||||||
print("")
|
print("")
|
||||||
@ -1350,11 +1366,11 @@ def main():
|
|||||||
selected_port = portlist[c_port-1]
|
selected_port = portlist[c_port-1]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("That port does not exist, exiting now.")
|
print("That port does not exist, exiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
if selected_port == None:
|
if selected_port == None:
|
||||||
print("Could not select port, exiting now.")
|
print("Could not select port, exiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
port_path = selected_port.device
|
port_path = selected_port.device
|
||||||
port_product = selected_port.product
|
port_product = selected_port.product
|
||||||
@ -1371,7 +1387,7 @@ def main():
|
|||||||
|
|
||||||
if selected_port == None:
|
if selected_port == None:
|
||||||
print("Could not find specified port "+str(args.port)+", exiting now")
|
print("Could not find specified port "+str(args.port)+", exiting now")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
port_path = selected_port.device
|
port_path = selected_port.device
|
||||||
port_product = selected_port.product
|
port_product = selected_port.product
|
||||||
@ -1386,7 +1402,7 @@ def main():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Could not open the specified serial port. The contained exception was:")
|
RNS.log("Could not open the specified serial port. The contained exception was:")
|
||||||
RNS.log(str(e))
|
RNS.log(str(e))
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
rnode = RNode(rnode_serial)
|
rnode = RNode(rnode_serial)
|
||||||
thread = threading.Thread(target=rnode.readLoop, daemon=True).start()
|
thread = threading.Thread(target=rnode.readLoop, daemon=True).start()
|
||||||
@ -1439,16 +1455,16 @@ def main():
|
|||||||
print("Extracting "+part+"...")
|
print("Extracting "+part+"...")
|
||||||
if subprocess.call(shlex.split(command), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) != 0:
|
if subprocess.call(shlex.split(command), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) != 0:
|
||||||
print("The extraction failed, the following command did not complete successfully:\n"+command)
|
print("The extraction failed, the following command did not complete successfully:\n"+command)
|
||||||
exit(182)
|
graceful_exit(182)
|
||||||
|
|
||||||
print("\nFirmware successfully extracted!")
|
print("\nFirmware successfully extracted!")
|
||||||
print("\nYou can now use this firmware to update or autoinstall other RNodes")
|
print("\nYou can now use this firmware to update or autoinstall other RNodes")
|
||||||
exit()
|
graceful_exit()
|
||||||
else:
|
else:
|
||||||
print("Could not read firmware information from device")
|
print("Could not read firmware information from device")
|
||||||
|
|
||||||
print("\nRNode firmware extraction failed")
|
print("\nRNode firmware extraction failed")
|
||||||
exit(180)
|
graceful_exit(180)
|
||||||
|
|
||||||
if args.autoinstall:
|
if args.autoinstall:
|
||||||
clear()
|
clear()
|
||||||
@ -1482,11 +1498,11 @@ def main():
|
|||||||
selected_port = portlist[c_port-1]
|
selected_port = portlist[c_port-1]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("That port does not exist, exiting now.")
|
print("That port does not exist, exiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
if selected_port == None:
|
if selected_port == None:
|
||||||
print("Could not select port, exiting now.")
|
print("Could not select port, exiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
port_path = selected_port.device
|
port_path = selected_port.device
|
||||||
port_product = selected_port.product
|
port_product = selected_port.product
|
||||||
@ -1504,7 +1520,7 @@ def main():
|
|||||||
|
|
||||||
if selected_port == None:
|
if selected_port == None:
|
||||||
print("Could not find specified port "+str(args.port)+", exiting now")
|
print("Could not find specified port "+str(args.port)+", exiting now")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
port_path = selected_port.device
|
port_path = selected_port.device
|
||||||
port_product = selected_port.product
|
port_product = selected_port.product
|
||||||
@ -1519,7 +1535,7 @@ def main():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Could not open the specified serial port. The contained exception was:")
|
RNS.log("Could not open the specified serial port. The contained exception was:")
|
||||||
RNS.log(str(e))
|
RNS.log(str(e))
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
rnode = RNode(rnode_serial)
|
rnode = RNode(rnode_serial)
|
||||||
thread = threading.Thread(target=rnode.readLoop, daemon=True).start()
|
thread = threading.Thread(target=rnode.readLoop, daemon=True).start()
|
||||||
@ -1536,7 +1552,7 @@ def main():
|
|||||||
print("\nThis device is already installed and provisioned. No further action will")
|
print("\nThis device is already installed and provisioned. No further action will")
|
||||||
print("be taken. If you wish to completely reinstall this device, you must first")
|
print("be taken. If you wish to completely reinstall this device, you must first")
|
||||||
print("wipe the current EEPROM. See the help for more info.\n\nExiting now.")
|
print("wipe the current EEPROM. See the help for more info.\n\nExiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
print("\n---------------------------------------------------------------------------")
|
print("\n---------------------------------------------------------------------------")
|
||||||
print(" Device Selection")
|
print(" Device Selection")
|
||||||
@ -1712,7 +1728,7 @@ def main():
|
|||||||
input()
|
input()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("That device type does not exist, exiting now.")
|
print("That device type does not exist, exiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
selected_platform = None
|
selected_platform = None
|
||||||
selected_model = None
|
selected_model = None
|
||||||
@ -1741,7 +1757,7 @@ def main():
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("That MCU type does not exist, exiting now.")
|
print("That MCU type does not exist, exiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
print("\nWhat transceiver module does your board use?\n")
|
print("\nWhat transceiver module does your board use?\n")
|
||||||
print("[1] SX1276/SX1278 with antenna port on PA_BOOST pin")
|
print("[1] SX1276/SX1278 with antenna port on PA_BOOST pin")
|
||||||
@ -1758,7 +1774,7 @@ def main():
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("That transceiver type does not exist, exiting now.")
|
print("That transceiver type does not exist, exiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
|
|
||||||
elif selected_product == ROM.PRODUCT_RNODE:
|
elif selected_product == ROM.PRODUCT_RNODE:
|
||||||
@ -1810,7 +1826,7 @@ def main():
|
|||||||
# selected_platform = ROM.PLATFORM_ESP32
|
# selected_platform = ROM.PLATFORM_ESP32
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("That model does not exist, exiting now.")
|
print("That model does not exist, exiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
else:
|
else:
|
||||||
print("\nWhat model is this T3S3?\n")
|
print("\nWhat model is this T3S3?\n")
|
||||||
print("[1] 410 - 525 MHz (with SX1268 chip)")
|
print("[1] 410 - 525 MHz (with SX1268 chip)")
|
||||||
@ -1830,7 +1846,7 @@ def main():
|
|||||||
selected_platform = ROM.PLATFORM_ESP32
|
selected_platform = ROM.PLATFORM_ESP32
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("That model does not exist, exiting now.")
|
print("That model does not exist, exiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
elif selected_product == ROM.PRODUCT_TBEAM:
|
elif selected_product == ROM.PRODUCT_TBEAM:
|
||||||
selected_mcu = ROM.MCU_ESP32
|
selected_mcu = ROM.MCU_ESP32
|
||||||
@ -1859,7 +1875,7 @@ def main():
|
|||||||
selected_platform = ROM.PLATFORM_ESP32
|
selected_platform = ROM.PLATFORM_ESP32
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("That band does not exist, exiting now.")
|
print("That band does not exist, exiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
elif selected_product == ROM.PRODUCT_T32_10:
|
elif selected_product == ROM.PRODUCT_T32_10:
|
||||||
selected_mcu = ROM.MCU_ESP32
|
selected_mcu = ROM.MCU_ESP32
|
||||||
@ -1881,7 +1897,7 @@ def main():
|
|||||||
selected_platform = ROM.PLATFORM_ESP32
|
selected_platform = ROM.PLATFORM_ESP32
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("That band does not exist, exiting now.")
|
print("That band does not exist, exiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
elif selected_product == ROM.PRODUCT_T32_20:
|
elif selected_product == ROM.PRODUCT_T32_20:
|
||||||
selected_mcu = ROM.MCU_ESP32
|
selected_mcu = ROM.MCU_ESP32
|
||||||
@ -1903,7 +1919,7 @@ def main():
|
|||||||
selected_platform = ROM.PLATFORM_ESP32
|
selected_platform = ROM.PLATFORM_ESP32
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("That band does not exist, exiting now.")
|
print("That band does not exist, exiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
elif selected_product == ROM.PRODUCT_T32_21:
|
elif selected_product == ROM.PRODUCT_T32_21:
|
||||||
selected_mcu = ROM.MCU_ESP32
|
selected_mcu = ROM.MCU_ESP32
|
||||||
@ -1931,7 +1947,7 @@ def main():
|
|||||||
selected_platform = ROM.PLATFORM_ESP32
|
selected_platform = ROM.PLATFORM_ESP32
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("That band does not exist, exiting now.")
|
print("That band does not exist, exiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
elif selected_product == ROM.PRODUCT_H32_V2:
|
elif selected_product == ROM.PRODUCT_H32_V2:
|
||||||
selected_mcu = ROM.MCU_ESP32
|
selected_mcu = ROM.MCU_ESP32
|
||||||
@ -1953,7 +1969,7 @@ def main():
|
|||||||
selected_platform = ROM.PLATFORM_ESP32
|
selected_platform = ROM.PLATFORM_ESP32
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("That band does not exist, exiting now.")
|
print("That band does not exist, exiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
elif selected_product == ROM.PRODUCT_H32_V3:
|
elif selected_product == ROM.PRODUCT_H32_V3:
|
||||||
selected_mcu = ROM.MCU_ESP32
|
selected_mcu = ROM.MCU_ESP32
|
||||||
@ -1975,7 +1991,7 @@ def main():
|
|||||||
selected_platform = ROM.PLATFORM_ESP32
|
selected_platform = ROM.PLATFORM_ESP32
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("That band does not exist, exiting now.")
|
print("That band does not exist, exiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
if selected_model != ROM.MODEL_FF and selected_model != ROM.MODEL_FE:
|
if selected_model != ROM.MODEL_FF and selected_model != ROM.MODEL_FE:
|
||||||
fw_filename = models[selected_model][4]
|
fw_filename = models[selected_model][4]
|
||||||
@ -2003,7 +2019,7 @@ def main():
|
|||||||
fw_filename = "rnode_firmware_esp32_generic.zip"
|
fw_filename = "rnode_firmware_esp32_generic.zip"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("That ESP32 board does not exist, exiting now.")
|
print("That ESP32 board does not exist, exiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
if fw_filename == None:
|
if fw_filename == None:
|
||||||
print("")
|
print("")
|
||||||
@ -2013,7 +2029,7 @@ def main():
|
|||||||
print("")
|
print("")
|
||||||
print_donation_block()
|
print_donation_block()
|
||||||
print("")
|
print("")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
if args.use_extracted:
|
if args.use_extracted:
|
||||||
fw_filename = "extracted_rnode_firmware.zip"
|
fw_filename = "extracted_rnode_firmware.zip"
|
||||||
@ -2043,7 +2059,7 @@ def main():
|
|||||||
raise ValueError()
|
raise ValueError()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("OK, aborting now.")
|
print("OK, aborting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
args.key = True
|
args.key = True
|
||||||
args.port = selected_port.device
|
args.port = selected_port.device
|
||||||
@ -2060,7 +2076,7 @@ def main():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Could not obain firmware package for your board")
|
RNS.log("Could not obain firmware package for your board")
|
||||||
RNS.log("The contained exception was: "+str(e))
|
RNS.log("The contained exception was: "+str(e))
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
rnode.disconnect()
|
rnode.disconnect()
|
||||||
|
|
||||||
@ -2101,7 +2117,7 @@ def main():
|
|||||||
RNS.log("Could not load device signing key")
|
RNS.log("Could not load device signing key")
|
||||||
|
|
||||||
|
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
if args.key:
|
if args.key:
|
||||||
if not os.path.isfile(FWD_DIR+"/device.key"):
|
if not os.path.isfile(FWD_DIR+"/device.key"):
|
||||||
@ -2114,7 +2130,7 @@ def main():
|
|||||||
RNS.log("Could not create new device signing key at "+str(FWD_DIR+"/device.key")+". The contained exception was:")
|
RNS.log("Could not create new device signing key at "+str(FWD_DIR+"/device.key")+". The contained exception was:")
|
||||||
RNS.log(str(e))
|
RNS.log(str(e))
|
||||||
RNS.log("Please ensure filesystem access and try again.")
|
RNS.log("Please ensure filesystem access and try again.")
|
||||||
exit(81)
|
graceful_exit(81)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
device_signer = RNS.Identity.from_file(FWD_DIR+"/device.key")
|
device_signer = RNS.Identity.from_file(FWD_DIR+"/device.key")
|
||||||
@ -2122,7 +2138,7 @@ def main():
|
|||||||
RNS.log("Could not load device signing key from "+str(FWD_DIR+"/device.key")+". The contained exception was:")
|
RNS.log("Could not load device signing key from "+str(FWD_DIR+"/device.key")+". The contained exception was:")
|
||||||
RNS.log(str(e))
|
RNS.log(str(e))
|
||||||
RNS.log("Please restore or clear the key and try again.")
|
RNS.log("Please restore or clear the key and try again.")
|
||||||
exit(82)
|
graceful_exit(82)
|
||||||
|
|
||||||
if not os.path.isfile(FWD_DIR+"/signing.key"):
|
if not os.path.isfile(FWD_DIR+"/signing.key"):
|
||||||
RNS.log("Generating a new EEPROM signing key...")
|
RNS.log("Generating a new EEPROM signing key...")
|
||||||
@ -2160,7 +2176,7 @@ def main():
|
|||||||
RNS.log("The firmware directory does not exist, can't write key!")
|
RNS.log("The firmware directory does not exist, can't write key!")
|
||||||
|
|
||||||
if not args.autoinstall:
|
if not args.autoinstall:
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
def get_partition_hash(partition_file):
|
def get_partition_hash(partition_file):
|
||||||
try:
|
try:
|
||||||
@ -2192,7 +2208,7 @@ def main():
|
|||||||
RNS.log(" sudo apt install "+flasher)
|
RNS.log(" sudo apt install "+flasher)
|
||||||
RNS.log("")
|
RNS.log("")
|
||||||
RNS.log("Please install \""+flasher+"\" and try again.")
|
RNS.log("Please install \""+flasher+"\" and try again.")
|
||||||
exit()
|
graceful_exit()
|
||||||
elif platform == ROM.PLATFORM_AVR:
|
elif platform == ROM.PLATFORM_AVR:
|
||||||
flasher = "avrdude"
|
flasher = "avrdude"
|
||||||
if which(flasher) is not None:
|
if which(flasher) is not None:
|
||||||
@ -2211,7 +2227,7 @@ def main():
|
|||||||
RNS.log(" sudo apt install avrdude")
|
RNS.log(" sudo apt install avrdude")
|
||||||
RNS.log("")
|
RNS.log("")
|
||||||
RNS.log("Please install \""+flasher+"\" and try again.")
|
RNS.log("Please install \""+flasher+"\" and try again.")
|
||||||
exit()
|
graceful_exit()
|
||||||
elif platform == ROM.PLATFORM_ESP32:
|
elif platform == ROM.PLATFORM_ESP32:
|
||||||
numeric_version = float(selected_version)
|
numeric_version = float(selected_version)
|
||||||
flasher_dir = UPD_DIR+"/"+selected_version
|
flasher_dir = UPD_DIR+"/"+selected_version
|
||||||
@ -2671,7 +2687,7 @@ def main():
|
|||||||
RNS.log(" sudo apt install esptool")
|
RNS.log(" sudo apt install esptool")
|
||||||
RNS.log("")
|
RNS.log("")
|
||||||
RNS.log("Please install \""+flasher+"\" and try again.")
|
RNS.log("Please install \""+flasher+"\" and try again.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
if args.port:
|
if args.port:
|
||||||
wants_fw_provision = False
|
wants_fw_provision = False
|
||||||
@ -2686,7 +2702,7 @@ def main():
|
|||||||
|
|
||||||
if selected_version == None:
|
if selected_version == None:
|
||||||
RNS.log("Missing parameters, cannot continue")
|
RNS.log("Missing parameters, cannot continue")
|
||||||
exit(68)
|
graceful_exit(68)
|
||||||
|
|
||||||
if fw_filename == "extracted_rnode_firmware.zip":
|
if fw_filename == "extracted_rnode_firmware.zip":
|
||||||
try:
|
try:
|
||||||
@ -2702,12 +2718,12 @@ def main():
|
|||||||
RNS.log("Waiting for ESP32 reset...")
|
RNS.log("Waiting for ESP32 reset...")
|
||||||
time.sleep(7)
|
time.sleep(7)
|
||||||
else:
|
else:
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Error while flashing")
|
RNS.log("Error while flashing")
|
||||||
RNS.log(str(e))
|
RNS.log(str(e))
|
||||||
exit(1)
|
graceful_exit(1)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
fw_src = UPD_DIR+"/"+selected_version+"/"
|
fw_src = UPD_DIR+"/"+selected_version+"/"
|
||||||
@ -2720,7 +2736,7 @@ def main():
|
|||||||
zip.extractall(fw_src)
|
zip.extractall(fw_src)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Could not decompress firmware from downloaded zip file")
|
RNS.log("Could not decompress firmware from downloaded zip file")
|
||||||
exit()
|
graceful_exit()
|
||||||
RNS.log("Firmware decompressed")
|
RNS.log("Firmware decompressed")
|
||||||
|
|
||||||
RNS.log("Flashing RNode firmware to device on "+args.port)
|
RNS.log("Flashing RNode firmware to device on "+args.port)
|
||||||
@ -2739,15 +2755,15 @@ def main():
|
|||||||
RNS.log("Some boards have trouble flashing at high speeds, and you can")
|
RNS.log("Some boards have trouble flashing at high speeds, and you can")
|
||||||
RNS.log("try flashing with a lower baud rate, as in this example:")
|
RNS.log("try flashing with a lower baud rate, as in this example:")
|
||||||
RNS.log("rnodeconf --autoinstall --baud-flash 115200")
|
RNS.log("rnodeconf --autoinstall --baud-flash 115200")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Error while flashing")
|
RNS.log("Error while flashing")
|
||||||
RNS.log(str(e))
|
RNS.log(str(e))
|
||||||
exit(1)
|
graceful_exit(1)
|
||||||
else:
|
else:
|
||||||
RNS.log("Firmware file not found")
|
RNS.log("Firmware file not found")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
RNS.log("Opening serial port "+args.port+"...")
|
RNS.log("Opening serial port "+args.port+"...")
|
||||||
try:
|
try:
|
||||||
@ -2756,7 +2772,7 @@ def main():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Could not open the specified serial port. The contained exception was:")
|
RNS.log("Could not open the specified serial port. The contained exception was:")
|
||||||
RNS.log(str(e))
|
RNS.log(str(e))
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
rnode = RNode(rnode_serial)
|
rnode = RNode(rnode_serial)
|
||||||
thread = threading.Thread(target=rnode.readLoop, daemon=True).start()
|
thread = threading.Thread(target=rnode.readLoop, daemon=True).start()
|
||||||
@ -2766,7 +2782,7 @@ def main():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Serial port opened, but RNode did not respond. Is a valid firmware installed?")
|
RNS.log("Serial port opened, but RNode did not respond. Is a valid firmware installed?")
|
||||||
print(e)
|
print(e)
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
if rnode.detected:
|
if rnode.detected:
|
||||||
if rnode.platform == None or rnode.mcu == None:
|
if rnode.platform == None or rnode.mcu == None:
|
||||||
@ -2778,7 +2794,7 @@ def main():
|
|||||||
RNS.log("WARNING: EEPROM is being wiped! Power down device NOW if you do not want this!")
|
RNS.log("WARNING: EEPROM is being wiped! Power down device NOW if you do not want this!")
|
||||||
rnode.wipe_eeprom()
|
rnode.wipe_eeprom()
|
||||||
rnode.hard_reset()
|
rnode.hard_reset()
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
RNS.log("Reading EEPROM...")
|
RNS.log("Reading EEPROM...")
|
||||||
rnode.download_eeprom()
|
rnode.download_eeprom()
|
||||||
@ -2804,12 +2820,12 @@ def main():
|
|||||||
fw_filename = None
|
fw_filename = None
|
||||||
if args.update:
|
if args.update:
|
||||||
RNS.log("ERROR: No firmware found for this board. Cannot update.")
|
RNS.log("ERROR: No firmware found for this board. Cannot update.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
if args.update:
|
if args.update:
|
||||||
if not rnode.provisioned:
|
if not rnode.provisioned:
|
||||||
RNS.log("Device not provisioned. Cannot update device firmware.")
|
RNS.log("Device not provisioned. Cannot update device firmware.")
|
||||||
exit(1)
|
graceful_exit(1)
|
||||||
|
|
||||||
if args.use_extracted:
|
if args.use_extracted:
|
||||||
fw_filename = "extracted_rnode_firmware.zip"
|
fw_filename = "extracted_rnode_firmware.zip"
|
||||||
@ -2828,21 +2844,21 @@ def main():
|
|||||||
if args.fw_version != None:
|
if args.fw_version != None:
|
||||||
RNS.log("Specified firmware version ("+selected_version+") is already installed on this device")
|
RNS.log("Specified firmware version ("+selected_version+") is already installed on this device")
|
||||||
RNS.log("Override with -U option to install anyway")
|
RNS.log("Override with -U option to install anyway")
|
||||||
exit(0)
|
graceful_exit(0)
|
||||||
else:
|
else:
|
||||||
RNS.log("Latest firmware version ("+selected_version+") is already installed on this device")
|
RNS.log("Latest firmware version ("+selected_version+") is already installed on this device")
|
||||||
RNS.log("Override with -U option to install anyway")
|
RNS.log("Override with -U option to install anyway")
|
||||||
exit(0)
|
graceful_exit(0)
|
||||||
|
|
||||||
if rnode.version > selected_version:
|
if rnode.version > selected_version:
|
||||||
if args.fw_version != None:
|
if args.fw_version != None:
|
||||||
RNS.log("Specified firmware version ("+selected_version+") is older than firmware already installed on this device")
|
RNS.log("Specified firmware version ("+selected_version+") is older than firmware already installed on this device")
|
||||||
RNS.log("Override with -U option to install anyway")
|
RNS.log("Override with -U option to install anyway")
|
||||||
exit(0)
|
graceful_exit(0)
|
||||||
else:
|
else:
|
||||||
RNS.log("Latest firmware version ("+selected_version+") is older than firmware already installed on this device")
|
RNS.log("Latest firmware version ("+selected_version+") is older than firmware already installed on this device")
|
||||||
RNS.log("Override with -U option to install anyway")
|
RNS.log("Override with -U option to install anyway")
|
||||||
exit(0)
|
graceful_exit(0)
|
||||||
|
|
||||||
if not fw_file_ensured and selected_version != None:
|
if not fw_file_ensured and selected_version != None:
|
||||||
ensure_firmware_file(fw_filename)
|
ensure_firmware_file(fw_filename)
|
||||||
@ -2855,13 +2871,13 @@ def main():
|
|||||||
zip.extractall(fw_src)
|
zip.extractall(fw_src)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Could not decompress firmware from downloaded zip file")
|
RNS.log("Could not decompress firmware from downloaded zip file")
|
||||||
exit()
|
graceful_exit()
|
||||||
RNS.log("Firmware decompressed")
|
RNS.log("Firmware decompressed")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Could not obtain firmware package for your board")
|
RNS.log("Could not obtain firmware package for your board")
|
||||||
RNS.log("The contained exception was: "+str(e))
|
RNS.log("The contained exception was: "+str(e))
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
if fw_filename == "extracted_rnode_firmware.zip":
|
if fw_filename == "extracted_rnode_firmware.zip":
|
||||||
update_full_path = EXT_DIR+"/extracted_rnode_firmware.version"
|
update_full_path = EXT_DIR+"/extracted_rnode_firmware.version"
|
||||||
@ -2899,7 +2915,7 @@ def main():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Could not open the specified serial port. The contained exception was:")
|
RNS.log("Could not open the specified serial port. The contained exception was:")
|
||||||
RNS.log(str(e))
|
RNS.log(str(e))
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
rnode = RNode(rnode_serial)
|
rnode = RNode(rnode_serial)
|
||||||
thread = threading.Thread(target=rnode.readLoop, daemon=True).start()
|
thread = threading.Thread(target=rnode.readLoop, daemon=True).start()
|
||||||
@ -2909,7 +2925,7 @@ def main():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Serial port opened, but RNode did not respond. Is a valid firmware installed?")
|
RNS.log("Serial port opened, but RNode did not respond. Is a valid firmware installed?")
|
||||||
print(e)
|
print(e)
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
if rnode.detected:
|
if rnode.detected:
|
||||||
if rnode.platform == None or rnode.mcu == None:
|
if rnode.platform == None or rnode.mcu == None:
|
||||||
@ -2933,19 +2949,19 @@ def main():
|
|||||||
RNS.log("Firmware update completed successfully")
|
RNS.log("Firmware update completed successfully")
|
||||||
else:
|
else:
|
||||||
RNS.log("An error occurred while flashing the new firmware, exiting now.")
|
RNS.log("An error occurred while flashing the new firmware, exiting now.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Error while updating firmware")
|
RNS.log("Error while updating firmware")
|
||||||
RNS.log(str(e))
|
RNS.log(str(e))
|
||||||
else:
|
else:
|
||||||
RNS.log("Firmware update file not found")
|
RNS.log("Firmware update file not found")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
if args.eeprom_dump:
|
if args.eeprom_dump:
|
||||||
RNS.log("EEPROM contents:")
|
RNS.log("EEPROM contents:")
|
||||||
RNS.log(RNS.hexrep(rnode.eeprom))
|
RNS.log(RNS.hexrep(rnode.eeprom))
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
if args.eeprom_backup:
|
if args.eeprom_backup:
|
||||||
try:
|
try:
|
||||||
@ -2959,7 +2975,7 @@ def main():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("EEPROM was successfully downloaded from device,")
|
RNS.log("EEPROM was successfully downloaded from device,")
|
||||||
RNS.log("but file could not be written to disk.")
|
RNS.log("but file could not be written to disk.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
if isinstance(args.display, int):
|
if isinstance(args.display, int):
|
||||||
di = args.display
|
di = args.display
|
||||||
@ -2984,7 +3000,7 @@ def main():
|
|||||||
RNS.log("Setting display address to "+RNS.hexrep(da, delimit=False))
|
RNS.log("Setting display address to "+RNS.hexrep(da, delimit=False))
|
||||||
rnode.set_display_address(ord(da))
|
rnode.set_display_address(ord(da))
|
||||||
rnode.hard_reset()
|
rnode.hard_reset()
|
||||||
exit()
|
graceful_exit()
|
||||||
else:
|
else:
|
||||||
RNS.log("Invalid display address specified")
|
RNS.log("Invalid display address specified")
|
||||||
|
|
||||||
@ -3054,23 +3070,23 @@ def main():
|
|||||||
|
|
||||||
print("")
|
print("")
|
||||||
rnode.disconnect()
|
rnode.disconnect()
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
RNS.log("EEPROM is invalid, no further information available")
|
RNS.log("EEPROM is invalid, no further information available")
|
||||||
exit()
|
egraceful_xit()
|
||||||
|
|
||||||
if args.rom:
|
if args.rom:
|
||||||
if rnode.provisioned and not args.autoinstall:
|
if rnode.provisioned and not args.autoinstall:
|
||||||
RNS.log("EEPROM bootstrap was requested, but a valid EEPROM was already present.")
|
RNS.log("EEPROM bootstrap was requested, but a valid EEPROM was already present.")
|
||||||
RNS.log("No changes are being made.")
|
RNS.log("No changes are being made.")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if rnode.signature_valid:
|
if rnode.signature_valid:
|
||||||
RNS.log("EEPROM bootstrap was requested, but a valid EEPROM was already present.")
|
RNS.log("EEPROM bootstrap was requested, but a valid EEPROM was already present.")
|
||||||
RNS.log("No changes are being made.")
|
RNS.log("No changes are being made.")
|
||||||
exit()
|
graceful_exit()
|
||||||
else:
|
else:
|
||||||
if args.autoinstall:
|
if args.autoinstall:
|
||||||
RNS.log("Clearing old EEPROM, this will take about 15 seconds...")
|
RNS.log("Clearing old EEPROM, this will take about 15 seconds...")
|
||||||
@ -3095,7 +3111,7 @@ def main():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Could not create device serial number, exiting")
|
RNS.log("Could not create device serial number, exiting")
|
||||||
RNS.log(str(e))
|
RNS.log(str(e))
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
serialno = counter+1
|
serialno = counter+1
|
||||||
model = None
|
model = None
|
||||||
@ -3191,7 +3207,7 @@ def main():
|
|||||||
RNS.log(str(e))
|
RNS.log(str(e))
|
||||||
else:
|
else:
|
||||||
RNS.log("No signing key found")
|
RNS.log("No signing key found")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
if model == ROM.MODEL_A1 or model == ROM.MODEL_A6:
|
if model == ROM.MODEL_A1 or model == ROM.MODEL_A6:
|
||||||
rnode.hard_reset()
|
rnode.hard_reset()
|
||||||
@ -3305,10 +3321,10 @@ def main():
|
|||||||
file.close()
|
file.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("WARNING: Could not backup device EEPROM to disk")
|
RNS.log("WARNING: Could not backup device EEPROM to disk")
|
||||||
exit()
|
graceful_exit()
|
||||||
else:
|
else:
|
||||||
RNS.log("EEPROM was written, but validation failed. Check your settings.")
|
RNS.log("EEPROM was written, but validation failed. Check your settings.")
|
||||||
exit()
|
graceful_exit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("An error occurred while writing EEPROM. The contained exception was:")
|
RNS.log("An error occurred while writing EEPROM. The contained exception was:")
|
||||||
RNS.log(str(e))
|
RNS.log(str(e))
|
||||||
@ -3316,7 +3332,7 @@ def main():
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
RNS.log("Invalid data specified, cancelling EEPROM write")
|
RNS.log("Invalid data specified, cancelling EEPROM write")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
if args.sign:
|
if args.sign:
|
||||||
if rnode.provisioned:
|
if rnode.provisioned:
|
||||||
@ -3330,14 +3346,14 @@ def main():
|
|||||||
else:
|
else:
|
||||||
if device_signer == None:
|
if device_signer == None:
|
||||||
RNS.log("No device signer loaded, cannot sign device")
|
RNS.log("No device signer loaded, cannot sign device")
|
||||||
exit(78)
|
graceful_exit(78)
|
||||||
else:
|
else:
|
||||||
new_device_signature = device_signer.sign(rnode.device_hash)
|
new_device_signature = device_signer.sign(rnode.device_hash)
|
||||||
rnode.store_signature(new_device_signature)
|
rnode.store_signature(new_device_signature)
|
||||||
RNS.log("Device signed")
|
RNS.log("Device signed")
|
||||||
else:
|
else:
|
||||||
RNS.log("This device has not been provisioned yet, cannot create device signature")
|
RNS.log("This device has not been provisioned yet, cannot create device signature")
|
||||||
exit(79)
|
graceful_exit(79)
|
||||||
|
|
||||||
if args.firmware_hash != None:
|
if args.firmware_hash != None:
|
||||||
if rnode.provisioned:
|
if rnode.provisioned:
|
||||||
@ -3350,11 +3366,11 @@ def main():
|
|||||||
RNS.log("Firmware hash set")
|
RNS.log("Firmware hash set")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("The provided value was not a valid SHA256 hash")
|
RNS.log("The provided value was not a valid SHA256 hash")
|
||||||
exit(78)
|
graceful_exit(78)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
RNS.log("This device has not been provisioned yet, cannot set firmware hash")
|
RNS.log("This device has not been provisioned yet, cannot set firmware hash")
|
||||||
exit(77)
|
graceful_exit(77)
|
||||||
|
|
||||||
if args.get_target_firmware_hash:
|
if args.get_target_firmware_hash:
|
||||||
if rnode.provisioned:
|
if rnode.provisioned:
|
||||||
@ -3376,7 +3392,7 @@ def main():
|
|||||||
if args.normal:
|
if args.normal:
|
||||||
rnode.setNormalMode()
|
rnode.setNormalMode()
|
||||||
RNS.log("Device set to normal (host-controlled) operating mode")
|
RNS.log("Device set to normal (host-controlled) operating mode")
|
||||||
exit()
|
graceful_exit()
|
||||||
if args.tnc:
|
if args.tnc:
|
||||||
if not (args.freq and args.bw and args.txp and args.sf and args.cr):
|
if not (args.freq and args.bw and args.txp and args.sf and args.cr):
|
||||||
RNS.log("Please input startup configuration:")
|
RNS.log("Please input startup configuration:")
|
||||||
@ -3421,7 +3437,7 @@ def main():
|
|||||||
RNS.log("Device set to TNC operating mode")
|
RNS.log("Device set to TNC operating mode")
|
||||||
sleep(1.0)
|
sleep(1.0)
|
||||||
|
|
||||||
exit()
|
graceful_exit()
|
||||||
else:
|
else:
|
||||||
RNS.log("This device contains a valid firmware, but EEPROM is invalid.")
|
RNS.log("This device contains a valid firmware, but EEPROM is invalid.")
|
||||||
RNS.log("Probably the device has not been initialised, or the EEPROM has been erased.")
|
RNS.log("Probably the device has not been initialised, or the EEPROM has been erased.")
|
||||||
@ -3431,12 +3447,14 @@ def main():
|
|||||||
print("")
|
print("")
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
print("")
|
print("")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("")
|
print("")
|
||||||
exit()
|
graceful_exit()
|
||||||
|
|
||||||
|
graceful_exit()
|
||||||
|
|
||||||
def extract_recovery_esptool():
|
def extract_recovery_esptool():
|
||||||
if not os.path.isfile(RT_PATH):
|
if not os.path.isfile(RT_PATH):
|
||||||
@ -3450,7 +3468,7 @@ def extract_recovery_esptool():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Error: Could not extract recovery ESP-Tool. The contained exception was:")
|
RNS.log("Error: Could not extract recovery ESP-Tool. The contained exception was:")
|
||||||
RNS.log(str(e))
|
RNS.log(str(e))
|
||||||
exit(181)
|
graceful_exit(181)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user