-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathloadFirmware.py
More file actions
30 lines (26 loc) · 1.03 KB
/
loadFirmware.py
File metadata and controls
30 lines (26 loc) · 1.03 KB
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
import subprocess
import sys
import time
import serial.tools.list_ports
ports = list(serial.tools.list_ports.comports())
if not ports:
print("No COM ports found.")
sys.exit(1)
com_port = ports[0].device
print(f"Using COM port: {com_port}")
commands = [
["esptool", "erase_flash"],
["esptool", "--baud", "460800", "write_flash", "0x1000", "ESP32_GENERIC-20250415-v1.25.0.bin"],
["python", "pyboard.py", "--device", com_port, "-f", "cp", "rover.py", ":rover.py"],
["python", "pyboard.py", "--device", com_port, "-f", "cp", "ir_control.py", ":ir_control.py"],
["python", "pyboard.py", "--device", com_port, "-f", "cp", "main.py", ":main.py"],
#["python", "pyboard.py", "--device", com_port, "systemTest.py"],
]
for cmd in commands:
print(f"Running: {' '.join(cmd)}")
result = subprocess.run(cmd)
if result.returncode != 0:
print(f"Command failed: {' '.join(cmd)}")
sys.exit(result.returncode)
time.sleep(2) # Wait for 2 seconds between commands
print("All commands completed successfully.")