Implement notetaking app, ST7796 display with touch support, audio beep navigation, and video streaming
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
import serial
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
|
||||
PORT = '/dev/cu.usbmodem101'
|
||||
print("=== MicroPython Boot Interrupter & Recovery Tool ===")
|
||||
print(f"Waiting for {PORT} to appear. Please press the RESET button on the board...")
|
||||
|
||||
while True:
|
||||
try:
|
||||
ser = serial.Serial(PORT, 115200, timeout=1.0)
|
||||
print("\n[+] Port opened successfully!")
|
||||
break
|
||||
except Exception as e:
|
||||
# Port not present or busy
|
||||
time.sleep(0.01)
|
||||
|
||||
print("[*] Sending Ctrl-C storm to halt boot sequence...")
|
||||
# Send 100 Ctrl-C interrupts in rapid succession
|
||||
for _ in range(100):
|
||||
try:
|
||||
ser.write(b'\x03')
|
||||
time.sleep(0.005)
|
||||
except Exception as e:
|
||||
print(f"Write error during storm: {e}")
|
||||
break
|
||||
|
||||
time.sleep(0.1)
|
||||
ser.reset_input_buffer()
|
||||
|
||||
# Check if we have REPL access by sending a newline and expecting a prompt
|
||||
print("[*] Verifying REPL responsiveness...")
|
||||
ser.write(b'\r\n')
|
||||
time.sleep(0.2)
|
||||
|
||||
if ser.in_waiting:
|
||||
resp = ser.read(ser.in_waiting)
|
||||
print(f"REPL Response:\n{resp.decode('utf-8', errors='ignore')}")
|
||||
else:
|
||||
print("[-] No response to newline, trying to force it...")
|
||||
ser.write(b'\x03\r\n')
|
||||
time.sleep(0.2)
|
||||
resp = ser.read(ser.in_waiting)
|
||||
print(f"REPL Response:\n{resp.decode('utf-8', errors='ignore')}")
|
||||
|
||||
# Try to rename main.py to stop it from running on subsequent boots
|
||||
print("[*] Attempting to disable main.py...")
|
||||
rename_code = b"""
|
||||
import os
|
||||
try:
|
||||
os.rename('main.py', 'main_bad.py')
|
||||
print('RENAME:OK')
|
||||
except Exception as e:
|
||||
print('RENAME:ERROR:', e)
|
||||
"""
|
||||
ser.write(rename_code + b'\r\n')
|
||||
time.sleep(0.5)
|
||||
|
||||
if ser.in_waiting:
|
||||
result = ser.read(ser.in_waiting).decode('utf-8', errors='ignore')
|
||||
print(f"Execution Output:\n{result}")
|
||||
if "RENAME:OK" in result:
|
||||
print("[+] SUCCESS! main.py has been disabled.")
|
||||
print("[+] You can now safely upload files or reboot.")
|
||||
else:
|
||||
print("[-] Rename failed or returned unexpected output.")
|
||||
else:
|
||||
print("[-] No response to rename command.")
|
||||
|
||||
ser.close()
|
||||
Reference in New Issue
Block a user