diff options
| author | Selene ToyKeeper | 2023-04-07 17:06:08 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2023-04-07 17:06:08 -0600 |
| commit | f4430bb7f2bcef62e6563f9c436b9a24d4482532 (patch) | |
| tree | fdf8d73cebe9193147c9922d5152df54f3171020 /bin | |
| parent | added a "tactical mode" on "Off -> 6C" (diff) | |
| download | anduril-f4430bb7f2bcef62e6563f9c436b9a24d4482532.tar.gz anduril-f4430bb7f2bcef62e6563f9c436b9a24d4482532.tar.bz2 anduril-f4430bb7f2bcef62e6563f9c436b9a24d4482532.zip | |
merging gchart's changes, part 1...
+ added Sofirn LT1S Pro
+ added Sofirn SC21 Pro
+ added Wurkkos TS10
+ added Wurkkos TS25
* small changes to other models
* improved dual voltage support
+ added attiny1616 flashing python script w/ pymcuprog
These changes are incomplete. It does not yet include:
- extended simple UI
- t1616 WDT reset detection
- gchart's OUTPUT_MUX code (I plan to rewrite the entire tint system)
Diffstat (limited to '')
| -rw-r--r-- | bin/flash-1616.py | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/bin/flash-1616.py b/bin/flash-1616.py new file mode 100644 index 0000000..6b3e2ee --- /dev/null +++ b/bin/flash-1616.py @@ -0,0 +1,76 @@ +# Use with Python3, make sure to have the pymcuprog module installed (via pip) + +# Read out the pymcuprog version +from pymcuprog.version import VERSION as pymcuprog_version +print("pymcuprog version {}".format(pymcuprog_version)) + + +# List out the available ports +import serial.tools.list_ports as ls; +#ports = ls.comports() +ports = [] +for p in ls.comports(): + if "COM" in p.device or "USB" in p.device: + ports.append(p) + +if len(ports) == 0: + print("No serial ports found, exiting") + exit() +elif len(ports) == 1: + print("Found one serial port:", ports[0].device, "-", ports[0].description) + port = ports[0].device +else: # found more than one serial port + print("Found multiple serial ports:") + for p in ports: + print(" *", p.device, "-", p.description) + print("Which serial port would you like to use? (default: " + ports[0].device + ") ", end="") + port = input() + if not port: + port = ports[0].device + + +import sys +args = sys.argv +if len(args) == 1: # only the program name, no arguements: ask for the hex file + print("Which hex file would you like to flash? ", end="") + hexfile = input() +else: + hexfile = args[1] + + +# pymcuprog uses the Python logging module +import logging +logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING) + +# Configure the session +from pymcuprog.backend import SessionConfig +sessionconfig = SessionConfig("attiny1616") + +# Instantiate Serial transport (only 1 tool connected) +from pymcuprog.toolconnection import ToolSerialConnection +transport = ToolSerialConnection(serialport=port) + +# Instantiate backend +from pymcuprog.backend import Backend +backend = Backend() + +# Connect to tool using transport +backend.connect_to_tool(transport) + +# Start the session +backend.start_session(sessionconfig) + +# Read the target device_id +device_id = backend.read_device_id() +print("Device ID is {0:06X}".format(int.from_bytes(device_id, byteorder="little"))) + +# Erase the device, write the hexfile, and verify the write +backend.erase() +print("Memories erased.") +print("Writing hex file to the device... ") +backend.write_hex_to_target(hexfile) +print("Writing complete.") +print("Verifying the write... ") +verify_status = backend.verify_hex(hexfile) +if verify_status is True: + print("Verification successful!")
\ No newline at end of file |
